Title: Unexpected errors with `willReturn` called on `with` · Issue #299 · phpstan/phpstan-phpunit · GitHub
Open Graph Title: Unexpected errors with `willReturn` called on `with` · Issue #299 · phpstan/phpstan-phpunit
X Title: Unexpected errors with `willReturn` called on `with` · Issue #299 · phpstan/phpstan-phpunit
Description: After upgrading to PHPStan 2.2.0 the willReturn on the with seems not longer be detected correctly: use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\ContainerBuilder; ...
Open Graph Description: After upgrading to PHPStan 2.2.0 the willReturn on the with seems not longer be detected correctly: use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Componen...
X Description: After upgrading to PHPStan 2.2.0 the willReturn on the with seems not longer be detected correctly: use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Componen...
Opengraph URL: https://github.com/phpstan/phpstan-phpunit/issues/299
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Unexpected errors with `willReturn` called on `with`","articleBody":"After upgrading to PHPStan 2.2.0 the `willReturn` on the `with` seems not longer be detected correctly:\n\n```php\nuse PHPUnit\\Framework\\MockObject\\MockObject;\nuse PHPUnit\\Framework\\TestCase;\nuse Symfony\\Component\\DependencyInjection\\ContainerBuilder;\n\nclass RegisterPreviewWebspaceClassPassTest extends TestCase\n{\n /** @var ContainerBuilder&MockObject */\n private $containerBuilderMock;\n\n public function testShouldNotOverrideWebspaceCacheClass(): void\n {\n $this->containerBuilderMock\n ->method('hasExtension')\n ->with('sulu_core')\n ->willReturn(false);\n }\n```\n\n```\n 28 Call to an undefined method PHPUnit\\Framework\\MockObject\\InvocationStubber::with().\n 🪪 method.notFound\n```\n\nPackages which are installed related to PHPUnit:\n\n```\nphpspec/prophecy-phpunit 2.5.0 Integrating the Prophecy mocking library in PHPUnit test cases\nphpstan/phpstan-phpunit 2.0.16 PHPUnit extensions and rules for PHPStan\nphpunit/php-code-coverage 14.1.9 Library that provides collection, processing, and rendering functionality for PHP code covera...\nphpunit/php-file-iterator 7.0.0 FilterIterator implementation that filters files based on a list of suffixes.\nphpunit/php-invoker 7.0.0 Invoke callables with a timeout\nphpunit/php-text-template 6.0.0 Simple template engine.\nphpunit/php-timer 9.0.0 Utility class for timing\nphpunit/phpunit 13.1.13 The PHP Unit Testing framework.\nsymfony/phpunit-bridge 7.4.8 Provides utilities for PHPUnit, especially user deprecation notices management\n```","author":{"url":"https://github.com/alexander-schranz","@type":"Person","name":"alexander-schranz"},"datePublished":"2026-05-28T10:28:27Z","url":"https://github.com/phpstan/phpstan-phpunit/issues/299"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:e254736b-62db-3b72-7e62-99c92cba2a6c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A79C:30B78A:3CB43D:530062:6B006D9C |
| html-safe-nonce | bbe80452e3cd3fca9e3908e3494eb46be9efc964c65f87a1cf69bf5cf3adcf0e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNzlDOjMwQjc4QTozQ0I0M0Q6NTMwMDYyOjZCMDA2RDlDIiwidmlzaXRvcl9pZCI6IjMzMTcyMjE3ODEwMjE5NDUyNDQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | f9fc72e4078011ec318cbc70aed18504628497d619d4fb7bb888bfd0108ac954 |
| hovercard-subject-tag | issue:4539668907 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/phpstan/phpstan-phpunit/299/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c3532293f8566a7895b9dc5183efa36e5ad40937e158c6365722f3d72ad84f08/phpstan/phpstan-phpunit/issues/299 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c3532293f8566a7895b9dc5183efa36e5ad40937e158c6365722f3d72ad84f08/phpstan/phpstan-phpunit/issues/299 |
| og:image:alt | After upgrading to PHPStan 2.2.0 the willReturn on the with seems not longer be detected correctly: use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Componen... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | alexander-schranz |
| hostname | github.com |
| expected-hostname | github.com |
| None | 6527e91c60c0b29d16606ff32ac5df8ecdc37a2a62205ea057a14d7762c870fa |
| turbo-cache-control | no-preview |
| go-import | github.com/phpstan/phpstan-phpunit git https://github.com/phpstan/phpstan-phpunit.git |
| octolytics-dimension-user_id | 16435710 |
| octolytics-dimension-user_login | phpstan |
| octolytics-dimension-repository_id | 105883921 |
| octolytics-dimension-repository_nwo | phpstan/phpstan-phpunit |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 105883921 |
| octolytics-dimension-repository_network_root_nwo | phpstan/phpstan-phpunit |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 46f1cd2ae3cd8ae1a81019b5d619742e76f13bbd |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width