You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just updated to PHPUnit 12.0.9 and PHPStan is reporting the same error hundreds of times, in every instance of $mockObject->expects(...)->method(...):
37 Call to method method() on an unknown class PHPUnit\Framework\MockObject\Builder\InvocationMocker.
🪪 class.notFound
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
I see the PHPUnit\Framework\MockObject\Builder\InvocationMocker has been in fact removed in this version (I had a direct reference in one test that I had to change with PHPUnit\Framework\MockObject\InvocationStubber), so it seems there's still some reference to it somewhere.
Running the tests work though. It's just a static analysis issue.
Current behavior
Running PHPStan over the test code reports Call to method method() on an unknown class PHPUnit\Framework\MockObject\Builder\InvocationMocker in every place where a mock has been created with ->createMock() and then ->method() is called.
How to reproduce
Create a test where a mock is created and then some expectations are configured on it:
usePHPUnit\Framework\MockObject\MockObject;
usePHPUnit\Framework\Reorderable;
class MyTest extends TestCase
{
publicfunctiontestSomething(): void
{
// I randomly picked Reorderable because it's part of PHPUnit. Anything produces the same result$mock = $this->createMock(Reorderable::class);
$mock->expects($this->never())->method('sortId');
}
}
Then run phpstan against this file:
vendor/bin/phpstan MyTest.php
------ ----------------------------------------------------------------------------------------------------
Line MyTest.php
------ ----------------------------------------------------------------------------------------------------
10 Call to method method() on an unknown class PHPUnit\Framework\MockObject\Builder\InvocationMocker.
🪪 class.notFound
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
------ ----------------------------------------------------------------------------------------------------
Expected behavior
PHPStan should not report any error
The text was updated successfully, but these errors were encountered:
Summary
I just updated to PHPUnit 12.0.9 and PHPStan is reporting the same error hundreds of times, in every instance of
$mockObject->expects(...)->method(...)
:I see the
PHPUnit\Framework\MockObject\Builder\InvocationMocker
has been in fact removed in this version (I had a direct reference in one test that I had to change withPHPUnit\Framework\MockObject\InvocationStubber
), so it seems there's still some reference to it somewhere.Running the tests work though. It's just a static analysis issue.
Current behavior
Running PHPStan over the test code reports
Call to method method() on an unknown class PHPUnit\Framework\MockObject\Builder\InvocationMocker
in every place where a mock has been created with->createMock()
and then->method()
is called.How to reproduce
Create a test where a mock is created and then some expectations are configured on it:
Then run phpstan against this file:
Expected behavior
PHPStan should not report any error
The text was updated successfully, but these errors were encountered: