From e47a59adcc10ef00e326b1c2856e2c2fd9145803 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sun, 28 Jan 2024 03:50:21 +0000 Subject: [PATCH] Updated Rector to commit b107a16f98aecf2a5ff969e30ff48595daadc06d https://github.com/rectorphp/rector-src/commit/b107a16f98aecf2a5ff969e30ff48595daadc06d [Performance] Reduce repetitive FileSystem::read() on AbstractRectorTestCase (#5511) --- src/Application/VersionResolver.php | 4 ++-- src/Testing/PHPUnit/AbstractRectorTestCase.php | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index bc8dc0081ddd..a285f170b851 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 = '63fbf41cc9a6cc66c720926beec4603892eb21d0'; + public const PACKAGE_VERSION = 'b107a16f98aecf2a5ff969e30ff48595daadc06d'; /** * @api * @var string */ - public const RELEASE_DATE = '2024-01-28 00:52:19'; + public const RELEASE_DATE = '2024-01-28 10:48:07'; /** * @var int */ diff --git a/src/Testing/PHPUnit/AbstractRectorTestCase.php b/src/Testing/PHPUnit/AbstractRectorTestCase.php index a3a042dd9496..5308d28bef34 100644 --- a/src/Testing/PHPUnit/AbstractRectorTestCase.php +++ b/src/Testing/PHPUnit/AbstractRectorTestCase.php @@ -134,7 +134,7 @@ protected function doTestFile(string $fixtureFilePath) : void } // write temp file FileSystem::write($inputFilePath, $inputFileContents); - $this->doTestFileMatchesExpectedContent($inputFilePath, $expectedFileContents, $fixtureFilePath); + $this->doTestFileMatchesExpectedContent($inputFilePath, $inputFileContents, $expectedFileContents, $fixtureFilePath); } protected function forgetRectorsRulesAndCollectors() : void { @@ -169,11 +169,9 @@ private function includePreloadFilesAndScoperAutoload() : void require_once __DIR__ . '/../../../vendor/scoper-autoload.php'; } } - private function doTestFileMatchesExpectedContent(string $originalFilePath, string $expectedFileContents, string $fixtureFilePath) : void + private function doTestFileMatchesExpectedContent(string $originalFilePath, string $inputFileContents, string $expectedFileContents, string $fixtureFilePath) : void { SimpleParameterProvider::setParameter(Option::SOURCE, [$originalFilePath]); - // the original file content must be loaded first - $originalFileContent = FileSystem::read($originalFilePath); // the file is now changed (if any rule matches) $rectorTestResult = $this->processFilePath($originalFilePath); $changedContents = $rectorTestResult->getChangedContents(); @@ -190,7 +188,7 @@ private function doTestFileMatchesExpectedContent(string $originalFilePath, stri try { $this->assertSame($expectedFileContents, $changedContents, $failureMessage); } catch (ExpectationFailedException $exception) { - FixtureFileUpdater::updateFixtureContent($originalFileContent, $changedContents, $fixtureFilePath); + FixtureFileUpdater::updateFixtureContent($inputFileContents, $changedContents, $fixtureFilePath); // if not exact match, check the regex version (useful for generated hashes/uuids in the code) $this->assertStringMatchesFormat($expectedFileContents, $changedContents, $failureMessage); }