Updated Rector to commit bd68c98f0bc5cb8b41a62dd9e7bd94bf82e731a5

bd68c98f0b Run tests workflow as well on push (#3301)
This commit is contained in:
Tomas Votruba 2023-01-22 12:23:23 +00:00
parent 69bec676cd
commit 8c235d2f05
8 changed files with 68 additions and 21 deletions

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '58da24c6aef2117167d14c79e2c0751f887e7f54';
public const PACKAGE_VERSION = 'bd68c98f0bc5cb8b41a62dd9e7bd94bf82e731a5';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-01-22 12:03:40';
public const RELEASE_DATE = '2023-01-22 12:15:24';
/**
* @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 ComposerAutoloaderInit7d4e8ecfec10a522b4492d020d26037d::getLoader();
return ComposerAutoloaderInit67d8f8d36ea54e58016aa202cecad38a::getLoader();

View File

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

View File

@ -2126,12 +2126,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-symfony.git",
"reference": "1bdbe762aaad357e72f47ba289b02dbe2d521433"
"reference": "d325645194683c4ee2897b0dfc2c744403f428d3"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/1bdbe762aaad357e72f47ba289b02dbe2d521433",
"reference": "1bdbe762aaad357e72f47ba289b02dbe2d521433",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/d325645194683c4ee2897b0dfc2c744403f428d3",
"reference": "d325645194683c4ee2897b0dfc2c744403f428d3",
"shasum": ""
},
"require": {
@ -2165,7 +2165,7 @@
"tomasvotruba\/type-coverage": "^0.0.9",
"tomasvotruba\/unused-public": "^0.0.34"
},
"time": "2023-01-22T11:31:10+00:00",
"time": "2023-01-22T12:18:25+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 1bdbe76'));
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 d325645'));
private function __construct()
{
}

View File

@ -29,6 +29,10 @@ final class ServicesSetNameToSetTypeRector extends AbstractRector
* @var bool
*/
private $hasChanged = \false;
/**
* @var array<string, string[]>
*/
private $servicesNamesByType = [];
/**
* @readonly
* @var \Rector\Symfony\NodeAnalyzer\SymfonyPhpClosureDetector
@ -76,7 +80,8 @@ CODE_SAMPLE
if (!$this->symfonyPhpClosureDetector->detect($node)) {
return null;
}
$this->handleSetServices($node);
$duplicatedTypeNames = $this->resolveDuplicatedTypeNames($node);
$this->handleSetServices($node, $duplicatedTypeNames);
$this->handleRefServiceFunctionReferences($node);
if ($this->hasChanged) {
return $node;
@ -90,9 +95,12 @@ CODE_SAMPLE
}
return $this->isObjectType($methodCall->var, new ObjectType('Symfony\\Component\\DependencyInjection\\Loader\\Configurator\\ServicesConfigurator'));
}
private function handleSetServices(Closure $closure) : void
/**
* @param string[] $serviceNamesToSkip
*/
private function handleSetServices(Closure $closure, array $serviceNamesToSkip) : void
{
$this->traverseNodesWithCallable($closure->stmts, function (Node $node) {
$this->traverseNodesWithCallable($closure->stmts, function (Node $node) use($serviceNamesToSkip) {
if (!$node instanceof MethodCall) {
return null;
}
@ -109,6 +117,10 @@ CODE_SAMPLE
if (!$firstArg->value instanceof String_) {
return null;
}
// skip
if ($this->valueResolver->isValues($firstArg->value, $serviceNamesToSkip)) {
return null;
}
$secondArg = $args[1];
/** @var string $serviceName */
$serviceName = $this->valueResolver->getValue($firstArg->value);
@ -149,4 +161,39 @@ CODE_SAMPLE
return $node;
});
}
/**
* @return string[]
*/
private function resolveDuplicatedTypeNames(Closure $closure) : array
{
$this->servicesNamesByType = [];
$this->traverseNodesWithCallable($closure, function (Node $node) {
if (!$node instanceof MethodCall) {
return null;
}
if (!$this->isSetServices($node)) {
return null;
}
$args = $node->getArgs();
if (\count($args) !== 2) {
return null;
}
$firstArg = $args[0];
$secondArg = $args[1];
$serviceName = $this->valueResolver->getValue($firstArg->value);
$serviceType = $this->valueResolver->getValue($secondArg->value);
if (!\is_string($serviceType)) {
return null;
}
$this->servicesNamesByType[$serviceType][] = $serviceName;
});
$duplicatedTypeNames = [];
foreach ($this->servicesNamesByType as $servicesNames) {
if (\count($servicesNames) <= 1) {
continue;
}
$duplicatedTypeNames = \array_merge($duplicatedTypeNames, $servicesNames);
}
return $duplicatedTypeNames;
}
}