diff --git a/packages/NodeNameResolver/NodeNameResolver.php b/packages/NodeNameResolver/NodeNameResolver.php index 60273b9839f5..f145f375af50 100644 --- a/packages/NodeNameResolver/NodeNameResolver.php +++ b/packages/NodeNameResolver/NodeNameResolver.php @@ -11,7 +11,6 @@ use PhpParser\Node\Expr\New_; use PhpParser\Node\Expr\PropertyFetch; use PhpParser\Node\Expr\StaticCall; -use PhpParser\Node\Expr\StaticPropertyFetch; use PhpParser\Node\Expr\Variable; use PhpParser\Node\Identifier; use PhpParser\Node\Name; @@ -183,22 +182,6 @@ public function getNames(array $nodes): array return $names; } - /** - * @param Node[] $nodes - */ - public function haveName(array $nodes, string $name): bool - { - foreach ($nodes as $node) { - if (! $this->isName($node, $name)) { - continue; - } - - return true; - } - - return false; - } - public function isLocalPropertyFetchNamed(Node $node, string $name): bool { if (! $node instanceof PropertyFetch) { @@ -220,15 +203,6 @@ public function isLocalPropertyFetchNamed(Node $node, string $name): bool return $this->isName($node->name, $name); } - public function isLocalStaticPropertyFetchNamed(Node $node, string $name): bool - { - if (! $node instanceof StaticPropertyFetch) { - return false; - } - - return $this->isName($node->name, $name); - } - /** * Ends with ucname * Starts with adjective, e.g. (Post $firstPost, Post $secondPost) diff --git a/rules/Naming/PropertyRenamer/PropertyFetchRenamer.php b/rules/Naming/PropertyRenamer/PropertyFetchRenamer.php index 92c81c8ca75c..5602a059da27 100644 --- a/rules/Naming/PropertyRenamer/PropertyFetchRenamer.php +++ b/rules/Naming/PropertyRenamer/PropertyFetchRenamer.php @@ -47,16 +47,16 @@ function (Node $node) use ($currentName, $expectedName): ?Node { return $node; } - if ($this->nodeNameResolver->isLocalStaticPropertyFetchNamed($node, $currentName)) { - if (! $node instanceof StaticPropertyFetch) { - return null; - } + if (! $node instanceof StaticPropertyFetch) { + return null; + } - $node->name = new VarLikeIdentifier($expectedName); - return $node; + if (! $this->nodeNameResolver->isName($node->name, $currentName)) { + return null; } - return null; + $node->name = new VarLikeIdentifier($expectedName); + return $node; } ); } diff --git a/src/HttpKernel/RectorKernel.php b/src/HttpKernel/RectorKernel.php index 6d9de0f4ade7..567db38a20bc 100644 --- a/src/HttpKernel/RectorKernel.php +++ b/src/HttpKernel/RectorKernel.php @@ -90,7 +90,7 @@ public function registerBundles(): iterable new ConsoleColorDiffBundle(), new ComposerJsonManipulatorBundle(), new SkipperBundle(), - new SimplePhpDocParserBundle() + new SimplePhpDocParserBundle(), ]; return $bundles;