Updated Rector to commit 93b225a3b3382fcf8bb0862746dab560ee64a53a

93b225a3b3 [Php72] Handle crash on CreateFunctionToAnonymousFunctionRector on quoted variable arg concat (#3300)
This commit is contained in:
Tomas Votruba 2023-01-22 12:07:32 +00:00
parent 475ff30ed0
commit 1d4fb67d29
17 changed files with 114 additions and 49 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 ComposerAutoloaderInita718bb1ac49dbacccadce5679a4f9d12::getLoader();
return ComposerAutoloaderInit0036377c8e08e1085a7ba10432029c96::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInita718bb1ac49dbacccadce5679a4f9d12
class ComposerAutoloaderInit0036377c8e08e1085a7ba10432029c96
{
private static $loader;
@ -22,17 +22,17 @@ class ComposerAutoloaderInita718bb1ac49dbacccadce5679a4f9d12
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInita718bb1ac49dbacccadce5679a4f9d12', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit0036377c8e08e1085a7ba10432029c96', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInita718bb1ac49dbacccadce5679a4f9d12', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit0036377c8e08e1085a7ba10432029c96', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInita718bb1ac49dbacccadce5679a4f9d12::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit0036377c8e08e1085a7ba10432029c96::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$filesToLoad = \Composer\Autoload\ComposerStaticInita718bb1ac49dbacccadce5679a4f9d12::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInit0036377c8e08e1085a7ba10432029c96::$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 ComposerStaticInita718bb1ac49dbacccadce5679a4f9d12
class ComposerStaticInit0036377c8e08e1085a7ba10432029c96
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -3071,9 +3071,9 @@ class ComposerStaticInita718bb1ac49dbacccadce5679a4f9d12
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInita718bb1ac49dbacccadce5679a4f9d12::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInita718bb1ac49dbacccadce5679a4f9d12::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInita718bb1ac49dbacccadce5679a4f9d12::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit0036377c8e08e1085a7ba10432029c96::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit0036377c8e08e1085a7ba10432029c96::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit0036377c8e08e1085a7ba10432029c96::$classMap;
}, null, ClassLoader::class);
}

View File

@ -2126,12 +2126,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-symfony.git",
"reference": "2f931343411b0a07fd2d9e955be2afbb6891ba79"
"reference": "1bdbe762aaad357e72f47ba289b02dbe2d521433"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/2f931343411b0a07fd2d9e955be2afbb6891ba79",
"reference": "2f931343411b0a07fd2d9e955be2afbb6891ba79",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/1bdbe762aaad357e72f47ba289b02dbe2d521433",
"reference": "1bdbe762aaad357e72f47ba289b02dbe2d521433",
"shasum": ""
},
"require": {
@ -2160,9 +2160,12 @@
"symplify\/phpstan-extensions": "^11.1",
"symplify\/phpstan-rules": "^11.1",
"symplify\/rule-doc-generator": "^11.1",
"symplify\/vendor-patches": "^11.1"
"symplify\/vendor-patches": "^11.1",
"tomasvotruba\/cognitive-complexity": "^0.0.5",
"tomasvotruba\/type-coverage": "^0.0.9",
"tomasvotruba\/unused-public": "^0.0.34"
},
"time": "2023-01-21T22:20:04+00:00",
"time": "2023-01-22T11:31:10+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 2f93134'));
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 1bdbe76'));
private function __construct()
{
}

View File

@ -26,7 +26,10 @@
"symplify\/phpstan-extensions": "^11.1",
"symplify\/phpstan-rules": "^11.1",
"symplify\/rule-doc-generator": "^11.1",
"symplify\/vendor-patches": "^11.1"
"symplify\/vendor-patches": "^11.1",
"tomasvotruba\/cognitive-complexity": "^0.0.5",
"tomasvotruba\/type-coverage": "^0.0.9",
"tomasvotruba\/unused-public": "^0.0.34"
},
"autoload": {
"psr-4": {

View File

@ -68,8 +68,8 @@ final class AddRouteAnnotationRector extends AbstractRector
}
$controllerReference = $this->resolveControllerReference($class, $node);
// is there a route for this annotation?
$symfonyRoutes = $this->matchSymfonyRouteMetadataByControllerReference($controllerReference);
if ($symfonyRoutes === []) {
$symfonyRouteMetadatas = $this->matchSymfonyRouteMetadataByControllerReference($controllerReference);
if ($symfonyRouteMetadatas === []) {
return null;
}
// skip if already has an annotation
@ -78,8 +78,8 @@ final class AddRouteAnnotationRector extends AbstractRector
if ($doctrineAnnotationTagValueNode !== null) {
return null;
}
foreach ($symfonyRoutes as $symfonyRoute) {
$items = $this->createRouteItems($symfonyRoute);
foreach ($symfonyRouteMetadatas as $symfonyRouteMetadata) {
$items = $this->createRouteItems($symfonyRouteMetadata);
$symfonyRouteTagValueNode = $this->symfonyRouteTagValueNodeFactory->createFromItems($items);
$phpDocInfo->addTagValueNode($symfonyRouteTagValueNode);
}

View File

@ -4,8 +4,12 @@ declare (strict_types=1);
namespace Rector\Symfony\Rector\Closure;
use PhpParser\Node;
use PhpParser\Node\Arg;
use PhpParser\Node\Expr\ClassConstFetch;
use PhpParser\Node\Expr\Closure;
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Scalar\String_;
use PHPStan\Type\ObjectType;
use Rector\Core\Rector\AbstractRector;
@ -17,6 +21,14 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
*/
final class ServicesSetNameToSetTypeRector extends AbstractRector
{
/**
* @var array<string, string>
*/
private $alreadyChangedServiceNamesToTypes = [];
/**
* @var bool
*/
private $hasChanged = \false;
/**
* @readonly
* @var \Rector\Symfony\NodeAnalyzer\SymfonyPhpClosureDetector
@ -60,19 +72,31 @@ CODE_SAMPLE
*/
public function refactor(Node $node) : ?Node
{
$hasChanged = \false;
$this->hasChanged = \false;
if (!$this->symfonyPhpClosureDetector->detect($node)) {
return null;
}
$this->traverseNodesWithCallable($node->stmts, function (Node $node) use(&$hasChanged) {
$this->handleSetServices($node);
$this->handleRefServiceFunctionReferences($node);
if ($this->hasChanged) {
return $node;
}
return null;
}
private function isSetServices(MethodCall $methodCall) : bool
{
if (!$this->isName($methodCall->name, 'set')) {
return \false;
}
return $this->isObjectType($methodCall->var, new ObjectType('Symfony\\Component\\DependencyInjection\\Loader\\Configurator\\ServicesConfigurator'));
}
private function handleSetServices(Closure $closure) : void
{
$this->traverseNodesWithCallable($closure->stmts, function (Node $node) {
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'))) {
if (!$this->isSetServices($node)) {
return null;
}
// must be exactly 2 args
@ -85,14 +109,44 @@ CODE_SAMPLE
if (!$firstArg->value instanceof String_) {
return null;
}
$secondArg = $args[1];
/** @var string $serviceName */
$serviceName = $this->valueResolver->getValue($firstArg->value);
$serviceType = $this->valueResolver->getValue($secondArg->value);
if (!\is_string($serviceType)) {
return null;
}
$this->alreadyChangedServiceNamesToTypes[$serviceName] = $serviceType;
// move 2nd arg to 1st position
$node->args = [$args[1]];
$hasChanged = \true;
$this->hasChanged = \true;
return $node;
});
if ($hasChanged) {
}
private function handleRefServiceFunctionReferences(Closure $closure) : void
{
$this->traverseNodesWithCallable($closure, function (Node $node) : ?Node {
if (!$node instanceof FuncCall) {
return null;
}
if (!$this->isNames($node->name, ['Symfony\\Component\\DependencyInjection\\Loader\\Configurator\\service', 'Symfony\\Component\\DependencyInjection\\Loader\\Configurator\\ref'])) {
return null;
}
$args = $node->getArgs();
if ($args === []) {
return null;
}
$firstArg = $args[0];
foreach ($this->alreadyChangedServiceNamesToTypes as $serviceName => $serviceType) {
if (!$this->valueResolver->isValue($firstArg->value, $serviceName)) {
continue;
}
// replace string value with type
$classConstFetch = new ClassConstFetch(new FullyQualified($serviceType), 'class');
$node->args = [new Arg($classConstFetch)];
$this->hasChanged = \true;
}
return $node;
}
return null;
});
}
}

View File

@ -46,7 +46,7 @@ CODE_SAMPLE
/**
* @param FuncCall $node
*/
public function refactor(Node $node)
public function refactor(Node $node) : ?FuncCall
{
if (!$this->isName($node, 'Symfony\\Component\\DependencyInjection\\Loader\\Configurator\\service')) {
return null;

View File

@ -4,6 +4,9 @@ declare (strict_types=1);
namespace Rector\Symfony\Set;
use Rector\Set\Contract\SetListInterface;
/**
* @api
*/
final class JMSSetList implements SetListInterface
{
/**

View File

@ -4,6 +4,9 @@ declare (strict_types=1);
namespace Rector\Symfony\Set;
use Rector\Set\Contract\SetListInterface;
/**
* @api
*/
final class SensiolabsSetList implements SetListInterface
{
/**

View File

@ -4,6 +4,9 @@ declare (strict_types=1);
namespace Rector\Symfony\Set;
use Rector\Set\Contract\SetListInterface;
/**
* @api
*/
final class SwiftmailerSetList implements SetListInterface
{
/**

View File

@ -4,6 +4,9 @@ declare (strict_types=1);
namespace Rector\Symfony\Set;
use Rector\Set\Contract\SetListInterface;
/**
* @api
*/
final class SymfonyLevelSetList implements SetListInterface
{
/**

View File

@ -4,6 +4,9 @@ declare (strict_types=1);
namespace Rector\Symfony\Set;
use Rector\Set\Contract\SetListInterface;
/**
* @api
*/
final class SymfonySetList implements SetListInterface
{
/**

View File

@ -4,6 +4,9 @@ declare (strict_types=1);
namespace Rector\Symfony\Set;
use Rector\Set\Contract\SetListInterface;
/**
* @api
*/
final class TwigLevelSetList implements SetListInterface
{
/**

View File

@ -3,7 +3,7 @@
declare (strict_types=1);
namespace Rector\Symfony\ValueObject;
class SymfonyRouteMetadata
final class SymfonyRouteMetadata
{
/**
* Format <class>::<method>
@ -84,13 +84,6 @@ class SymfonyRouteMetadata
{
return $this->path;
}
/**
* @return array<string, mixed>
*/
public function getDefaults() : array
{
return $this->defaults;
}
/**
* @return array<string, mixed>
*/
@ -101,6 +94,7 @@ class SymfonyRouteMetadata
return $defaults;
}
/**
* @api used
* @return mixed
*/
public function getDefault(string $name)
@ -136,13 +130,6 @@ class SymfonyRouteMetadata
{
return $this->condition;
}
/**
* @return array<string, mixed>
*/
public function getOptions() : array
{
return $this->options;
}
/**
* @return array<string, mixed>
*/