Skip to content

Commit

Permalink
Updated Rector to commit 0bfd08d038d2932ff6efb6a210a8985ac6364afa
Browse files Browse the repository at this point in the history
rectorphp/rector-src@0bfd08d [NodeTypeResolver] Handle namespaced function call name on NodeTypeResolver (#6564)
  • Loading branch information
TomasVotruba committed Dec 12, 2024
1 parent c578222 commit 6e4ecfe
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/Application/VersionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '184eb2ed84405c011740792f1fee4e914e11b445';
public const PACKAGE_VERSION = '0bfd08d038d2932ff6efb6a210a8985ac6364afa';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2024-12-12 08:12:34';
public const RELEASE_DATE = '2024-12-12 16:24:52';
/**
* @var int
*/
Expand Down
13 changes: 10 additions & 3 deletions src/NodeTypeResolver/NodeTypeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
use Rector\Configuration\RenamedClassesDataCollector;
use Rector\Exception\ShouldNotHappenException;
use Rector\NodeAnalyzer\ClassAnalyzer;
use Rector\NodeNameResolver\NodeNameResolver;
use Rector\NodeTypeResolver\Contract\NodeTypeResolverAwareInterface;
use Rector\NodeTypeResolver\Contract\NodeTypeResolverInterface;
use Rector\NodeTypeResolver\Node\AttributeKey;
Expand Down Expand Up @@ -78,6 +79,10 @@ final class NodeTypeResolver
* @readonly
*/
private RenamedClassesDataCollector $renamedClassesDataCollector;
/**
* @readonly
*/
private NodeNameResolver $nodeNameResolver;
/**
* @var string
*/
Expand All @@ -89,14 +94,15 @@ final class NodeTypeResolver
/**
* @param NodeTypeResolverInterface[] $nodeTypeResolvers
*/
public function __construct(ObjectTypeSpecifier $objectTypeSpecifier, ClassAnalyzer $classAnalyzer, GenericClassStringTypeCorrector $genericClassStringTypeCorrector, ReflectionProvider $reflectionProvider, AccessoryNonEmptyStringTypeCorrector $accessoryNonEmptyStringTypeCorrector, RenamedClassesDataCollector $renamedClassesDataCollector, iterable $nodeTypeResolvers)
public function __construct(ObjectTypeSpecifier $objectTypeSpecifier, ClassAnalyzer $classAnalyzer, GenericClassStringTypeCorrector $genericClassStringTypeCorrector, ReflectionProvider $reflectionProvider, AccessoryNonEmptyStringTypeCorrector $accessoryNonEmptyStringTypeCorrector, RenamedClassesDataCollector $renamedClassesDataCollector, NodeNameResolver $nodeNameResolver, iterable $nodeTypeResolvers)
{
$this->objectTypeSpecifier = $objectTypeSpecifier;
$this->classAnalyzer = $classAnalyzer;
$this->genericClassStringTypeCorrector = $genericClassStringTypeCorrector;
$this->reflectionProvider = $reflectionProvider;
$this->accessoryNonEmptyStringTypeCorrector = $accessoryNonEmptyStringTypeCorrector;
$this->renamedClassesDataCollector = $renamedClassesDataCollector;
$this->nodeNameResolver = $nodeNameResolver;
foreach ($nodeTypeResolvers as $nodeTypeResolver) {
if ($nodeTypeResolver instanceof NodeTypeResolverAwareInterface) {
$nodeTypeResolver->autowire($this);
Expand Down Expand Up @@ -479,10 +485,11 @@ private function resolveNativeTypeWithBuiltinMethodCallFallback(Expr $expr, Scop
if (!$expr->name instanceof Name) {
return $scope->getNativeType($expr);
}
if (!$this->reflectionProvider->hasFunction($expr->name, $scope)) {
$functionName = new Name((string) $this->nodeNameResolver->getName($expr));
if (!$this->reflectionProvider->hasFunction($functionName, $scope)) {
return $scope->getNativeType($expr);
}
$functionReflection = $this->reflectionProvider->getFunction($expr->name, $scope);
$functionReflection = $this->reflectionProvider->getFunction($functionName, $scope);
if (!$functionReflection instanceof NativeFunctionReflection) {
return $scope->getNativeType($expr);
}
Expand Down
6 changes: 4 additions & 2 deletions src/PhpParser/AstResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\NullsafeMethodCall;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Name;
use PhpParser\Node\Param;
use PhpParser\Node\Stmt;
use PhpParser\Node\Stmt\Class_;
Expand Down Expand Up @@ -340,10 +341,11 @@ private function resolveFunctionFromFuncCall(FuncCall $funcCall, Scope $scope) :
if ($funcCall->name instanceof Expr) {
return null;
}
if (!$this->reflectionProvider->hasFunction($funcCall->name, $scope)) {
$functionName = new Name((string) $this->nodeNameResolver->getName($funcCall));
if (!$this->reflectionProvider->hasFunction($functionName, $scope)) {
return null;
}
$functionReflection = $this->reflectionProvider->getFunction($funcCall->name, $scope);
$functionReflection = $this->reflectionProvider->getFunction($functionName, $scope);
return $this->resolveFunctionFromFunctionReflection($functionReflection);
}
}
5 changes: 3 additions & 2 deletions src/Reflection/ReflectionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,9 @@ private function resolveFunctionReflectionFromFuncCall(FuncCall $funcCall)
if (!$funcCall->name instanceof Name) {
return null;
}
if ($this->reflectionProvider->hasFunction($funcCall->name, $scope)) {
return $this->reflectionProvider->getFunction($funcCall->name, $scope);
$functionName = new Name((string) $this->nodeNameResolver->getName($funcCall));
if ($this->reflectionProvider->hasFunction($functionName, $scope)) {
return $this->reflectionProvider->getFunction($functionName, $scope);
}
return null;
}
Expand Down

0 comments on commit 6e4ecfe

Please sign in to comment.