Updated Rector to commit d29457125b19aecffb4d05bb703e5df285dff80c

d29457125b simplify changed files cache (#271)
This commit is contained in:
Tomas Votruba 2021-06-22 17:07:57 +00:00
parent d33c0ae997
commit 4b1f72895c
10 changed files with 61 additions and 93 deletions

View File

@ -1,43 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\Caching\Application;
use Rector\Caching\Detector\ChangedFilesDetector;
use Rector\Caching\UnchangedFilesFilter;
use Rector\Core\Configuration\Configuration;
use Symplify\SmartFileSystem\SmartFileInfo;
final class CachedFileInfoFilterAndReporter
{
/**
* @var \Rector\Core\Configuration\Configuration
*/
private $configuration;
/**
* @var \Rector\Caching\Detector\ChangedFilesDetector
*/
private $changedFilesDetector;
/**
* @var \Rector\Caching\UnchangedFilesFilter
*/
private $unchangedFilesFilter;
public function __construct(\Rector\Core\Configuration\Configuration $configuration, \Rector\Caching\Detector\ChangedFilesDetector $changedFilesDetector, \Rector\Caching\UnchangedFilesFilter $unchangedFilesFilter)
{
$this->configuration = $configuration;
$this->changedFilesDetector = $changedFilesDetector;
$this->unchangedFilesFilter = $unchangedFilesFilter;
}
/**
* @param SmartFileInfo[] $phpFileInfos
* @return SmartFileInfo[]
*/
public function filterFileInfos(array $phpFileInfos) : array
{
// cache stuff
if ($this->configuration->shouldClearCache()) {
$this->changedFilesDetector->clear();
return $phpFileInfos;
}
return $this->unchangedFilesFilter->filterAndJoinWithDependentFileInfos($phpFileInfos);
}
}

View File

@ -5,6 +5,7 @@ namespace Rector\NodeTypeResolver\PHPStan\Scope;
use RectorPrefix20210622\Nette\Utils\Strings;
use PhpParser\Node;
use PhpParser\Node\Stmt;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\Interface_;
use PhpParser\Node\Stmt\Trait_;
@ -36,10 +37,6 @@ final class PHPStanNodeScopeResolver
* @see https://regex101.com/r/aXsCkK/1
*/
private const ANONYMOUS_CLASS_START_REGEX = '#^AnonymousClass(\\w+)#';
/**
* @var string[]
*/
private $dependentFiles = [];
/**
* @var \Rector\Caching\Detector\ChangedFilesDetector
*/
@ -89,14 +86,13 @@ final class PHPStanNodeScopeResolver
$this->traitNodeScopeCollector = $traitNodeScopeCollector;
}
/**
* @param Node[] $nodes
* @return Node[]
* @param Stmt[] $nodes
* @return Stmt[]
*/
public function processNodes(array $nodes, \Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo) : array
{
$this->removeDeepChainMethodCallNodes($nodes);
$scope = $this->scopeFactory->createFromFile($smartFileInfo);
$this->dependentFiles = [];
// skip chain method calls, performance issue: https://github.com/phpstan/phpstan/issues/254
$nodeCallback = function (\PhpParser\Node $node, \PHPStan\Analyser\Scope $scope) : void {
// traversing trait inside class that is using it scope (from referenced) - the trait traversed by Rector is different (directly from parsed file)
@ -122,12 +118,9 @@ final class PHPStanNodeScopeResolver
$node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE, $scope);
}
};
foreach ($nodes as $node) {
$this->resolveDependentFiles($node, $scope);
}
/** @var MutatingScope $scope */
$this->nodeScopeResolver->processNodes($nodes, $scope, $nodeCallback);
$this->changedFilesDetector->addFileWithDependencies($smartFileInfo, $this->dependentFiles);
$this->resolveAndSaveDependentFiles($nodes, $scope, $smartFileInfo);
return $nodes;
}
/**
@ -156,17 +149,6 @@ final class PHPStanNodeScopeResolver
/** @var MutatingScope $scope */
return $scope->enterClass($classReflection);
}
private function resolveDependentFiles(\PhpParser\Node $node, \PHPStan\Analyser\MutatingScope $mutatingScope) : void
{
try {
$dependentFiles = $this->dependencyResolver->resolveDependencies($node, $mutatingScope);
foreach ($dependentFiles as $dependentFile) {
$this->dependentFiles[] = $dependentFile;
}
} catch (\PHPStan\AnalysedCodeException $exception) {
// @ignoreException
}
}
/**
* @param \PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\Interface_|\PhpParser\Node\Stmt\Trait_ $classLike
*/
@ -180,4 +162,20 @@ final class PHPStanNodeScopeResolver
}
return $classLike->name->toString();
}
/**
* @param Stmt[] $stmts
*/
private function resolveAndSaveDependentFiles(array $stmts, \PHPStan\Analyser\MutatingScope $mutatingScope, \Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo) : void
{
$dependentFiles = [];
foreach ($stmts as $stmt) {
try {
$nodeDependentFiles = $this->dependencyResolver->resolveDependencies($stmt, $mutatingScope);
$dependentFiles = \array_merge($dependentFiles, $nodeDependentFiles);
} catch (\PHPStan\AnalysedCodeException $exception) {
// @ignoreException
}
}
$this->changedFilesDetector->addFileWithDependencies($smartFileInfo, $dependentFiles);
}
}

View File

@ -16,11 +16,11 @@ final class VersionResolver
/**
* @var string
*/
public const PACKAGE_VERSION = '697c20ec33039ef7f6199c4fcffef4817f54a135';
public const PACKAGE_VERSION = 'd29457125b19aecffb4d05bb703e5df285dff80c';
/**
* @var string
*/
public const RELEASE_DATE = '2021-06-22 18:06:13';
public const RELEASE_DATE = '2021-06-22 16:57:48';
public static function resolvePackageVersion() : string
{
$process = new \RectorPrefix20210622\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);

View File

@ -3,7 +3,7 @@
declare (strict_types=1);
namespace Rector\Core\FileSystem;
use Rector\Caching\Application\CachedFileInfoFilterAndReporter;
use Rector\Caching\UnchangedFilesFilter;
use Rector\Core\Configuration\Configuration;
use Symplify\SmartFileSystem\SmartFileInfo;
final class PhpFilesFinder
@ -17,14 +17,14 @@ final class PhpFilesFinder
*/
private $configuration;
/**
* @var \Rector\Caching\Application\CachedFileInfoFilterAndReporter
* @var \Rector\Caching\UnchangedFilesFilter
*/
private $cachedFileInfoFilterAndReporter;
public function __construct(\Rector\Core\FileSystem\FilesFinder $filesFinder, \Rector\Core\Configuration\Configuration $configuration, \Rector\Caching\Application\CachedFileInfoFilterAndReporter $cachedFileInfoFilterAndReporter)
private $unchangedFilesFilter;
public function __construct(\Rector\Core\FileSystem\FilesFinder $filesFinder, \Rector\Core\Configuration\Configuration $configuration, \Rector\Caching\UnchangedFilesFilter $unchangedFilesFilter)
{
$this->filesFinder = $filesFinder;
$this->configuration = $configuration;
$this->cachedFileInfoFilterAndReporter = $cachedFileInfoFilterAndReporter;
$this->unchangedFilesFilter = $unchangedFilesFilter;
}
/**
* @param string[] $paths
@ -37,6 +37,6 @@ final class PhpFilesFinder
$phpFileInfos = \array_filter($phpFileInfos, function (\Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo) : bool {
return \substr_compare($smartFileInfo->getPathname(), '.blade.php', -\strlen('.blade.php')) !== 0;
});
return $this->cachedFileInfoFilterAndReporter->filterFileInfos($phpFileInfos);
return $this->unchangedFilesFilter->filterAndJoinWithDependentFileInfos($phpFileInfos);
}
}

View File

@ -3,6 +3,8 @@
declare (strict_types=1);
namespace Rector\Core\ValueObjectFactory\Application;
use Rector\Caching\Detector\ChangedFilesDetector;
use Rector\Core\Configuration\Configuration;
use Rector\Core\Contract\Processor\FileProcessorInterface;
use Rector\Core\FileSystem\FilesFinder;
use Rector\Core\ValueObject\Application\File;
@ -15,6 +17,14 @@ final class FileFactory
* @var \Rector\Core\FileSystem\FilesFinder
*/
private $filesFinder;
/**
* @var \Rector\Core\Configuration\Configuration
*/
private $configuration;
/**
* @var \Rector\Caching\Detector\ChangedFilesDetector
*/
private $changedFilesDetector;
/**
* @var mixed[]
*/
@ -22,9 +32,11 @@ final class FileFactory
/**
* @param FileProcessorInterface[] $fileProcessors
*/
public function __construct(\Rector\Core\FileSystem\FilesFinder $filesFinder, array $fileProcessors)
public function __construct(\Rector\Core\FileSystem\FilesFinder $filesFinder, \Rector\Core\Configuration\Configuration $configuration, \Rector\Caching\Detector\ChangedFilesDetector $changedFilesDetector, array $fileProcessors)
{
$this->filesFinder = $filesFinder;
$this->configuration = $configuration;
$this->changedFilesDetector = $changedFilesDetector;
$this->fileProcessors = $fileProcessors;
}
/**
@ -33,6 +45,9 @@ final class FileFactory
*/
public function createFromPaths(array $paths) : array
{
if ($this->configuration->shouldClearCache()) {
$this->changedFilesDetector->clear();
}
$supportedFileExtensions = $this->resolveSupportedFileExtensions();
$fileInfos = $this->filesFinder->findInDirectoriesAndFiles($paths, $supportedFileExtensions);
$files = [];

2
vendor/autoload.php vendored
View File

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit525b2b80e2dc8e7ae04b349eee83fe29::getLoader();
return ComposerAutoloaderInitbbb9b98d0490e23e3f6d2aa5d7819e3f::getLoader();

View File

@ -1560,7 +1560,6 @@ return array(
'Rector\\BetterPhpDocParser\\ValueObject\\Type\\FullyQualifiedIdentifierTypeNode' => $baseDir . '/packages/BetterPhpDocParser/ValueObject/Type/FullyQualifiedIdentifierTypeNode.php',
'Rector\\BetterPhpDocParser\\ValueObject\\Type\\SpacingAwareArrayTypeNode' => $baseDir . '/packages/BetterPhpDocParser/ValueObject/Type/SpacingAwareArrayTypeNode.php',
'Rector\\BetterPhpDocParser\\ValueObject\\Type\\SpacingAwareCallableTypeNode' => $baseDir . '/packages/BetterPhpDocParser/ValueObject/Type/SpacingAwareCallableTypeNode.php',
'Rector\\Caching\\Application\\CachedFileInfoFilterAndReporter' => $baseDir . '/packages/Caching/Application/CachedFileInfoFilterAndReporter.php',
'Rector\\Caching\\Cache' => $baseDir . '/packages/Caching/Cache.php',
'Rector\\Caching\\CacheFactory' => $baseDir . '/packages/Caching/CacheFactory.php',
'Rector\\Caching\\Config\\FileHashComputer' => $baseDir . '/packages/Caching/Config/FileHashComputer.php',

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit525b2b80e2dc8e7ae04b349eee83fe29
class ComposerAutoloaderInitbbb9b98d0490e23e3f6d2aa5d7819e3f
{
private static $loader;
@ -22,15 +22,15 @@ class ComposerAutoloaderInit525b2b80e2dc8e7ae04b349eee83fe29
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit525b2b80e2dc8e7ae04b349eee83fe29', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInitbbb9b98d0490e23e3f6d2aa5d7819e3f', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInit525b2b80e2dc8e7ae04b349eee83fe29', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitbbb9b98d0490e23e3f6d2aa5d7819e3f', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit525b2b80e2dc8e7ae04b349eee83fe29::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInitbbb9b98d0490e23e3f6d2aa5d7819e3f::getInitializer($loader));
} else {
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
@ -42,19 +42,19 @@ class ComposerAutoloaderInit525b2b80e2dc8e7ae04b349eee83fe29
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInit525b2b80e2dc8e7ae04b349eee83fe29::$files;
$includeFiles = Composer\Autoload\ComposerStaticInitbbb9b98d0490e23e3f6d2aa5d7819e3f::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire525b2b80e2dc8e7ae04b349eee83fe29($fileIdentifier, $file);
composerRequirebbb9b98d0490e23e3f6d2aa5d7819e3f($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequire525b2b80e2dc8e7ae04b349eee83fe29($fileIdentifier, $file)
function composerRequirebbb9b98d0490e23e3f6d2aa5d7819e3f($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit525b2b80e2dc8e7ae04b349eee83fe29
class ComposerStaticInitbbb9b98d0490e23e3f6d2aa5d7819e3f
{
public static $files = array (
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
@ -1915,7 +1915,6 @@ class ComposerStaticInit525b2b80e2dc8e7ae04b349eee83fe29
'Rector\\BetterPhpDocParser\\ValueObject\\Type\\FullyQualifiedIdentifierTypeNode' => __DIR__ . '/../..' . '/packages/BetterPhpDocParser/ValueObject/Type/FullyQualifiedIdentifierTypeNode.php',
'Rector\\BetterPhpDocParser\\ValueObject\\Type\\SpacingAwareArrayTypeNode' => __DIR__ . '/../..' . '/packages/BetterPhpDocParser/ValueObject/Type/SpacingAwareArrayTypeNode.php',
'Rector\\BetterPhpDocParser\\ValueObject\\Type\\SpacingAwareCallableTypeNode' => __DIR__ . '/../..' . '/packages/BetterPhpDocParser/ValueObject/Type/SpacingAwareCallableTypeNode.php',
'Rector\\Caching\\Application\\CachedFileInfoFilterAndReporter' => __DIR__ . '/../..' . '/packages/Caching/Application/CachedFileInfoFilterAndReporter.php',
'Rector\\Caching\\Cache' => __DIR__ . '/../..' . '/packages/Caching/Cache.php',
'Rector\\Caching\\CacheFactory' => __DIR__ . '/../..' . '/packages/Caching/CacheFactory.php',
'Rector\\Caching\\Config\\FileHashComputer' => __DIR__ . '/../..' . '/packages/Caching/Config/FileHashComputer.php',
@ -3869,9 +3868,9 @@ class ComposerStaticInit525b2b80e2dc8e7ae04b349eee83fe29
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit525b2b80e2dc8e7ae04b349eee83fe29::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit525b2b80e2dc8e7ae04b349eee83fe29::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit525b2b80e2dc8e7ae04b349eee83fe29::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInitbbb9b98d0490e23e3f6d2aa5d7819e3f::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitbbb9b98d0490e23e3f6d2aa5d7819e3f::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitbbb9b98d0490e23e3f6d2aa5d7819e3f::$classMap;
}, null, ClassLoader::class);
}

View File

@ -21,8 +21,8 @@ if (!class_exists('SomeTestCase', false) && !interface_exists('SomeTestCase', fa
if (!class_exists('CheckoutEntityFactory', false) && !interface_exists('CheckoutEntityFactory', false) && !trait_exists('CheckoutEntityFactory', false)) {
spl_autoload_call('RectorPrefix20210622\CheckoutEntityFactory');
}
if (!class_exists('ComposerAutoloaderInit525b2b80e2dc8e7ae04b349eee83fe29', false) && !interface_exists('ComposerAutoloaderInit525b2b80e2dc8e7ae04b349eee83fe29', false) && !trait_exists('ComposerAutoloaderInit525b2b80e2dc8e7ae04b349eee83fe29', false)) {
spl_autoload_call('RectorPrefix20210622\ComposerAutoloaderInit525b2b80e2dc8e7ae04b349eee83fe29');
if (!class_exists('ComposerAutoloaderInitbbb9b98d0490e23e3f6d2aa5d7819e3f', false) && !interface_exists('ComposerAutoloaderInitbbb9b98d0490e23e3f6d2aa5d7819e3f', false) && !trait_exists('ComposerAutoloaderInitbbb9b98d0490e23e3f6d2aa5d7819e3f', false)) {
spl_autoload_call('RectorPrefix20210622\ComposerAutoloaderInitbbb9b98d0490e23e3f6d2aa5d7819e3f');
}
if (!class_exists('Doctrine\Inflector\Inflector', false) && !interface_exists('Doctrine\Inflector\Inflector', false) && !trait_exists('Doctrine\Inflector\Inflector', false)) {
spl_autoload_call('RectorPrefix20210622\Doctrine\Inflector\Inflector');
@ -3323,9 +3323,9 @@ if (!function_exists('print_node')) {
return \RectorPrefix20210622\print_node(...func_get_args());
}
}
if (!function_exists('composerRequire525b2b80e2dc8e7ae04b349eee83fe29')) {
function composerRequire525b2b80e2dc8e7ae04b349eee83fe29() {
return \RectorPrefix20210622\composerRequire525b2b80e2dc8e7ae04b349eee83fe29(...func_get_args());
if (!function_exists('composerRequirebbb9b98d0490e23e3f6d2aa5d7819e3f')) {
function composerRequirebbb9b98d0490e23e3f6d2aa5d7819e3f() {
return \RectorPrefix20210622\composerRequirebbb9b98d0490e23e3f6d2aa5d7819e3f(...func_get_args());
}
}
if (!function_exists('parseArgs')) {