Updated Rector to commit 5e20015ec5d8002b9a11f8bfa7c70f4f2a5b5c5d

5e20015ec5 [Php81] Skip named constructor on ReadOnlyPropertyRector (#4359)
This commit is contained in:
Tomas Votruba 2023-06-27 06:35:24 +00:00
parent 688d913bbc
commit 2528c0753a
6 changed files with 25 additions and 17 deletions

View File

@ -134,7 +134,7 @@ CODE_SAMPLE
}
private function removePropertyAssigns(Class_ $class, string $propertyName) : void
{
$this->traverseNodesWithCallable($class, function (Node $node) use($propertyName) : ?int {
$this->traverseNodesWithCallable($class, function (Node $node) use($class, $propertyName) : ?int {
if (!$node instanceof Expression) {
return null;
}
@ -142,7 +142,7 @@ CODE_SAMPLE
return null;
}
$assign = $node->expr;
if (!$this->propertyFetchFinder->isLocalPropertyFetchByName($assign->var, $propertyName)) {
if (!$this->propertyFetchFinder->isLocalPropertyFetchByName($assign->var, $class, $propertyName)) {
return null;
}
return NodeTraverser::REMOVE_NODE;

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = 'd630cc6f7961d53af1dd8fb09f7bfb93ab5591e6';
public const PACKAGE_VERSION = '5e20015ec5d8002b9a11f8bfa7c70f4f2a5b5c5d';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-06-27 06:01:50';
public const RELEASE_DATE = '2023-06-27 13:30:57';
/**
* @var int
*/

View File

@ -23,6 +23,7 @@ use Rector\Core\Reflection\ReflectionResolver;
use Rector\NodeNameResolver\NodeNameResolver;
use Rector\NodeTypeResolver\NodeTypeResolver;
use Rector\PhpDocParser\NodeTraverser\SimpleCallableNodeTraverser;
use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType;
final class PropertyFetchFinder
{
/**
@ -131,7 +132,10 @@ final class PropertyFetchFinder
});
return $propertyArrayDimFetches;
}
public function isLocalPropertyFetchByName(Expr $expr, string $propertyName) : bool
/**
* @param \PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\Trait_ $class
*/
public function isLocalPropertyFetchByName(Expr $expr, $class, string $propertyName) : bool
{
if (!$expr instanceof PropertyFetch) {
return \false;
@ -139,7 +143,11 @@ final class PropertyFetchFinder
if (!$this->nodeNameResolver->isName($expr->name, $propertyName)) {
return \false;
}
return $this->nodeNameResolver->isName($expr->var, 'this');
if ($this->nodeNameResolver->isName($expr->var, 'this')) {
return \true;
}
$type = $this->nodeTypeResolver->getType($expr->var);
return $type instanceof FullyQualifiedObjectType && $this->nodeNameResolver->isName($class, $type->getClassName());
}
/**
* @param Stmt[] $stmts
@ -184,7 +192,7 @@ final class PropertyFetchFinder
{
// early check if property fetch name is not equals with property name
// so next check is check var name and var type only
if (!$this->isLocalPropertyFetchByName($propertyFetch, $propertyName)) {
if (!$this->isLocalPropertyFetchByName($propertyFetch, $class, $propertyName)) {
return \false;
}
$propertyFetchVarType = $this->nodeTypeResolver->getType($propertyFetch->var);

2
vendor/autoload.php vendored
View File

@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInitba7b2cd40952c7decad7e28ce970948a::getLoader();
return ComposerAutoloaderInita6a0d3595a78bfd0ec59468f5dc68822::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitba7b2cd40952c7decad7e28ce970948a
class ComposerAutoloaderInita6a0d3595a78bfd0ec59468f5dc68822
{
private static $loader;
@ -22,17 +22,17 @@ class ComposerAutoloaderInitba7b2cd40952c7decad7e28ce970948a
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitba7b2cd40952c7decad7e28ce970948a', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInita6a0d3595a78bfd0ec59468f5dc68822', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInitba7b2cd40952c7decad7e28ce970948a', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInita6a0d3595a78bfd0ec59468f5dc68822', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitba7b2cd40952c7decad7e28ce970948a::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInita6a0d3595a78bfd0ec59468f5dc68822::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$filesToLoad = \Composer\Autoload\ComposerStaticInitba7b2cd40952c7decad7e28ce970948a::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInita6a0d3595a78bfd0ec59468f5dc68822::$files;
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInitba7b2cd40952c7decad7e28ce970948a
class ComposerStaticInita6a0d3595a78bfd0ec59468f5dc68822
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -3098,9 +3098,9 @@ class ComposerStaticInitba7b2cd40952c7decad7e28ce970948a
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitba7b2cd40952c7decad7e28ce970948a::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitba7b2cd40952c7decad7e28ce970948a::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitba7b2cd40952c7decad7e28ce970948a::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInita6a0d3595a78bfd0ec59468f5dc68822::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInita6a0d3595a78bfd0ec59468f5dc68822::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInita6a0d3595a78bfd0ec59468f5dc68822::$classMap;
}, null, ClassLoader::class);
}