Skip to content

False positive "has no effect" on call to late static binding method of abstract class #12062

@proton-ab

Description

@proton-ab

Bug report

False positive Call to {} on a separate line has no effect. is reported when calling method via late static binding of abstract class. PHPStan seems to assume that call refers to empty method of current scope, however scope differs during runtime and this is not being accounted for.

I believe PHPStan should absolutely not report error in this case because it makes any usage of late static binding impossible without explicitly ignoring false positives, which is certainly not a desired effect.

Code snippet that reproduces the problem

https://phpstan.org/r/d387fcdc-ef44-44a8-93a3-f725397a2609

Expected output

No error is reported because it is impossible to derive actual function being called via static:: late binding, hence it is also impossible to accurately say that there will be no effect.

In the example provided, the call absolutely has effect (of throwing exception).

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

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions