mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-18 22:08:00 +01:00
Updated Rector to commit dbc2638e4267c557e55bfe2372a8c91c72cec736
dbc2638e42
[Php74][TypeDeclaration] Document for INLINE_PUBLIC constant set to false by default allow change protected on final with extends as far as property and/or its usage only in current class (#2198)
This commit is contained in:
parent
639bf5c5d4
commit
d9f463102f
@ -5,11 +5,9 @@ namespace Rector\Naming\ExpectedNameResolver;
|
||||
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\Property;
|
||||
use PHPStan\Reflection\ClassReflection;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
|
||||
use Rector\Core\NodeManipulator\PropertyManipulator;
|
||||
use Rector\Core\PhpParser\Node\BetterNodeFinder;
|
||||
use Rector\Core\Reflection\ReflectionResolver;
|
||||
use Rector\Naming\Naming\PropertyNaming;
|
||||
use Rector\Naming\ValueObject\ExpectedName;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
@ -40,19 +38,13 @@ final class MatchPropertyTypeExpectedNameResolver
|
||||
* @var \Rector\Core\NodeManipulator\PropertyManipulator
|
||||
*/
|
||||
private $propertyManipulator;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\Reflection\ReflectionResolver
|
||||
*/
|
||||
private $reflectionResolver;
|
||||
public function __construct(\Rector\Naming\Naming\PropertyNaming $propertyNaming, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\Core\NodeManipulator\PropertyManipulator $propertyManipulator, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver)
|
||||
public function __construct(\Rector\Naming\Naming\PropertyNaming $propertyNaming, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\Core\NodeManipulator\PropertyManipulator $propertyManipulator)
|
||||
{
|
||||
$this->propertyNaming = $propertyNaming;
|
||||
$this->phpDocInfoFactory = $phpDocInfoFactory;
|
||||
$this->nodeNameResolver = $nodeNameResolver;
|
||||
$this->betterNodeFinder = $betterNodeFinder;
|
||||
$this->propertyManipulator = $propertyManipulator;
|
||||
$this->reflectionResolver = $reflectionResolver;
|
||||
}
|
||||
public function resolve(\PhpParser\Node\Stmt\Property $property) : ?string
|
||||
{
|
||||
@ -60,12 +52,8 @@ final class MatchPropertyTypeExpectedNameResolver
|
||||
if (!$class instanceof \PhpParser\Node\Stmt\Class_) {
|
||||
return null;
|
||||
}
|
||||
$classReflection = $this->reflectionResolver->resolveClassReflection($property);
|
||||
if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) {
|
||||
return null;
|
||||
}
|
||||
$propertyName = $this->nodeNameResolver->getName($property);
|
||||
if ($this->propertyManipulator->isUsedByTrait($classReflection, $propertyName)) {
|
||||
if ($this->propertyManipulator->isUsedByTrait($class, $propertyName)) {
|
||||
return null;
|
||||
}
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property);
|
||||
|
@ -3,16 +3,23 @@
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Php74\Guard;
|
||||
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\Property;
|
||||
use PHPStan\Analyser\Scope;
|
||||
use PHPStan\Reflection\ClassReflection;
|
||||
use Rector\Core\NodeAnalyzer\PropertyAnalyzer;
|
||||
use Rector\Core\NodeManipulator\PropertyManipulator;
|
||||
use Rector\Core\PhpParser\Node\BetterNodeFinder;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\Privatization\Guard\ParentPropertyLookupGuard;
|
||||
final class MakePropertyTypedGuard
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\PhpParser\Node\BetterNodeFinder
|
||||
*/
|
||||
private $betterNodeFinder;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\NodeNameResolver\NodeNameResolver
|
||||
@ -33,8 +40,9 @@ final class MakePropertyTypedGuard
|
||||
* @var \Rector\Privatization\Guard\ParentPropertyLookupGuard
|
||||
*/
|
||||
private $parentPropertyLookupGuard;
|
||||
public function __construct(\Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\NodeAnalyzer\PropertyAnalyzer $propertyAnalyzer, \Rector\Core\NodeManipulator\PropertyManipulator $propertyManipulator, \Rector\Privatization\Guard\ParentPropertyLookupGuard $parentPropertyLookupGuard)
|
||||
public function __construct(\Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\Core\NodeAnalyzer\PropertyAnalyzer $propertyAnalyzer, \Rector\Core\NodeManipulator\PropertyManipulator $propertyManipulator, \Rector\Privatization\Guard\ParentPropertyLookupGuard $parentPropertyLookupGuard)
|
||||
{
|
||||
$this->betterNodeFinder = $betterNodeFinder;
|
||||
$this->nodeNameResolver = $nodeNameResolver;
|
||||
$this->propertyAnalyzer = $propertyAnalyzer;
|
||||
$this->propertyManipulator = $propertyManipulator;
|
||||
@ -60,11 +68,12 @@ final class MakePropertyTypedGuard
|
||||
* - trait properties are unpredictable based on class context they appear in
|
||||
* - on interface properties as well, as interface not allowed to have property
|
||||
*/
|
||||
if (!$classReflection->isClass()) {
|
||||
$class = $this->betterNodeFinder->findParentType($property, \PhpParser\Node\Stmt\Class_::class);
|
||||
if (!$class instanceof \PhpParser\Node\Stmt\Class_) {
|
||||
return \false;
|
||||
}
|
||||
$propertyName = $this->nodeNameResolver->getName($property);
|
||||
if ($this->propertyManipulator->isUsedByTrait($classReflection, $propertyName)) {
|
||||
if ($this->propertyManipulator->isUsedByTrait($class, $propertyName)) {
|
||||
return \false;
|
||||
}
|
||||
if ($inlinePublic) {
|
||||
@ -73,14 +82,14 @@ final class MakePropertyTypedGuard
|
||||
if ($property->isPrivate()) {
|
||||
return !$this->propertyAnalyzer->hasForbiddenType($property);
|
||||
}
|
||||
return $this->isSafeProtectedProperty($property, $classReflection);
|
||||
return $this->isSafeProtectedProperty($property, $class);
|
||||
}
|
||||
private function isSafeProtectedProperty(\PhpParser\Node\Stmt\Property $property, \PHPStan\Reflection\ClassReflection $classReflection) : bool
|
||||
private function isSafeProtectedProperty(\PhpParser\Node\Stmt\Property $property, \PhpParser\Node\Stmt\Class_ $class) : bool
|
||||
{
|
||||
if (!$property->isProtected()) {
|
||||
return \false;
|
||||
}
|
||||
if (!$classReflection->isFinal()) {
|
||||
if (!$class->isFinal()) {
|
||||
return \false;
|
||||
}
|
||||
return $this->parentPropertyLookupGuard->isLegal($property);
|
||||
|
@ -16,11 +16,11 @@ final class VersionResolver
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '6063b59cde02c08a540ba18ab90d69ab8ba8acc7';
|
||||
public const PACKAGE_VERSION = 'dbc2638e4267c557e55bfe2372a8c91c72cec736';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2022-04-29 16:45:18';
|
||||
public const RELEASE_DATE = '2022-04-29 16:44:44';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
@ -25,7 +25,6 @@ use PhpParser\Node\Stmt\Interface_;
|
||||
use PhpParser\Node\Stmt\Property;
|
||||
use PhpParser\Node\Stmt\Trait_;
|
||||
use PhpParser\Node\Stmt\Unset_;
|
||||
use PHPStan\Reflection\ClassReflection;
|
||||
use PHPStan\Reflection\ParametersAcceptorSelector;
|
||||
use PHPStan\Type\Type;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||
@ -266,15 +265,17 @@ final class PropertyManipulator
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public function isUsedByTrait(\PHPStan\Reflection\ClassReflection $classReflection, string $propertyName) : bool
|
||||
public function isUsedByTrait(\PhpParser\Node\Stmt\Class_ $class, string $propertyName) : bool
|
||||
{
|
||||
foreach ($classReflection->getTraits() as $traitUse) {
|
||||
$trait = $this->astResolver->resolveClassFromName($traitUse->getName());
|
||||
if (!$trait instanceof \PhpParser\Node\Stmt\Trait_) {
|
||||
continue;
|
||||
}
|
||||
if ($this->propertyFetchAnalyzer->containsLocalPropertyFetchName($trait, $propertyName)) {
|
||||
return \true;
|
||||
foreach ($class->getTraitUses() as $traitUse) {
|
||||
foreach ($traitUse->traits as $traitName) {
|
||||
$trait = $this->astResolver->resolveClassFromName($traitName->toString());
|
||||
if (!$trait instanceof \PhpParser\Node\Stmt\Trait_) {
|
||||
continue;
|
||||
}
|
||||
if ($this->propertyFetchAnalyzer->containsLocalPropertyFetchName($trait, $propertyName)) {
|
||||
return \true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return \false;
|
||||
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -9,4 +9,4 @@ if (PHP_VERSION_ID < 50600) {
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit55db0c5f6658a42b4e4572f3b217369f::getLoader();
|
||||
return ComposerAutoloaderInit8b9b49c35bc5226227b3d3ebf0c5ac81::getLoader();
|
||||
|
14
vendor/composer/autoload_real.php
vendored
14
vendor/composer/autoload_real.php
vendored
@ -2,7 +2,7 @@
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit55db0c5f6658a42b4e4572f3b217369f
|
||||
class ComposerAutoloaderInit8b9b49c35bc5226227b3d3ebf0c5ac81
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,19 +22,19 @@ class ComposerAutoloaderInit55db0c5f6658a42b4e4572f3b217369f
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit55db0c5f6658a42b4e4572f3b217369f', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit8b9b49c35bc5226227b3d3ebf0c5ac81', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit55db0c5f6658a42b4e4572f3b217369f', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit8b9b49c35bc5226227b3d3ebf0c5ac81', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit55db0c5f6658a42b4e4572f3b217369f::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit8b9b49c35bc5226227b3d3ebf0c5ac81::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInit55db0c5f6658a42b4e4572f3b217369f::$files;
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInit8b9b49c35bc5226227b3d3ebf0c5ac81::$files;
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire55db0c5f6658a42b4e4572f3b217369f($fileIdentifier, $file);
|
||||
composerRequire8b9b49c35bc5226227b3d3ebf0c5ac81($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
@ -46,7 +46,7 @@ class ComposerAutoloaderInit55db0c5f6658a42b4e4572f3b217369f
|
||||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
function composerRequire55db0c5f6658a42b4e4572f3b217369f($fileIdentifier, $file)
|
||||
function composerRequire8b9b49c35bc5226227b3d3ebf0c5ac81($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
8
vendor/composer/autoload_static.php
vendored
8
vendor/composer/autoload_static.php
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit55db0c5f6658a42b4e4572f3b217369f
|
||||
class ComposerStaticInit8b9b49c35bc5226227b3d3ebf0c5ac81
|
||||
{
|
||||
public static $files = array (
|
||||
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
|
||||
@ -3881,9 +3881,9 @@ class ComposerStaticInit55db0c5f6658a42b4e4572f3b217369f
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit55db0c5f6658a42b4e4572f3b217369f::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit55db0c5f6658a42b4e4572f3b217369f::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit55db0c5f6658a42b4e4572f3b217369f::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit8b9b49c35bc5226227b3d3ebf0c5ac81::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit8b9b49c35bc5226227b3d3ebf0c5ac81::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit8b9b49c35bc5226227b3d3ebf0c5ac81::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
10
vendor/scoper-autoload.php
vendored
10
vendor/scoper-autoload.php
vendored
@ -9,8 +9,8 @@ $loader = require_once __DIR__.'/autoload.php';
|
||||
if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) {
|
||||
spl_autoload_call('RectorPrefix20220429\AutoloadIncluder');
|
||||
}
|
||||
if (!class_exists('ComposerAutoloaderInit55db0c5f6658a42b4e4572f3b217369f', false) && !interface_exists('ComposerAutoloaderInit55db0c5f6658a42b4e4572f3b217369f', false) && !trait_exists('ComposerAutoloaderInit55db0c5f6658a42b4e4572f3b217369f', false)) {
|
||||
spl_autoload_call('RectorPrefix20220429\ComposerAutoloaderInit55db0c5f6658a42b4e4572f3b217369f');
|
||||
if (!class_exists('ComposerAutoloaderInit8b9b49c35bc5226227b3d3ebf0c5ac81', false) && !interface_exists('ComposerAutoloaderInit8b9b49c35bc5226227b3d3ebf0c5ac81', false) && !trait_exists('ComposerAutoloaderInit8b9b49c35bc5226227b3d3ebf0c5ac81', false)) {
|
||||
spl_autoload_call('RectorPrefix20220429\ComposerAutoloaderInit8b9b49c35bc5226227b3d3ebf0c5ac81');
|
||||
}
|
||||
if (!class_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !interface_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !trait_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false)) {
|
||||
spl_autoload_call('RectorPrefix20220429\Helmich\TypoScriptParser\Parser\AST\Statement');
|
||||
@ -59,9 +59,9 @@ if (!function_exists('print_node')) {
|
||||
return \RectorPrefix20220429\print_node(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('composerRequire55db0c5f6658a42b4e4572f3b217369f')) {
|
||||
function composerRequire55db0c5f6658a42b4e4572f3b217369f() {
|
||||
return \RectorPrefix20220429\composerRequire55db0c5f6658a42b4e4572f3b217369f(...func_get_args());
|
||||
if (!function_exists('composerRequire8b9b49c35bc5226227b3d3ebf0c5ac81')) {
|
||||
function composerRequire8b9b49c35bc5226227b3d3ebf0c5ac81() {
|
||||
return \RectorPrefix20220429\composerRequire8b9b49c35bc5226227b3d3ebf0c5ac81(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('scanPath')) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user