Skip to content

Commit

Permalink
Updated Rector to commit 172d354a23c7b437f255709c7b85dcf667f41adb
Browse files Browse the repository at this point in the history
rectorphp/rector-src@172d354 [Core] Ensure locate on same ClassLike name on AstResolver (#3493)
  • Loading branch information
TomasVotruba committed Mar 20, 2023
1 parent 5acf36b commit 9186224
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 21 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 = '7dcd5f6503afa3ee7ab086cbfe6afb71cbd6d6ec';
public const PACKAGE_VERSION = '172d354a23c7b437f255709c7b85dcf667f41adb';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-03-20 15:25:39';
public const RELEASE_DATE = '2023-03-20 17:22:54';
/**
* @var int
*/
Expand Down
37 changes: 28 additions & 9 deletions src/PhpParser/AstResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use Rector\Core\ValueObject\Application\File;
use Rector\Core\ValueObject\MethodName;
use Rector\NodeNameResolver\NodeNameResolver;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\NodeTypeResolver\NodeScopeAndMetadataDecorator;
use Rector\NodeTypeResolver\NodeTypeResolver;
use Rector\PhpDocParser\PhpParser\SmartPhpParser;
Expand Down Expand Up @@ -123,14 +124,21 @@ public function resolveClassMethodFromMethodReflection(MethodReflection $methodR
if ($nodes === null) {
return null;
}
/** @var ClassLike|null $classLike */
$classLike = $this->betterNodeFinder->findFirst($nodes, function (Node $node) use($classLikeName, $methodName) : bool {
return $node instanceof ClassLike && $this->nodeNameResolver->isName($node, $classLikeName) && $node->getMethod($methodName) instanceof ClassMethod;
/** @var ClassMethod|null $classMethod */
$classMethod = $this->betterNodeFinder->findFirst($nodes, function (Node $node) use($classLikeName, $methodName) : bool {
if (!$node instanceof ClassMethod) {
return \false;
}
$parentNode = $node->getAttribute(AttributeKey::PARENT_NODE);
if (!$parentNode instanceof ClassLike) {
return \false;
}
if (!$this->nodeNameResolver->isName($parentNode, $classLikeName)) {
return \false;
}
return $parentNode->getMethod($methodName) === $node;
});
if ($classLike instanceof ClassLike && ($method = $classLike->getMethod($methodName)) instanceof ClassMethod) {
return $method;
}
return null;
return $classMethod;
}
/**
* @param \PhpParser\Node\Expr\FuncCall|\PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\MethodCall $call
Expand Down Expand Up @@ -244,10 +252,21 @@ public function resolvePropertyFromPropertyReflection(PhpPropertyReflection $php
return null;
}
$nativeReflectionProperty = $phpPropertyReflection->getNativeReflection();
$desiredClassName = $classReflection->getName();
$desiredPropertyName = $nativeReflectionProperty->getName();
/** @var Property|null $property */
$property = $this->betterNodeFinder->findFirst($nodes, function (Node $node) use($desiredPropertyName) : bool {
return $node instanceof Property && $this->nodeNameResolver->isName($node, $desiredPropertyName);
$property = $this->betterNodeFinder->findFirst($nodes, function (Node $node) use($desiredClassName, $desiredPropertyName) : bool {
if (!$node instanceof Property) {
return \false;
}
$parentNode = $node->getAttribute(AttributeKey::PARENT_NODE);
if (!$parentNode instanceof ClassLike) {
return \false;
}
if (!$this->nodeNameResolver->isName($parentNode, $desiredClassName)) {
return \false;
}
return $parentNode->getProperty($desiredPropertyName) === $node;
});
if ($property instanceof Property) {
return $property;
Expand Down
2 changes: 1 addition & 1 deletion vendor/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInit42dbbea9f76bc2ad016504e8bbeaac67::getLoader();
return ComposerAutoloaderInit5768fe3ac9bf02789dddb40517996133::getLoader();
10 changes: 5 additions & 5 deletions vendor/composer/autoload_real.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// autoload_real.php @generated by Composer

class ComposerAutoloaderInit42dbbea9f76bc2ad016504e8bbeaac67
class ComposerAutoloaderInit5768fe3ac9bf02789dddb40517996133
{
private static $loader;

Expand All @@ -22,17 +22,17 @@ public static function getLoader()
return self::$loader;
}

spl_autoload_register(array('ComposerAutoloaderInit42dbbea9f76bc2ad016504e8bbeaac67', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit5768fe3ac9bf02789dddb40517996133', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit42dbbea9f76bc2ad016504e8bbeaac67', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit5768fe3ac9bf02789dddb40517996133', 'loadClassLoader'));

require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit42dbbea9f76bc2ad016504e8bbeaac67::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit5768fe3ac9bf02789dddb40517996133::getInitializer($loader));

$loader->setClassMapAuthoritative(true);
$loader->register(true);

$filesToLoad = \Composer\Autoload\ComposerStaticInit42dbbea9f76bc2ad016504e8bbeaac67::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInit5768fe3ac9bf02789dddb40517996133::$files;
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
Expand Down
8 changes: 4 additions & 4 deletions vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Composer\Autoload;

class ComposerStaticInit42dbbea9f76bc2ad016504e8bbeaac67
class ComposerStaticInit5768fe3ac9bf02789dddb40517996133
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
Expand Down Expand Up @@ -3127,9 +3127,9 @@ class ComposerStaticInit42dbbea9f76bc2ad016504e8bbeaac67
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit42dbbea9f76bc2ad016504e8bbeaac67::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit42dbbea9f76bc2ad016504e8bbeaac67::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit42dbbea9f76bc2ad016504e8bbeaac67::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit5768fe3ac9bf02789dddb40517996133::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit5768fe3ac9bf02789dddb40517996133::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit5768fe3ac9bf02789dddb40517996133::$classMap;

}, null, ClassLoader::class);
}
Expand Down

0 comments on commit 9186224

Please sign in to comment.