mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-22 02:52:23 +00:00
BetterNodeFinder improvements
This commit is contained in:
parent
e61f80bd21
commit
8685a44ed0
|
@ -202,7 +202,7 @@ final class ClassMethodReturnTypeOverrideGuard
|
|||
|
||||
private function hasClassMethodExprReturn(ClassMethod $classMethod): bool
|
||||
{
|
||||
return (bool) $this->betterNodeFinder->findFirst($classMethod->getStmts(), function (Node $node): bool {
|
||||
return (bool) $this->betterNodeFinder->findFirst((array) $classMethod->stmts, function (Node $node): bool {
|
||||
if (! $node instanceof Return_) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -584,3 +584,6 @@ parameters:
|
|||
|
||||
- '#Method Rector\\Testing\\Finder\\RectorsFinder\:\:findClassesInDirectoriesByName\(\) should return array<class\-string\> but returns array<int, string\>#'
|
||||
- '#Cannot cast array<string\>\|string\|null to string#'
|
||||
|
||||
# phpstan bug
|
||||
- '#Unable to resolve the template type T in call to method Rector\\Core\\PhpParser\\Node\\BetterNodeFinder\:\:findParentTypes\(\)#'
|
||||
|
|
|
@ -130,7 +130,7 @@ final class PromotedPropertyResolver
|
|||
foreach ($classMethod->params as $param) {
|
||||
$paramName = $this->nodeNameResolver->getName($param);
|
||||
|
||||
$firstParamVariable = $this->betterNodeFinder->findFirst($classMethod->stmts, function (Node $node) use (
|
||||
$firstParamVariable = $this->betterNodeFinder->findFirst((array) $classMethod->stmts, function (Node $node) use (
|
||||
$paramName
|
||||
): bool {
|
||||
if (! $node instanceof Variable) {
|
||||
|
|
|
@ -182,10 +182,8 @@ final class ComplexNodeRemover
|
|||
return;
|
||||
}
|
||||
|
||||
$constructClassMethodStmts = $constructClassMethod->stmts;
|
||||
|
||||
foreach ($constructClassMethod->getParams() as $param) {
|
||||
$variable = $this->betterNodeFinder->findFirst($constructClassMethodStmts, function (Node $node) use (
|
||||
$variable = $this->betterNodeFinder->findFirst((array) $constructClassMethod->stmts, function (Node $node) use (
|
||||
$param
|
||||
): bool {
|
||||
return $this->nodeComparator->areNodesEqual($param->var, $node);
|
||||
|
|
|
@ -85,7 +85,7 @@ final class BetterNodeFinder
|
|||
}
|
||||
|
||||
/**
|
||||
* @template T of Node
|
||||
* @template T of \PhpParser\Node
|
||||
* @param array<class-string<T>> $types
|
||||
* @return T|null
|
||||
*/
|
||||
|
@ -347,8 +347,8 @@ final class BetterNodeFinder
|
|||
}
|
||||
|
||||
/**
|
||||
* @param Node|Node[] $nodes
|
||||
* @template T of Node
|
||||
* @param Node|Node[] $nodes
|
||||
* @param class-string<T> $type
|
||||
* @return T|null
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue
Block a user