Updated Rector to commit c4ffdb5d8e724c3a3142e912e481111240e01d82

c4ffdb5d8e [DeadCode] Handle parent:: call with assign when no parent on RemoveParentCallWithoutParentRector (#1531)
This commit is contained in:
Tomas Votruba 2021-12-20 12:15:10 +00:00
parent 84f68c601f
commit e888119375
26 changed files with 50 additions and 333 deletions

View File

@ -23,7 +23,6 @@ use Rector\DowngradePhp80\Rector\FunctionLike\DowngradeMixedTypeDeclarationRecto
use Rector\DowngradePhp80\Rector\FunctionLike\DowngradeUnionTypeDeclarationRector;
use Rector\DowngradePhp80\Rector\Instanceof_\DowngradePhp80ResourceReturnToObjectRector;
use Rector\DowngradePhp80\Rector\MethodCall\DowngradeNamedArgumentRector;
use Rector\DowngradePhp80\Rector\MethodCall\DowngradeReflectionClassGetConstantsFilterRector;
use Rector\DowngradePhp80\Rector\MethodCall\DowngradeReflectionGetAttributesRector;
use Rector\DowngradePhp80\Rector\MethodCall\DowngradeReflectionPropertyGetDefaultValueRector;
use Rector\DowngradePhp80\Rector\New_\DowngradeArbitraryExpressionsSupportRector;
@ -70,5 +69,4 @@ return static function (\Symfony\Component\DependencyInjection\Loader\Configurat
$services->set(\Rector\DowngradePhp80\Rector\MethodCall\DowngradeReflectionGetAttributesRector::class);
$services->set(\Rector\DowngradePhp80\Rector\ClassMethod\DowngradeRecursiveDirectoryIteratorHasChildrenRector::class);
$services->set(\Rector\DowngradePhp80\Rector\MethodCall\DowngradeReflectionPropertyGetDefaultValueRector::class);
$services->set(\Rector\DowngradePhp80\Rector\MethodCall\DowngradeReflectionClassGetConstantsFilterRector::class);
};

View File

@ -1,29 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\NodeCollector\NodeAnalyzer;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\BinaryOp;
use PhpParser\Node\Expr\BinaryOp\BitwiseOr;
final class BitwiseOrAnalyzer
{
/**
* @return Expr[]
*/
public function findBitwiseOrConditions(\PhpParser\Node\Expr\BinaryOp\BitwiseOr $bitwiseOr) : array
{
$conditions = [];
/** @var BinaryOp|Expr $bitwiseOr */
while ($bitwiseOr instanceof \PhpParser\Node\Expr\BinaryOp) {
$conditions[] = $bitwiseOr->right;
$bitwiseOr = $bitwiseOr->left;
if (!$bitwiseOr instanceof \PhpParser\Node\Expr\BinaryOp\BitwiseOr) {
$conditions[] = $bitwiseOr;
break;
}
}
\krsort($conditions);
return $conditions;
}
}

View File

@ -14,7 +14,6 @@ final class BooleanAndAnalyzer
public function findBooleanAndConditions(\PhpParser\Node\Expr\BinaryOp\BooleanAnd $booleanAnd) : array
{
$conditions = [];
/** @var BinaryOp|Expr $booleanAnd */
while ($booleanAnd instanceof \PhpParser\Node\Expr\BinaryOp) {
$conditions[] = $booleanAnd->right;
$booleanAnd = $booleanAnd->left;

View File

@ -4,11 +4,8 @@ declare (strict_types=1);
namespace Rector\DowngradePhp74\Rector\MethodCall;
use PhpParser\Node;
use PhpParser\Node\Arg;
use PhpParser\Node\Expr\Instanceof_;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\Ternary;
use PhpParser\Node\Scalar\String_;
use PHPStan\Type\ObjectType;
use Rector\Core\Rector\AbstractRector;
use Rector\NodeTypeResolver\Node\AttributeKey;
@ -71,13 +68,6 @@ CODE_SAMPLE
if ($parent instanceof \PhpParser\Node\Expr\Instanceof_) {
return null;
}
// avoid infinite loop
$createdByRule = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::CREATED_BY_RULE);
if ($createdByRule === self::class) {
return null;
}
$node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::CREATED_BY_RULE, self::class);
$args = [new \PhpParser\Node\Arg($node->var), new \PhpParser\Node\Arg(new \PhpParser\Node\Scalar\String_('getType'))];
return new \PhpParser\Node\Expr\Ternary($this->nodeFactory->createFuncCall('method_exists', $args), $node, $this->nodeFactory->createNull());
return $this->nodeFactory->createNull();
}
}

View File

@ -1,219 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\DowngradePhp80\Rector\MethodCall;
use PhpParser\Node;
use PhpParser\Node\Expr\Array_;
use PhpParser\Node\Expr\ArrayDimFetch;
use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Expr\BinaryOp\BitwiseOr;
use PhpParser\Node\Expr\ClassConstFetch;
use PhpParser\Node\Expr\Closure;
use PhpParser\Node\Expr\ClosureUse;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Identifier;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Param;
use PhpParser\Node\Stmt;
use PhpParser\Node\Stmt\Expression;
use PHPStan\Type\ObjectType;
use Rector\Core\NodeManipulator\IfManipulator;
use Rector\Core\Rector\AbstractRector;
use Rector\Naming\Naming\VariableNaming;
use Rector\NodeCollector\NodeAnalyzer\BitwiseOrAnalyzer;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @see \Rector\Tests\DowngradePhp80\Rector\MethodCall\DowngradeReflectionClassGetConstantsFilterRector\DowngradeReflectionClassGetConstantsFilterRectorTest
*/
final class DowngradeReflectionClassGetConstantsFilterRector extends \Rector\Core\Rector\AbstractRector
{
/**
* @var array<string, string>
*/
private const MAP_CONSTANT_TO_METHOD = ['IS_PUBLIC' => 'isPublic', 'IS_PROTECTED' => 'isProtected', 'IS_PRIVATE' => 'isPrivate'];
/**
* @readonly
* @var \Rector\Naming\Naming\VariableNaming
*/
private $variableNaming;
/**
* @readonly
* @var \Rector\Core\NodeManipulator\IfManipulator
*/
private $ifManipulator;
/**
* @readonly
* @var \Rector\NodeCollector\NodeAnalyzer\BitwiseOrAnalyzer
*/
private $bitwiseOrAnalyzer;
public function __construct(\Rector\Naming\Naming\VariableNaming $variableNaming, \Rector\Core\NodeManipulator\IfManipulator $ifManipulator, \Rector\NodeCollector\NodeAnalyzer\BitwiseOrAnalyzer $bitwiseOrAnalyzer)
{
$this->variableNaming = $variableNaming;
$this->ifManipulator = $ifManipulator;
$this->bitwiseOrAnalyzer = $bitwiseOrAnalyzer;
}
/**
* @return array<class-string<Node>>
*/
public function getNodeTypes() : array
{
return [\PhpParser\Node\Expr\MethodCall::class];
}
public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition
{
return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Downgrade ReflectionClass->getConstants(ReflectionClassConstant::IS_*)', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE'
$reflectionClass = new ReflectionClass('SomeClass');
$constants = $reflectionClass->getConstants(ReflectionClassConstant::IS_PUBLIC));
CODE_SAMPLE
, <<<'CODE_SAMPLE'
$reflectionClass = new ReflectionClass('SomeClass');
$reflectionClassConstants = $reflectionClass->getReflectionConstants();
$result = [];
array_walk($reflectionClassConstants, function ($value) use (&$result) {
if ($value->isPublic()) {
$result[$value->getName()] = $value->getValue();
}
});
$constants = $result;
CODE_SAMPLE
)]);
}
/**
* @param MethodCall $node
*/
public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node
{
if ($this->shouldSkip($node)) {
return null;
}
$args = $node->getArgs();
$value = $args[0]->value;
if (!\in_array(\get_class($value), [\PhpParser\Node\Expr\ClassConstFetch::class, \PhpParser\Node\Expr\BinaryOp\BitwiseOr::class], \true)) {
return null;
}
$classConstFetchNames = [];
if ($value instanceof \PhpParser\Node\Expr\ClassConstFetch) {
$classConstFetchName = $this->resolveClassConstFetchName($value);
if (\is_string($classConstFetchName)) {
$classConstFetchNames = [$classConstFetchName];
}
}
if ($value instanceof \PhpParser\Node\Expr\BinaryOp\BitwiseOr) {
$classConstFetchNames = $this->resolveClassConstFetchNames($value);
}
if ($classConstFetchNames !== []) {
return $this->processClassConstFetches($node, $classConstFetchNames);
}
return null;
}
/**
* @param string[] $classConstFetchNames
*/
private function processClassConstFetches(\PhpParser\Node\Expr\MethodCall $methodCall, array $classConstFetchNames) : ?\PhpParser\Node\Expr\Variable
{
$scope = $methodCall->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE);
$reflectionClassConstants = $this->variableNaming->createCountedValueName('reflectionClassConstants', $scope);
$currentStmt = $methodCall->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::CURRENT_STATEMENT);
if (!$currentStmt instanceof \PhpParser\Node\Stmt) {
return null;
}
$variableReflectionClassConstants = new \PhpParser\Node\Expr\Variable($this->variableNaming->createCountedValueName($reflectionClassConstants, $scope));
$assign = new \PhpParser\Node\Expr\Assign($variableReflectionClassConstants, new \PhpParser\Node\Expr\MethodCall($methodCall->var, 'getReflectionConstants'));
$this->addNodeBeforeNode(new \PhpParser\Node\Stmt\Expression($assign), $currentStmt);
$result = $this->variableNaming->createCountedValueName('result', $scope);
$variableResult = new \PhpParser\Node\Expr\Variable($result);
$assignVariableResult = new \PhpParser\Node\Expr\Assign($variableResult, new \PhpParser\Node\Expr\Array_());
$this->addNodeBeforeNode(new \PhpParser\Node\Stmt\Expression($assignVariableResult), $currentStmt);
$ifs = [];
$valueVariable = new \PhpParser\Node\Expr\Variable('value');
$key = new \PhpParser\Node\Expr\MethodCall($valueVariable, 'getName');
$value = new \PhpParser\Node\Expr\MethodCall($valueVariable, 'getValue');
$arrayDimFetch = new \PhpParser\Node\Expr\ArrayDimFetch($variableResult, $key);
$assignValue = $value;
foreach ($classConstFetchNames as $classConstFetchName) {
$methodCallName = self::MAP_CONSTANT_TO_METHOD[$classConstFetchName];
$ifs[] = $this->ifManipulator->createIfExpr(new \PhpParser\Node\Expr\MethodCall($valueVariable, $methodCallName), new \PhpParser\Node\Stmt\Expression(new \PhpParser\Node\Expr\Assign($arrayDimFetch, $assignValue)));
}
$closure = new \PhpParser\Node\Expr\Closure();
$closure->params = [new \PhpParser\Node\Param(new \PhpParser\Node\Expr\Variable('value'))];
$closure->uses = [new \PhpParser\Node\Expr\ClosureUse($variableResult, \true)];
$closure->stmts = $ifs;
$funcCall = $this->nodeFactory->createFuncCall('array_walk', [$variableReflectionClassConstants, $closure]);
$this->addNodeBeforeNode(new \PhpParser\Node\Stmt\Expression($funcCall), $currentStmt);
return $variableResult;
}
private function resolveClassConstFetchName(\PhpParser\Node\Expr\ClassConstFetch $classConstFetch) : ?string
{
if ($this->shouldSkipClassConstFetch($classConstFetch)) {
return null;
}
/** @var Identifier $name */
$name = $classConstFetch->name;
return $name->toString();
}
/**
* @return string[]
*/
private function resolveClassConstFetchNames(\PhpParser\Node\Expr\BinaryOp\BitwiseOr $bitwiseOr) : array
{
$values = $this->bitwiseOrAnalyzer->findBitwiseOrConditions($bitwiseOr);
if ($this->shouldSkipBitwiseOrValues($values)) {
return [];
}
$classConstFetchNames = [];
/** @var ClassConstFetch[] $values */
foreach ($values as $value) {
/** @var Identifier $name */
$name = $value->name;
$classConstFetchNames[] = $name->toString();
}
return \array_unique($classConstFetchNames);
}
/**
* @param Node[] $values
*/
private function shouldSkipBitwiseOrValues(array $values) : bool
{
foreach ($values as $value) {
if (!$value instanceof \PhpParser\Node\Expr\ClassConstFetch) {
return \true;
}
if ($this->shouldSkipClassConstFetch($value)) {
return \true;
}
}
return \false;
}
private function shouldSkipClassConstFetch(\PhpParser\Node\Expr\ClassConstFetch $classConstFetch) : bool
{
if (!$classConstFetch->class instanceof \PhpParser\Node\Name\FullyQualified) {
return \true;
}
if ($classConstFetch->class->toString() !== 'ReflectionClassConstant') {
return \true;
}
if (!$classConstFetch->name instanceof \PhpParser\Node\Identifier) {
return \true;
}
$constants = \array_keys(self::MAP_CONSTANT_TO_METHOD);
return !$this->nodeNameResolver->isNames($classConstFetch->name, $constants);
}
private function shouldSkip(\PhpParser\Node\Expr\MethodCall $methodCall) : bool
{
if (!$this->nodeNameResolver->isName($methodCall->name, 'getConstants')) {
return \true;
}
$varType = $this->nodeTypeResolver->getType($methodCall->var);
if (!$varType instanceof \PHPStan\Type\ObjectType) {
return \true;
}
if ($varType->getClassName() !== 'ReflectionClass') {
return \true;
}
return $methodCall->getArgs() === [];
}
}

View File

@ -4,14 +4,10 @@ declare (strict_types=1);
namespace Rector\DowngradePhp80\Rector\MethodCall;
use PhpParser\Node;
use PhpParser\Node\Arg;
use PhpParser\Node\Expr\Array_;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\Ternary;
use PhpParser\Node\Scalar\String_;
use PHPStan\Type\ObjectType;
use Rector\Core\Rector\AbstractRector;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
@ -67,13 +63,6 @@ CODE_SAMPLE
if (!$this->isObjectType($node->var, new \PHPStan\Type\ObjectType('Reflector'))) {
return null;
}
// avoid infinite loop
$createdByRule = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::CREATED_BY_RULE);
if ($createdByRule === self::class) {
return null;
}
$node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::CREATED_BY_RULE, self::class);
$args = [new \PhpParser\Node\Arg($node->var), new \PhpParser\Node\Arg(new \PhpParser\Node\Scalar\String_('getAttributes'))];
return new \PhpParser\Node\Expr\Ternary($this->nodeFactory->createFuncCall('method_exists', $args), $node, new \PhpParser\Node\Expr\Array_([]));
return new \PhpParser\Node\Expr\Array_([]);
}
}

View File

@ -16,11 +16,11 @@ final class VersionResolver
/**
* @var string
*/
public const PACKAGE_VERSION = 'daa44253f9b2f28c488d2b39d6f661a9356ff571';
public const PACKAGE_VERSION = 'c4ffdb5d8e724c3a3142e912e481111240e01d82';
/**
* @var string
*/
public const RELEASE_DATE = '2021-12-20 12:58:52';
public const RELEASE_DATE = '2021-12-20 12:57:47';
public static function resolvePackageVersion() : string
{
$process = new \RectorPrefix20211220\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);

View File

@ -5,7 +5,6 @@ namespace Rector\Core\DependencyInjection\Collector;
use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
use ReflectionClass;
use ReflectionClassConstant;
use RectorPrefix20211220\Symfony\Component\Console\Style\SymfonyStyle;
use RectorPrefix20211220\Symfony\Component\DependencyInjection\Definition;
use RectorPrefix20211220\Symplify\PackageBuilder\Console\Style\SymfonyStyleFactory;
@ -67,20 +66,14 @@ final class ConfigureCallValuesCollector
// fixes bug when 1 item is unwrapped and treated as constant key, without rule having public constant
$classReflection = new \ReflectionClass($rectorClass);
$reflectionClassConstants = $classReflection->getReflectionConstants();
$result = [];
\array_walk($reflectionClassConstants, function ($value) use(&$result) {
if ($value->isPublic()) {
$result[$value->getName()] = $value->getValue();
foreach ($reflectionClassConstants as $reflectionClassConstant) {
if (!$reflectionClassConstant->isPublic()) {
continue;
}
});
$constantNamesToValues = $result;
foreach ($constantNamesToValues as $constantName => $constantValue) {
$constantValue = $reflectionClassConstant->getValue();
$constantName = $reflectionClassConstant->getName();
if ($constantValue === $firstKey) {
$reflectionConstant = $classReflection->getReflectionConstant($constantName);
if ($reflectionConstant === \false) {
continue;
}
if (\strpos((string) $reflectionConstant->getDocComment(), '@deprecated') === \false) {
if (\strpos((string) $reflectionClassConstant->getDocComment(), '@deprecated') === \false) {
continue;
}
$warningMessage = \sprintf('The constant for "%s::%s" is deprecated.%sUse "->configure()" directly instead.', $rectorClass, $constantName, \PHP_EOL);

2
vendor/autoload.php vendored
View File

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInitd107d1ba77db5896bc9586f3697f65ff::getLoader();
return ComposerAutoloaderInit92bcbf4746a781392c39f1d4f13799d9::getLoader();

View File

@ -2029,7 +2029,6 @@ return array(
'Rector\\DowngradePhp80\\Rector\\FunctionLike\\DowngradeUnionTypeDeclarationRector' => $baseDir . '/rules/DowngradePhp80/Rector/FunctionLike/DowngradeUnionTypeDeclarationRector.php',
'Rector\\DowngradePhp80\\Rector\\Instanceof_\\DowngradePhp80ResourceReturnToObjectRector' => $baseDir . '/rules/DowngradePhp80/Rector/Instanceof_/DowngradePhp80ResourceReturnToObjectRector.php',
'Rector\\DowngradePhp80\\Rector\\MethodCall\\DowngradeNamedArgumentRector' => $baseDir . '/rules/DowngradePhp80/Rector/MethodCall/DowngradeNamedArgumentRector.php',
'Rector\\DowngradePhp80\\Rector\\MethodCall\\DowngradeReflectionClassGetConstantsFilterRector' => $baseDir . '/rules/DowngradePhp80/Rector/MethodCall/DowngradeReflectionClassGetConstantsFilterRector.php',
'Rector\\DowngradePhp80\\Rector\\MethodCall\\DowngradeReflectionGetAttributesRector' => $baseDir . '/rules/DowngradePhp80/Rector/MethodCall/DowngradeReflectionGetAttributesRector.php',
'Rector\\DowngradePhp80\\Rector\\MethodCall\\DowngradeReflectionPropertyGetDefaultValueRector' => $baseDir . '/rules/DowngradePhp80/Rector/MethodCall/DowngradeReflectionPropertyGetDefaultValueRector.php',
'Rector\\DowngradePhp80\\Rector\\New_\\DowngradeArbitraryExpressionsSupportRector' => $baseDir . '/rules/DowngradePhp80/Rector/New_/DowngradeArbitraryExpressionsSupportRector.php',
@ -2295,7 +2294,6 @@ return array(
'Rector\\Nette\\ValueObject\\ParameterAssign' => $vendorDir . '/rector/rector-nette/src/ValueObject/ParameterAssign.php',
'Rector\\Nette\\ValueObject\\TemplateParametersAssigns' => $vendorDir . '/rector/rector-nette/src/ValueObject/TemplateParametersAssigns.php',
'Rector\\NodeCollector\\NodeAnalyzer\\ArrayCallableMethodMatcher' => $baseDir . '/packages/NodeCollector/NodeAnalyzer/ArrayCallableMethodMatcher.php',
'Rector\\NodeCollector\\NodeAnalyzer\\BitwiseOrAnalyzer' => $baseDir . '/packages/NodeCollector/NodeAnalyzer/BitwiseOrAnalyzer.php',
'Rector\\NodeCollector\\NodeAnalyzer\\BooleanAndAnalyzer' => $baseDir . '/packages/NodeCollector/NodeAnalyzer/BooleanAndAnalyzer.php',
'Rector\\NodeCollector\\ScopeResolver\\ParentClassScopeResolver' => $baseDir . '/packages/NodeCollector/ScopeResolver/ParentClassScopeResolver.php',
'Rector\\NodeCollector\\StaticAnalyzer' => $baseDir . '/packages/NodeCollector/StaticAnalyzer.php',

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitd107d1ba77db5896bc9586f3697f65ff
class ComposerAutoloaderInit92bcbf4746a781392c39f1d4f13799d9
{
private static $loader;
@ -22,15 +22,15 @@ class ComposerAutoloaderInitd107d1ba77db5896bc9586f3697f65ff
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitd107d1ba77db5896bc9586f3697f65ff', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit92bcbf4746a781392c39f1d4f13799d9', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInitd107d1ba77db5896bc9586f3697f65ff', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit92bcbf4746a781392c39f1d4f13799d9', '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\ComposerStaticInitd107d1ba77db5896bc9586f3697f65ff::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit92bcbf4746a781392c39f1d4f13799d9::getInitializer($loader));
} else {
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
@ -42,19 +42,19 @@ class ComposerAutoloaderInitd107d1ba77db5896bc9586f3697f65ff
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInitd107d1ba77db5896bc9586f3697f65ff::$files;
$includeFiles = Composer\Autoload\ComposerStaticInit92bcbf4746a781392c39f1d4f13799d9::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequired107d1ba77db5896bc9586f3697f65ff($fileIdentifier, $file);
composerRequire92bcbf4746a781392c39f1d4f13799d9($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequired107d1ba77db5896bc9586f3697f65ff($fileIdentifier, $file)
function composerRequire92bcbf4746a781392c39f1d4f13799d9($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInitd107d1ba77db5896bc9586f3697f65ff
class ComposerStaticInit92bcbf4746a781392c39f1d4f13799d9
{
public static $files = array (
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
@ -2424,7 +2424,6 @@ class ComposerStaticInitd107d1ba77db5896bc9586f3697f65ff
'Rector\\DowngradePhp80\\Rector\\FunctionLike\\DowngradeUnionTypeDeclarationRector' => __DIR__ . '/../..' . '/rules/DowngradePhp80/Rector/FunctionLike/DowngradeUnionTypeDeclarationRector.php',
'Rector\\DowngradePhp80\\Rector\\Instanceof_\\DowngradePhp80ResourceReturnToObjectRector' => __DIR__ . '/../..' . '/rules/DowngradePhp80/Rector/Instanceof_/DowngradePhp80ResourceReturnToObjectRector.php',
'Rector\\DowngradePhp80\\Rector\\MethodCall\\DowngradeNamedArgumentRector' => __DIR__ . '/../..' . '/rules/DowngradePhp80/Rector/MethodCall/DowngradeNamedArgumentRector.php',
'Rector\\DowngradePhp80\\Rector\\MethodCall\\DowngradeReflectionClassGetConstantsFilterRector' => __DIR__ . '/../..' . '/rules/DowngradePhp80/Rector/MethodCall/DowngradeReflectionClassGetConstantsFilterRector.php',
'Rector\\DowngradePhp80\\Rector\\MethodCall\\DowngradeReflectionGetAttributesRector' => __DIR__ . '/../..' . '/rules/DowngradePhp80/Rector/MethodCall/DowngradeReflectionGetAttributesRector.php',
'Rector\\DowngradePhp80\\Rector\\MethodCall\\DowngradeReflectionPropertyGetDefaultValueRector' => __DIR__ . '/../..' . '/rules/DowngradePhp80/Rector/MethodCall/DowngradeReflectionPropertyGetDefaultValueRector.php',
'Rector\\DowngradePhp80\\Rector\\New_\\DowngradeArbitraryExpressionsSupportRector' => __DIR__ . '/../..' . '/rules/DowngradePhp80/Rector/New_/DowngradeArbitraryExpressionsSupportRector.php',
@ -2690,7 +2689,6 @@ class ComposerStaticInitd107d1ba77db5896bc9586f3697f65ff
'Rector\\Nette\\ValueObject\\ParameterAssign' => __DIR__ . '/..' . '/rector/rector-nette/src/ValueObject/ParameterAssign.php',
'Rector\\Nette\\ValueObject\\TemplateParametersAssigns' => __DIR__ . '/..' . '/rector/rector-nette/src/ValueObject/TemplateParametersAssigns.php',
'Rector\\NodeCollector\\NodeAnalyzer\\ArrayCallableMethodMatcher' => __DIR__ . '/../..' . '/packages/NodeCollector/NodeAnalyzer/ArrayCallableMethodMatcher.php',
'Rector\\NodeCollector\\NodeAnalyzer\\BitwiseOrAnalyzer' => __DIR__ . '/../..' . '/packages/NodeCollector/NodeAnalyzer/BitwiseOrAnalyzer.php',
'Rector\\NodeCollector\\NodeAnalyzer\\BooleanAndAnalyzer' => __DIR__ . '/../..' . '/packages/NodeCollector/NodeAnalyzer/BooleanAndAnalyzer.php',
'Rector\\NodeCollector\\ScopeResolver\\ParentClassScopeResolver' => __DIR__ . '/../..' . '/packages/NodeCollector/ScopeResolver/ParentClassScopeResolver.php',
'Rector\\NodeCollector\\StaticAnalyzer' => __DIR__ . '/../..' . '/packages/NodeCollector/StaticAnalyzer.php',
@ -3832,9 +3830,9 @@ class ComposerStaticInitd107d1ba77db5896bc9586f3697f65ff
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitd107d1ba77db5896bc9586f3697f65ff::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitd107d1ba77db5896bc9586f3697f65ff::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitd107d1ba77db5896bc9586f3697f65ff::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit92bcbf4746a781392c39f1d4f13799d9::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit92bcbf4746a781392c39f1d4f13799d9::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit92bcbf4746a781392c39f1d4f13799d9::$classMap;
}, null, ClassLoader::class);
}

View File

@ -72,7 +72,7 @@ final class Reflection
*/
public static function getPropertyType(\ReflectionProperty $prop) : ?string
{
return self::getType($prop, \PHP_VERSION_ID >= 70400 ? \method_exists($prop, 'getType') ? $prop->getType() : null : null);
return self::getType($prop, \PHP_VERSION_ID >= 70400 ? null : null);
}
/**
* @deprecated

View File

@ -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('RectorPrefix20211220\AutoloadIncluder');
}
if (!class_exists('ComposerAutoloaderInitd107d1ba77db5896bc9586f3697f65ff', false) && !interface_exists('ComposerAutoloaderInitd107d1ba77db5896bc9586f3697f65ff', false) && !trait_exists('ComposerAutoloaderInitd107d1ba77db5896bc9586f3697f65ff', false)) {
spl_autoload_call('RectorPrefix20211220\ComposerAutoloaderInitd107d1ba77db5896bc9586f3697f65ff');
if (!class_exists('ComposerAutoloaderInit92bcbf4746a781392c39f1d4f13799d9', false) && !interface_exists('ComposerAutoloaderInit92bcbf4746a781392c39f1d4f13799d9', false) && !trait_exists('ComposerAutoloaderInit92bcbf4746a781392c39f1d4f13799d9', false)) {
spl_autoload_call('RectorPrefix20211220\ComposerAutoloaderInit92bcbf4746a781392c39f1d4f13799d9');
}
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('RectorPrefix20211220\Helmich\TypoScriptParser\Parser\AST\Statement');
@ -78,9 +78,9 @@ if (!function_exists('print_node')) {
return \RectorPrefix20211220\print_node(...func_get_args());
}
}
if (!function_exists('composerRequired107d1ba77db5896bc9586f3697f65ff')) {
function composerRequired107d1ba77db5896bc9586f3697f65ff() {
return \RectorPrefix20211220\composerRequired107d1ba77db5896bc9586f3697f65ff(...func_get_args());
if (!function_exists('composerRequire92bcbf4746a781392c39f1d4f13799d9')) {
function composerRequire92bcbf4746a781392c39f1d4f13799d9() {
return \RectorPrefix20211220\composerRequire92bcbf4746a781392c39f1d4f13799d9(...func_get_args());
}
}
if (!function_exists('scanPath')) {

View File

@ -108,7 +108,7 @@ class ReflectionClassResource implements \RectorPrefix20211220\Symfony\Component
{
if (\PHP_VERSION_ID >= 80000) {
$attributes = [];
foreach (\method_exists($class, 'getAttributes') ? $class->getAttributes() : [] as $a) {
foreach ([] as $a) {
$attributes[] = [$a->getName(), \PHP_VERSION_ID >= 80100 ? (string) $a : $a->getArguments()];
}
(yield \print_r($attributes, \true));
@ -128,7 +128,7 @@ class ReflectionClassResource implements \RectorPrefix20211220\Symfony\Component
$defaults = $class->getDefaultProperties();
foreach ($class->getProperties(\ReflectionProperty::IS_PUBLIC | \ReflectionProperty::IS_PROTECTED) as $p) {
if (\PHP_VERSION_ID >= 80000) {
foreach (\method_exists($p, 'getAttributes') ? $p->getAttributes() : [] as $a) {
foreach ([] as $a) {
$attributes[] = [$a->getName(), \PHP_VERSION_ID >= 80100 ? (string) $a : $a->getArguments()];
}
(yield \print_r($attributes, \true));
@ -147,7 +147,7 @@ class ReflectionClassResource implements \RectorPrefix20211220\Symfony\Component
}, null, $class->name);
foreach ($class->getMethods(\ReflectionMethod::IS_PUBLIC | \ReflectionMethod::IS_PROTECTED) as $m) {
if (\PHP_VERSION_ID >= 80000) {
foreach (\method_exists($m, 'getAttributes') ? $m->getAttributes() : [] as $a) {
foreach ([] as $a) {
$attributes[] = [$a->getName(), \PHP_VERSION_ID >= 80100 ? (string) $a : $a->getArguments()];
}
(yield \print_r($attributes, \true));
@ -157,7 +157,7 @@ class ReflectionClassResource implements \RectorPrefix20211220\Symfony\Component
$parametersWithUndefinedConstants = [];
foreach ($m->getParameters() as $p) {
if (\PHP_VERSION_ID >= 80000) {
foreach (\method_exists($p, 'getAttributes') ? $p->getAttributes() : [] as $a) {
foreach ([] as $a) {
$attributes[] = [$a->getName(), \PHP_VERSION_ID >= 80100 ? (string) $a : $a->getArguments()];
}
(yield \print_r($attributes, \true));

View File

@ -89,7 +89,7 @@ class Command
public static function getDefaultName() : ?string
{
$class = static::class;
if ($attribute = \method_exists(new \ReflectionClass($class), 'getAttributes') ? \method_exists(new \ReflectionClass($class), 'getAttributes') ? (new \ReflectionClass($class))->getAttributes(\RectorPrefix20211220\Symfony\Component\Console\Attribute\AsCommand::class) : [] : []) {
if ($attribute = []) {
return $attribute[0]->newInstance()->name;
}
$r = new \ReflectionProperty($class, 'defaultName');
@ -98,7 +98,7 @@ class Command
public static function getDefaultDescription() : ?string
{
$class = static::class;
if ($attribute = \method_exists(new \ReflectionClass($class), 'getAttributes') ? \method_exists(new \ReflectionClass($class), 'getAttributes') ? (new \ReflectionClass($class))->getAttributes(\RectorPrefix20211220\Symfony\Component\Console\Attribute\AsCommand::class) : [] : []) {
if ($attribute = []) {
return $attribute[0]->newInstance()->description;
}
$r = new \ReflectionProperty($class, 'defaultDescription');

View File

@ -38,7 +38,7 @@ trait ServiceSubscriberTrait
if (self::class !== $method->getDeclaringClass()->name) {
continue;
}
if (!($attribute = (\method_exists($method, 'getAttributes') ? $method->getAttributes(\RectorPrefix20211220\Symfony\Contracts\Service\Attribute\SubscribedService::class) : [])[0] ?? null)) {
if (!($attribute = [][0] ?? null)) {
continue;
}
if ($method->isStatic() || $method->isAbstract() || $method->isGenerator() || $method->isInternal() || $method->getNumberOfRequiredParameters()) {

View File

@ -29,7 +29,7 @@ final class Target
}
public static function parseName(\ReflectionParameter $parameter) : string
{
if (80000 > \PHP_VERSION_ID || !($target = (\method_exists($parameter, 'getAttributes') ? \method_exists($parameter, 'getAttributes') ? $parameter->getAttributes(self::class) : [] : [])[0] ?? null)) {
if (80000 > \PHP_VERSION_ID || !($target = [][0] ?? null)) {
return $parameter->name;
}
$name = $target->newInstance()->name;

View File

@ -52,7 +52,7 @@ final class AttributeAutoconfigurationPass extends \RectorPrefix20211220\Symfony
} catch (\ReflectionException $e) {
continue;
}
$targets = (\method_exists($attributeReflector, 'getAttributes') ? \method_exists($attributeReflector, 'getAttributes') ? $attributeReflector->getAttributes(\Attribute::class) : [] : [])[0] ?? 0;
$targets = [][0] ?? 0;
$targets = $targets ? $targets->getArguments()[0] ?? -1 : 0;
foreach (['class', 'method', 'property', 'parameter'] as $symbol) {
if (['Reflector'] !== $types) {
@ -76,7 +76,7 @@ final class AttributeAutoconfigurationPass extends \RectorPrefix20211220\Symfony
$instanceof = $value->getInstanceofConditionals();
$conditionals = $instanceof[$classReflector->getName()] ?? new \RectorPrefix20211220\Symfony\Component\DependencyInjection\ChildDefinition('');
if ($this->classAttributeConfigurators) {
foreach (\method_exists($classReflector, 'getAttributes') ? \method_exists($classReflector, 'getAttributes') ? $classReflector->getAttributes() : [] : [] as $attribute) {
foreach ([] as $attribute) {
if ($configurator = $this->classAttributeConfigurators[$attribute->getName()] ?? null) {
$configurator($conditionals, $attribute->newInstance(), $classReflector);
}
@ -90,7 +90,7 @@ final class AttributeAutoconfigurationPass extends \RectorPrefix20211220\Symfony
}
if ($constructorReflector) {
foreach ($constructorReflector->getParameters() as $parameterReflector) {
foreach (\method_exists($parameterReflector, 'getAttributes') ? \method_exists($parameterReflector, 'getAttributes') ? $parameterReflector->getAttributes() : [] : [] as $attribute) {
foreach ([] as $attribute) {
if ($configurator = $this->parameterAttributeConfigurators[$attribute->getName()] ?? null) {
$configurator($conditionals, $attribute->newInstance(), $parameterReflector);
}
@ -104,7 +104,7 @@ final class AttributeAutoconfigurationPass extends \RectorPrefix20211220\Symfony
continue;
}
if ($this->methodAttributeConfigurators) {
foreach (\method_exists($methodReflector, 'getAttributes') ? \method_exists($methodReflector, 'getAttributes') ? $methodReflector->getAttributes() : [] : [] as $attribute) {
foreach ([] as $attribute) {
if ($configurator = $this->methodAttributeConfigurators[$attribute->getName()] ?? null) {
$configurator($conditionals, $attribute->newInstance(), $methodReflector);
}
@ -112,7 +112,7 @@ final class AttributeAutoconfigurationPass extends \RectorPrefix20211220\Symfony
}
if ($this->parameterAttributeConfigurators) {
foreach ($methodReflector->getParameters() as $parameterReflector) {
foreach (\method_exists($parameterReflector, 'getAttributes') ? \method_exists($parameterReflector, 'getAttributes') ? $parameterReflector->getAttributes() : [] : [] as $attribute) {
foreach ([] as $attribute) {
if ($configurator = $this->parameterAttributeConfigurators[$attribute->getName()] ?? null) {
$configurator($conditionals, $attribute->newInstance(), $parameterReflector);
}
@ -126,7 +126,7 @@ final class AttributeAutoconfigurationPass extends \RectorPrefix20211220\Symfony
if ($propertyReflector->isStatic()) {
continue;
}
foreach (\method_exists($propertyReflector, 'getAttributes') ? \method_exists($propertyReflector, 'getAttributes') ? $propertyReflector->getAttributes() : [] : [] as $attribute) {
foreach ([] as $attribute) {
if ($configurator = $this->propertyAttributeConfigurators[$attribute->getName()] ?? null) {
$configurator($conditionals, $attribute->newInstance(), $propertyReflector);
}

View File

@ -209,7 +209,7 @@ class AutowirePass extends \RectorPrefix20211220\Symfony\Component\DependencyInj
}
$type = \RectorPrefix20211220\Symfony\Component\DependencyInjection\LazyProxy\ProxyHelper::getTypeHint($reflectionMethod, $parameter, \true);
if ($checkAttributes) {
foreach (\method_exists($parameter, 'getAttributes') ? \method_exists($parameter, 'getAttributes') ? $parameter->getAttributes() : [] : [] as $attribute) {
foreach ([] as $attribute) {
if (\RectorPrefix20211220\Symfony\Component\DependencyInjection\Attribute\TaggedIterator::class === $attribute->getName()) {
$attribute = $attribute->newInstance();
$arguments[$index] = new \RectorPrefix20211220\Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument($attribute->tag, $attribute->indexAttribute, $attribute->defaultIndexMethod, \false, $attribute->defaultPriorityMethod);

View File

@ -42,7 +42,7 @@ class AutowireRequiredMethodsPass extends \RectorPrefix20211220\Symfony\Componen
continue;
}
while (\true) {
if (\PHP_VERSION_ID >= 80000 && (\method_exists($r, 'getAttributes') ? \method_exists($r, 'getAttributes') ? $r->getAttributes(\RectorPrefix20211220\Symfony\Contracts\Service\Attribute\Required::class) : [] : [])) {
if (\PHP_VERSION_ID >= 80000 && []) {
if ($this->isWither($r, $r->getDocComment() ?: '')) {
$withers[] = [$r->name, [], \true];
} else {

View File

@ -39,10 +39,10 @@ class AutowireRequiredPropertiesPass extends \RectorPrefix20211220\Symfony\Compo
}
$properties = $value->getProperties();
foreach ($reflectionClass->getProperties() as $reflectionProperty) {
if (!($type = \method_exists($reflectionProperty, 'getType') ? \method_exists($reflectionProperty, 'getType') ? $reflectionProperty->getType() : null : null) instanceof \ReflectionNamedType) {
if (!($type = null) instanceof \ReflectionNamedType) {
continue;
}
if ((\PHP_VERSION_ID < 80000 || !(\method_exists($reflectionProperty, 'getAttributes') ? \method_exists($reflectionProperty, 'getAttributes') ? $reflectionProperty->getAttributes(\RectorPrefix20211220\Symfony\Contracts\Service\Attribute\Required::class) : [] : [])) && (\false === ($doc = $reflectionProperty->getDocComment()) || \false === \stripos($doc, '@required') || !\preg_match('#(?:^/\\*\\*|\\n\\s*+\\*)\\s*+@required(?:\\s|\\*/$)#i', $doc))) {
if ((\PHP_VERSION_ID < 80000 || ![]) && (\false === ($doc = $reflectionProperty->getDocComment()) || \false === \stripos($doc, '@required') || !\preg_match('#(?:^/\\*\\*|\\n\\s*+\\*)\\s*+@required(?:\\s|\\*/$)#i', $doc))) {
continue;
}
if (\array_key_exists($name = $reflectionProperty->getName(), $properties)) {

View File

@ -112,7 +112,7 @@ class PriorityTaggedServiceUtil
return null;
}
if ($checkTaggedItem && !$r->hasMethod($defaultMethod)) {
foreach (\method_exists($r, 'getAttributes') ? \method_exists($r, 'getAttributes') ? $r->getAttributes(\RectorPrefix20211220\Symfony\Component\DependencyInjection\Attribute\AsTaggedItem::class) : [] : [] as $attribute) {
foreach ([] as $attribute) {
return 'priority' === $indexAttribute ? $attribute->newInstance()->priority : $attribute->newInstance()->index;
}
return null;

View File

@ -43,7 +43,7 @@ final class RegisterAutoconfigureAttributesPass implements \RectorPrefix20211220
}
public function processClass(\RectorPrefix20211220\Symfony\Component\DependencyInjection\ContainerBuilder $container, \ReflectionClass $class)
{
foreach (\method_exists($class, 'getAttributes') ? \method_exists($class, 'getAttributes') ? $class->getAttributes(\RectorPrefix20211220\Symfony\Component\DependencyInjection\Attribute\Autoconfigure::class, \ReflectionAttribute::IS_INSTANCEOF) : [] : [] as $attribute) {
foreach ([] as $attribute) {
self::registerForAutoconfiguration($container, $class, $attribute);
}
}

View File

@ -75,7 +75,7 @@ final class Preloader
$r->getDefaultProperties();
if (\PHP_VERSION_ID >= 70400) {
foreach ($r->getProperties(\ReflectionProperty::IS_PUBLIC) as $p) {
self::preloadType(\method_exists($p, 'getType') ? \method_exists($p, 'getType') ? $p->getType() : null : null, $preloaded);
self::preloadType(null, $preloaded);
}
}
foreach ($r->getMethods(\ReflectionMethod::IS_PUBLIC) as $m) {

View File

@ -91,7 +91,7 @@ class PhpFileLoader extends \RectorPrefix20211220\Symfony\Component\DependencyIn
$r = new \ReflectionFunction($callback);
if (\PHP_VERSION_ID >= 80000) {
$attribute = null;
foreach (\method_exists($r, 'getAttributes') ? \method_exists($r, 'getAttributes') ? $r->getAttributes(\RectorPrefix20211220\Symfony\Component\DependencyInjection\Attribute\When::class) : [] : [] as $attribute) {
foreach ([] as $attribute) {
if ($this->env === $attribute->newInstance()->env) {
$attribute = null;
break;