Updated Rector to commit e8dd953f10a7afc3610d5185c6b42216e6d9e050

e8dd953f10 [Php80] Don't add null as default to variadic parameter (#3270)
This commit is contained in:
Tomas Votruba 2023-01-10 10:35:25 +00:00
parent 4734e7527f
commit 70d56f8d24
11 changed files with 19 additions and 187 deletions

2
vendor/autoload.php vendored
View File

@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit32a21627d1903237ad7d0cb6bce9d116::getLoader();
return ComposerAutoloaderInit94cdc26f3ced1adb2ace61719468a5ec::getLoader();

View File

@ -2563,7 +2563,6 @@ return array(
'Rector\\Symfony\\Rector\\MethodCall\\FormIsValidRector' => $vendorDir . '/rector/rector-symfony/src/Rector/MethodCall/FormIsValidRector.php',
'Rector\\Symfony\\Rector\\MethodCall\\FormTypeInstanceToClassConstRector' => $vendorDir . '/rector/rector-symfony/src/Rector/MethodCall/FormTypeInstanceToClassConstRector.php',
'Rector\\Symfony\\Rector\\MethodCall\\GetHelperControllerToServiceRector' => $vendorDir . '/rector/rector-symfony/src/Rector/MethodCall/GetHelperControllerToServiceRector.php',
'Rector\\Symfony\\Rector\\MethodCall\\GetParameterToConstructorInjectionRector' => $vendorDir . '/rector/rector-symfony/src/Rector/MethodCall/GetParameterToConstructorInjectionRector.php',
'Rector\\Symfony\\Rector\\MethodCall\\GetToConstructorInjectionRector' => $vendorDir . '/rector/rector-symfony/src/Rector/MethodCall/GetToConstructorInjectionRector.php',
'Rector\\Symfony\\Rector\\MethodCall\\LiteralGetToRequestClassConstantRector' => $vendorDir . '/rector/rector-symfony/src/Rector/MethodCall/LiteralGetToRequestClassConstantRector.php',
'Rector\\Symfony\\Rector\\MethodCall\\MakeDispatchFirstArgumentEventRector' => $vendorDir . '/rector/rector-symfony/src/Rector/MethodCall/MakeDispatchFirstArgumentEventRector.php',

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit32a21627d1903237ad7d0cb6bce9d116
class ComposerAutoloaderInit94cdc26f3ced1adb2ace61719468a5ec
{
private static $loader;
@ -22,17 +22,17 @@ class ComposerAutoloaderInit32a21627d1903237ad7d0cb6bce9d116
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit32a21627d1903237ad7d0cb6bce9d116', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit94cdc26f3ced1adb2ace61719468a5ec', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit32a21627d1903237ad7d0cb6bce9d116', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit94cdc26f3ced1adb2ace61719468a5ec', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit32a21627d1903237ad7d0cb6bce9d116::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit94cdc26f3ced1adb2ace61719468a5ec::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$filesToLoad = \Composer\Autoload\ComposerStaticInit32a21627d1903237ad7d0cb6bce9d116::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInit94cdc26f3ced1adb2ace61719468a5ec::$files;
$requireFile = static function ($fileIdentifier, $file) {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit32a21627d1903237ad7d0cb6bce9d116
class ComposerStaticInit94cdc26f3ced1adb2ace61719468a5ec
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -2808,7 +2808,6 @@ class ComposerStaticInit32a21627d1903237ad7d0cb6bce9d116
'Rector\\Symfony\\Rector\\MethodCall\\FormIsValidRector' => __DIR__ . '/..' . '/rector/rector-symfony/src/Rector/MethodCall/FormIsValidRector.php',
'Rector\\Symfony\\Rector\\MethodCall\\FormTypeInstanceToClassConstRector' => __DIR__ . '/..' . '/rector/rector-symfony/src/Rector/MethodCall/FormTypeInstanceToClassConstRector.php',
'Rector\\Symfony\\Rector\\MethodCall\\GetHelperControllerToServiceRector' => __DIR__ . '/..' . '/rector/rector-symfony/src/Rector/MethodCall/GetHelperControllerToServiceRector.php',
'Rector\\Symfony\\Rector\\MethodCall\\GetParameterToConstructorInjectionRector' => __DIR__ . '/..' . '/rector/rector-symfony/src/Rector/MethodCall/GetParameterToConstructorInjectionRector.php',
'Rector\\Symfony\\Rector\\MethodCall\\GetToConstructorInjectionRector' => __DIR__ . '/..' . '/rector/rector-symfony/src/Rector/MethodCall/GetToConstructorInjectionRector.php',
'Rector\\Symfony\\Rector\\MethodCall\\LiteralGetToRequestClassConstantRector' => __DIR__ . '/..' . '/rector/rector-symfony/src/Rector/MethodCall/LiteralGetToRequestClassConstantRector.php',
'Rector\\Symfony\\Rector\\MethodCall\\MakeDispatchFirstArgumentEventRector' => __DIR__ . '/..' . '/rector/rector-symfony/src/Rector/MethodCall/MakeDispatchFirstArgumentEventRector.php',
@ -3064,9 +3063,9 @@ class ComposerStaticInit32a21627d1903237ad7d0cb6bce9d116
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit32a21627d1903237ad7d0cb6bce9d116::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit32a21627d1903237ad7d0cb6bce9d116::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit32a21627d1903237ad7d0cb6bce9d116::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit94cdc26f3ced1adb2ace61719468a5ec::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit94cdc26f3ced1adb2ace61719468a5ec::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit94cdc26f3ced1adb2ace61719468a5ec::$classMap;
}, null, ClassLoader::class);
}

View File

@ -2122,12 +2122,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-symfony.git",
"reference": "5b66a88d36ce062e16317a5baef054679cf4abcc"
"reference": "46a2234f3463d662ea9756e0a1f25d61e146f331"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/5b66a88d36ce062e16317a5baef054679cf4abcc",
"reference": "5b66a88d36ce062e16317a5baef054679cf4abcc",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/46a2234f3463d662ea9756e0a1f25d61e146f331",
"reference": "46a2234f3463d662ea9756e0a1f25d61e146f331",
"shasum": ""
},
"require": {
@ -2157,7 +2157,7 @@
"symplify\/rule-doc-generator": "^11.1",
"symplify\/vendor-patches": "^11.1"
},
"time": "2022-12-30T10:00:03+00:00",
"time": "2023-01-10T10:22:55+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {

File diff suppressed because one or more lines are too long

View File

@ -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 f0c3c11'), '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 6cf8d9d'), 'rector/rector-php-parser' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-php-parser', 'relative_install_path' => '../../rector-php-parser', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 9ea5f62'), '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 97cab8d'), '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 5b66a88'));
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 f0c3c11'), '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 6cf8d9d'), 'rector/rector-php-parser' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-php-parser', 'relative_install_path' => '../../rector-php-parser', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 9ea5f62'), '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 97cab8d'), '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 46a2234'));
private function __construct()
{
}

View File

@ -5,10 +5,8 @@ namespace RectorPrefix202301;
use Rector\Config\RectorConfig;
use Rector\Symfony\Rector\MethodCall\ContainerGetToConstructorInjectionRector;
use Rector\Symfony\Rector\MethodCall\GetParameterToConstructorInjectionRector;
use Rector\Symfony\Rector\MethodCall\GetToConstructorInjectionRector;
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->rule(ContainerGetToConstructorInjectionRector::class);
$rectorConfig->rule(GetParameterToConstructorInjectionRector::class);
$rectorConfig->rule(GetToConstructorInjectionRector::class);
};

View File

@ -1,4 +1,4 @@
# 74 Rules Overview
# 72 Rules Overview
## ActionSuffixRemoverRector
@ -263,7 +263,7 @@ Changes int return from execute to use Symfony Command constants.
protected function execute(InputInterface $input, OutputInterface $output): int
{
- return 0;
+ return Command::SUCCESS;
+ return \Symfony\Component\Console\Command\Command::SUCCESS;
}
}
@ -627,33 +627,6 @@ Replace `$this->getDoctrine()` and `$this->dispatchMessage()` calls in AbstractC
<br>
## GetParameterToConstructorInjectionRector
Turns fetching of parameters via `getParameter()` in ContainerAware to constructor injection in Command and Controller in Symfony
- class: [`Rector\Symfony\Rector\MethodCall\GetParameterToConstructorInjectionRector`](../src/Rector/MethodCall/GetParameterToConstructorInjectionRector.php)
```diff
-class MyCommand extends ContainerAwareCommand
+class MyCommand extends Command
{
+ private $someParameter;
+
+ public function __construct($someParameter)
+ {
+ $this->someParameter = $someParameter;
+ }
+
public function someMethod()
{
- $this->getParameter('someParameter');
+ $this->someParameter;
}
}
```
<br>
## GetRequestRector
Turns fetching of Request via `$this->getRequest()` to action injection
@ -1276,31 +1249,6 @@ Remove unused `$request` parameter from controller action
<br>
## RenderMethodParamToTypeDeclarationRector
Move `@param` docs on `render()` method in Symfony controller to strict type declaration
- class: [`Rector\Symfony\Rector\ClassMethod\RenderMethodParamToTypeDeclarationRector`](../src/Rector/ClassMethod/RenderMethodParamToTypeDeclarationRector.php)
```diff
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
final class SomeController extends AbstractController
{
/**
* @Route()
- * @param string $name
*/
- public function render($name)
+ public function render(string $name)
{
}
}
```
<br>
## ReplaceSensioRouteAnnotationWithSymfonyRector
Replace Sensio `@Route` annotation with Symfony one

View File

@ -166,7 +166,7 @@ CODE_SAMPLE
return null;
}
foreach (NodeTypeGroup::STMTS_AWARE as $stmtsAwareType) {
if (!\is_a($node, $stmtsAwareType, \true)) {
if (!$node instanceof $stmtsAwareType) {
continue;
}
$this->refactorStmtsAwareNode($node, $templateDoctrineAnnotationTagValueNode, $hasThisRenderOrReturnsResponse, $classMethod);

View File

@ -1,112 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\Symfony\Rector\MethodCall;
use RectorPrefix202301\Nette\Utils\Strings;
use PhpParser\Node;
use PhpParser\Node\Arg;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Scalar\String_;
use PhpParser\Node\Stmt\Class_;
use PHPStan\Type\StringType;
use Rector\Core\Rector\AbstractRector;
use Rector\Naming\Naming\PropertyNaming;
use Rector\PostRector\Collector\PropertyToAddCollector;
use Rector\PostRector\ValueObject\PropertyMetadata;
use Rector\Symfony\TypeAnalyzer\ControllerAnalyzer;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @see \Rector\Symfony\Tests\Rector\MethodCall\GetParameterToConstructorInjectionRector\GetParameterToConstructorInjectionRectorTest
*/
final class GetParameterToConstructorInjectionRector extends AbstractRector
{
/**
* @readonly
* @var \Rector\Naming\Naming\PropertyNaming
*/
private $propertyNaming;
/**
* @readonly
* @var \Rector\PostRector\Collector\PropertyToAddCollector
*/
private $propertyToAddCollector;
/**
* @readonly
* @var \Rector\Symfony\TypeAnalyzer\ControllerAnalyzer
*/
private $controllerAnalyzer;
public function __construct(PropertyNaming $propertyNaming, PropertyToAddCollector $propertyToAddCollector, ControllerAnalyzer $controllerAnalyzer)
{
$this->propertyNaming = $propertyNaming;
$this->propertyToAddCollector = $propertyToAddCollector;
$this->controllerAnalyzer = $controllerAnalyzer;
}
public function getRuleDefinition() : RuleDefinition
{
return new RuleDefinition('Turns fetching of parameters via `getParameter()` in ContainerAware to constructor injection in Command and Controller in Symfony', [new CodeSample(<<<'CODE_SAMPLE'
class MyCommand extends ContainerAwareCommand
{
public function someMethod()
{
$this->getParameter('someParameter');
}
}
CODE_SAMPLE
, <<<'CODE_SAMPLE'
class MyCommand extends Command
{
private $someParameter;
public function __construct($someParameter)
{
$this->someParameter = $someParameter;
}
public function someMethod()
{
$this->someParameter;
}
}
CODE_SAMPLE
)]);
}
/**
* @return array<class-string<Node>>
*/
public function getNodeTypes() : array
{
return [MethodCall::class];
}
/**
* @param MethodCall $node
*/
public function refactor(Node $node) : ?Node
{
if (!$this->controllerAnalyzer->isController($node->var)) {
return null;
}
if (!$this->isName($node->name, 'getParameter')) {
return null;
}
$firstArg = $node->args[0];
if (!$firstArg instanceof Arg) {
return null;
}
$stringArgument = $firstArg->value;
if (!$stringArgument instanceof String_) {
return null;
}
$parameterName = $stringArgument->value;
$parameterName = Strings::replace($parameterName, '#\\.#', '_');
$propertyName = $this->propertyNaming->underscoreToName($parameterName);
$class = $this->betterNodeFinder->findParentType($node, Class_::class);
if (!$class instanceof Class_) {
return null;
}
$propertyMetadata = new PropertyMetadata($propertyName, new StringType(), Class_::MODIFIER_PRIVATE);
$this->propertyToAddCollector->addPropertyToClass($class, $propertyMetadata);
return $this->nodeFactory->createPropertyFetch('this', $propertyName);
}
}