Skip to content

Commit ea3c9e5

Browse files
committed
Updated Rector to commit 5ce62c73c14eea1926c23bd58fecd67a6852816e
rectorphp/rector-src@5ce62c7 Fix StaticCallOnNonStaticToInstanceCallRector for same-class calls (#7876)
1 parent 003bde1 commit ea3c9e5

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

rules/Php70/Rector/StaticCall/StaticCallOnNonStaticToInstanceCallRector.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use PhpParser\Node\Expr\New_;
1010
use PhpParser\Node\Expr\PropertyFetch;
1111
use PhpParser\Node\Expr\StaticCall;
12+
use PhpParser\Node\Expr\Variable;
1213
use PHPStan\Analyser\Scope;
1314
use PHPStan\Reflection\ClassReflection;
1415
use PHPStan\Reflection\MethodReflection;
@@ -121,6 +122,10 @@ public function refactor(Node $node): ?Node
121122
if ($this->shouldSkip($methodName, $className, $node, $scope)) {
122123
return null;
123124
}
125+
$classReflection = $scope->getClassReflection();
126+
if ($classReflection instanceof ClassReflection && $classReflection->getName() === $className) {
127+
return new MethodCall(new Variable('this'), $node->name, $node->args);
128+
}
124129
if ($this->isInstantiable($className, $scope)) {
125130
$new = new New_($node->class);
126131
return new MethodCall($new, $node->name, $node->args);
@@ -157,8 +162,8 @@ private function shouldSkip(string $methodName, string $className, StaticCall $s
157162
if ($isStaticMethod) {
158163
return \true;
159164
}
160-
$reflection = $scope->getClassReflection();
161-
if ($reflection instanceof ClassReflection && $reflection->is($className)) {
165+
$currentClassReflection = $scope->getClassReflection();
166+
if ($currentClassReflection instanceof ClassReflection && $this->reflectionProvider->hasClass($className) && $currentClassReflection->isSubclassOfClass($this->reflectionProvider->getClass($className))) {
162167
return \true;
163168
}
164169
$className = $this->getName($staticCall->class);

src/Application/VersionResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ final class VersionResolver
1919
* @api
2020
* @var string
2121
*/
22-
public const PACKAGE_VERSION = 'ca9da16d1620daf8ca4a12912dee1aa8fbbb5b71';
22+
public const PACKAGE_VERSION = '5ce62c73c14eea1926c23bd58fecd67a6852816e';
2323
/**
2424
* @api
2525
* @var string
2626
*/
27-
public const RELEASE_DATE = '2026-02-03 14:12:25';
27+
public const RELEASE_DATE = '2026-02-03 19:00:29';
2828
/**
2929
* @var int
3030
*/

0 commit comments

Comments
 (0)