mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-02 01:10:53 +00:00
Updated Rector to commit b1fff57b7bdd56bff43211412483d6c33880533b
b1fff57b7b
[Core] Make consistent only setAnalysedFiles() from PHPStan NodeScopeResolver in both parallel and non-parallel for .php files (#3221)
This commit is contained in:
parent
d640953d4e
commit
705057ef68
|
@ -6,7 +6,7 @@ namespace Rector\Parallel;
|
|||
use RectorPrefix202212\Clue\React\NDJson\Decoder;
|
||||
use RectorPrefix202212\Clue\React\NDJson\Encoder;
|
||||
use RectorPrefix202212\Nette\Utils\FileSystem;
|
||||
use PHPStan\Analyser\NodeScopeResolver;
|
||||
use Rector\Core\Application\ApplicationFileProcessor;
|
||||
use Rector\Core\Application\FileSystem\RemovedAndAddedFilesProcessor;
|
||||
use Rector\Core\Console\Style\RectorConsoleOutputStyle;
|
||||
use Rector\Core\Contract\Processor\FileProcessorInterface;
|
||||
|
@ -38,11 +38,6 @@ final class WorkerRunner
|
|||
* @var \Rector\Core\Provider\CurrentFileProvider
|
||||
*/
|
||||
private $currentFileProvider;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \PHPStan\Analyser\NodeScopeResolver
|
||||
*/
|
||||
private $nodeScopeResolver;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\StaticReflection\DynamicSourceLocatorDecorator
|
||||
|
@ -58,6 +53,11 @@ final class WorkerRunner
|
|||
* @var \Rector\Core\Application\FileSystem\RemovedAndAddedFilesProcessor
|
||||
*/
|
||||
private $removedAndAddedFilesProcessor;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\Application\ApplicationFileProcessor
|
||||
*/
|
||||
private $applicationFileProcessor;
|
||||
/**
|
||||
* @var FileProcessorInterface[]
|
||||
* @readonly
|
||||
|
@ -66,14 +66,14 @@ final class WorkerRunner
|
|||
/**
|
||||
* @param FileProcessorInterface[] $fileProcessors
|
||||
*/
|
||||
public function __construct(ArrayParametersMerger $arrayParametersMerger, CurrentFileProvider $currentFileProvider, NodeScopeResolver $nodeScopeResolver, DynamicSourceLocatorDecorator $dynamicSourceLocatorDecorator, RectorConsoleOutputStyle $rectorConsoleOutputStyle, RemovedAndAddedFilesProcessor $removedAndAddedFilesProcessor, array $fileProcessors = [])
|
||||
public function __construct(ArrayParametersMerger $arrayParametersMerger, CurrentFileProvider $currentFileProvider, DynamicSourceLocatorDecorator $dynamicSourceLocatorDecorator, RectorConsoleOutputStyle $rectorConsoleOutputStyle, RemovedAndAddedFilesProcessor $removedAndAddedFilesProcessor, ApplicationFileProcessor $applicationFileProcessor, array $fileProcessors = [])
|
||||
{
|
||||
$this->arrayParametersMerger = $arrayParametersMerger;
|
||||
$this->currentFileProvider = $currentFileProvider;
|
||||
$this->nodeScopeResolver = $nodeScopeResolver;
|
||||
$this->dynamicSourceLocatorDecorator = $dynamicSourceLocatorDecorator;
|
||||
$this->rectorConsoleOutputStyle = $rectorConsoleOutputStyle;
|
||||
$this->removedAndAddedFilesProcessor = $removedAndAddedFilesProcessor;
|
||||
$this->applicationFileProcessor = $applicationFileProcessor;
|
||||
$this->fileProcessors = $fileProcessors;
|
||||
}
|
||||
public function run(Encoder $encoder, Decoder $decoder, Configuration $configuration) : void
|
||||
|
@ -98,7 +98,7 @@ final class WorkerRunner
|
|||
$errorAndFileDiffs = [];
|
||||
$systemErrors = [];
|
||||
// 1. allow PHPStan to work with static reflection on provided files
|
||||
$this->nodeScopeResolver->setAnalysedFiles($filePaths);
|
||||
$this->applicationFileProcessor->configurePHPStanNodeScopeResolver($filePaths);
|
||||
foreach ($filePaths as $filePath) {
|
||||
try {
|
||||
$file = new File($filePath, FileSystem::read($filePath));
|
||||
|
|
|
@ -23,7 +23,6 @@ use RectorPrefix202212\Symfony\Component\Filesystem\Filesystem;
|
|||
use RectorPrefix202212\Symplify\EasyParallel\CpuCoreCountProvider;
|
||||
use RectorPrefix202212\Symplify\EasyParallel\Exception\ParallelShouldNotHappenException;
|
||||
use RectorPrefix202212\Symplify\EasyParallel\ScheduleFactory;
|
||||
use RectorPrefix202212\Webmozart\Assert\Assert;
|
||||
final class ApplicationFileProcessor
|
||||
{
|
||||
/**
|
||||
|
@ -129,7 +128,7 @@ final class ApplicationFileProcessor
|
|||
// 1. collect all files from files+dirs provided paths
|
||||
$files = $this->fileFactory->createFromPaths($fileInfos);
|
||||
// 2. PHPStan has to know about all files too
|
||||
$this->configurePHPStanNodeScopeResolver($files);
|
||||
$this->configurePHPStanNodeScopeResolver($fileInfos);
|
||||
$systemErrorsAndFileDiffs = $this->processFiles($files, $configuration);
|
||||
$this->fileDiffFileDecorator->decorate($files);
|
||||
$this->printFiles($files, $configuration);
|
||||
|
@ -168,6 +167,16 @@ final class ApplicationFileProcessor
|
|||
$this->removedAndAddedFilesProcessor->run($configuration);
|
||||
return $systemErrorsAndFileDiffs;
|
||||
}
|
||||
/**
|
||||
* @param string[] $filePaths
|
||||
*/
|
||||
public function configurePHPStanNodeScopeResolver(array $filePaths) : void
|
||||
{
|
||||
$phpFilePaths = \array_filter($filePaths, static function (string $filePath) : bool {
|
||||
return \substr_compare($filePath, '.php', -\strlen('.php')) === 0;
|
||||
});
|
||||
$this->nodeScopeResolver->setAnalysedFiles($phpFilePaths);
|
||||
}
|
||||
/**
|
||||
* @param File[] $files
|
||||
*/
|
||||
|
@ -259,28 +268,4 @@ final class ApplicationFileProcessor
|
|||
}
|
||||
return $potentialEcsBinaryPath;
|
||||
}
|
||||
/**
|
||||
* @param File[] $files
|
||||
*/
|
||||
private function configurePHPStanNodeScopeResolver(array $files) : void
|
||||
{
|
||||
$filePaths = $this->resolvePhpFilePaths($files);
|
||||
$this->nodeScopeResolver->setAnalysedFiles($filePaths);
|
||||
}
|
||||
/**
|
||||
* @param File[] $files
|
||||
* @return string[]
|
||||
*/
|
||||
private function resolvePhpFilePaths(array $files) : array
|
||||
{
|
||||
Assert::allIsAOf($files, File::class);
|
||||
$phpFilePaths = [];
|
||||
foreach ($files as $file) {
|
||||
$filePath = $file->getFilePath();
|
||||
if (\substr_compare($filePath, '.php', -\strlen('.php')) === 0) {
|
||||
$phpFilePaths[] = $filePath;
|
||||
}
|
||||
}
|
||||
return $phpFilePaths;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,12 +17,12 @@ final class VersionResolver
|
|||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'c80cd6f1f03f6f4e1b1aee6504126699e6a06fe3';
|
||||
public const PACKAGE_VERSION = 'b1fff57b7bdd56bff43211412483d6c33880533b';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2022-12-20 22:33:44';
|
||||
public const RELEASE_DATE = '2022-12-21 10:30:05';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
|
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 ComposerAutoloaderInit0a175e31a2ee9764fddefeb139fc1787::getLoader();
|
||||
return ComposerAutoloaderInite6a2fa32a1cc64a3fef0c04459b73d39::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 ComposerAutoloaderInit0a175e31a2ee9764fddefeb139fc1787
|
||||
class ComposerAutoloaderInite6a2fa32a1cc64a3fef0c04459b73d39
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,17 +22,17 @@ class ComposerAutoloaderInit0a175e31a2ee9764fddefeb139fc1787
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit0a175e31a2ee9764fddefeb139fc1787', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInite6a2fa32a1cc64a3fef0c04459b73d39', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit0a175e31a2ee9764fddefeb139fc1787', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInite6a2fa32a1cc64a3fef0c04459b73d39', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit0a175e31a2ee9764fddefeb139fc1787::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInite6a2fa32a1cc64a3fef0c04459b73d39::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit0a175e31a2ee9764fddefeb139fc1787::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInite6a2fa32a1cc64a3fef0c04459b73d39::$files;
|
||||
$requireFile = 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 ComposerStaticInit0a175e31a2ee9764fddefeb139fc1787
|
||||
class ComposerStaticInite6a2fa32a1cc64a3fef0c04459b73d39
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
|
@ -3059,9 +3059,9 @@ class ComposerStaticInit0a175e31a2ee9764fddefeb139fc1787
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit0a175e31a2ee9764fddefeb139fc1787::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit0a175e31a2ee9764fddefeb139fc1787::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit0a175e31a2ee9764fddefeb139fc1787::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInite6a2fa32a1cc64a3fef0c04459b73d39::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInite6a2fa32a1cc64a3fef0c04459b73d39::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInite6a2fa32a1cc64a3fef0c04459b73d39::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user