mirror of
https://github.com/rectorphp/rector.git
synced 2025-04-25 18:04:42 +02:00
Updated Rector to commit b7d8787a257e94da73348cace71d2384bcc97930
b7d8787a25
remove fixture
This commit is contained in:
parent
30fbb286cf
commit
9d3486b554
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';
|
require_once __DIR__ . '/composer/autoload_real.php';
|
||||||
|
|
||||||
return ComposerAutoloaderInitf543dd885299697716397dd03f6f5d19::getLoader();
|
return ComposerAutoloaderInit9badb1a20a1849a022489166140360b1::getLoader();
|
||||||
|
1
vendor/composer/autoload_classmap.php
vendored
1
vendor/composer/autoload_classmap.php
vendored
@ -2202,6 +2202,7 @@ return array(
|
|||||||
'Rector\\Symfony\\Symfony61\\Rector\\Class_\\CommandPropertyToAttributeRector' => $vendorDir . '/rector/rector-symfony/rules/Symfony61/Rector/Class_/CommandPropertyToAttributeRector.php',
|
'Rector\\Symfony\\Symfony61\\Rector\\Class_\\CommandPropertyToAttributeRector' => $vendorDir . '/rector/rector-symfony/rules/Symfony61/Rector/Class_/CommandPropertyToAttributeRector.php',
|
||||||
'Rector\\Symfony\\Symfony61\\Rector\\Class_\\MagicClosureTwigExtensionToNativeMethodsRector' => $vendorDir . '/rector/rector-symfony/rules/Symfony61/Rector/Class_/MagicClosureTwigExtensionToNativeMethodsRector.php',
|
'Rector\\Symfony\\Symfony61\\Rector\\Class_\\MagicClosureTwigExtensionToNativeMethodsRector' => $vendorDir . '/rector/rector-symfony/rules/Symfony61/Rector/Class_/MagicClosureTwigExtensionToNativeMethodsRector.php',
|
||||||
'Rector\\Symfony\\Symfony61\\Rector\\StaticPropertyFetch\\ErrorNamesPropertyToConstantRector' => $vendorDir . '/rector/rector-symfony/rules/Symfony61/Rector/StaticPropertyFetch/ErrorNamesPropertyToConstantRector.php',
|
'Rector\\Symfony\\Symfony61\\Rector\\StaticPropertyFetch\\ErrorNamesPropertyToConstantRector' => $vendorDir . '/rector/rector-symfony/rules/Symfony61/Rector/StaticPropertyFetch/ErrorNamesPropertyToConstantRector.php',
|
||||||
|
'Rector\\Symfony\\Symfony62\\Rector\\ClassMethod\\ClassMethod\\ArgumentValueResolverToValueResolverRector' => $vendorDir . '/rector/rector-symfony/rules/Symfony62/Rector/ClassMethod/ClassMethod/ArgumentValueResolverToValueResolverRector.php',
|
||||||
'Rector\\Symfony\\Symfony62\\Rector\\ClassMethod\\ParamConverterAttributeToMapEntityAttributeRector' => $vendorDir . '/rector/rector-symfony/rules/Symfony62/Rector/ClassMethod/ParamConverterAttributeToMapEntityAttributeRector.php',
|
'Rector\\Symfony\\Symfony62\\Rector\\ClassMethod\\ParamConverterAttributeToMapEntityAttributeRector' => $vendorDir . '/rector/rector-symfony/rules/Symfony62/Rector/ClassMethod/ParamConverterAttributeToMapEntityAttributeRector.php',
|
||||||
'Rector\\Symfony\\Symfony62\\Rector\\Class_\\MessageHandlerInterfaceToAttributeRector' => $vendorDir . '/rector/rector-symfony/rules/Symfony62/Rector/Class_/MessageHandlerInterfaceToAttributeRector.php',
|
'Rector\\Symfony\\Symfony62\\Rector\\Class_\\MessageHandlerInterfaceToAttributeRector' => $vendorDir . '/rector/rector-symfony/rules/Symfony62/Rector/Class_/MessageHandlerInterfaceToAttributeRector.php',
|
||||||
'Rector\\Symfony\\Symfony62\\Rector\\Class_\\MessageSubscriberInterfaceToAttributeRector' => $vendorDir . '/rector/rector-symfony/rules/Symfony62/Rector/Class_/MessageSubscriberInterfaceToAttributeRector.php',
|
'Rector\\Symfony\\Symfony62\\Rector\\Class_\\MessageSubscriberInterfaceToAttributeRector' => $vendorDir . '/rector/rector-symfony/rules/Symfony62/Rector/Class_/MessageSubscriberInterfaceToAttributeRector.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
|
// autoload_real.php @generated by Composer
|
||||||
|
|
||||||
class ComposerAutoloaderInitf543dd885299697716397dd03f6f5d19
|
class ComposerAutoloaderInit9badb1a20a1849a022489166140360b1
|
||||||
{
|
{
|
||||||
private static $loader;
|
private static $loader;
|
||||||
|
|
||||||
@ -22,17 +22,17 @@ class ComposerAutoloaderInitf543dd885299697716397dd03f6f5d19
|
|||||||
return self::$loader;
|
return self::$loader;
|
||||||
}
|
}
|
||||||
|
|
||||||
spl_autoload_register(array('ComposerAutoloaderInitf543dd885299697716397dd03f6f5d19', 'loadClassLoader'), true, true);
|
spl_autoload_register(array('ComposerAutoloaderInit9badb1a20a1849a022489166140360b1', 'loadClassLoader'), true, true);
|
||||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||||
spl_autoload_unregister(array('ComposerAutoloaderInitf543dd885299697716397dd03f6f5d19', 'loadClassLoader'));
|
spl_autoload_unregister(array('ComposerAutoloaderInit9badb1a20a1849a022489166140360b1', 'loadClassLoader'));
|
||||||
|
|
||||||
require __DIR__ . '/autoload_static.php';
|
require __DIR__ . '/autoload_static.php';
|
||||||
call_user_func(\Composer\Autoload\ComposerStaticInitf543dd885299697716397dd03f6f5d19::getInitializer($loader));
|
call_user_func(\Composer\Autoload\ComposerStaticInit9badb1a20a1849a022489166140360b1::getInitializer($loader));
|
||||||
|
|
||||||
$loader->setClassMapAuthoritative(true);
|
$loader->setClassMapAuthoritative(true);
|
||||||
$loader->register(true);
|
$loader->register(true);
|
||||||
|
|
||||||
$filesToLoad = \Composer\Autoload\ComposerStaticInitf543dd885299697716397dd03f6f5d19::$files;
|
$filesToLoad = \Composer\Autoload\ComposerStaticInit9badb1a20a1849a022489166140360b1::$files;
|
||||||
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
|
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
|
||||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
$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;
|
namespace Composer\Autoload;
|
||||||
|
|
||||||
class ComposerStaticInitf543dd885299697716397dd03f6f5d19
|
class ComposerStaticInit9badb1a20a1849a022489166140360b1
|
||||||
{
|
{
|
||||||
public static $files = array (
|
public static $files = array (
|
||||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||||
@ -2434,6 +2434,7 @@ class ComposerStaticInitf543dd885299697716397dd03f6f5d19
|
|||||||
'Rector\\Symfony\\Symfony61\\Rector\\Class_\\CommandPropertyToAttributeRector' => __DIR__ . '/..' . '/rector/rector-symfony/rules/Symfony61/Rector/Class_/CommandPropertyToAttributeRector.php',
|
'Rector\\Symfony\\Symfony61\\Rector\\Class_\\CommandPropertyToAttributeRector' => __DIR__ . '/..' . '/rector/rector-symfony/rules/Symfony61/Rector/Class_/CommandPropertyToAttributeRector.php',
|
||||||
'Rector\\Symfony\\Symfony61\\Rector\\Class_\\MagicClosureTwigExtensionToNativeMethodsRector' => __DIR__ . '/..' . '/rector/rector-symfony/rules/Symfony61/Rector/Class_/MagicClosureTwigExtensionToNativeMethodsRector.php',
|
'Rector\\Symfony\\Symfony61\\Rector\\Class_\\MagicClosureTwigExtensionToNativeMethodsRector' => __DIR__ . '/..' . '/rector/rector-symfony/rules/Symfony61/Rector/Class_/MagicClosureTwigExtensionToNativeMethodsRector.php',
|
||||||
'Rector\\Symfony\\Symfony61\\Rector\\StaticPropertyFetch\\ErrorNamesPropertyToConstantRector' => __DIR__ . '/..' . '/rector/rector-symfony/rules/Symfony61/Rector/StaticPropertyFetch/ErrorNamesPropertyToConstantRector.php',
|
'Rector\\Symfony\\Symfony61\\Rector\\StaticPropertyFetch\\ErrorNamesPropertyToConstantRector' => __DIR__ . '/..' . '/rector/rector-symfony/rules/Symfony61/Rector/StaticPropertyFetch/ErrorNamesPropertyToConstantRector.php',
|
||||||
|
'Rector\\Symfony\\Symfony62\\Rector\\ClassMethod\\ClassMethod\\ArgumentValueResolverToValueResolverRector' => __DIR__ . '/..' . '/rector/rector-symfony/rules/Symfony62/Rector/ClassMethod/ClassMethod/ArgumentValueResolverToValueResolverRector.php',
|
||||||
'Rector\\Symfony\\Symfony62\\Rector\\ClassMethod\\ParamConverterAttributeToMapEntityAttributeRector' => __DIR__ . '/..' . '/rector/rector-symfony/rules/Symfony62/Rector/ClassMethod/ParamConverterAttributeToMapEntityAttributeRector.php',
|
'Rector\\Symfony\\Symfony62\\Rector\\ClassMethod\\ParamConverterAttributeToMapEntityAttributeRector' => __DIR__ . '/..' . '/rector/rector-symfony/rules/Symfony62/Rector/ClassMethod/ParamConverterAttributeToMapEntityAttributeRector.php',
|
||||||
'Rector\\Symfony\\Symfony62\\Rector\\Class_\\MessageHandlerInterfaceToAttributeRector' => __DIR__ . '/..' . '/rector/rector-symfony/rules/Symfony62/Rector/Class_/MessageHandlerInterfaceToAttributeRector.php',
|
'Rector\\Symfony\\Symfony62\\Rector\\Class_\\MessageHandlerInterfaceToAttributeRector' => __DIR__ . '/..' . '/rector/rector-symfony/rules/Symfony62/Rector/Class_/MessageHandlerInterfaceToAttributeRector.php',
|
||||||
'Rector\\Symfony\\Symfony62\\Rector\\Class_\\MessageSubscriberInterfaceToAttributeRector' => __DIR__ . '/..' . '/rector/rector-symfony/rules/Symfony62/Rector/Class_/MessageSubscriberInterfaceToAttributeRector.php',
|
'Rector\\Symfony\\Symfony62\\Rector\\Class_\\MessageSubscriberInterfaceToAttributeRector' => __DIR__ . '/..' . '/rector/rector-symfony/rules/Symfony62/Rector/Class_/MessageSubscriberInterfaceToAttributeRector.php',
|
||||||
@ -2638,9 +2639,9 @@ class ComposerStaticInitf543dd885299697716397dd03f6f5d19
|
|||||||
public static function getInitializer(ClassLoader $loader)
|
public static function getInitializer(ClassLoader $loader)
|
||||||
{
|
{
|
||||||
return \Closure::bind(function () use ($loader) {
|
return \Closure::bind(function () use ($loader) {
|
||||||
$loader->prefixLengthsPsr4 = ComposerStaticInitf543dd885299697716397dd03f6f5d19::$prefixLengthsPsr4;
|
$loader->prefixLengthsPsr4 = ComposerStaticInit9badb1a20a1849a022489166140360b1::$prefixLengthsPsr4;
|
||||||
$loader->prefixDirsPsr4 = ComposerStaticInitf543dd885299697716397dd03f6f5d19::$prefixDirsPsr4;
|
$loader->prefixDirsPsr4 = ComposerStaticInit9badb1a20a1849a022489166140360b1::$prefixDirsPsr4;
|
||||||
$loader->classMap = ComposerStaticInitf543dd885299697716397dd03f6f5d19::$classMap;
|
$loader->classMap = ComposerStaticInit9badb1a20a1849a022489166140360b1::$classMap;
|
||||||
|
|
||||||
}, null, ClassLoader::class);
|
}, null, ClassLoader::class);
|
||||||
}
|
}
|
||||||
|
8
vendor/composer/installed.json
vendored
8
vendor/composer/installed.json
vendored
@ -1956,12 +1956,12 @@
|
|||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https:\/\/github.com\/rectorphp\/rector-symfony.git",
|
"url": "https:\/\/github.com\/rectorphp\/rector-symfony.git",
|
||||||
"reference": "670cccb40f93da45ade80bd508693e4408361b09"
|
"reference": "2a4d4c0380037bf78f513abe3da9bcb6f35abc48"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/670cccb40f93da45ade80bd508693e4408361b09",
|
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/2a4d4c0380037bf78f513abe3da9bcb6f35abc48",
|
||||||
"reference": "670cccb40f93da45ade80bd508693e4408361b09",
|
"reference": "2a4d4c0380037bf78f513abe3da9bcb6f35abc48",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -1993,7 +1993,7 @@
|
|||||||
"tomasvotruba\/unused-public": "^0.2",
|
"tomasvotruba\/unused-public": "^0.2",
|
||||||
"tracy\/tracy": "^2.10"
|
"tracy\/tracy": "^2.10"
|
||||||
},
|
},
|
||||||
"time": "2023-08-15T22:30:03+00:00",
|
"time": "2023-08-17T14:03:59+00:00",
|
||||||
"default-branch": true,
|
"default-branch": true,
|
||||||
"type": "rector-extension",
|
"type": "rector-extension",
|
||||||
"extra": {
|
"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
|
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 c0ab738'), '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 ae6d18d'), '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 cec1a6c'), '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 670cccb'));
|
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 c0ab738'), '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 ae6d18d'), '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 cec1a6c'), '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 2a4d4c0'));
|
||||||
private function __construct()
|
private function __construct()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ use Rector\Renaming\ValueObject\MethodCallRename;
|
|||||||
use Rector\Renaming\ValueObject\RenameClassAndConstFetch;
|
use Rector\Renaming\ValueObject\RenameClassAndConstFetch;
|
||||||
use Rector\Symfony\Symfony62\Rector\Class_\MessageHandlerInterfaceToAttributeRector;
|
use Rector\Symfony\Symfony62\Rector\Class_\MessageHandlerInterfaceToAttributeRector;
|
||||||
use Rector\Symfony\Symfony62\Rector\Class_\MessageSubscriberInterfaceToAttributeRector;
|
use Rector\Symfony\Symfony62\Rector\Class_\MessageSubscriberInterfaceToAttributeRector;
|
||||||
|
use Rector\Symfony\Symfony62\Rector\ClassMethod\ClassMethod\ArgumentValueResolverToValueResolverRector;
|
||||||
use Rector\Symfony\Symfony62\Rector\ClassMethod\ParamConverterAttributeToMapEntityAttributeRector;
|
use Rector\Symfony\Symfony62\Rector\ClassMethod\ParamConverterAttributeToMapEntityAttributeRector;
|
||||||
use Rector\Symfony\Symfony62\Rector\MethodCall\SimplifyFormRenderingRector;
|
use Rector\Symfony\Symfony62\Rector\MethodCall\SimplifyFormRenderingRector;
|
||||||
return static function (RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
@ -52,4 +53,6 @@ return static function (RectorConfig $rectorConfig) : void {
|
|||||||
// @see https://github.com/symfony/symfony/pull/47068
|
// @see https://github.com/symfony/symfony/pull/47068
|
||||||
$rectorConfig->rule(MessageHandlerInterfaceToAttributeRector::class);
|
$rectorConfig->rule(MessageHandlerInterfaceToAttributeRector::class);
|
||||||
$rectorConfig->rule(MessageSubscriberInterfaceToAttributeRector::class);
|
$rectorConfig->rule(MessageSubscriberInterfaceToAttributeRector::class);
|
||||||
|
// @see https://github.com/symfony/symfony/pull/47363
|
||||||
|
$rectorConfig->rule(ArgumentValueResolverToValueResolverRector::class);
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# 81 Rules Overview
|
# 82 Rules Overview
|
||||||
|
|
||||||
## ActionSuffixRemoverRector
|
## ActionSuffixRemoverRector
|
||||||
|
|
||||||
@ -59,6 +59,31 @@ Change `$context->addViolationAt` to `$context->buildViolation` on Validator Exe
|
|||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
|
## ArgumentValueResolverToValueResolverRector
|
||||||
|
|
||||||
|
Replaces ArgumentValueResolverInterface by ValueResolverInterface
|
||||||
|
|
||||||
|
- class: [`Rector\Symfony\Symfony62\Rector\ClassMethod\ClassMethod\ArgumentValueResolverToValueResolverRector`](../rules/Symfony62/Rector/ClassMethod/ClassMethod/ArgumentValueResolverToValueResolverRector.php)
|
||||||
|
|
||||||
|
```diff
|
||||||
|
-use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface;
|
||||||
|
+use Symfony\Component\HttpKernel\Controller\ValueResolverInterface;
|
||||||
|
|
||||||
|
-final class EntityValueResolver implements ArgumentValueResolverInterface
|
||||||
|
+final class EntityValueResolver implements ValueResolverInterface
|
||||||
|
{
|
||||||
|
- public function supports(Request $request, ArgumentMetadata $argument): bool
|
||||||
|
- {
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
public function resolve(Request $request, ArgumentMetadata $argument): iterable
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
## AuthorizationCheckerIsGrantedExtractorRector
|
## AuthorizationCheckerIsGrantedExtractorRector
|
||||||
|
|
||||||
Change `$this->authorizationChecker->isGranted([$a, $b])` to `$this->authorizationChecker->isGranted($a) || $this->authorizationChecker->isGranted($b)`
|
Change `$this->authorizationChecker->isGranted([$a, $b])` to `$this->authorizationChecker->isGranted($a) || $this->authorizationChecker->isGranted($b)`
|
||||||
|
@ -19,7 +19,6 @@ use PHPStan\Reflection\ReflectionProvider;
|
|||||||
use PHPStan\Type\ObjectType;
|
use PHPStan\Type\ObjectType;
|
||||||
use Rector\Core\Exception\ShouldNotHappenException;
|
use Rector\Core\Exception\ShouldNotHappenException;
|
||||||
use Rector\Core\Rector\AbstractRector;
|
use Rector\Core\Rector\AbstractRector;
|
||||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
|
||||||
use Rector\Symfony\MinimalSharedStringSolver;
|
use Rector\Symfony\MinimalSharedStringSolver;
|
||||||
use Rector\Symfony\NodeAnalyzer\SymfonyPhpClosureDetector;
|
use Rector\Symfony\NodeAnalyzer\SymfonyPhpClosureDetector;
|
||||||
use Rector\Symfony\ValueObject\ClassNameAndFilePath;
|
use Rector\Symfony\ValueObject\ClassNameAndFilePath;
|
||||||
@ -203,8 +202,8 @@ CODE_SAMPLE
|
|||||||
private function removeServicesSetMethodCalls(Closure $closure, array $stmtsToRemove) : void
|
private function removeServicesSetMethodCalls(Closure $closure, array $stmtsToRemove) : void
|
||||||
{
|
{
|
||||||
foreach ($closure->stmts as $key => $stmt) {
|
foreach ($closure->stmts as $key => $stmt) {
|
||||||
foreach ($stmtsToRemove as $bareServicesSetMethodCallExpression) {
|
foreach ($stmtsToRemove as $stmtToRemove) {
|
||||||
if ($stmt === $bareServicesSetMethodCallExpression) {
|
if ($stmt === $stmtToRemove) {
|
||||||
unset($closure->stmts[$key]);
|
unset($closure->stmts[$key]);
|
||||||
continue 2;
|
continue 2;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ use PhpParser\Node;
|
|||||||
use PhpParser\Node\Arg;
|
use PhpParser\Node\Arg;
|
||||||
use PhpParser\Node\Expr;
|
use PhpParser\Node\Expr;
|
||||||
use PhpParser\Node\Expr\Array_;
|
use PhpParser\Node\Expr\Array_;
|
||||||
use PhpParser\Node\Expr\Assign;
|
|
||||||
use PhpParser\Node\Expr\BinaryOp\Concat;
|
use PhpParser\Node\Expr\BinaryOp\Concat;
|
||||||
use PhpParser\Node\Expr\FuncCall;
|
use PhpParser\Node\Expr\FuncCall;
|
||||||
use PhpParser\Node\Expr\MethodCall;
|
use PhpParser\Node\Expr\MethodCall;
|
||||||
|
@ -0,0 +1,131 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare (strict_types=1);
|
||||||
|
namespace Rector\Symfony\Symfony62\Rector\ClassMethod\ClassMethod;
|
||||||
|
|
||||||
|
use PhpParser\Node;
|
||||||
|
use PhpParser\Node\Expr;
|
||||||
|
use PhpParser\Node\Expr\BinaryOp;
|
||||||
|
use PhpParser\Node\Expr\BinaryOp\Identical;
|
||||||
|
use PhpParser\Node\Expr\BinaryOp\NotIdentical;
|
||||||
|
use PhpParser\Node\Expr\ConstFetch;
|
||||||
|
use PhpParser\Node\Name;
|
||||||
|
use PhpParser\Node\Name\FullyQualified;
|
||||||
|
use PhpParser\Node\Stmt\Class_;
|
||||||
|
use PhpParser\Node\Stmt\ClassMethod;
|
||||||
|
use PhpParser\Node\Stmt\If_;
|
||||||
|
use PhpParser\Node\Stmt\Return_;
|
||||||
|
use Rector\Core\Rector\AbstractRector;
|
||||||
|
use RectorPrefix202308\Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface;
|
||||||
|
use RectorPrefix202308\Symfony\Component\HttpKernel\Controller\ValueResolverInterface;
|
||||||
|
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||||
|
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||||
|
/**
|
||||||
|
* @see \Rector\Symfony\Tests\Symfony62\Rector\ClassMethod\ArgumentValueResolverToValueResolverRector\ArgumentValueResolverToValueResolverRectorTest
|
||||||
|
*/
|
||||||
|
final class ArgumentValueResolverToValueResolverRector extends AbstractRector
|
||||||
|
{
|
||||||
|
public function getNodeTypes() : array
|
||||||
|
{
|
||||||
|
return [Class_::class];
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param Class_ $node
|
||||||
|
*/
|
||||||
|
public function refactor(Node $node) : ?Node
|
||||||
|
{
|
||||||
|
if (!$this->shouldRefactorClass($node)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
foreach ($node->getMethods() as $key => $classMethod) {
|
||||||
|
if ($classMethod->name->toString() === 'supports') {
|
||||||
|
[$isIdentical, $supportFirstArg, $supportSecondArg] = $this->extractSupportsArguments($node, $key, $classMethod);
|
||||||
|
}
|
||||||
|
if ($classMethod->name->toString() === 'resolve' && isset($isIdentical) && isset($supportFirstArg) && isset($supportSecondArg)) {
|
||||||
|
$this->processResolveMethod($classMethod, $isIdentical, $supportFirstArg, $supportSecondArg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $node;
|
||||||
|
}
|
||||||
|
public function getRuleDefinition() : RuleDefinition
|
||||||
|
{
|
||||||
|
return new RuleDefinition('Replaces ArgumentValueResolverInterface by ValueResolverInterface', [new CodeSample(<<<'CODE_SAMPLE'
|
||||||
|
use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface;
|
||||||
|
|
||||||
|
final class EntityValueResolver implements ArgumentValueResolverInterface
|
||||||
|
{
|
||||||
|
public function supports(Request $request, ArgumentMetadata $argument): bool
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resolve(Request $request, ArgumentMetadata $argument): iterable
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CODE_SAMPLE
|
||||||
|
, <<<'CODE_SAMPLE'
|
||||||
|
use Symfony\Component\HttpKernel\Controller\ValueResolverInterface;
|
||||||
|
|
||||||
|
final class EntityValueResolver implements ValueResolverInterface
|
||||||
|
{
|
||||||
|
public function resolve(Request $request, ArgumentMetadata $argument): iterable
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CODE_SAMPLE
|
||||||
|
)]);
|
||||||
|
}
|
||||||
|
private function shouldRefactorClass(Class_ $class) : bool
|
||||||
|
{
|
||||||
|
// Check if the class implements ArgumentValueResolverInterface
|
||||||
|
foreach ($class->implements as $key => $interface) {
|
||||||
|
if ($interface->toString() === ArgumentValueResolverInterface::class) {
|
||||||
|
$class->implements[$key] = new FullyQualified(ValueResolverInterface::class);
|
||||||
|
return \true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// If it doesn't implement ArgumentValueResolverInterface, skip
|
||||||
|
return \false;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return array{bool, Expr|null, Expr|null}
|
||||||
|
*/
|
||||||
|
private function extractSupportsArguments(Class_ $class, int $key, ClassMethod $classMethod) : array
|
||||||
|
{
|
||||||
|
$isIdentical = \true;
|
||||||
|
$supportFirstArg = $supportSecondArg = null;
|
||||||
|
if (null === $classMethod->getStmts()) {
|
||||||
|
return [$isIdentical, $supportFirstArg, $supportSecondArg];
|
||||||
|
}
|
||||||
|
foreach ($classMethod->getStmts() as $statement) {
|
||||||
|
if (!$statement instanceof Return_) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$expression = $statement->expr;
|
||||||
|
if (!$expression instanceof BinaryOp) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($expression instanceof NotIdentical) {
|
||||||
|
$isIdentical = \false;
|
||||||
|
}
|
||||||
|
$supportFirstArg = $expression->left;
|
||||||
|
$supportSecondArg = $expression->right;
|
||||||
|
unset($class->stmts[$key]);
|
||||||
|
break;
|
||||||
|
// We only need the first matching condition
|
||||||
|
}
|
||||||
|
return [$isIdentical, $supportFirstArg, $supportSecondArg];
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param mixed $classMethod
|
||||||
|
* @param mixed $isIdentical
|
||||||
|
* @param mixed $supportFirstArg
|
||||||
|
* @param mixed $supportSecondArg
|
||||||
|
*/
|
||||||
|
private function processResolveMethod($classMethod, $isIdentical, $supportFirstArg, $supportSecondArg) : void
|
||||||
|
{
|
||||||
|
$ifCondition = $isIdentical ? new NotIdentical($supportFirstArg, $supportSecondArg) : new Identical($supportFirstArg, $supportSecondArg);
|
||||||
|
$classMethod->stmts = \array_merge([new If_($ifCondition, ['stmts' => [new Return_(new ConstFetch(new Name('[]')))]])], $classMethod->getStmts());
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user