Skip to content

Commit 594fe2a

Browse files
committed
Updated Rector to commit a67177aaba985b73a259f638c612328d667553ac
rectorphp/rector-src@a67177a [renaming Add enum support to rename method (#6832)
1 parent 4d63e54 commit 594fe2a

2 files changed

Lines changed: 29 additions & 2 deletions

File tree

src/Application/VersionResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ final class VersionResolver
1919
* @api
2020
* @var string
2121
*/
22-
public const PACKAGE_VERSION = '09122aac68a2581a18059a321a25cee1a0513408';
22+
public const PACKAGE_VERSION = 'a67177aaba985b73a259f638c612328d667553ac';
2323
/**
2424
* @api
2525
* @var string
2626
*/
27-
public const RELEASE_DATE = '2025-04-12 16:18:59';
27+
public const RELEASE_DATE = '2025-04-14 13:32:01';
2828
/**
2929
* @var int
3030
*/

src/NodeTypeResolver/NodeTypeResolver.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
declare (strict_types=1);
44
namespace Rector\NodeTypeResolver;
55

6+
use PhpParser\Node\Name\FullyQualified;
67
use PhpParser\Node;
78
use PhpParser\Node\Expr;
89
use PhpParser\Node\Expr\ArrayDimFetch;
@@ -281,6 +282,9 @@ public function getFullyQualifiedClassName(TypeWithClassName $typeWithClassName)
281282
public function isMethodStaticCallOrClassMethodObjectType(Node $node, ObjectType $objectType) : bool
282283
{
283284
if ($node instanceof MethodCall || $node instanceof NullsafeMethodCall) {
285+
if ($this->isEnumTypeMatch($node, $objectType)) {
286+
return \true;
287+
}
284288
// method call is variable return
285289
return $this->isObjectType($node->var, $objectType);
286290
}
@@ -497,4 +501,27 @@ private function resolveNativeTypeWithBuiltinMethodCallFallback(Expr $expr, Scop
497501
}
498502
return $scope->getNativeType($expr);
499503
}
504+
/**
505+
* @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\NullsafeMethodCall $call
506+
*/
507+
private function isEnumTypeMatch($call, ObjectType $objectType) : bool
508+
{
509+
if (!$call->var instanceof ClassConstFetch) {
510+
return \false;
511+
}
512+
// possibly enum
513+
$classConstFetch = $call->var;
514+
if (!$classConstFetch->class instanceof FullyQualified) {
515+
return \false;
516+
}
517+
$className = $classConstFetch->class->toString();
518+
if (!$this->reflectionProvider->hasClass($className)) {
519+
return \false;
520+
}
521+
$classReflection = $this->reflectionProvider->getClass($className);
522+
if (!$classReflection->isEnum()) {
523+
return \false;
524+
}
525+
return $classReflection->getName() === $objectType->getClassName();
526+
}
500527
}

0 commit comments

Comments
 (0)