Skip to content

Commit

Permalink
remove isLocalStaticPropertyFetchNamed()
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Mar 19, 2021
1 parent 83dd98e commit d2595f5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 34 deletions.
26 changes: 0 additions & 26 deletions packages/NodeNameResolver/NodeNameResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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)
Expand Down
14 changes: 7 additions & 7 deletions rules/Naming/PropertyRenamer/PropertyFetchRenamer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/HttpKernel/RectorKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function registerBundles(): iterable
new ConsoleColorDiffBundle(),
new ComposerJsonManipulatorBundle(),
new SkipperBundle(),
new SimplePhpDocParserBundle()
new SimplePhpDocParserBundle(),
];

return $bundles;
Expand Down

0 comments on commit d2595f5

Please sign in to comment.