Skip to content

Commit 9ada35f

Browse files
committed
Updated Rector to commit c7278fa576a22288228814bc2b20bd0cddea4677
rectorphp/rector-src@c7278fa [Renaming] Allow rename method in trait itself on RenameMethodRector (#6942)
1 parent 3ba0a66 commit 9ada35f

File tree

6 files changed

+20
-19
lines changed

6 files changed

+20
-19
lines changed

rules/Renaming/Rector/MethodCall/RenameMethodRector.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use PhpParser\Node\Stmt\Class_;
1414
use PhpParser\Node\Stmt\ClassMethod;
1515
use PhpParser\Node\Stmt\Interface_;
16+
use PhpParser\Node\Stmt\Trait_;
1617
use PHPStan\Analyser\Scope;
1718
use PHPStan\Reflection\ClassReflection;
1819
use PHPStan\Reflection\ReflectionProvider;
@@ -71,15 +72,15 @@ public function getRuleDefinition() : RuleDefinition
7172
*/
7273
public function getNodeTypes() : array
7374
{
74-
return [MethodCall::class, NullsafeMethodCall::class, StaticCall::class, Class_::class, Interface_::class];
75+
return [MethodCall::class, NullsafeMethodCall::class, StaticCall::class, Class_::class, Trait_::class, Interface_::class];
7576
}
7677
/**
77-
* @param MethodCall|NullsafeMethodCall|StaticCall|Class_|Interface_ $node
78+
* @param MethodCall|NullsafeMethodCall|StaticCall|Class_|Interface_|Trait_ $node
7879
*/
7980
public function refactor(Node $node) : ?Node
8081
{
8182
$scope = ScopeFetcher::fetch($node);
82-
if ($node instanceof Class_ || $node instanceof Interface_) {
83+
if ($node instanceof Class_ || $node instanceof Trait_ || $node instanceof Interface_) {
8384
return $this->refactorClass($node, $scope);
8485
}
8586
return $this->refactorMethodCallAndStaticCall($node);
@@ -116,7 +117,7 @@ private function shouldSkipClassMethod($call, MethodCallRenameInterface $methodC
116117
return $classReflection->hasMethod($methodCallRename->getNewMethod());
117118
}
118119
/**
119-
* @param \PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\Interface_ $classOrInterface
120+
* @param \PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\Trait_|\PhpParser\Node\Stmt\Interface_ $classOrInterface
120121
*/
121122
private function hasClassNewClassMethod($classOrInterface, MethodCallRenameInterface $methodCallRename) : bool
122123
{
@@ -134,14 +135,11 @@ private function shouldKeepForParentInterface(MethodCallRenameInterface $methodC
134135
return $this->classManipulator->hasParentMethodOrInterface($methodCallRename->getObjectType(), $methodCallRename->getOldMethod());
135136
}
136137
/**
137-
* @param \PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\Interface_ $classOrInterface
138-
* @return \PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\Interface_|null
138+
* @param \PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\Trait_|\PhpParser\Node\Stmt\Interface_ $classOrInterface
139+
* @return \PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\Trait_|\PhpParser\Node\Stmt\Interface_|null
139140
*/
140141
private function refactorClass($classOrInterface, Scope $scope)
141142
{
142-
if (!$scope->isInClass()) {
143-
return null;
144-
}
145143
$classReflection = $scope->getClassReflection();
146144
$hasChanged = \false;
147145
foreach ($classOrInterface->getMethods() as $classMethod) {
@@ -164,13 +162,16 @@ private function refactorClass($classOrInterface, Scope $scope)
164162
return null;
165163
}
166164
/**
167-
* @param \PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\Interface_ $classOrInterface
165+
* @param \PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\Trait_|\PhpParser\Node\Stmt\Interface_ $classOrInterface
168166
*/
169167
private function shouldSkipRename(string $methodName, ClassMethod $classMethod, MethodCallRenameInterface $methodCallRename, $classOrInterface, ?ClassReflection $classReflection) : bool
170168
{
171169
if (!$this->nodeNameResolver->isStringName($methodName, $methodCallRename->getOldMethod())) {
172170
return \true;
173171
}
172+
if (!$classReflection instanceof ClassReflection && $classOrInterface instanceof Trait_) {
173+
return $this->hasClassNewClassMethod($classOrInterface, $methodCallRename);
174+
}
174175
if (!$this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType($classMethod, $methodCallRename->getObjectType())) {
175176
return \true;
176177
}

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 = '8874702f3aeacf4dfe59e8f57b5d62c63d1dce79';
22+
public const PACKAGE_VERSION = 'c7278fa576a22288228814bc2b20bd0cddea4677';
2323
/**
2424
* @api
2525
* @var string
2626
*/
27-
public const RELEASE_DATE = '2025-05-28 23:48:48';
27+
public const RELEASE_DATE = '2025-05-29 09:00:48';
2828
/**
2929
* @var int
3030
*/

vendor/composer/installed.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,12 +1687,12 @@
16871687
"source": {
16881688
"type": "git",
16891689
"url": "https:\/\/github.com\/rectorphp\/rector-doctrine.git",
1690-
"reference": "5bb5fdc4d5f0801579f60d3963a1d9db2d1a66ff"
1690+
"reference": "f3e5d75fc7ba1aa8421e4709ec150c3b3fbbdb11"
16911691
},
16921692
"dist": {
16931693
"type": "zip",
1694-
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/5bb5fdc4d5f0801579f60d3963a1d9db2d1a66ff",
1695-
"reference": "5bb5fdc4d5f0801579f60d3963a1d9db2d1a66ff",
1694+
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/f3e5d75fc7ba1aa8421e4709ec150c3b3fbbdb11",
1695+
"reference": "f3e5d75fc7ba1aa8421e4709ec150c3b3fbbdb11",
16961696
"shasum": ""
16971697
},
16981698
"require": {
@@ -1715,7 +1715,7 @@
17151715
"tomasvotruba\/class-leak": "^2.0",
17161716
"tracy\/tracy": "^2.10"
17171717
},
1718-
"time": "2025-05-28T20:55:14+00:00",
1718+
"time": "2025-05-28T23:02:46+00:00",
17191719
"default-branch": true,
17201720
"type": "rector-extension",
17211721
"extra": {

vendor/composer/installed.php

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

vendor/rector/extension-installer/src/GeneratedConfig.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010
final class GeneratedConfig
1111
{
12-
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => NULL, 'version' => 'dev-main 5bb5fdc'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => NULL, 'version' => 'dev-main e43dd7a'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => NULL, 'version' => 'dev-main 52398e7'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => NULL, 'version' => 'dev-main ca5ee11'));
12+
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => NULL, 'version' => 'dev-main f3e5d75'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => NULL, 'version' => 'dev-main e43dd7a'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => NULL, 'version' => 'dev-main 52398e7'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => NULL, 'version' => 'dev-main ca5ee11'));
1313
private function __construct()
1414
{
1515
}

vendor/rector/rector-doctrine/rules/TypedCollections/Rector/ClassMethod/CollectionSetterParamNativeTypeRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function getNodeTypes() : array
7878
*/
7979
public function refactor(Node $node) : ?ClassMethod
8080
{
81-
if ($node->isAbstract() || $node->stmts === null) {
81+
if ($node->isAbstract()) {
8282
return null;
8383
}
8484
$hasChanged = \false;

0 commit comments

Comments
 (0)