False positive `Dynamic call to static method` when mixing in another class and implementing `__call` and `__callStatic`
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 52/100
Research direction
Start with the linked PHPStan playground reproduction and trace the rule identified as staticMethod.dynamicCall, focusing on the interaction between mixed-in instance methods and __call/__callStatic. Done means the reported Bar::bar() false positive no longer occurs while genuine dynamic calls remain detected, with a regression test covering the example.
Written by the indexing model from the issue text.
Description
When you've a class Foo that:
- provides implementations of both
__calland__callStatic, and - mixes in another class
Barthat has an instance methodbar
creating an instance of Foo and calling that instance method results in an error of the form:
Dynamic call to static method Bar::bar(). [identifier=staticMethod.dynamicCall]
Playground: https://phpstan.org/r/bfd29cdb-749b-4b97-bd50-92ecb0fcfc92
Thanks!
- Dominant language
- PHP
- Stars
- 711
- Forks
- 62
- Avg merge
- 3d 14h
- Merged PRs (30d)
- 5
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from phpstan/phpstan-strict-rules
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
phpstan/phpstan-strict-rules#317 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
phpstan/phpstan-strict-rules#316 · 3 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
phpstan/phpstan-strict-rules#289 · 1 comment ·
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 35/100
phpstan/phpstan-strict-rules#283 · 6 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
phpstan/phpstan-strict-rules#276 · 2 comments ·
All issues in phpstan/phpstan-strict-rules
Similar issues
-
Messenger
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
symfony/symfony-docs#23237 ·
Maintainers usually reply within 3 days
-
sync-en
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
sync-en
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 4 days
-
Documentation Feature: Financial
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
coollabsio/coolify#12127 ·
Maintainers usually reply within 1 day