Updated Rector to commit cc8c4d0933a25224d93f1dd206547b96f5918ec5

cc8c4d0933 misc
This commit is contained in:
Tomas Votruba 2023-01-21 21:36:32 +00:00
parent 000bfb6f79
commit bad766b609
10 changed files with 138 additions and 19 deletions

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '0.15.10';
public const PACKAGE_VERSION = 'cc8c4d0933a25224d93f1dd206547b96f5918ec5';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-01-21 13:04:15';
public const RELEASE_DATE = '2023-01-21 21:32:11';
/**
* @var int
*/

2
vendor/autoload.php vendored
View File

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

View File

@ -2556,6 +2556,7 @@ return array(
'Rector\\Symfony\\Rector\\Class_\\MagicClosureTwigExtensionToNativeMethodsRector' => $vendorDir . '/rector/rector-symfony/src/Rector/Class_/MagicClosureTwigExtensionToNativeMethodsRector.php',
'Rector\\Symfony\\Rector\\Class_\\MakeCommandLazyRector' => $vendorDir . '/rector/rector-symfony/src/Rector/Class_/MakeCommandLazyRector.php',
'Rector\\Symfony\\Rector\\Closure\\ServiceSetStringNameToClassNameRector' => $vendorDir . '/rector/rector-symfony/src/Rector/Closure/ServiceSetStringNameToClassNameRector.php',
'Rector\\Symfony\\Rector\\Closure\\ServicesSetNameToSetTypeRector' => $vendorDir . '/rector/rector-symfony/src/Rector/Closure/ServicesSetNameToSetTypeRector.php',
'Rector\\Symfony\\Rector\\ConstFetch\\ConstraintUrlOptionRector' => $vendorDir . '/rector/rector-symfony/src/Rector/ConstFetch/ConstraintUrlOptionRector.php',
'Rector\\Symfony\\Rector\\FuncCall\\ReplaceServiceArgumentRector' => $vendorDir . '/rector/rector-symfony/src/Rector/FuncCall/ReplaceServiceArgumentRector.php',
'Rector\\Symfony\\Rector\\MethodCall\\AddViolationToBuildViolationRector' => $vendorDir . '/rector/rector-symfony/src/Rector/MethodCall/AddViolationToBuildViolationRector.php',

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit7e658fbe9fcecca748641e9505f9eb08
class ComposerAutoloaderInit7ba6dd554afc2c025ed4ce3f34723d88
{
private static $loader;
@ -22,17 +22,17 @@ class ComposerAutoloaderInit7e658fbe9fcecca748641e9505f9eb08
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit7e658fbe9fcecca748641e9505f9eb08', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit7ba6dd554afc2c025ed4ce3f34723d88', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit7e658fbe9fcecca748641e9505f9eb08', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit7ba6dd554afc2c025ed4ce3f34723d88', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit7e658fbe9fcecca748641e9505f9eb08::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit7ba6dd554afc2c025ed4ce3f34723d88::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$filesToLoad = \Composer\Autoload\ComposerStaticInit7e658fbe9fcecca748641e9505f9eb08::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInit7ba6dd554afc2c025ed4ce3f34723d88::$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 ComposerStaticInit7e658fbe9fcecca748641e9505f9eb08
class ComposerStaticInit7ba6dd554afc2c025ed4ce3f34723d88
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -2801,6 +2801,7 @@ class ComposerStaticInit7e658fbe9fcecca748641e9505f9eb08
'Rector\\Symfony\\Rector\\Class_\\MagicClosureTwigExtensionToNativeMethodsRector' => __DIR__ . '/..' . '/rector/rector-symfony/src/Rector/Class_/MagicClosureTwigExtensionToNativeMethodsRector.php',
'Rector\\Symfony\\Rector\\Class_\\MakeCommandLazyRector' => __DIR__ . '/..' . '/rector/rector-symfony/src/Rector/Class_/MakeCommandLazyRector.php',
'Rector\\Symfony\\Rector\\Closure\\ServiceSetStringNameToClassNameRector' => __DIR__ . '/..' . '/rector/rector-symfony/src/Rector/Closure/ServiceSetStringNameToClassNameRector.php',
'Rector\\Symfony\\Rector\\Closure\\ServicesSetNameToSetTypeRector' => __DIR__ . '/..' . '/rector/rector-symfony/src/Rector/Closure/ServicesSetNameToSetTypeRector.php',
'Rector\\Symfony\\Rector\\ConstFetch\\ConstraintUrlOptionRector' => __DIR__ . '/..' . '/rector/rector-symfony/src/Rector/ConstFetch/ConstraintUrlOptionRector.php',
'Rector\\Symfony\\Rector\\FuncCall\\ReplaceServiceArgumentRector' => __DIR__ . '/..' . '/rector/rector-symfony/src/Rector/FuncCall/ReplaceServiceArgumentRector.php',
'Rector\\Symfony\\Rector\\MethodCall\\AddViolationToBuildViolationRector' => __DIR__ . '/..' . '/rector/rector-symfony/src/Rector/MethodCall/AddViolationToBuildViolationRector.php',
@ -3070,9 +3071,9 @@ class ComposerStaticInit7e658fbe9fcecca748641e9505f9eb08
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit7e658fbe9fcecca748641e9505f9eb08::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit7e658fbe9fcecca748641e9505f9eb08::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit7e658fbe9fcecca748641e9505f9eb08::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit7ba6dd554afc2c025ed4ce3f34723d88::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit7ba6dd554afc2c025ed4ce3f34723d88::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit7ba6dd554afc2c025ed4ce3f34723d88::$classMap;
}, null, ClassLoader::class);
}

View File

@ -2126,12 +2126,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-symfony.git",
"reference": "65d1307213ea07e2e4012ccf147f62b9df88c866"
"reference": "1412672122a4407ea1b398e1b28161f93241b407"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/65d1307213ea07e2e4012ccf147f62b9df88c866",
"reference": "65d1307213ea07e2e4012ccf147f62b9df88c866",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/1412672122a4407ea1b398e1b28161f93241b407",
"reference": "1412672122a4407ea1b398e1b28161f93241b407",
"shasum": ""
},
"require": {
@ -2162,7 +2162,7 @@
"symplify\/rule-doc-generator": "^11.1",
"symplify\/vendor-patches": "^11.1"
},
"time": "2023-01-19T15:00:18+00:00",
"time": "2023-01-21T16:42:05+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 cda9d4d'), '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 2cfc0a5'), '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 65d1307'));
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 cda9d4d'), '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 2cfc0a5'), '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 1412672'));
private function __construct()
{
}

View File

@ -1,4 +1,4 @@
# 72 Rules Overview
# 73 Rules Overview
## ActionSuffixRemoverRector
@ -1421,6 +1421,25 @@ Change `$service->set()` string names to class-type-based names, to allow `$cont
<br>
## ServicesSetNameToSetTypeRector
Change `$services->set("name_type",` SomeType::class) to bare type, useful since Symfony 3.4
- class: [`Rector\Symfony\Rector\Closure\ServicesSetNameToSetTypeRector`](../src/Rector/Closure/ServicesSetNameToSetTypeRector.php)
```diff
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
- $services->set('some_name', App\SomeClass::class);
+ $services->set(App\SomeClass::class);
};
```
<br>
## SimpleFunctionAndFilterRector
Changes Twig_Function_Method to Twig_SimpleFunction calls in Twig_Extension.

View File

@ -0,0 +1,98 @@
<?php
declare (strict_types=1);
namespace Rector\Symfony\Rector\Closure;
use PhpParser\Node;
use PhpParser\Node\Expr\Closure;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Scalar\String_;
use PHPStan\Type\ObjectType;
use Rector\Core\Rector\AbstractRector;
use Rector\Symfony\NodeAnalyzer\SymfonyPhpClosureDetector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @see \Rector\Symfony\Tests\Rector\Closure\ServicesSetNameToSetTypeRector\ServicesSetNameToSetTypeRectorTest
*/
final class ServicesSetNameToSetTypeRector extends AbstractRector
{
/**
* @readonly
* @var \Rector\Symfony\NodeAnalyzer\SymfonyPhpClosureDetector
*/
private $symfonyPhpClosureDetector;
public function __construct(SymfonyPhpClosureDetector $symfonyPhpClosureDetector)
{
$this->symfonyPhpClosureDetector = $symfonyPhpClosureDetector;
}
public function getRuleDefinition() : RuleDefinition
{
return new RuleDefinition('Change $services->set("name_type", SomeType::class) to bare type, useful since Symfony 3.4', [new CodeSample(<<<'CODE_SAMPLE'
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set('some_name', App\SomeClass::class);
};
CODE_SAMPLE
, <<<'CODE_SAMPLE'
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(App\SomeClass::class);
};
CODE_SAMPLE
)]);
}
/**
* @return array<class-string<Node>>
*/
public function getNodeTypes() : array
{
return [Closure::class];
}
/**
* @param Closure $node
*/
public function refactor(Node $node) : ?Node
{
$hasChanged = \false;
if (!$this->symfonyPhpClosureDetector->detect($node)) {
return null;
}
$this->traverseNodesWithCallable($node->stmts, function (Node $node) use(&$hasChanged) {
if (!$node instanceof MethodCall) {
return null;
}
// @todo not parameters! check type :)
if (!$this->isName($node->name, 'set')) {
return null;
}
if (!$this->isObjectType($node->var, new ObjectType('Symfony\\Component\\DependencyInjection\\Loader\\Configurator\\ServicesConfigurator'))) {
return null;
}
// must be exactly 2 args
if (\count($node->args) !== 2) {
return null;
}
// exchange type and service name
$args = $node->getArgs();
$firstArg = $args[0];
if (!$firstArg->value instanceof String_) {
return null;
}
// move 2nd arg to 1st position
$node->args = [$args[1]];
$hasChanged = \true;
return $node;
});
if ($hasChanged) {
return $node;
}
return null;
}
}