mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-01 00:40:52 +00:00
Node too free types fixes
This commit is contained in:
parent
dfa47b493e
commit
480381bbe1
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Rector\NodeTypeResolver;
|
||||
|
||||
use PhpParser\Node\Expr\Closure;
|
||||
use PhpParser\Node\FunctionLike;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassLike;
|
||||
|
@ -100,6 +101,10 @@ final class TypeContext
|
|||
return null;
|
||||
}
|
||||
|
||||
if ($functionLikeNode instanceof Closure) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$methodName = (string) $functionLikeNode->name;
|
||||
|
||||
return new ReflectionMethod($className, $methodName);
|
||||
|
|
|
@ -5,8 +5,10 @@ namespace Rector\NodeTypeResolver\TypesExtractor;
|
|||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\Assign;
|
||||
use PhpParser\Node\Expr\PropertyFetch;
|
||||
use PhpParser\Node\Expr\StaticCall;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
use ReflectionClass;
|
||||
|
||||
final class ConstructorPropertyTypesExtractor
|
||||
|
@ -68,6 +70,14 @@ final class ConstructorPropertyTypesExtractor
|
|||
|
||||
private function isAssignThisNode(Node $node): bool
|
||||
{
|
||||
if (! $node instanceof Expression) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->isParentConstructCall($node)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (! $node->expr instanceof Assign) {
|
||||
return false;
|
||||
}
|
||||
|
@ -106,4 +116,17 @@ final class ConstructorPropertyTypesExtractor
|
|||
|
||||
return $propertiesWithTypes;
|
||||
}
|
||||
|
||||
private function isParentConstructCall(Node $node): bool
|
||||
{
|
||||
if (! $node instanceof Expression) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (! $node->expr instanceof StaticCall) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $node->expr->name === '__construct';
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user