From 56658a578d4d7eaae3df7473d6215ad051814099 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Thu, 29 Jan 2026 17:31:24 +0100 Subject: [PATCH] skip property fetch --- ...y_as_can_be_defined_multiple_times.php.inc | 21 +++++++++++++++++++ .../ExplicitMockExpectsCallRector.php | 3 +-- 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 rules-tests/PHPUnit120/Rector/MethodCall/ExplicitMockExpectsCallRector/Fixture/skip_property_as_can_be_defined_multiple_times.php.inc diff --git a/rules-tests/PHPUnit120/Rector/MethodCall/ExplicitMockExpectsCallRector/Fixture/skip_property_as_can_be_defined_multiple_times.php.inc b/rules-tests/PHPUnit120/Rector/MethodCall/ExplicitMockExpectsCallRector/Fixture/skip_property_as_can_be_defined_multiple_times.php.inc new file mode 100644 index 00000000..60aad890 --- /dev/null +++ b/rules-tests/PHPUnit120/Rector/MethodCall/ExplicitMockExpectsCallRector/Fixture/skip_property_as_can_be_defined_multiple_times.php.inc @@ -0,0 +1,21 @@ +someClass = $this->createMock(\stdClass::class); + } + + public function test(): void + { + $this->someClass->method('some'); + } +} diff --git a/rules/PHPUnit120/Rector/MethodCall/ExplicitMockExpectsCallRector.php b/rules/PHPUnit120/Rector/MethodCall/ExplicitMockExpectsCallRector.php index 7ae04e76..d6b417af 100644 --- a/rules/PHPUnit120/Rector/MethodCall/ExplicitMockExpectsCallRector.php +++ b/rules/PHPUnit120/Rector/MethodCall/ExplicitMockExpectsCallRector.php @@ -7,7 +7,6 @@ use PhpParser\Node; use PhpParser\Node\Arg; use PhpParser\Node\Expr\MethodCall; -use PhpParser\Node\Expr\PropertyFetch; use PhpParser\Node\Expr\Variable; use PHPStan\Type\ObjectType; use Rector\PHPStan\ScopeFetcher; @@ -87,7 +86,7 @@ public function refactor(Node $node): Node|null return null; } - if (! $node->var instanceof Variable && ! $node->var instanceof PropertyFetch) { + if (! $node->var instanceof Variable) { return null; }