Skip to content

False positive narrowing type when checking method or property existence inside trait #13687

@chack1172

Description

@chack1172

Bug report

When checking if a method or a property exists in an instanced class inside a trait method. Phpstan reports an invalid function.alreadyNarrowedType.

This is wrong because for some methods may be needed in some classes or not needed.

Code snippet that reproduces the problem

https://phpstan.org/r/f7e4cae8-7133-4e5e-9340-40b5c56a5d3f

Expected output

It should not report errors

Did PHPStan help you today? Did it make you happy in any way?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions