mirror of
https://github.com/rectorphp/rector.git
synced 2025-04-13 03:52:15 +02:00
Updated Rector to commit 3c90b2d0ec9aef15c1d869ceadf1dfeaea8235ce
3c90b2d0ec
[DX] Remove parent node fixture, to avoid false positive on node discovery (#4440)
This commit is contained in:
parent
830b50116f
commit
0ae22238e2
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '951fb8be8f890b118b87858d45afc93f2cd9a29c';
|
||||
public const PACKAGE_VERSION = '3c90b2d0ec9aef15c1d869ceadf1dfeaea8235ce';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-07-08 21:36:04';
|
||||
public const RELEASE_DATE = '2023-07-08 22:42:42';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
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 ComposerAutoloaderInitc19849416545bf164a97759c7fcc6076::getLoader();
|
||||
return ComposerAutoloaderInit769b5c3b84fa1409afc39b8b32b13410::getLoader();
|
||||
|
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 ComposerAutoloaderInitc19849416545bf164a97759c7fcc6076
|
||||
class ComposerAutoloaderInit769b5c3b84fa1409afc39b8b32b13410
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,17 +22,17 @@ class ComposerAutoloaderInitc19849416545bf164a97759c7fcc6076
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInitc19849416545bf164a97759c7fcc6076', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit769b5c3b84fa1409afc39b8b32b13410', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitc19849416545bf164a97759c7fcc6076', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit769b5c3b84fa1409afc39b8b32b13410', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitc19849416545bf164a97759c7fcc6076::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit769b5c3b84fa1409afc39b8b32b13410::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInitc19849416545bf164a97759c7fcc6076::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit769b5c3b84fa1409afc39b8b32b13410::$files;
|
||||
$requireFile = \Closure::bind(static function ($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 ComposerStaticInitc19849416545bf164a97759c7fcc6076
|
||||
class ComposerStaticInit769b5c3b84fa1409afc39b8b32b13410
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
@ -3080,9 +3080,9 @@ class ComposerStaticInitc19849416545bf164a97759c7fcc6076
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitc19849416545bf164a97759c7fcc6076::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitc19849416545bf164a97759c7fcc6076::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitc19849416545bf164a97759c7fcc6076::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit769b5c3b84fa1409afc39b8b32b13410::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit769b5c3b84fa1409afc39b8b32b13410::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit769b5c3b84fa1409afc39b8b32b13410::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
16
vendor/composer/installed.json
vendored
16
vendor/composer/installed.json
vendored
@ -1982,12 +1982,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-downgrade-php.git",
|
||||
"reference": "57ad03c027f04921edea6e081c7346f21d23d104"
|
||||
"reference": "790ebf25df1b94e814e75dafe3b05338f828a15e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/57ad03c027f04921edea6e081c7346f21d23d104",
|
||||
"reference": "57ad03c027f04921edea6e081c7346f21d23d104",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-downgrade-php\/zipball\/790ebf25df1b94e814e75dafe3b05338f828a15e",
|
||||
"reference": "790ebf25df1b94e814e75dafe3b05338f828a15e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -2011,7 +2011,7 @@
|
||||
"tomasvotruba\/type-coverage": "^0.2",
|
||||
"tomasvotruba\/unused-public": "^0.1"
|
||||
},
|
||||
"time": "2023-06-30T11:54:35+00:00",
|
||||
"time": "2023-07-08T20:59:02+00:00",
|
||||
"default-branch": true,
|
||||
"type": "rector-extension",
|
||||
"extra": {
|
||||
@ -2121,12 +2121,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-symfony.git",
|
||||
"reference": "23da46cac1eeeb675a07ee10f74a7c4513db1802"
|
||||
"reference": "2e0c69345877efe2748c2181681a594cb2325e72"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/23da46cac1eeeb675a07ee10f74a7c4513db1802",
|
||||
"reference": "23da46cac1eeeb675a07ee10f74a7c4513db1802",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/2e0c69345877efe2748c2181681a594cb2325e72",
|
||||
"reference": "2e0c69345877efe2748c2181681a594cb2325e72",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -2156,7 +2156,7 @@
|
||||
"tomasvotruba\/type-coverage": "^0.2",
|
||||
"tomasvotruba\/unused-public": "^0.1"
|
||||
},
|
||||
"time": "2023-07-06T18:46:27+00:00",
|
||||
"time": "2023-07-08T21:38:13+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
@ -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 8afdccb'), '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 57ad03c'), '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 c6bf48b'), '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 23da46c'));
|
||||
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 8afdccb'), '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 790ebf2'), '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 c6bf48b'), '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 2e0c693'));
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
@ -13,10 +13,5 @@ use Rector\DowngradePhp72\Rector\FuncCall\DowngradeStreamIsattyRector;
|
||||
use Rector\DowngradePhp72\Rector\FunctionLike\DowngradeObjectTypeDeclarationRector;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->phpVersion(PhpVersion::PHP_71);
|
||||
$rectorConfig->rule(DowngradeObjectTypeDeclarationRector::class);
|
||||
$rectorConfig->rule(DowngradeParameterTypeWideningRector::class);
|
||||
$rectorConfig->rule(DowngradePregUnmatchedAsNullConstantRector::class);
|
||||
$rectorConfig->rule(DowngradeStreamIsattyRector::class);
|
||||
$rectorConfig->rule(DowngradeJsonDecodeNullAssociativeArgRector::class);
|
||||
$rectorConfig->rule(DowngradePhp72JsonConstRector::class);
|
||||
$rectorConfig->rules([DowngradeObjectTypeDeclarationRector::class, DowngradeParameterTypeWideningRector::class, DowngradePregUnmatchedAsNullConstantRector::class, DowngradeStreamIsattyRector::class, DowngradeJsonDecodeNullAssociativeArgRector::class, DowngradePhp72JsonConstRector::class]);
|
||||
};
|
||||
|
@ -15,12 +15,5 @@ use Rector\DowngradePhp73\Rector\String_\DowngradeFlexibleHeredocSyntaxRector;
|
||||
use Rector\DowngradePhp73\Rector\Unset_\DowngradeTrailingCommasInUnsetRector;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->phpVersion(PhpVersion::PHP_72);
|
||||
$rectorConfig->rule(DowngradeFlexibleHeredocSyntaxRector::class);
|
||||
$rectorConfig->rule(DowngradeListReferenceAssignmentRector::class);
|
||||
$rectorConfig->rule(DowngradeTrailingCommasInFunctionCallsRector::class);
|
||||
$rectorConfig->rule(DowngradeArrayKeyFirstLastRector::class);
|
||||
$rectorConfig->rule(SetCookieOptionsArrayToArgumentsRector::class);
|
||||
$rectorConfig->rule(DowngradeIsCountableRector::class);
|
||||
$rectorConfig->rule(DowngradePhp73JsonConstRector::class);
|
||||
$rectorConfig->rule(DowngradeTrailingCommasInUnsetRector::class);
|
||||
$rectorConfig->rules([DowngradeFlexibleHeredocSyntaxRector::class, DowngradeListReferenceAssignmentRector::class, DowngradeTrailingCommasInFunctionCallsRector::class, DowngradeArrayKeyFirstLastRector::class, SetCookieOptionsArrayToArgumentsRector::class, DowngradeIsCountableRector::class, DowngradePhp73JsonConstRector::class, DowngradeTrailingCommasInUnsetRector::class]);
|
||||
};
|
||||
|
@ -20,17 +20,5 @@ use Rector\DowngradePhp74\Rector\MethodCall\DowngradeReflectionGetTypeRector;
|
||||
use Rector\DowngradePhp74\Rector\Property\DowngradeTypedPropertyRector;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->phpVersion(PhpVersion::PHP_73);
|
||||
$rectorConfig->rule(DowngradeTypedPropertyRector::class);
|
||||
$rectorConfig->rule(ArrowFunctionToAnonymousFunctionRector::class);
|
||||
$rectorConfig->rule(DowngradeCovariantReturnTypeRector::class);
|
||||
$rectorConfig->rule(DowngradeContravariantArgumentTypeRector::class);
|
||||
$rectorConfig->rule(DowngradeNullCoalescingOperatorRector::class);
|
||||
$rectorConfig->rule(DowngradeNumericLiteralSeparatorRector::class);
|
||||
$rectorConfig->rule(DowngradeStripTagsCallWithArrayRector::class);
|
||||
$rectorConfig->rule(DowngradeArraySpreadRector::class);
|
||||
$rectorConfig->rule(DowngradeArrayMergeCallWithoutArgumentsRector::class);
|
||||
$rectorConfig->rule(DowngradeFreadFwriteFalsyToNegationRector::class);
|
||||
$rectorConfig->rule(DowngradePreviouslyImplementedInterfaceRector::class);
|
||||
$rectorConfig->rule(DowngradeReflectionGetTypeRector::class);
|
||||
$rectorConfig->rule(DowngradeProcOpenArrayCommandArgRector::class);
|
||||
$rectorConfig->rules([DowngradeTypedPropertyRector::class, ArrowFunctionToAnonymousFunctionRector::class, DowngradeCovariantReturnTypeRector::class, DowngradeContravariantArgumentTypeRector::class, DowngradeNullCoalescingOperatorRector::class, DowngradeNumericLiteralSeparatorRector::class, DowngradeStripTagsCallWithArrayRector::class, DowngradeArraySpreadRector::class, DowngradeArrayMergeCallWithoutArgumentsRector::class, DowngradeFreadFwriteFalsyToNegationRector::class, DowngradePreviouslyImplementedInterfaceRector::class, DowngradeReflectionGetTypeRector::class, DowngradeProcOpenArrayCommandArgRector::class]);
|
||||
};
|
||||
|
@ -157,8 +157,7 @@ CODE_SAMPLE
|
||||
return null;
|
||||
}
|
||||
$switchCases = $this->createSwitchCasesFromMatchArms($node, $match);
|
||||
$switch = new Switch_($match->cond, $switchCases);
|
||||
return $switch;
|
||||
return new Switch_($match->cond, $switchCases);
|
||||
}
|
||||
private function isEqualScope(Match_ $match, ?Scope $containerScope) : bool
|
||||
{
|
||||
|
@ -7,6 +7,5 @@ use Rector\Config\RectorConfig;
|
||||
use Rector\Symfony\Symfony28\Rector\MethodCall\GetToConstructorInjectionRector;
|
||||
use Rector\Symfony\Symfony42\Rector\MethodCall\ContainerGetToConstructorInjectionRector;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->rule(ContainerGetToConstructorInjectionRector::class);
|
||||
$rectorConfig->rule(GetToConstructorInjectionRector::class);
|
||||
$rectorConfig->rules([ContainerGetToConstructorInjectionRector::class, GetToConstructorInjectionRector::class]);
|
||||
};
|
||||
|
@ -3,16 +3,17 @@
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Symfony\NodeAnalyzer;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\Assign;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Expr\New_;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PHPStan\Reflection\ClassReflection;
|
||||
use PHPStan\Type\TypeWithClassName;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\PhpParser\Node\BetterNodeFinder;
|
||||
use Rector\Core\PhpParser\Node\NodeFactory;
|
||||
use Rector\NodeTypeResolver\NodeTypeResolver;
|
||||
use Rector\Symfony\NodeAnalyzer\FormType\CreateFormTypeOptionsArgMover;
|
||||
use Rector\Symfony\NodeAnalyzer\FormType\FormTypeClassResolver;
|
||||
use ReflectionMethod;
|
||||
final class FormInstanceToFormClassConstFetchConverter
|
||||
{
|
||||
/**
|
||||
@ -32,15 +33,15 @@ final class FormInstanceToFormClassConstFetchConverter
|
||||
private $formTypeClassResolver;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\PhpParser\Node\BetterNodeFinder
|
||||
* @var \Rector\NodeTypeResolver\NodeTypeResolver
|
||||
*/
|
||||
private $betterNodeFinder;
|
||||
public function __construct(CreateFormTypeOptionsArgMover $createFormTypeOptionsArgMover, NodeFactory $nodeFactory, FormTypeClassResolver $formTypeClassResolver, BetterNodeFinder $betterNodeFinder)
|
||||
private $nodeTypeResolver;
|
||||
public function __construct(CreateFormTypeOptionsArgMover $createFormTypeOptionsArgMover, NodeFactory $nodeFactory, FormTypeClassResolver $formTypeClassResolver, NodeTypeResolver $nodeTypeResolver)
|
||||
{
|
||||
$this->createFormTypeOptionsArgMover = $createFormTypeOptionsArgMover;
|
||||
$this->nodeFactory = $nodeFactory;
|
||||
$this->formTypeClassResolver = $formTypeClassResolver;
|
||||
$this->betterNodeFinder = $betterNodeFinder;
|
||||
$this->nodeTypeResolver = $nodeTypeResolver;
|
||||
}
|
||||
public function processNewInstance(MethodCall $methodCall, int $position, int $optionsPosition) : ?MethodCall
|
||||
{
|
||||
@ -53,9 +54,12 @@ final class FormInstanceToFormClassConstFetchConverter
|
||||
if ($formClassName === null) {
|
||||
return null;
|
||||
}
|
||||
$formNew = $this->resolveFormNew($argValue);
|
||||
if ($formNew instanceof New_ && $formNew->getArgs() !== []) {
|
||||
$methodCall = $this->createFormTypeOptionsArgMover->moveArgumentsToOptions($methodCall, $position, $optionsPosition, $formClassName, $formNew->getArgs());
|
||||
// better skip and ahndle manualyl
|
||||
if ($argValue instanceof Variable && $this->isVariableOfTypeWithRequiredConstructorParmaeters($argValue)) {
|
||||
return null;
|
||||
}
|
||||
if ($argValue instanceof New_ && $argValue->getArgs() !== []) {
|
||||
$methodCall = $this->createFormTypeOptionsArgMover->moveArgumentsToOptions($methodCall, $position, $optionsPosition, $formClassName, $argValue->getArgs());
|
||||
if (!$methodCall instanceof MethodCall) {
|
||||
throw new ShouldNotHappenException();
|
||||
}
|
||||
@ -65,20 +69,25 @@ final class FormInstanceToFormClassConstFetchConverter
|
||||
$currentArg->value = $classConstFetch;
|
||||
return $methodCall;
|
||||
}
|
||||
private function resolveFormNew(Expr $expr) : ?New_
|
||||
private function isVariableOfTypeWithRequiredConstructorParmaeters(Variable $variable) : bool
|
||||
{
|
||||
if ($expr instanceof New_) {
|
||||
return $expr;
|
||||
// if form type is object with constructor args, handle manually
|
||||
$variableType = $this->nodeTypeResolver->getType($variable);
|
||||
if (!$variableType instanceof TypeWithClassName) {
|
||||
return \false;
|
||||
}
|
||||
if ($expr instanceof Variable) {
|
||||
$previousAssign = $this->betterNodeFinder->findPreviousAssignToExpr($expr);
|
||||
if (!$previousAssign instanceof Assign) {
|
||||
return null;
|
||||
}
|
||||
if ($previousAssign->expr instanceof New_) {
|
||||
return $previousAssign->expr;
|
||||
}
|
||||
$classReflection = $variableType->getClassReflection();
|
||||
if (!$classReflection instanceof ClassReflection) {
|
||||
return \false;
|
||||
}
|
||||
return null;
|
||||
if (!$classReflection->hasConstructor()) {
|
||||
return \false;
|
||||
}
|
||||
$nativeReflection = $classReflection->getNativeReflection();
|
||||
$reflectionMethod = $nativeReflection->getConstructor();
|
||||
if (!$reflectionMethod instanceof ReflectionMethod) {
|
||||
return \false;
|
||||
}
|
||||
return $reflectionMethod->getNumberOfRequiredParameters() > 0;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user