Skip to content

Commit

Permalink
Updated Rector to commit b71c3265d5f90745d52b081a1201e3d97617e14a
Browse files Browse the repository at this point in the history
rectorphp/rector-src@b71c326 fix: RenameMethodRector should handle NullsafeMethodCall (#5444)
  • Loading branch information
TomasVotruba committed Jan 7, 2024
1 parent 2a79360 commit bddc91b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
11 changes: 6 additions & 5 deletions rules/Renaming/Rector/MethodCall/RenameMethodRector.php
Expand Up @@ -7,6 +7,7 @@
use PhpParser\Node;
use PhpParser\Node\Expr\ArrayDimFetch;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\NullsafeMethodCall;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Identifier;
use PhpParser\Node\Stmt\Class_;
Expand Down Expand Up @@ -72,10 +73,10 @@ public function getRuleDefinition() : RuleDefinition
*/
public function getNodeTypes() : array
{
return [MethodCall::class, StaticCall::class, Class_::class, Interface_::class];
return [MethodCall::class, NullsafeMethodCall::class, StaticCall::class, Class_::class, Interface_::class];
}
/**
* @param MethodCall|StaticCall|Class_|Interface_ $node
* @param MethodCall|NullsafeMethodCall|StaticCall|Class_|Interface_ $node
*/
public function refactorWithScope(Node $node, Scope $scope) : ?Node
{
Expand All @@ -93,7 +94,7 @@ public function configure(array $configuration) : void
$this->methodCallRenames = $configuration;
}
/**
* @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall $call
* @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\NullsafeMethodCall|\PhpParser\Node\Expr\StaticCall $call
*/
private function shouldSkipClassMethod($call, MethodCallRenameInterface $methodCallRename) : bool
{
Expand Down Expand Up @@ -179,8 +180,8 @@ private function shouldSkipRename(string $methodName, ClassMethod $classMethod,
return $this->hasClassNewClassMethod($classOrInterface, $methodCallRename);
}
/**
* @param \PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\MethodCall $call
* @return \PhpParser\Node\Expr\ArrayDimFetch|null|\PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall
* @param \PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\NullsafeMethodCall $call
* @return \PhpParser\Node\Expr\ArrayDimFetch|null|\PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\NullsafeMethodCall
*/
private function refactorMethodCallAndStaticCall($call)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Application/VersionResolver.php
Expand Up @@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '7f2155d5c0058a002790c05cae54b49405e154ac';
public const PACKAGE_VERSION = 'b71c3265d5f90745d52b081a1201e3d97617e14a';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2024-01-07 12:12:27';
public const RELEASE_DATE = '2024-01-07 17:54:29';
/**
* @var int
*/
Expand Down
2 changes: 1 addition & 1 deletion src/NodeTypeResolver/NodeTypeResolver.php
Expand Up @@ -280,7 +280,7 @@ public function getFullyQualifiedClassName(TypeWithClassName $typeWithClassName)
}
public function isMethodStaticCallOrClassMethodObjectType(Node $node, ObjectType $objectType) : bool
{
if ($node instanceof MethodCall) {
if ($node instanceof MethodCall || $node instanceof Expr\NullsafeMethodCall) {
// method call is variable return
return $this->isObjectType($node->var, $objectType);
}
Expand Down
5 changes: 3 additions & 2 deletions src/PhpParser/AstResolver.php
Expand Up @@ -7,6 +7,7 @@
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\NullsafeMethodCall;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Param;
use PhpParser\Node\Stmt;
Expand Down Expand Up @@ -186,11 +187,11 @@ public function resolveClassMethod(string $className, string $methodName) : ?Cla
return $classMethod;
}
/**
* @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall $call
* @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\NullsafeMethodCall $call
*/
public function resolveClassMethodFromCall($call) : ?ClassMethod
{
$callerStaticType = $call instanceof MethodCall ? $this->nodeTypeResolver->getType($call->var) : $this->nodeTypeResolver->getType($call->class);
$callerStaticType = $call instanceof MethodCall || $call instanceof NullsafeMethodCall ? $this->nodeTypeResolver->getType($call->var) : $this->nodeTypeResolver->getType($call->class);
if (!$callerStaticType instanceof TypeWithClassName) {
return null;
}
Expand Down
3 changes: 2 additions & 1 deletion src/Reflection/ReflectionResolver.php
Expand Up @@ -7,6 +7,7 @@
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\New_;
use PhpParser\Node\Expr\NullsafeMethodCall;
use PhpParser\Node\Expr\PropertyFetch;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Expr\StaticPropertyFetch;
Expand Down Expand Up @@ -97,7 +98,7 @@ public function resolveClassReflection(?Node $node) : ?ClassReflection
return $scope->getClassReflection();
}
/**
* @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\PropertyFetch|\PhpParser\Node\Expr\StaticPropertyFetch $node
* @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\NullsafeMethodCall|\PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\PropertyFetch|\PhpParser\Node\Expr\StaticPropertyFetch $node
*/
public function resolveClassReflectionSourceObject($node) : ?ClassReflection
{
Expand Down

0 comments on commit bddc91b

Please sign in to comment.