From 489106fbd3c63a05b3231a5bbcb61bbf0eec8fcf Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Wed, 9 Aug 2023 13:52:33 +0000 Subject: [PATCH] Updated Rector to commit 7ebdc9fb6004d687f80d346c69ec868206a1a5f0 https://github.com/rectorphp/rector-src/commit/7ebdc9fb6004d687f80d346c69ec868206a1a5f0 [DX] Keep parameter pure file paths (#4738) --- .../Testing/PHPUnit/AbstractRectorTestCase.php | 14 ++++++-------- src/Application/ApplicationFileProcessor.php | 14 +++----------- src/Application/VersionResolver.php | 4 ++-- src/Configuration/ConfigurationFactory.php | 2 +- vendor/autoload.php | 2 +- vendor/composer/autoload_real.php | 10 +++++----- vendor/composer/autoload_static.php | 8 ++++---- 7 files changed, 22 insertions(+), 32 deletions(-) diff --git a/packages/Testing/PHPUnit/AbstractRectorTestCase.php b/packages/Testing/PHPUnit/AbstractRectorTestCase.php index ef7d262f2b7..86f8e574afb 100644 --- a/packages/Testing/PHPUnit/AbstractRectorTestCase.php +++ b/packages/Testing/PHPUnit/AbstractRectorTestCase.php @@ -15,7 +15,6 @@ use Rector\Core\Configuration\ConfigurationFactory; use Rector\Core\Configuration\Option; use Rector\Core\Configuration\Parameter\SimpleParameterProvider; use Rector\Core\Exception\ShouldNotHappenException; -use Rector\Core\ValueObject\Application\File; use Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocatorProvider\DynamicSourceLocatorProvider; use Rector\Testing\Contract\RectorTestInterface; use Rector\Testing\Fixture\FixtureFileFinder; @@ -100,7 +99,7 @@ abstract class AbstractRectorTestCase extends \Rector\Testing\PHPUnit\AbstractTe } // write temp file FileSystem::write($inputFilePath, $inputFileContents); - $this->doTestFileMatchesExpectedContent($inputFilePath, $inputFileContents, $expectedFileContents, $fixtureFilePath); + $this->doTestFileMatchesExpectedContent($inputFilePath, $expectedFileContents, $fixtureFilePath); } private function includePreloadFilesAndScoperAutoload() : void { @@ -116,10 +115,10 @@ abstract class AbstractRectorTestCase extends \Rector\Testing\PHPUnit\AbstractTe require_once __DIR__ . '/../../../vendor/scoper-autoload.php'; } } - private function doTestFileMatchesExpectedContent(string $originalFilePath, string $inputFileContents, string $expectedFileContents, string $fixtureFilePath) : void + private function doTestFileMatchesExpectedContent(string $originalFilePath, string $expectedFileContents, string $fixtureFilePath) : void { SimpleParameterProvider::setParameter(Option::SOURCE, [$originalFilePath]); - $changedContent = $this->processFilePath($originalFilePath, $inputFileContents); + $changedContent = $this->processFilePath($originalFilePath); $fixtureFilename = \basename($fixtureFilePath); $failureMessage = \sprintf('Failed on fixture file "%s"', $fixtureFilename); try { @@ -130,7 +129,7 @@ abstract class AbstractRectorTestCase extends \Rector\Testing\PHPUnit\AbstractTe $this->assertStringMatchesFormat($expectedFileContents, $changedContent, $failureMessage); } } - private function processFilePath(string $filePath, string $inputFileContents) : string + private function processFilePath(string $filePath) : string { $this->dynamicSourceLocatorProvider->setFilePath($filePath); // needed for PHPStan, because the analyzed file is just created in /temp - need for trait and similar deps @@ -140,9 +139,8 @@ abstract class AbstractRectorTestCase extends \Rector\Testing\PHPUnit\AbstractTe /** @var ConfigurationFactory $configurationFactory */ $configurationFactory = $this->getService(ConfigurationFactory::class); $configuration = $configurationFactory->createForTests([$filePath]); - $file = new File($filePath, $inputFileContents); - $this->applicationFileProcessor->processFiles([$file], $configuration); - return $file->getFileContent(); + $this->applicationFileProcessor->processFiles([$filePath], $configuration); + return FileSystem::read($filePath); } private function createInputFilePath(string $fixtureFilePath) : string { diff --git a/src/Application/ApplicationFileProcessor.php b/src/Application/ApplicationFileProcessor.php index 9d5e390943e..afac1831642 100644 --- a/src/Application/ApplicationFileProcessor.php +++ b/src/Application/ApplicationFileProcessor.php @@ -124,7 +124,7 @@ final class ApplicationFileProcessor return $systemErrorsAndFileDiffs; } /** - * @param string[]|File[] $filePaths + * @param string[] $filePaths * @return array{system_errors: SystemError[], file_diffs: FileDiff[], system_errors_count: int} */ public function processFiles(array $filePaths, Configuration $configuration, bool $isParallel = \true) : array @@ -138,9 +138,8 @@ final class ApplicationFileProcessor } $systemErrorsAndFileDiffs = [Bridge::SYSTEM_ERRORS => [], Bridge::FILE_DIFFS => [], Bridge::SYSTEM_ERRORS_COUNT => 0]; foreach ($filePaths as $filePath) { - $file = null; + $file = new File($filePath, UtilsFileSystem::read($filePath)); try { - $file = $filePath instanceof File ? $filePath : new File($filePath, UtilsFileSystem::read($filePath)); $systemErrorsAndFileDiffs = $this->processFile($file, $systemErrorsAndFileDiffs, $configuration); // progress bar +1, // progress bar on parallel handled on runParallel() @@ -148,7 +147,7 @@ final class ApplicationFileProcessor $this->symfonyStyle->progressAdvance(); } } catch (Throwable $throwable) { - $this->invalidateFile($file); + $this->changedFilesDetector->invalidateFile($filePath); if (StaticPHPUnitEnvironment::isPHPUnitRun()) { throw $throwable; } @@ -191,13 +190,6 @@ final class ApplicationFileProcessor $errorMessage .= 'Run Rector with "--debug" option and post the report here: https://github.com/rectorphp/rector/issues/new'; return new SystemError($errorMessage, $filePath, $throwable->getLine()); } - private function invalidateFile(?File $file) : void - { - if (!$file instanceof File) { - return; - } - $this->changedFilesDetector->invalidateFile($file->getFilePath()); - } /** * Inspired by @see https://github.com/phpstan/phpstan-src/blob/89af4e7db257750cdee5d4259ad312941b6b25e8/src/Analyser/Analyser.php#L134 */ diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 656ea420179..d86901151f5 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -19,12 +19,12 @@ final class VersionResolver * @api * @var string */ - public const PACKAGE_VERSION = '31ad417ee444a31ed1ca07c54e9dddac2404fc1b'; + public const PACKAGE_VERSION = '7ebdc9fb6004d687f80d346c69ec868206a1a5f0'; /** * @api * @var string */ - public const RELEASE_DATE = '2023-08-09 13:15:10'; + public const RELEASE_DATE = '2023-08-09 14:47:56'; /** * @var int */ diff --git a/src/Configuration/ConfigurationFactory.php b/src/Configuration/ConfigurationFactory.php index 4dc9a3d4a8d..333fdaa3467 100644 --- a/src/Configuration/ConfigurationFactory.php +++ b/src/Configuration/ConfigurationFactory.php @@ -26,7 +26,7 @@ final class ConfigurationFactory public function createForTests(array $paths) : Configuration { $fileExtensions = SimpleParameterProvider::provideArrayParameter(\Rector\Core\Configuration\Option::FILE_EXTENSIONS); - return new Configuration(\true, \true, \false, ConsoleOutputFormatter::NAME, $fileExtensions, $paths); + return new Configuration(\false, \true, \false, ConsoleOutputFormatter::NAME, $fileExtensions, $paths); } /** * Needs to run in the start of the life cycle, since the rest of workflow uses it. diff --git a/vendor/autoload.php b/vendor/autoload.php index d272ab63f3a..25e89de89be 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) { require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInitf171f725e817867a26e3a828aeeaf5de::getLoader(); +return ComposerAutoloaderInit48fa3674fed5db480614f03086888e52::getLoader(); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index fbfe5ae6478..cc5a65c09e1 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInitf171f725e817867a26e3a828aeeaf5de +class ComposerAutoloaderInit48fa3674fed5db480614f03086888e52 { private static $loader; @@ -22,17 +22,17 @@ class ComposerAutoloaderInitf171f725e817867a26e3a828aeeaf5de return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInitf171f725e817867a26e3a828aeeaf5de', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit48fa3674fed5db480614f03086888e52', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); - spl_autoload_unregister(array('ComposerAutoloaderInitf171f725e817867a26e3a828aeeaf5de', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit48fa3674fed5db480614f03086888e52', 'loadClassLoader')); require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInitf171f725e817867a26e3a828aeeaf5de::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInit48fa3674fed5db480614f03086888e52::getInitializer($loader)); $loader->setClassMapAuthoritative(true); $loader->register(true); - $filesToLoad = \Composer\Autoload\ComposerStaticInitf171f725e817867a26e3a828aeeaf5de::$files; + $filesToLoad = \Composer\Autoload\ComposerStaticInit48fa3674fed5db480614f03086888e52::$files; $requireFile = \Closure::bind(static function ($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index e45cd38d72f..594a68e14b8 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInitf171f725e817867a26e3a828aeeaf5de +class ComposerStaticInit48fa3674fed5db480614f03086888e52 { public static $files = array ( 'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php', @@ -3002,9 +3002,9 @@ class ComposerStaticInitf171f725e817867a26e3a828aeeaf5de public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInitf171f725e817867a26e3a828aeeaf5de::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInitf171f725e817867a26e3a828aeeaf5de::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInitf171f725e817867a26e3a828aeeaf5de::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInit48fa3674fed5db480614f03086888e52::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit48fa3674fed5db480614f03086888e52::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInit48fa3674fed5db480614f03086888e52::$classMap; }, null, ClassLoader::class); }