Skip to content

Commit

Permalink
Updated Rector to commit 4a3627e63426e3c590ec21815621f6684ff41f87
Browse files Browse the repository at this point in the history
rectorphp/rector-src@4a3627e [Performance][Testing] Avoid double call FileSystem::read() on AbstractRectorTestCase (#4908)
  • Loading branch information
TomasVotruba committed Sep 4, 2023
1 parent 491915e commit bdf398e
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 20 deletions.
12 changes: 9 additions & 3 deletions packages/Testing/PHPUnit/AbstractRectorTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Rector\Core\Contract\Rector\RectorInterface;
use Rector\Core\Exception\ShouldNotHappenException;
use Rector\Core\PhpParser\NodeTraverser\RectorNodeTraverser;
use Rector\Core\Provider\CurrentFileProvider;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\Util\Reflection\PrivatesAccessor;
use Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocatorProvider\DynamicSourceLocatorProvider;
Expand All @@ -44,6 +45,10 @@ abstract class AbstractRectorTestCase extends \Rector\Testing\PHPUnit\AbstractLa
* @var array<string, true>
*/
private static $cacheByRuleAndConfig = [];
/**
* @var \Rector\Core\Provider\CurrentFileProvider
*/
private $currentFileProvider;
/**
* Restore default parameters
*/
Expand Down Expand Up @@ -98,6 +103,7 @@ protected function setUp() : void
/** @var BootstrapFilesIncluder $bootstrapFilesIncluder */
$bootstrapFilesIncluder = $this->make(BootstrapFilesIncluder::class);
$bootstrapFilesIncluder->includeBootstrapFiles();
$this->currentFileProvider = $this->make(CurrentFileProvider::class);
}
protected function tearDown() : void
{
Expand Down Expand Up @@ -183,14 +189,14 @@ private function includePreloadFilesAndScoperAutoload() : void
private function doTestFileMatchesExpectedContent(string $originalFilePath, string $expectedFileContents, string $fixtureFilePath) : void
{
SimpleParameterProvider::setParameter(Option::SOURCE, [$originalFilePath]);
$originalContents = FileSystem::read($originalFilePath);
$changedContent = $this->processFilePath($originalFilePath);
$originalFileContent = $this->currentFileProvider->getFile()->getOriginalFileContent();
$fixtureFilename = \basename($fixtureFilePath);
$failureMessage = \sprintf('Failed on fixture file "%s"', $fixtureFilename);
try {
$this->assertSame($expectedFileContents, $changedContent, $failureMessage);
} catch (ExpectationFailedException $exception) {
FixtureFileUpdater::updateFixtureContent($originalContents, $changedContent, $fixtureFilePath);
FixtureFileUpdater::updateFixtureContent($originalFileContent, $changedContent, $fixtureFilePath);
// if not exact match, check the regex version (useful for generated hashes/uuids in the code)
$this->assertStringMatchesFormat($expectedFileContents, $changedContent, $failureMessage);
}
Expand All @@ -206,7 +212,7 @@ private function processFilePath(string $filePath) : string
$configurationFactory = $this->make(ConfigurationFactory::class);
$configuration = $configurationFactory->createForTests([$filePath]);
$this->applicationFileProcessor->processFiles([$filePath], $configuration);
return FileSystem::read($filePath);
return $this->currentFileProvider->getFile()->getFileContent();
}
private function createInputFilePath(string $fixtureFilePath) : string
{
Expand Down
4 changes: 2 additions & 2 deletions src/Application/VersionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '5595f80ed176f93485f50ff6dabad79cedbb72dc';
public const PACKAGE_VERSION = '4a3627e63426e3c590ec21815621f6684ff41f87';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-09-04 20:57:25';
public const RELEASE_DATE = '2023-09-04 22:44:56';
/**
* @var int
*/
Expand Down
2 changes: 1 addition & 1 deletion vendor/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInita4822cf75470888d0b97f29c7b22e1fb::getLoader();
return ComposerAutoloaderInit73427d818a69148d6c15f4795548a71c::getLoader();
10 changes: 5 additions & 5 deletions vendor/composer/autoload_real.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// autoload_real.php @generated by Composer

class ComposerAutoloaderInita4822cf75470888d0b97f29c7b22e1fb
class ComposerAutoloaderInit73427d818a69148d6c15f4795548a71c
{
private static $loader;

Expand All @@ -22,17 +22,17 @@ public static function getLoader()
return self::$loader;
}

spl_autoload_register(array('ComposerAutoloaderInita4822cf75470888d0b97f29c7b22e1fb', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit73427d818a69148d6c15f4795548a71c', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInita4822cf75470888d0b97f29c7b22e1fb', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit73427d818a69148d6c15f4795548a71c', 'loadClassLoader'));

require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInita4822cf75470888d0b97f29c7b22e1fb::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit73427d818a69148d6c15f4795548a71c::getInitializer($loader));

$loader->setClassMapAuthoritative(true);
$loader->register(true);

$filesToLoad = \Composer\Autoload\ComposerStaticInita4822cf75470888d0b97f29c7b22e1fb::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInit73427d818a69148d6c15f4795548a71c::$files;
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
Expand Down
8 changes: 4 additions & 4 deletions vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Composer\Autoload;

class ComposerStaticInita4822cf75470888d0b97f29c7b22e1fb
class ComposerStaticInit73427d818a69148d6c15f4795548a71c
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
Expand Down Expand Up @@ -2611,9 +2611,9 @@ class ComposerStaticInita4822cf75470888d0b97f29c7b22e1fb
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInita4822cf75470888d0b97f29c7b22e1fb::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInita4822cf75470888d0b97f29c7b22e1fb::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInita4822cf75470888d0b97f29c7b22e1fb::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit73427d818a69148d6c15f4795548a71c::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit73427d818a69148d6c15f4795548a71c::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit73427d818a69148d6c15f4795548a71c::$classMap;

}, null, ClassLoader::class);
}
Expand Down
8 changes: 4 additions & 4 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -504,8 +504,8 @@
},
{
"name": "illuminate\/container",
"version": "v10.21.0",
"version_normalized": "10.21.0.0",
"version": "v10.21.1",
"version_normalized": "10.21.1.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/illuminate\/container.git",
Expand Down Expand Up @@ -561,8 +561,8 @@
},
{
"name": "illuminate\/contracts",
"version": "v10.21.0",
"version_normalized": "10.21.0.0",
"version": "v10.21.1",
"version_normalized": "10.21.1.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/illuminate\/contracts.git",
Expand Down
2 changes: 1 addition & 1 deletion vendor/composer/installed.php

Large diffs are not rendered by default.

0 comments on commit bdf398e

Please sign in to comment.