René's URL Explorer Experiment


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

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@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-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:e254736b-62db-3b72-7e62-99c92cba2a6c
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idA79C:30B78A:3CB43D:530062:6B006D9C
html-safe-noncebbe80452e3cd3fca9e3908e3494eb46be9efc964c65f87a1cf69bf5cf3adcf0e
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNzlDOjMwQjc4QTozQ0I0M0Q6NTMwMDYyOjZCMDA2RDlDIiwidmlzaXRvcl9pZCI6IjMzMTcyMjE3ODEwMjE5NDUyNDQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacf9fc72e4078011ec318cbc70aed18504628497d619d4fb7bb888bfd0108ac954
hovercard-subject-tagissue:4539668907
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/phpstan/phpstan-phpunit/299/issue_layout
twitter:imagehttps://opengraph.githubassets.com/c3532293f8566a7895b9dc5183efa36e5ad40937e158c6365722f3d72ad84f08/phpstan/phpstan-phpunit/issues/299
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/c3532293f8566a7895b9dc5183efa36e5ad40937e158c6365722f3d72ad84f08/phpstan/phpstan-phpunit/issues/299
og:image:altAfter 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:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamealexander-schranz
hostnamegithub.com
expected-hostnamegithub.com
None6527e91c60c0b29d16606ff32ac5df8ecdc37a2a62205ea057a14d7762c870fa
turbo-cache-controlno-preview
go-importgithub.com/phpstan/phpstan-phpunit git https://github.com/phpstan/phpstan-phpunit.git
octolytics-dimension-user_id16435710
octolytics-dimension-user_loginphpstan
octolytics-dimension-repository_id105883921
octolytics-dimension-repository_nwophpstan/phpstan-phpunit
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id105883921
octolytics-dimension-repository_network_root_nwophpstan/phpstan-phpunit
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release46f1cd2ae3cd8ae1a81019b5d619742e76f13bbd
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/phpstan/phpstan-phpunit/issues/299#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fphpstan%2Fphpstan-phpunit%2Fissues%2F299
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fphpstan%2Fphpstan-phpunit%2Fissues%2F299
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=phpstan%2Fphpstan-phpunit
Reloadhttps://github.com/phpstan/phpstan-phpunit/issues/299
Reloadhttps://github.com/phpstan/phpstan-phpunit/issues/299
Reloadhttps://github.com/phpstan/phpstan-phpunit/issues/299
phpstanhttps://github.com/phpstan
phpstan-phpunithttps://github.com/phpstan/phpstan-phpunit
Codehttps://github.com/phpstan/phpstan-phpunit
Issues34 (34)https://github.com/phpstan/phpstan-phpunit/issues
Pull requests7 (7)https://github.com/phpstan/phpstan-phpunit/pulls
Actionshttps://github.com/phpstan/phpstan-phpunit/actions
Projectshttps://github.com/phpstan/phpstan-phpunit/projects
Security and qualityhttps://github.com/phpstan/phpstan-phpunit/security
Insightshttps://github.com/phpstan/phpstan-phpunit/insights
https://github.com/phpstan/phpstan-phpunit
New issuehttps://github.com/login?return_to=https://github.com/phpstan/phpstan-phpunit/issues/299
New issuehttps://github.com/login?return_to=https://github.com/phpstan/phpstan-phpunit/issues/299
Unexpected errors with willReturn called on withhttps://github.com/phpstan/phpstan-phpunit/issues/299#top
https://github.com/alexander-schranz
alexander-schranzhttps://github.com/alexander-schranz
on May 28, 2026https://github.com/phpstan/phpstan-phpunit/issues/299#issue-4539668907
https://github.com/VincentLanglet
VincentLanglethttps://github.com/VincentLanglet
on May 28, 2026https://github.com/phpstan/phpstan-phpunit/issues/299#issuecomment-4563303259
with*() can be used without expects() sebastianbergmann/phpunit#6504https://github.com/sebastianbergmann/phpunit/issues/6504
Deprecate support for using with*() without expects() sebastianbergmann/phpunit#6507https://github.com/sebastianbergmann/phpunit/issues/6507
Remove support for using with() without expects() sebastianbergmann/phpunit#6508https://github.com/sebastianbergmann/phpunit/issues/6508
https://github.com/alexander-schranz
alexander-schranzhttps://github.com/alexander-schranz
on May 28, 2026https://github.com/phpstan/phpstan-phpunit/issues/299#issuecomment-4563467403
@VincentLanglethttps://github.com/VincentLanglet
alexander-schranzhttps://github.com/alexander-schranz
on May 28, 2026https://github.com/phpstan/phpstan-phpunit/issues/299#event-26059418257
Sign up for freehttps://github.com/signup?return_to=https://github.com/phpstan/phpstan-phpunit/issues/299
Sign in to commenthttps://github.com/login?return_to=https://github.com/phpstan/phpstan-phpunit/issues/299
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.