Updated Rector to commit 88a27f43efbcdf7004b6f7b2a6c6255cc81b6fff

88a27f43ef [Config] Add registerService() method to allow container extension (#5591)
This commit is contained in:
Tomas Votruba 2024-02-09 12:02:07 +00:00
parent 5d5a36456b
commit bbbbb87f7d
8 changed files with 71 additions and 8 deletions

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '76504227a46a540c8736759103478db2459ec5ca';
public const PACKAGE_VERSION = '88a27f43efbcdf7004b6f7b2a6c6255cc81b6fff';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2024-02-09 08:56:07';
public const RELEASE_DATE = '2024-02-09 12:59:57';
/**
* @var int
*/

View File

@ -0,0 +1,41 @@
<?php
declare (strict_types=1);
namespace Rector\Config;
final class RegisteredService
{
/**
* @readonly
* @var string
*/
private $className;
/**
* @readonly
* @var string|null
*/
private $alias;
/**
* @readonly
* @var string|null
*/
private $tag;
public function __construct(string $className, ?string $alias, ?string $tag)
{
$this->className = $className;
$this->alias = $alias;
$this->tag = $tag;
}
public function getClassName() : string
{
return $this->className;
}
public function getAlias() : ?string
{
return $this->alias;
}
public function getTag() : ?string
{
return $this->tag;
}
}

View File

@ -7,6 +7,7 @@ use Rector\Caching\Contract\ValueObject\Storage\CacheStorageInterface;
use Rector\Config\Level\DeadCodeLevel;
use Rector\Config\Level\TypeDeclarationLevel;
use Rector\Config\RectorConfig;
use Rector\Config\RegisteredService;
use Rector\Configuration\Levels\LevelRulesResolver;
use Rector\Contract\Rector\ConfigurableRectorInterface;
use Rector\Contract\Rector\RectorInterface;
@ -146,6 +147,10 @@ final class RectorConfigBuilder
* @var bool
*/
private $isDeadCodeLevelUsed = \false;
/**
* @var RegisteredService[]
*/
private $registerServices = [];
public function __invoke(RectorConfig $rectorConfig) : void
{
$uniqueSets = \array_unique($this->sets);
@ -159,6 +164,16 @@ final class RectorConfigBuilder
if ($this->paths !== []) {
$rectorConfig->paths($this->paths);
}
// must be in upper part, as these services might be used by rule registered bellow
foreach ($this->registerServices as $registerService) {
$rectorConfig->singleton($registerService->getClassName());
if ($registerService->getAlias()) {
$rectorConfig->alias($registerService->getClassName(), $registerService->getAlias());
}
if ($registerService->getTag()) {
$rectorConfig->tag($registerService->getClassName(), $registerService->getTag());
}
}
$rectorConfig->skip($this->skip);
$rectorConfig->rules($this->rules);
foreach ($this->rulesWithConfigurations as $rectorClass => $configurations) {
@ -509,4 +524,9 @@ final class RectorConfigBuilder
$this->rules = \array_merge($this->rules, $levelRules);
return $this;
}
public function registerService(string $className, ?string $alias = null, ?string $tag = null) : self
{
$this->registerServices[] = new RegisteredService($className, $alias, $tag);
return $this;
}
}

View File

@ -1177,6 +1177,7 @@ return array(
'Rector\\Config\\Level\\DeadCodeLevel' => $baseDir . '/src/Config/Level/DeadCodeLevel.php',
'Rector\\Config\\Level\\TypeDeclarationLevel' => $baseDir . '/src/Config/Level/TypeDeclarationLevel.php',
'Rector\\Config\\RectorConfig' => $baseDir . '/src/Config/RectorConfig.php',
'Rector\\Config\\RegisteredService' => $baseDir . '/src/Config/RegisteredService.php',
'Rector\\Configuration\\ConfigInitializer' => $baseDir . '/src/Configuration/ConfigInitializer.php',
'Rector\\Configuration\\ConfigurationFactory' => $baseDir . '/src/Configuration/ConfigurationFactory.php',
'Rector\\Configuration\\Levels\\LevelRulesResolver' => $baseDir . '/src/Configuration/Levels/LevelRulesResolver.php',

View File

@ -1391,6 +1391,7 @@ class ComposerStaticInit2d887a2f87c676eb32b3e04612865e54
'Rector\\Config\\Level\\DeadCodeLevel' => __DIR__ . '/../..' . '/src/Config/Level/DeadCodeLevel.php',
'Rector\\Config\\Level\\TypeDeclarationLevel' => __DIR__ . '/../..' . '/src/Config/Level/TypeDeclarationLevel.php',
'Rector\\Config\\RectorConfig' => __DIR__ . '/../..' . '/src/Config/RectorConfig.php',
'Rector\\Config\\RegisteredService' => __DIR__ . '/../..' . '/src/Config/RegisteredService.php',
'Rector\\Configuration\\ConfigInitializer' => __DIR__ . '/../..' . '/src/Configuration/ConfigInitializer.php',
'Rector\\Configuration\\ConfigurationFactory' => __DIR__ . '/../..' . '/src/Configuration/ConfigurationFactory.php',
'Rector\\Configuration\\Levels\\LevelRulesResolver' => __DIR__ . '/../..' . '/src/Configuration/Levels/LevelRulesResolver.php',

View File

@ -1679,12 +1679,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-doctrine.git",
"reference": "981048a16974f8b38916ba3b4e028c0388543585"
"reference": "9057680e74d0243c60b9f6fb89c1fe448d363505"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/981048a16974f8b38916ba3b4e028c0388543585",
"reference": "981048a16974f8b38916ba3b4e028c0388543585",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/9057680e74d0243c60b9f6fb89c1fe448d363505",
"reference": "9057680e74d0243c60b9f6fb89c1fe448d363505",
"shasum": ""
},
"require": {
@ -1707,7 +1707,7 @@
"tomasvotruba\/unused-public": "^0.3",
"tracy\/tracy": "^2.10"
},
"time": "2024-02-09T11:39:24+00:00",
"time": "2024-02-09T11:41:38+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/rector-build/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => NULL, 'version' => 'dev-main 981048a'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => NULL, 'version' => 'dev-main 8d1aab2'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => NULL, 'version' => 'dev-main f091938'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => NULL, 'version' => 'dev-main 92f8dec'));
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => NULL, 'version' => 'dev-main 9057680'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => NULL, 'version' => 'dev-main 8d1aab2'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => NULL, 'version' => 'dev-main f091938'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => NULL, 'version' => 'dev-main 92f8dec'));
private function __construct()
{
}