mirror of
https://github.com/rectorphp/rector.git
synced 2025-04-14 04:22:17 +02:00
Updated Rector to commit 099994eb803ebf550ae77bbd5ebcac1263d6571a
099994eb80
[DI] introduce boot() method to avoid hacking beforeResolving() closures (#4937)
This commit is contained in:
parent
fedb3edc8a
commit
df5f31835a
@ -9,11 +9,13 @@ use Rector\Core\Configuration\Option;
|
||||
use Rector\Core\Configuration\Parameter\SimpleParameterProvider;
|
||||
use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
|
||||
use Rector\Core\Contract\Rector\RectorInterface;
|
||||
use Rector\Core\DependencyInjection\Laravel\ContainerMemento;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\FileSystem\FilesystemTweaker;
|
||||
use Rector\Core\NodeAnalyzer\ScopeAnalyzer;
|
||||
use Rector\Core\Rector\AbstractScopeAwareRector;
|
||||
use Rector\Core\ValueObject\PhpVersion;
|
||||
use Rector\Skipper\SkipCriteriaResolver\SkippedClassResolver;
|
||||
use RectorPrefix202309\Webmozart\Assert\Assert;
|
||||
/**
|
||||
* @api
|
||||
@ -273,6 +275,21 @@ final class RectorConfig extends Container
|
||||
{
|
||||
$this->ruleConfigurations = [];
|
||||
}
|
||||
/**
|
||||
* Compiler passes-like method
|
||||
*/
|
||||
public function boot() : void
|
||||
{
|
||||
$skippedClassResolver = new SkippedClassResolver();
|
||||
$skippedElements = $skippedClassResolver->resolve();
|
||||
foreach ($skippedElements as $skippedClass => $path) {
|
||||
if ($path !== null) {
|
||||
continue;
|
||||
}
|
||||
// completely forget the Rector rule only when no path specified
|
||||
ContainerMemento::forgetService($this, $skippedClass);
|
||||
}
|
||||
}
|
||||
private function importFile(string $filePath) : void
|
||||
{
|
||||
Assert::fileExists($filePath);
|
||||
|
@ -38,6 +38,7 @@ abstract class AbstractLazyTestCase extends TestCase
|
||||
$lazyContainerFactory = new LazyContainerFactory();
|
||||
self::$rectorConfig = $lazyContainerFactory->create();
|
||||
}
|
||||
self::$rectorConfig->boot();
|
||||
return self::$rectorConfig;
|
||||
}
|
||||
}
|
||||
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'e4f1f1bab4d008108bf537ba3877dc2c4e64fa25';
|
||||
public const PACKAGE_VERSION = '099994eb803ebf550ae77bbd5ebcac1263d6571a';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-09-08 01:34:31';
|
||||
public const RELEASE_DATE = '2023-09-08 12:16:43';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
@ -59,7 +59,6 @@ use Rector\Core\Console\Style\RectorStyle;
|
||||
use Rector\Core\Console\Style\SymfonyStyleFactory;
|
||||
use Rector\Core\Contract\DependencyInjection\ResetableInterface;
|
||||
use Rector\Core\Contract\Rector\RectorInterface;
|
||||
use Rector\Core\DependencyInjection\Laravel\ContainerMemento;
|
||||
use Rector\Core\Logging\CurrentRectorProvider;
|
||||
use Rector\Core\Logging\RectorOutput;
|
||||
use Rector\Core\NodeDecorator\CreatedByRuleDecorator;
|
||||
@ -161,7 +160,6 @@ use Rector\PHPStanStaticTypeMapper\TypeMapper\VoidTypeMapper;
|
||||
use Rector\PostRector\Application\PostFileProcessor;
|
||||
use Rector\RectorGenerator\Command\GenerateCommand;
|
||||
use Rector\RectorGenerator\Command\InitRecipeCommand;
|
||||
use Rector\Skipper\SkipCriteriaResolver\SkippedClassResolver;
|
||||
use Rector\Skipper\Skipper\Skipper;
|
||||
use Rector\StaticTypeMapper\Contract\PhpDocParser\PhpDocTypeMapperInterface;
|
||||
use Rector\StaticTypeMapper\Contract\PhpParser\PhpParserNodeMapperInterface;
|
||||
@ -384,23 +382,6 @@ final class LazyContainerFactory
|
||||
$this->registerTagged($rectorConfig, self::SCOPE_RESOLVER_NODE_VISITOR_CLASSES, ScopeResolverNodeVisitorInterface::class);
|
||||
$this->createPHPStanServices($rectorConfig);
|
||||
$rectorConfig->when(PhpDocNodeMapper::class)->needs('$phpDocNodeVisitors')->giveTagged(BasePhpDocNodeVisitorInterface::class);
|
||||
/** @param mixed $parameters */
|
||||
$hasForgotten = \false;
|
||||
$rectorConfig->beforeResolving(static function (string $abstract, array $parameters, Container $container) use(&$hasForgotten) : void {
|
||||
// run only once
|
||||
if ($hasForgotten && !\defined('PHPUNIT_COMPOSER_INSTALL')) {
|
||||
return;
|
||||
}
|
||||
$skippedClassResolver = new SkippedClassResolver();
|
||||
$skippedElements = $skippedClassResolver->resolve();
|
||||
foreach ($skippedElements as $skippedClass => $path) {
|
||||
// completely forget the Rector rule only when no path specified
|
||||
if ($path === null) {
|
||||
ContainerMemento::forgetService($container, $skippedClass);
|
||||
}
|
||||
}
|
||||
$hasForgotten = \true;
|
||||
});
|
||||
return $rectorConfig;
|
||||
}
|
||||
/**
|
||||
|
@ -33,6 +33,7 @@ final class RectorContainerFactory
|
||||
foreach ($configFiles as $configFile) {
|
||||
$container->import($configFile);
|
||||
}
|
||||
$container->boot();
|
||||
return $container;
|
||||
}
|
||||
}
|
||||
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInitb269d5fb6e838d9850dc2db99bc595ae::getLoader();
|
||||
return ComposerAutoloaderInitfdc9248fe3af80f7aa4f0074e437d7c1::getLoader();
|
||||
|
10
vendor/composer/autoload_real.php
vendored
10
vendor/composer/autoload_real.php
vendored
@ -2,7 +2,7 @@
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInitb269d5fb6e838d9850dc2db99bc595ae
|
||||
class ComposerAutoloaderInitfdc9248fe3af80f7aa4f0074e437d7c1
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,17 +22,17 @@ class ComposerAutoloaderInitb269d5fb6e838d9850dc2db99bc595ae
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInitb269d5fb6e838d9850dc2db99bc595ae', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInitfdc9248fe3af80f7aa4f0074e437d7c1', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitb269d5fb6e838d9850dc2db99bc595ae', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitfdc9248fe3af80f7aa4f0074e437d7c1', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitb269d5fb6e838d9850dc2db99bc595ae::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitfdc9248fe3af80f7aa4f0074e437d7c1::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInitb269d5fb6e838d9850dc2db99bc595ae::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInitfdc9248fe3af80f7aa4f0074e437d7c1::$files;
|
||||
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
8
vendor/composer/autoload_static.php
vendored
8
vendor/composer/autoload_static.php
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInitb269d5fb6e838d9850dc2db99bc595ae
|
||||
class ComposerStaticInitfdc9248fe3af80f7aa4f0074e437d7c1
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
@ -2603,9 +2603,9 @@ class ComposerStaticInitb269d5fb6e838d9850dc2db99bc595ae
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitb269d5fb6e838d9850dc2db99bc595ae::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitb269d5fb6e838d9850dc2db99bc595ae::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitb269d5fb6e838d9850dc2db99bc595ae::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitfdc9248fe3af80f7aa4f0074e437d7c1::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitfdc9248fe3af80f7aa4f0074e437d7c1::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitfdc9248fe3af80f7aa4f0074e437d7c1::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
14
vendor/composer/installed.json
vendored
14
vendor/composer/installed.json
vendored
@ -858,17 +858,17 @@
|
||||
},
|
||||
{
|
||||
"name": "phpstan\/phpdoc-parser",
|
||||
"version": "1.23.1",
|
||||
"version_normalized": "1.23.1.0",
|
||||
"version": "1.24.0",
|
||||
"version_normalized": "1.24.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/phpstan\/phpdoc-parser.git",
|
||||
"reference": "846ae76eef31c6d7790fac9bc399ecee45160b26"
|
||||
"reference": "3510b0a6274cc42f7219367cb3abfc123ffa09d6"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/phpstan\/phpdoc-parser\/zipball\/846ae76eef31c6d7790fac9bc399ecee45160b26",
|
||||
"reference": "846ae76eef31c6d7790fac9bc399ecee45160b26",
|
||||
"url": "https:\/\/api.github.com\/repos\/phpstan\/phpdoc-parser\/zipball\/3510b0a6274cc42f7219367cb3abfc123ffa09d6",
|
||||
"reference": "3510b0a6274cc42f7219367cb3abfc123ffa09d6",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -885,7 +885,7 @@
|
||||
"phpunit\/phpunit": "^9.5",
|
||||
"symfony\/process": "^5.2"
|
||||
},
|
||||
"time": "2023-08-03T16:32:59+00:00",
|
||||
"time": "2023-09-07T20:46:32+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
@ -902,7 +902,7 @@
|
||||
"description": "PHPDoc parser with support for nullable, intersection and generic types",
|
||||
"support": {
|
||||
"issues": "https:\/\/github.com\/phpstan\/phpdoc-parser\/issues",
|
||||
"source": "https:\/\/github.com\/phpstan\/phpdoc-parser\/tree\/1.23.1"
|
||||
"source": "https:\/\/github.com\/phpstan\/phpdoc-parser\/tree\/1.24.0"
|
||||
},
|
||||
"install-path": "..\/phpstan\/phpdoc-parser"
|
||||
},
|
||||
|
2
vendor/composer/installed.php
vendored
2
vendor/composer/installed.php
vendored
File diff suppressed because one or more lines are too long
@ -487,15 +487,18 @@ class PhpDocParser
|
||||
$tokens->dropSavePoint();
|
||||
// because of ConstFetchNode
|
||||
}
|
||||
$exception = new \PHPStan\PhpDocParser\Parser\ParserException($tokens->currentTokenValue(), $tokens->currentTokenType(), $tokens->currentTokenOffset(), Lexer::TOKEN_IDENTIFIER, null, $tokens->currentTokenLine());
|
||||
$currentTokenValue = $tokens->currentTokenValue();
|
||||
$currentTokenType = $tokens->currentTokenType();
|
||||
$currentTokenOffset = $tokens->currentTokenOffset();
|
||||
$currentTokenLine = $tokens->currentTokenLine();
|
||||
try {
|
||||
$constExpr = $this->doctrineConstantExprParser->parse($tokens, \true);
|
||||
if ($constExpr instanceof Ast\ConstExpr\ConstExprArrayNode) {
|
||||
throw $exception;
|
||||
throw new \PHPStan\PhpDocParser\Parser\ParserException($currentTokenValue, $currentTokenType, $currentTokenOffset, Lexer::TOKEN_IDENTIFIER, null, $currentTokenLine);
|
||||
}
|
||||
return $constExpr;
|
||||
} catch (LogicException $e) {
|
||||
throw $exception;
|
||||
throw new \PHPStan\PhpDocParser\Parser\ParserException($currentTokenValue, $currentTokenType, $currentTokenOffset, Lexer::TOKEN_IDENTIFIER, null, $currentTokenLine);
|
||||
}
|
||||
}
|
||||
private function parseDoctrineArrayItem(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : Doctrine\DoctrineArrayItem
|
||||
@ -782,14 +785,12 @@ class PhpDocParser
|
||||
{
|
||||
if ($tokens->isCurrentTokenType(Lexer::TOKEN_THIS_VARIABLE)) {
|
||||
$parameter = '$this';
|
||||
$requirePropertyOrMethod = \true;
|
||||
$tokens->next();
|
||||
} else {
|
||||
$parameter = $tokens->currentTokenValue();
|
||||
$requirePropertyOrMethod = \false;
|
||||
$tokens->consumeTokenType(Lexer::TOKEN_VARIABLE);
|
||||
}
|
||||
if ($requirePropertyOrMethod || $tokens->isCurrentTokenType(Lexer::TOKEN_ARROW)) {
|
||||
if ($tokens->isCurrentTokenType(Lexer::TOKEN_ARROW)) {
|
||||
$tokens->consumeTokenType(Lexer::TOKEN_ARROW);
|
||||
$propertyOrMethod = $tokens->currentTokenValue();
|
||||
$tokens->consumeTokenType(Lexer::TOKEN_IDENTIFIER);
|
||||
|
@ -153,18 +153,21 @@ class TypeParser
|
||||
$tokens->dropSavePoint();
|
||||
// because of ConstFetchNode
|
||||
}
|
||||
$exception = new \PHPStan\PhpDocParser\Parser\ParserException($tokens->currentTokenValue(), $tokens->currentTokenType(), $tokens->currentTokenOffset(), Lexer::TOKEN_IDENTIFIER, null, $tokens->currentTokenLine());
|
||||
$currentTokenValue = $tokens->currentTokenValue();
|
||||
$currentTokenType = $tokens->currentTokenType();
|
||||
$currentTokenOffset = $tokens->currentTokenOffset();
|
||||
$currentTokenLine = $tokens->currentTokenLine();
|
||||
if ($this->constExprParser === null) {
|
||||
throw $exception;
|
||||
throw new \PHPStan\PhpDocParser\Parser\ParserException($currentTokenValue, $currentTokenType, $currentTokenOffset, Lexer::TOKEN_IDENTIFIER, null, $currentTokenLine);
|
||||
}
|
||||
try {
|
||||
$constExpr = $this->constExprParser->parse($tokens, \true);
|
||||
if ($constExpr instanceof Ast\ConstExpr\ConstExprArrayNode) {
|
||||
throw $exception;
|
||||
throw new \PHPStan\PhpDocParser\Parser\ParserException($currentTokenValue, $currentTokenType, $currentTokenOffset, Lexer::TOKEN_IDENTIFIER, null, $currentTokenLine);
|
||||
}
|
||||
return $this->enrichWithAttributes($tokens, new Ast\Type\ConstTypeNode($constExpr), $startLine, $startIndex);
|
||||
} catch (LogicException $e) {
|
||||
throw $exception;
|
||||
throw new \PHPStan\PhpDocParser\Parser\ParserException($currentTokenValue, $currentTokenType, $currentTokenOffset, Lexer::TOKEN_IDENTIFIER, null, $currentTokenLine);
|
||||
}
|
||||
}
|
||||
/** @phpstan-impure */
|
||||
@ -426,14 +429,17 @@ class TypeParser
|
||||
// because of ConstFetchNode
|
||||
}
|
||||
}
|
||||
$exception = new \PHPStan\PhpDocParser\Parser\ParserException($tokens->currentTokenValue(), $tokens->currentTokenType(), $tokens->currentTokenOffset(), Lexer::TOKEN_IDENTIFIER, null, $tokens->currentTokenLine());
|
||||
$currentTokenValue = $tokens->currentTokenValue();
|
||||
$currentTokenType = $tokens->currentTokenType();
|
||||
$currentTokenOffset = $tokens->currentTokenOffset();
|
||||
$currentTokenLine = $tokens->currentTokenLine();
|
||||
if ($this->constExprParser === null) {
|
||||
throw $exception;
|
||||
throw new \PHPStan\PhpDocParser\Parser\ParserException($currentTokenValue, $currentTokenType, $currentTokenOffset, Lexer::TOKEN_IDENTIFIER, null, $currentTokenLine);
|
||||
}
|
||||
try {
|
||||
$constExpr = $this->constExprParser->parse($tokens, \true);
|
||||
if ($constExpr instanceof Ast\ConstExpr\ConstExprArrayNode) {
|
||||
throw $exception;
|
||||
throw new \PHPStan\PhpDocParser\Parser\ParserException($currentTokenValue, $currentTokenType, $currentTokenOffset, Lexer::TOKEN_IDENTIFIER, null, $currentTokenLine);
|
||||
}
|
||||
$type = new Ast\Type\ConstTypeNode($constExpr);
|
||||
if ($tokens->isCurrentTokenType(Lexer::TOKEN_OPEN_SQUARE_BRACKET)) {
|
||||
@ -441,7 +447,7 @@ class TypeParser
|
||||
}
|
||||
return $type;
|
||||
} catch (LogicException $e) {
|
||||
throw $exception;
|
||||
throw new \PHPStan\PhpDocParser\Parser\ParserException($currentTokenValue, $currentTokenType, $currentTokenOffset, Lexer::TOKEN_IDENTIFIER, null, $currentTokenLine);
|
||||
}
|
||||
}
|
||||
/** @phpstan-impure */
|
||||
|
Loading…
x
Reference in New Issue
Block a user