Still on Drupal 7? Security support for Drupal 7 ended on 5 January 2025. Please visit our Drupal 7 End of Life resources page to review all of your options.Problem/Motivation
Amongst the "new" errors found when running PHPStan on level 2 is: Cannot call method Foo() on Bar.
This child-issue exists to fix all of those that are not related to Prophecy.
Steps to reproduce
./vendor/bin/phpstan analyse -c core/phpstan.neon.dist --error-format=raw --level=2 | sed "s|$PWD/||" | grep -P 'Cannot call method (?!(expects|shouldBeCalled|shouldNotBeCalled|shouldHaveBeenCalled|will|willReturn|willThrow)\(\))'
Proposed resolution
- Solve all of the the above mentioned reported errors.
- Run PHPStan on level 2 and don't see the above mentioned error any more.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Issue fork drupal-3323650
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
spokjeComment #4
mstrelan commentedUpdated steps to reproduce. There are currently 181 of these to fix.
Comment #5
mstrelan commentedI think we should split this in to errors related to prophecy and errors not related to prophecy. Let's keep this one for not related, I've opened #3542341: Fix PHPStan L2 error "Cannot call method Foo() on Bar" related to Prophecy for related. Note that jangregor/phpstan-prophecy doesn't resolve all of them, hence the need for another issue.
Comment #6
mstrelan commentedComment #7
libbna commentedHi @mstrelan,
Before I start working on the issue, I wanted to double-check something. I ran the following command:
./vendor/bin/phpstan analyse -c core/phpstan.neon.dist --error-format=raw --level=2 | sed "s|$PWD/||" | grep -P 'Cannot call method (?!(expects|shouldBeCalled|shouldNotBeCalled|shouldHaveBeenCalled|will|willReturn|willThrow)\(\))'I got below errors.
From my understanding, Prophecy is used to:
Based on the errors below, I don’t believe they are related to Prophecy issues.
Could you please confirm?
Comment #8
mstrelan commentedYeah the command in the issue summary is filtering out prophecy errors already.
Comment #9
libbna commentedOkay, thanks! Working on it.
Comment #11
libbna commentedI’ve resolved many of the PHPStan errors, but there are still three issues remaining that I wasn’t able to fix. I’m changing the status to NW and unassigning myself so that someone else can continue working on this.
Comment #12
libbna commented