Updated Rector to commit 754fca568f1d19b792bd5ccd476d10c675ba77f3

754fca568f [Php74] Remove parent attribute on PropertyTypeChangeGuard (#3992)
This commit is contained in:
Tomas Votruba 2023-05-27 12:07:30 +00:00
parent 3ab41786d6
commit 88a00032b7
6 changed files with 29 additions and 24 deletions

View File

@ -6,12 +6,11 @@ namespace Rector\Php74\Guard;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\Property;
use PHPStan\Reflection\ClassReflection;
use Rector\Core\Exception\ShouldNotHappenException;
use Rector\Core\NodeAnalyzer\PropertyAnalyzer;
use Rector\Core\NodeManipulator\PropertyManipulator;
use Rector\Core\PhpParser\ClassLikeAstResolver;
use Rector\Core\Reflection\ReflectionResolver;
use Rector\NodeNameResolver\NodeNameResolver;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\Privatization\Guard\ParentPropertyLookupGuard;
final class PropertyTypeChangeGuard
{
@ -40,13 +39,19 @@ final class PropertyTypeChangeGuard
* @var \Rector\Core\Reflection\ReflectionResolver
*/
private $reflectionResolver;
public function __construct(NodeNameResolver $nodeNameResolver, PropertyAnalyzer $propertyAnalyzer, PropertyManipulator $propertyManipulator, ParentPropertyLookupGuard $parentPropertyLookupGuard, ReflectionResolver $reflectionResolver)
/**
* @readonly
* @var \Rector\Core\PhpParser\ClassLikeAstResolver
*/
private $classLikeAstResolver;
public function __construct(NodeNameResolver $nodeNameResolver, PropertyAnalyzer $propertyAnalyzer, PropertyManipulator $propertyManipulator, ParentPropertyLookupGuard $parentPropertyLookupGuard, ReflectionResolver $reflectionResolver, ClassLikeAstResolver $classLikeAstResolver)
{
$this->nodeNameResolver = $nodeNameResolver;
$this->propertyAnalyzer = $propertyAnalyzer;
$this->propertyManipulator = $propertyManipulator;
$this->parentPropertyLookupGuard = $parentPropertyLookupGuard;
$this->reflectionResolver = $reflectionResolver;
$this->classLikeAstResolver = $classLikeAstResolver;
}
public function isLegal(Property $property, bool $inlinePublic = \true, bool $isConstructorPromotion = \false) : bool
{
@ -80,20 +85,20 @@ final class PropertyTypeChangeGuard
if ($isConstructorPromotion) {
return \true;
}
return $this->isSafeProtectedProperty($property);
return $this->isSafeProtectedProperty($classReflection, $property);
}
private function isSafeProtectedProperty(Property $property) : bool
private function isSafeProtectedProperty(ClassReflection $classReflection, Property $property) : bool
{
if (!$property->isProtected()) {
return \false;
}
$parentNode = $property->getAttribute(AttributeKey::PARENT_NODE);
if (!$parentNode instanceof Class_) {
throw new ShouldNotHappenException();
}
if (!$parentNode->isFinal()) {
$class = $this->classLikeAstResolver->resolveClassFromClassReflection($classReflection);
if (!$class instanceof Class_) {
return \false;
}
return $this->parentPropertyLookupGuard->isLegal($property, $parentNode);
if (!$class->isFinal()) {
return \false;
}
return $this->parentPropertyLookupGuard->isLegal($property, $class);
}
}

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = 'f9f1c269c7cfb02b3a78efca476cb2f189fbb33c';
public const PACKAGE_VERSION = '754fca568f1d19b792bd5ccd476d10c675ba77f3';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-05-27 11:20:08';
public const RELEASE_DATE = '2023-05-27 19:03:19';
/**
* @var int
*/

View File

@ -15,7 +15,7 @@ final class RectorKernel
/**
* @var string
*/
private const CACHE_KEY = 'v37';
private const CACHE_KEY = 'v38';
/**
* @var \Symfony\Component\DependencyInjection\ContainerInterface|null
*/

2
vendor/autoload.php vendored
View File

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

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit2d3544febfb0412e1f69c403d797729d
class ComposerAutoloaderInit010c9f364f099f90d8ec581e67be515a
{
private static $loader;
@ -22,17 +22,17 @@ class ComposerAutoloaderInit2d3544febfb0412e1f69c403d797729d
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit2d3544febfb0412e1f69c403d797729d', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit010c9f364f099f90d8ec581e67be515a', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit2d3544febfb0412e1f69c403d797729d', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit010c9f364f099f90d8ec581e67be515a', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit2d3544febfb0412e1f69c403d797729d::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit010c9f364f099f90d8ec581e67be515a::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$filesToLoad = \Composer\Autoload\ComposerStaticInit2d3544febfb0412e1f69c403d797729d::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInit010c9f364f099f90d8ec581e67be515a::$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 ComposerStaticInit2d3544febfb0412e1f69c403d797729d
class ComposerStaticInit010c9f364f099f90d8ec581e67be515a
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -3089,9 +3089,9 @@ class ComposerStaticInit2d3544febfb0412e1f69c403d797729d
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit2d3544febfb0412e1f69c403d797729d::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit2d3544febfb0412e1f69c403d797729d::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit2d3544febfb0412e1f69c403d797729d::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit010c9f364f099f90d8ec581e67be515a::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit010c9f364f099f90d8ec581e67be515a::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit010c9f364f099f90d8ec581e67be515a::$classMap;
}, null, ClassLoader::class);
}