mirror of
https://github.com/rectorphp/rector.git
synced 2025-04-22 16:32:27 +02:00
Updated Rector to commit 58273de24474dee2a5463949ad127a86526c4e3a
58273de244
[CodingStyle][Php80][Privatization] Handle SeparateMultiUseImportsRector+ClassPropertyAssignToConstructorPromotionRector+FinalizeClassesWithoutChildrenRector cause invalid removal (#4649)
This commit is contained in:
parent
420f332cf3
commit
d79728bb9f
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderIniteba2d00fce57247563ebbdd0a16175fc::getLoader();
|
||||
return ComposerAutoloaderInitef089378e00b4e03d24df5a4b0515ea4::getLoader();
|
||||
|
1
vendor/composer/autoload_classmap.php
vendored
1
vendor/composer/autoload_classmap.php
vendored
@ -1850,6 +1850,7 @@ return array(
|
||||
'Rector\\DowngradePhp81\\Rector\\FunctionLike\\DowngradePureIntersectionTypeRector' => $vendorDir . '/rector/rector-downgrade-php/rules/DowngradePhp81/Rector/FunctionLike/DowngradePureIntersectionTypeRector.php',
|
||||
'Rector\\DowngradePhp81\\Rector\\Instanceof_\\DowngradePhp81ResourceReturnToObjectRector' => $vendorDir . '/rector/rector-downgrade-php/rules/DowngradePhp81/Rector/Instanceof_/DowngradePhp81ResourceReturnToObjectRector.php',
|
||||
'Rector\\DowngradePhp81\\Rector\\Property\\DowngradeReadonlyPropertyRector' => $vendorDir . '/rector/rector-downgrade-php/rules/DowngradePhp81/Rector/Property/DowngradeReadonlyPropertyRector.php',
|
||||
'Rector\\DowngradePhp81\\Rector\\StmtsAwareInterface\\DowngradeSetAccessibleReflectionPropertyRector' => $vendorDir . '/rector/rector-downgrade-php/rules/DowngradePhp81/Rector/StmtsAwareInterface/DowngradeSetAccessibleReflectionPropertyRector.php',
|
||||
'Rector\\DowngradePhp82\\Rector\\Class_\\DowngradeReadonlyClassRector' => $vendorDir . '/rector/rector-downgrade-php/rules/DowngradePhp82/Rector/Class_/DowngradeReadonlyClassRector.php',
|
||||
'Rector\\EarlyReturn\\NodeAnalyzer\\IfAndAnalyzer' => $baseDir . '/rules/EarlyReturn/NodeAnalyzer/IfAndAnalyzer.php',
|
||||
'Rector\\EarlyReturn\\NodeAnalyzer\\SimpleScalarAnalyzer' => $baseDir . '/rules/EarlyReturn/NodeAnalyzer/SimpleScalarAnalyzer.php',
|
||||
|
10
vendor/composer/autoload_real.php
vendored
10
vendor/composer/autoload_real.php
vendored
@ -2,7 +2,7 @@
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderIniteba2d00fce57247563ebbdd0a16175fc
|
||||
class ComposerAutoloaderInitef089378e00b4e03d24df5a4b0515ea4
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,17 +22,17 @@ class ComposerAutoloaderIniteba2d00fce57247563ebbdd0a16175fc
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderIniteba2d00fce57247563ebbdd0a16175fc', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInitef089378e00b4e03d24df5a4b0515ea4', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderIniteba2d00fce57247563ebbdd0a16175fc', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitef089378e00b4e03d24df5a4b0515ea4', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticIniteba2d00fce57247563ebbdd0a16175fc::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitef089378e00b4e03d24df5a4b0515ea4::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticIniteba2d00fce57247563ebbdd0a16175fc::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInitef089378e00b4e03d24df5a4b0515ea4::$files;
|
||||
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
9
vendor/composer/autoload_static.php
vendored
9
vendor/composer/autoload_static.php
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticIniteba2d00fce57247563ebbdd0a16175fc
|
||||
class ComposerStaticInitef089378e00b4e03d24df5a4b0515ea4
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
@ -2104,6 +2104,7 @@ class ComposerStaticIniteba2d00fce57247563ebbdd0a16175fc
|
||||
'Rector\\DowngradePhp81\\Rector\\FunctionLike\\DowngradePureIntersectionTypeRector' => __DIR__ . '/..' . '/rector/rector-downgrade-php/rules/DowngradePhp81/Rector/FunctionLike/DowngradePureIntersectionTypeRector.php',
|
||||
'Rector\\DowngradePhp81\\Rector\\Instanceof_\\DowngradePhp81ResourceReturnToObjectRector' => __DIR__ . '/..' . '/rector/rector-downgrade-php/rules/DowngradePhp81/Rector/Instanceof_/DowngradePhp81ResourceReturnToObjectRector.php',
|
||||
'Rector\\DowngradePhp81\\Rector\\Property\\DowngradeReadonlyPropertyRector' => __DIR__ . '/..' . '/rector/rector-downgrade-php/rules/DowngradePhp81/Rector/Property/DowngradeReadonlyPropertyRector.php',
|
||||
'Rector\\DowngradePhp81\\Rector\\StmtsAwareInterface\\DowngradeSetAccessibleReflectionPropertyRector' => __DIR__ . '/..' . '/rector/rector-downgrade-php/rules/DowngradePhp81/Rector/StmtsAwareInterface/DowngradeSetAccessibleReflectionPropertyRector.php',
|
||||
'Rector\\DowngradePhp82\\Rector\\Class_\\DowngradeReadonlyClassRector' => __DIR__ . '/..' . '/rector/rector-downgrade-php/rules/DowngradePhp82/Rector/Class_/DowngradeReadonlyClassRector.php',
|
||||
'Rector\\EarlyReturn\\NodeAnalyzer\\IfAndAnalyzer' => __DIR__ . '/../..' . '/rules/EarlyReturn/NodeAnalyzer/IfAndAnalyzer.php',
|
||||
'Rector\\EarlyReturn\\NodeAnalyzer\\SimpleScalarAnalyzer' => __DIR__ . '/../..' . '/rules/EarlyReturn/NodeAnalyzer/SimpleScalarAnalyzer.php',
|
||||
@ -3014,9 +3015,9 @@ class ComposerStaticIniteba2d00fce57247563ebbdd0a16175fc
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticIniteba2d00fce57247563ebbdd0a16175fc::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticIniteba2d00fce57247563ebbdd0a16175fc::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticIniteba2d00fce57247563ebbdd0a16175fc::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitef089378e00b4e03d24df5a4b0515ea4::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitef089378e00b4e03d24df5a4b0515ea4::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitef089378e00b4e03d24df5a4b0515ea4::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
8
vendor/composer/installed.json
vendored
8
vendor/composer/installed.json
vendored
@ -1986,12 +1986,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-downgrade-php.git",
|
||||
"reference": "8df23f0cabdf045dc4e131f8aa9a4f8e3c61295c"
|
||||
"reference": "63c4f203cf3f2cef2c715f7478bc35a0e76854c2"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/8df23f0cabdf045dc4e131f8aa9a4f8e3c61295c",
|
||||
"reference": "8df23f0cabdf045dc4e131f8aa9a4f8e3c61295c",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/63c4f203cf3f2cef2c715f7478bc35a0e76854c2",
|
||||
"reference": "63c4f203cf3f2cef2c715f7478bc35a0e76854c2",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -2017,7 +2017,7 @@
|
||||
"tomasvotruba\/type-coverage": "^0.2",
|
||||
"tomasvotruba\/unused-public": "^0.1"
|
||||
},
|
||||
"time": "2023-08-04T13:45:50+00:00",
|
||||
"time": "2023-08-04T16:21:52+00:00",
|
||||
"default-branch": true,
|
||||
"type": "rector-extension",
|
||||
"extra": {
|
||||
|
2
vendor/composer/installed.php
vendored
2
vendor/composer/installed.php
vendored
File diff suppressed because one or more lines are too long
@ -163,6 +163,7 @@ final class ObjectHelpers
|
||||
$prop = \false;
|
||||
try {
|
||||
$rp = new \ReflectionProperty($class, $name);
|
||||
$rp->setAccessible(\true);
|
||||
if ($rp->isPublic() && !$rp->isStatic()) {
|
||||
$prop = $name >= 'onA' && $name < 'on_' ? 'event' : \true;
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
|
||||
*/
|
||||
final class GeneratedConfig
|
||||
{
|
||||
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 1c50ebb'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 8df23f0'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 0438162'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main a0af12a'));
|
||||
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 1c50ebb'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 63c4f20'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 0438162'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main a0af12a'));
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
@ -14,10 +14,11 @@ use Rector\DowngradePhp81\Rector\FunctionLike\DowngradeNewInInitializerRector;
|
||||
use Rector\DowngradePhp81\Rector\FunctionLike\DowngradePureIntersectionTypeRector;
|
||||
use Rector\DowngradePhp81\Rector\Instanceof_\DowngradePhp81ResourceReturnToObjectRector;
|
||||
use Rector\DowngradePhp81\Rector\Property\DowngradeReadonlyPropertyRector;
|
||||
use Rector\DowngradePhp81\Rector\StmtsAwareInterface\DowngradeSetAccessibleReflectionPropertyRector;
|
||||
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->phpVersion(PhpVersion::PHP_80);
|
||||
$rectorConfig->rules([DowngradeFinalizePublicClassConstantRector::class, DowngradeFirstClassCallableSyntaxRector::class, DowngradeNeverTypeDeclarationRector::class, DowngradePureIntersectionTypeRector::class, DowngradeNewInInitializerRector::class, DowngradePhp81ResourceReturnToObjectRector::class, DowngradeReadonlyPropertyRector::class, DowngradeArraySpreadStringKeyRector::class, DowngradeArrayIsListRector::class]);
|
||||
$rectorConfig->rules([DowngradeFinalizePublicClassConstantRector::class, DowngradeFirstClassCallableSyntaxRector::class, DowngradeNeverTypeDeclarationRector::class, DowngradePureIntersectionTypeRector::class, DowngradeNewInInitializerRector::class, DowngradePhp81ResourceReturnToObjectRector::class, DowngradeReadonlyPropertyRector::class, DowngradeArraySpreadStringKeyRector::class, DowngradeArrayIsListRector::class, DowngradeSetAccessibleReflectionPropertyRector::class]);
|
||||
$rectorConfig->ruleWithConfiguration(RenameFunctionRector::class, [
|
||||
// @see https://php.watch/versions/8.1/enums#enum-exists
|
||||
'enum_exists' => 'class_exists',
|
||||
|
@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\DowngradePhp81\Rector\StmtsAwareInterface;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\Assign;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Expr\New_;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
use Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @changelog https://phpbackend.com/blog/post/php-8-1-accessing-private-protected-properties-methods-via-reflection-api-is-now-allowed-without-calling-setAccessible
|
||||
*
|
||||
* @see \Rector\Tests\DowngradePhp81\Rector\StmtsAwareInterface\DowngradeSetAccessibleReflectionPropertyRector\DowngradeSetAccessibleReflectionPropertyRectorTest
|
||||
*/
|
||||
final class DowngradeSetAccessibleReflectionPropertyRector extends AbstractRector
|
||||
{
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Add setAccessible() on ReflectionProperty to allow reading private properties in PHP 8.0-', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
class SomeClass
|
||||
{
|
||||
public function run($object)
|
||||
{
|
||||
$reflectionProperty = new ReflectionProperty($object, 'bar');
|
||||
|
||||
return $reflectionProperty->getValue($object);
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
class SomeClass
|
||||
{
|
||||
public function run($object)
|
||||
{
|
||||
$reflectionProperty = new ReflectionProperty($object, 'bar');
|
||||
$reflectionProperty->setAccessible(true);
|
||||
|
||||
return $reflectionProperty->getValue($object);
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [StmtsAwareInterface::class];
|
||||
}
|
||||
/**
|
||||
* @param StmtsAwareInterface $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
if ($node->stmts === null) {
|
||||
return null;
|
||||
}
|
||||
$hasChanged = \false;
|
||||
foreach ($node->stmts as $key => $stmt) {
|
||||
if (!$stmt instanceof Expression) {
|
||||
continue;
|
||||
}
|
||||
if (!$stmt->expr instanceof Assign) {
|
||||
continue;
|
||||
}
|
||||
$assign = $stmt->expr;
|
||||
if (!$assign->expr instanceof New_) {
|
||||
continue;
|
||||
}
|
||||
$new = $assign->expr;
|
||||
if (!$this->isName($new->class, 'ReflectionProperty')) {
|
||||
continue;
|
||||
}
|
||||
// next stmts should be setAccessible() call
|
||||
$nextStmt = $node->stmts[$key + 1] ?? null;
|
||||
if ($this->isSetAccessibleMethodCall($nextStmt)) {
|
||||
continue;
|
||||
}
|
||||
\array_splice($node->stmts, $key + 1, 0, [$this->createSetAccessibleExpression($assign->var)]);
|
||||
$hasChanged = \true;
|
||||
}
|
||||
if ($hasChanged) {
|
||||
return $node;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private function createSetAccessibleExpression(Expr $expr) : Expression
|
||||
{
|
||||
$args = [$this->nodeFactory->createArg($this->nodeFactory->createTrue())];
|
||||
$setAccessibleMethodCall = $this->nodeFactory->createMethodCall($expr, 'setAccessible', $args);
|
||||
return new Expression($setAccessibleMethodCall);
|
||||
}
|
||||
private function isSetAccessibleMethodCall(?Stmt $stmt) : bool
|
||||
{
|
||||
if (!$stmt instanceof Expression) {
|
||||
return \false;
|
||||
}
|
||||
if (!$stmt->expr instanceof MethodCall) {
|
||||
return \false;
|
||||
}
|
||||
$methodCall = $stmt->expr;
|
||||
return $this->isName($methodCall->name, 'setAccessible');
|
||||
}
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
<?php
|
||||
|
||||
function (string $enum, bool $autoload = true) : bool {
|
||||
if (function_exists('enum_exists')) {
|
||||
return enum_exists($enum, $autoload);
|
||||
}
|
||||
return $autoload && class_exists($enum) && false;
|
||||
};
|
@ -492,6 +492,7 @@ public function NAME(string $key, mixed $value): static
|
||||
{
|
||||
try {
|
||||
$r = new \ReflectionProperty($node, 'normalizationClosures');
|
||||
$r->setAccessible(\true);
|
||||
} catch (\ReflectionException $exception) {
|
||||
return \false;
|
||||
}
|
||||
|
@ -196,6 +196,7 @@ class ClassExistenceResource implements SelfCheckingResourceInterface
|
||||
foreach ($props as $p => $v) {
|
||||
if (null !== $v) {
|
||||
$r = new \ReflectionProperty(\Exception::class, $p);
|
||||
$r->setAccessible(\true);
|
||||
$r->setValue($e, $v);
|
||||
}
|
||||
}
|
||||
|
2
vendor/symfony/console/Command/Command.php
vendored
2
vendor/symfony/console/Command/Command.php
vendored
@ -111,6 +111,7 @@ class Command
|
||||
return $attribute[0]->newInstance()->name;
|
||||
}
|
||||
$r = new \ReflectionProperty($class, 'defaultName');
|
||||
$r->setAccessible(\true);
|
||||
if ($class !== $r->class || null === static::$defaultName) {
|
||||
return null;
|
||||
}
|
||||
@ -124,6 +125,7 @@ class Command
|
||||
return $attribute[0]->newInstance()->description;
|
||||
}
|
||||
$r = new \ReflectionProperty($class, 'defaultDescription');
|
||||
$r->setAccessible(\true);
|
||||
if ($class !== $r->class || null === static::$defaultDescription) {
|
||||
return null;
|
||||
}
|
||||
|
@ -78,6 +78,7 @@ class Compiler
|
||||
$msg = $prev->getMessage();
|
||||
if ($msg !== ($resolvedMsg = $container->resolveEnvPlaceholders($msg, null, $usedEnvs))) {
|
||||
$r = new \ReflectionProperty($prev, 'message');
|
||||
$r->setAccessible(\true);
|
||||
$r->setValue($prev, $resolvedMsg);
|
||||
}
|
||||
} while ($prev = $prev->getPrevious());
|
||||
|
@ -65,6 +65,7 @@ class ResolveChildDefinitionsPass extends AbstractRecursivePass
|
||||
throw $e;
|
||||
} catch (ExceptionInterface $e) {
|
||||
$r = new \ReflectionProperty($e, 'message');
|
||||
$r->setAccessible(\true);
|
||||
$r->setValue($e, \sprintf('Service "%s": %s', $this->currentId, $e->getMessage()));
|
||||
throw $e;
|
||||
}
|
||||
|
@ -53,6 +53,7 @@ class ServiceLocator implements ServiceProviderInterface, \Countable
|
||||
$message = \sprintf('Cannot resolve %s: %s', $what, $message);
|
||||
}
|
||||
$r = new \ReflectionProperty($e, 'message');
|
||||
$r->setAccessible(\true);
|
||||
$r->setValue($e, $message);
|
||||
throw $e;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user