Updated Rector to commit 7ebdc9fb6004d687f80d346c69ec868206a1a5f0

7ebdc9fb60 [DX] Keep parameter pure file paths (#4738)
This commit is contained in:
Tomas Votruba 2023-08-09 13:52:33 +00:00
parent 86016b833d
commit 489106fbd3
7 changed files with 22 additions and 32 deletions

View File

@ -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
{

View File

@ -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
*/

View File

@ -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
*/

View File

@ -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.

2
vendor/autoload.php vendored
View File

@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInitf171f725e817867a26e3a828aeeaf5de::getLoader();
return ComposerAutoloaderInit48fa3674fed5db480614f03086888e52::getLoader();

View File

@ -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;

View File

@ -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);
}