Fix PHPStan L2 error "Cannot call method Foo() on Bar" related to Prophecy

Created on 21 August 2025, about 2 months ago

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 related to Prophecy. Note that adding jangregor/phpstan-prophecy will resolve some of these, but not all of them.

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

📌 Task
Status

Active

Version

11.0 🔥

Component

base system

Created by

🇦🇺Australia mstrelan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024