mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-16 16:12:22 +00:00
Updated Rector to commit 10e8d3e25c
10e8d3e25c
[Php81] Skip set method in trait on ReadOnlyPropertyRector (#1816)
This commit is contained in:
parent
ce1f10d495
commit
8e96dfe03e
|
@ -12,7 +12,6 @@ use PHPStan\Reflection\ParametersAcceptorSelector;
|
|||
use Rector\CodingStyle\Reflection\VendorLocationDetector;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\Reflection\ReflectionResolver;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\Php80\NodeResolver\ArgumentSorter;
|
||||
use Rector\Php80\NodeResolver\RequireOptionalParamResolver;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
|
|
|
@ -16,11 +16,11 @@ final class VersionResolver
|
|||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '7d8444e81ba3ee6f25e0e05f5f1a7866a902d335';
|
||||
public const PACKAGE_VERSION = '10e8d3e25c12491608ec097539b456ae55d891eb';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2022-02-15 16:28:35';
|
||||
public const RELEASE_DATE = '2022-02-15 20:00:30';
|
||||
public static function resolvePackageVersion() : string
|
||||
{
|
||||
$process = new \RectorPrefix20220215\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);
|
||||
|
|
|
@ -17,9 +17,9 @@ use PhpParser\Node\Expr\PropertyFetch;
|
|||
use PhpParser\Node\Expr\StaticCall;
|
||||
use PhpParser\Node\Expr\StaticPropertyFetch;
|
||||
use PhpParser\Node\Param;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassLike;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Interface_;
|
||||
use PhpParser\Node\Stmt\Property;
|
||||
use PHPStan\Reflection\ParametersAcceptorSelector;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
|
||||
|
@ -148,15 +148,21 @@ final class PropertyManipulator
|
|||
*/
|
||||
public function isPropertyChangeableExceptConstructor($propertyOrParam) : bool
|
||||
{
|
||||
$class = $this->betterNodeFinder->findParentType($propertyOrParam, \PhpParser\Node\Stmt\Class_::class);
|
||||
if ($class instanceof \PhpParser\Node\Stmt\Class_) {
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($class);
|
||||
if ($phpDocInfo->hasByAnnotationClasses(self::ALLOWED_NOT_READONLY_ANNOTATION_CLASS_OR_ATTRIBUTES)) {
|
||||
return \true;
|
||||
}
|
||||
if ($this->phpAttributeAnalyzer->hasPhpAttributes($class, self::ALLOWED_NOT_READONLY_ANNOTATION_CLASS_OR_ATTRIBUTES)) {
|
||||
return \true;
|
||||
}
|
||||
$classLike = $this->betterNodeFinder->findParentType($propertyOrParam, \PhpParser\Node\Stmt\ClassLike::class);
|
||||
// does not has parent type ClassLike? Possibly parent is changed by other rule
|
||||
if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) {
|
||||
return \true;
|
||||
}
|
||||
// Property or Param in interface? return true early as no property in interface
|
||||
if ($classLike instanceof \PhpParser\Node\Stmt\Interface_) {
|
||||
return \true;
|
||||
}
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classLike);
|
||||
if ($phpDocInfo->hasByAnnotationClasses(self::ALLOWED_NOT_READONLY_ANNOTATION_CLASS_OR_ATTRIBUTES)) {
|
||||
return \true;
|
||||
}
|
||||
if ($this->phpAttributeAnalyzer->hasPhpAttributes($classLike, self::ALLOWED_NOT_READONLY_ANNOTATION_CLASS_OR_ATTRIBUTES)) {
|
||||
return \true;
|
||||
}
|
||||
$propertyFetches = $this->propertyFetchFinder->findPrivatePropertyFetches($propertyOrParam);
|
||||
foreach ($propertyFetches as $propertyFetch) {
|
||||
|
|
|
@ -9,7 +9,9 @@ use PhpParser\Node\Param;
|
|||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassLike;
|
||||
use PhpParser\Node\Stmt\Interface_;
|
||||
use PhpParser\Node\Stmt\Property;
|
||||
use PhpParser\Node\Stmt\Trait_;
|
||||
use PHPStan\Type\TypeWithClassName;
|
||||
use Rector\Core\Enum\ObjectReference;
|
||||
use Rector\Core\PhpParser\AstResolver;
|
||||
|
@ -63,7 +65,10 @@ final class PropertyFetchFinder
|
|||
public function findPrivatePropertyFetches($propertyOrPromotedParam) : array
|
||||
{
|
||||
$classLike = $this->betterNodeFinder->findParentType($propertyOrPromotedParam, \PhpParser\Node\Stmt\ClassLike::class);
|
||||
if (!$classLike instanceof \PhpParser\Node\Stmt\Class_) {
|
||||
if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) {
|
||||
return [];
|
||||
}
|
||||
if ($classLike instanceof \PhpParser\Node\Stmt\Interface_) {
|
||||
return [];
|
||||
}
|
||||
$propertyName = $this->resolvePropertyName($propertyOrPromotedParam);
|
||||
|
@ -75,6 +80,7 @@ final class PropertyFetchFinder
|
|||
$nodesTrait = $this->astResolver->parseClassReflectionTraits($classReflection);
|
||||
$hasTrait = $nodesTrait !== [];
|
||||
$nodes = \array_merge($nodes, $nodesTrait);
|
||||
/** @var Class_|Trait_ $classLike */
|
||||
return $this->findPropertyFetchesInClassLike($classLike, $nodes, $propertyName, $hasTrait);
|
||||
}
|
||||
/**
|
||||
|
@ -102,8 +108,9 @@ final class PropertyFetchFinder
|
|||
/**
|
||||
* @param Stmt[] $stmts
|
||||
* @return PropertyFetch[]|StaticPropertyFetch[]
|
||||
* @param \PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\Trait_ $class
|
||||
*/
|
||||
private function findPropertyFetchesInClassLike(\PhpParser\Node\Stmt\Class_ $class, array $stmts, string $propertyName, bool $hasTrait) : array
|
||||
private function findPropertyFetchesInClassLike($class, array $stmts, string $propertyName, bool $hasTrait) : array
|
||||
{
|
||||
/** @var PropertyFetch[] $propertyFetches */
|
||||
$propertyFetches = $this->betterNodeFinder->findInstanceOf($stmts, \PhpParser\Node\Expr\PropertyFetch::class);
|
||||
|
@ -122,7 +129,10 @@ final class PropertyFetchFinder
|
|||
});
|
||||
return \array_merge($matchingPropertyFetches, $matchingStaticPropertyFetches);
|
||||
}
|
||||
private function isInAnonymous(\PhpParser\Node\Expr\PropertyFetch $propertyFetch, \PhpParser\Node\Stmt\Class_ $class, bool $hasTrait) : bool
|
||||
/**
|
||||
* @param \PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\Trait_ $class
|
||||
*/
|
||||
private function isInAnonymous(\PhpParser\Node\Expr\PropertyFetch $propertyFetch, $class, bool $hasTrait) : bool
|
||||
{
|
||||
$parent = $this->betterNodeFinder->findParentType($propertyFetch, \PhpParser\Node\Stmt\Class_::class);
|
||||
if (!$parent instanceof \PhpParser\Node\Stmt\Class_) {
|
||||
|
@ -130,7 +140,10 @@ final class PropertyFetchFinder
|
|||
}
|
||||
return $parent !== $class && !$hasTrait;
|
||||
}
|
||||
private function isNamePropertyNameEquals(\PhpParser\Node\Expr\PropertyFetch $propertyFetch, string $propertyName, \PhpParser\Node\Stmt\Class_ $class) : bool
|
||||
/**
|
||||
* @param \PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\Trait_ $class
|
||||
*/
|
||||
private function isNamePropertyNameEquals(\PhpParser\Node\Expr\PropertyFetch $propertyFetch, string $propertyName, $class) : bool
|
||||
{
|
||||
// early check if property fetch name is not equals with property name
|
||||
// so next check is check var name and var type only
|
||||
|
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
|
@ -4,4 +4,4 @@
|
|||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit07caeb5c70366cf5e84944aa213c6105::getLoader();
|
||||
return ComposerAutoloaderInit8219b620e89f761a966a3b4e5966ad67::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 ComposerAutoloaderInit07caeb5c70366cf5e84944aa213c6105
|
||||
class ComposerAutoloaderInit8219b620e89f761a966a3b4e5966ad67
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,15 +22,15 @@ class ComposerAutoloaderInit07caeb5c70366cf5e84944aa213c6105
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit07caeb5c70366cf5e84944aa213c6105', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit8219b620e89f761a966a3b4e5966ad67', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit07caeb5c70366cf5e84944aa213c6105', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit8219b620e89f761a966a3b4e5966ad67', 'loadClassLoader'));
|
||||
|
||||
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
||||
if ($useStaticLoader) {
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit07caeb5c70366cf5e84944aa213c6105::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit8219b620e89f761a966a3b4e5966ad67::getInitializer($loader));
|
||||
} else {
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
|
@ -42,12 +42,12 @@ class ComposerAutoloaderInit07caeb5c70366cf5e84944aa213c6105
|
|||
$loader->register(true);
|
||||
|
||||
if ($useStaticLoader) {
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit07caeb5c70366cf5e84944aa213c6105::$files;
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit8219b620e89f761a966a3b4e5966ad67::$files;
|
||||
} else {
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
}
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire07caeb5c70366cf5e84944aa213c6105($fileIdentifier, $file);
|
||||
composerRequire8219b620e89f761a966a3b4e5966ad67($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
|
@ -59,7 +59,7 @@ class ComposerAutoloaderInit07caeb5c70366cf5e84944aa213c6105
|
|||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
function composerRequire07caeb5c70366cf5e84944aa213c6105($fileIdentifier, $file)
|
||||
function composerRequire8219b620e89f761a966a3b4e5966ad67($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 ComposerStaticInit07caeb5c70366cf5e84944aa213c6105
|
||||
class ComposerStaticInit8219b620e89f761a966a3b4e5966ad67
|
||||
{
|
||||
public static $files = array (
|
||||
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
|
||||
|
@ -3881,9 +3881,9 @@ class ComposerStaticInit07caeb5c70366cf5e84944aa213c6105
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit07caeb5c70366cf5e84944aa213c6105::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit07caeb5c70366cf5e84944aa213c6105::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit07caeb5c70366cf5e84944aa213c6105::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit8219b620e89f761a966a3b4e5966ad67::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit8219b620e89f761a966a3b4e5966ad67::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit8219b620e89f761a966a3b4e5966ad67::$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('RectorPrefix20220215\AutoloadIncluder');
|
||||
}
|
||||
if (!class_exists('ComposerAutoloaderInit07caeb5c70366cf5e84944aa213c6105', false) && !interface_exists('ComposerAutoloaderInit07caeb5c70366cf5e84944aa213c6105', false) && !trait_exists('ComposerAutoloaderInit07caeb5c70366cf5e84944aa213c6105', false)) {
|
||||
spl_autoload_call('RectorPrefix20220215\ComposerAutoloaderInit07caeb5c70366cf5e84944aa213c6105');
|
||||
if (!class_exists('ComposerAutoloaderInit8219b620e89f761a966a3b4e5966ad67', false) && !interface_exists('ComposerAutoloaderInit8219b620e89f761a966a3b4e5966ad67', false) && !trait_exists('ComposerAutoloaderInit8219b620e89f761a966a3b4e5966ad67', false)) {
|
||||
spl_autoload_call('RectorPrefix20220215\ComposerAutoloaderInit8219b620e89f761a966a3b4e5966ad67');
|
||||
}
|
||||
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('RectorPrefix20220215\Helmich\TypoScriptParser\Parser\AST\Statement');
|
||||
|
@ -59,9 +59,9 @@ if (!function_exists('print_node')) {
|
|||
return \RectorPrefix20220215\print_node(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('composerRequire07caeb5c70366cf5e84944aa213c6105')) {
|
||||
function composerRequire07caeb5c70366cf5e84944aa213c6105() {
|
||||
return \RectorPrefix20220215\composerRequire07caeb5c70366cf5e84944aa213c6105(...func_get_args());
|
||||
if (!function_exists('composerRequire8219b620e89f761a966a3b4e5966ad67')) {
|
||||
function composerRequire8219b620e89f761a966a3b4e5966ad67() {
|
||||
return \RectorPrefix20220215\composerRequire8219b620e89f761a966a3b4e5966ad67(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('scanPath')) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user