Unexpected errors with `willReturn` called on `with`
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Reproduce the reported diagnostic using the shown PHPUnit mock chain and the listed PHPStan and PHPUnit versions. Inspect the PHPStan PHPUnit extension's handling of with() and willReturn(); done means the chain no longer reports InvocationStubber::with() as undefined while unrelated invalid calls remain detectable.
Written by the indexing model from the issue text.
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;
class RegisterPreviewWebspaceClassPassTest extends TestCase
{
/** @var ContainerBuilder&MockObject */
private $containerBuilderMock;
public function testShouldNotOverrideWebspaceCacheClass(): void
{
$this->containerBuilderMock
->method('hasExtension')
->with('sulu_core')
->willReturn(false);
}
28 Call to an undefined method PHPUnit\Framework\MockObject\InvocationStubber::with().
🪪 method.notFound
Packages which are installed related to PHPUnit:
phpspec/prophecy-phpunit 2.5.0 Integrating the Prophecy mocking library in PHPUnit test cases
phpstan/phpstan-phpunit 2.0.16 PHPUnit extensions and rules for PHPStan
phpunit/php-code-coverage 14.1.9 Library that provides collection, processing, and rendering functionality for PHP code covera...
phpunit/php-file-iterator 7.0.0 FilterIterator implementation that filters files based on a list of suffixes.
phpunit/php-invoker 7.0.0 Invoke callables with a timeout
phpunit/php-text-template 6.0.0 Simple template engine.
phpunit/php-timer 9.0.0 Utility class for timing
phpunit/phpunit 13.1.13 The PHP Unit Testing framework.
symfony/phpunit-bridge 7.4.8 Provides utilities for PHPUnit, especially user deprecation notices management
- Dominant language
- PHP
- Stars
- 547
- Forks
- 61
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 13
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from phpstan/phpstan-phpunit
-
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
phpstan/phpstan-phpunit#361 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
phpstan/phpstan-phpunit#321 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
phpstan/phpstan-phpunit#309 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 52/100
phpstan/phpstan-phpunit#292 · 3 comments ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 20/100
phpstan/phpstan-phpunit#291 ·
Maintainers usually reply within 1 day
All issues in phpstan/phpstan-phpunit
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
2DAW-CarlosIII/eportfolio_g5#35 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
2DAW-CarlosIII/eportfolio_g4#33 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
2DAW-CarlosIII/eportfolio_g1#34 ·
Maintainers usually reply within 2 days
-
area/admin type/enhancement when/soon
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
P2 Team S Type: Infrastructure
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
google/site-kit-wp#14271 ·
Maintainers usually reply within 2 days