mirror of
https://github.com/rectorphp/rector.git
synced 2024-05-28 23:10:51 +00:00
Updated Rector to commit 8ce5353f6217d9220edab09db656a51a3708dd8d
8ce5353f62
Fix class not found from Easy-Testing package (#2864)
This commit is contained in:
parent
c152c5642c
commit
30a3e6e86b
|
@ -4,9 +4,12 @@ declare (strict_types=1);
|
|||
namespace Rector\Testing\Fixture;
|
||||
|
||||
use Iterator;
|
||||
use RectorPrefix202208\Nette\Utils\Strings;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use RectorPrefix202208\Symfony\Component\Finder\Finder;
|
||||
use RectorPrefix202208\Symfony\Component\Finder\SplFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
use RectorPrefix202208\Symplify\SmartFileSystem\Exception\FileNotFoundException;
|
||||
final class FixtureFileFinder
|
||||
{
|
||||
/**
|
||||
|
@ -30,4 +33,50 @@ final class FixtureFileFinder
|
|||
$fileInfos = \iterator_to_array($finder);
|
||||
return \array_values($fileInfos);
|
||||
}
|
||||
/**
|
||||
* @return Iterator<array<int, SmartFileInfo>>
|
||||
*/
|
||||
public static function yieldDirectoryExclusively(string $directory, string $suffix = '*.php.inc') : Iterator
|
||||
{
|
||||
$fileInfos = self::findFilesInDirectoryExclusively($directory, $suffix);
|
||||
return self::yieldFileInfos($fileInfos);
|
||||
}
|
||||
private static function ensureNoOtherFileName(string $directory, string $suffix) : void
|
||||
{
|
||||
$finder = Finder::create()->in($directory)->files()->notName($suffix);
|
||||
/** @var SplFileInfo[] $fileInfos */
|
||||
$fileInfos = \iterator_to_array($finder->getIterator());
|
||||
$relativeFilePaths = [];
|
||||
foreach ($fileInfos as $fileInfo) {
|
||||
$relativeFilePaths[] = Strings::substring($fileInfo->getRealPath(), \strlen(\getcwd()) + 1);
|
||||
}
|
||||
if ($relativeFilePaths === []) {
|
||||
return;
|
||||
}
|
||||
throw new ShouldNotHappenException(\sprintf('Files "%s" have invalid suffix, use "%s" suffix instead', \implode('", ', $relativeFilePaths), $suffix));
|
||||
}
|
||||
/**
|
||||
* @return SplFileInfo[]
|
||||
*/
|
||||
private static function findFilesInDirectoryExclusively(string $directory, string $suffix) : array
|
||||
{
|
||||
self::ensureNoOtherFileName($directory, $suffix);
|
||||
$finder = Finder::create()->in($directory)->files()->name($suffix);
|
||||
$fileInfos = \iterator_to_array($finder->getIterator());
|
||||
return \array_values($fileInfos);
|
||||
}
|
||||
/**
|
||||
* @param SplFileInfo[] $fileInfos
|
||||
* @return Iterator<array<int, SmartFileInfo>>
|
||||
*/
|
||||
private static function yieldFileInfos(array $fileInfos) : Iterator
|
||||
{
|
||||
foreach ($fileInfos as $fileInfo) {
|
||||
try {
|
||||
$smartFileInfo = new SmartFileInfo($fileInfo->getRealPath());
|
||||
(yield [$smartFileInfo]);
|
||||
} catch (FileNotFoundException $exception) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
50
packages/Testing/Fixture/FixtureFileUpdater.php
Normal file
50
packages/Testing/Fixture/FixtureFileUpdater.php
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Testing\Fixture;
|
||||
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
use RectorPrefix202208\Symplify\SmartFileSystem\SmartFileSystem;
|
||||
/**
|
||||
* @api
|
||||
*/
|
||||
final class FixtureFileUpdater
|
||||
{
|
||||
/**
|
||||
* @param \Symplify\SmartFileSystem\SmartFileInfo|string $originalFileInfo
|
||||
*/
|
||||
public static function updateFixtureContent($originalFileInfo, string $changedContent, SmartFileInfo $fixtureFileInfo) : void
|
||||
{
|
||||
if (!\getenv('UPDATE_TESTS') && !\getenv('UT')) {
|
||||
return;
|
||||
}
|
||||
$newOriginalContent = self::resolveNewFixtureContent($originalFileInfo, $changedContent);
|
||||
self::getSmartFileSystem()->dumpFile($fixtureFileInfo->getRealPath(), $newOriginalContent);
|
||||
}
|
||||
public static function updateExpectedFixtureContent(string $newOriginalContent, SmartFileInfo $expectedFixtureFileInfo) : void
|
||||
{
|
||||
if (!\getenv('UPDATE_TESTS') && !\getenv('UT')) {
|
||||
return;
|
||||
}
|
||||
self::getSmartFileSystem()->dumpFile($expectedFixtureFileInfo->getRealPath(), $newOriginalContent);
|
||||
}
|
||||
private static function getSmartFileSystem() : SmartFileSystem
|
||||
{
|
||||
return new SmartFileSystem();
|
||||
}
|
||||
/**
|
||||
* @param \Symplify\SmartFileSystem\SmartFileInfo|string $originalFileInfo
|
||||
*/
|
||||
private static function resolveNewFixtureContent($originalFileInfo, string $changedContent) : string
|
||||
{
|
||||
if ($originalFileInfo instanceof SmartFileInfo) {
|
||||
$originalContent = $originalFileInfo->getContents();
|
||||
} else {
|
||||
$originalContent = $originalFileInfo;
|
||||
}
|
||||
if ($originalContent === $changedContent) {
|
||||
return $originalContent;
|
||||
}
|
||||
return $originalContent . '-----' . \PHP_EOL . $changedContent;
|
||||
}
|
||||
}
|
|
@ -18,11 +18,11 @@ use Rector\Core\ValueObject\Application\File;
|
|||
use Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocatorProvider\DynamicSourceLocatorProvider;
|
||||
use Rector\Testing\Contract\RectorTestInterface;
|
||||
use Rector\Testing\Fixture\FixtureFileFinder;
|
||||
use Rector\Testing\Fixture\FixtureFileUpdater;
|
||||
use Rector\Testing\Fixture\FixtureSplitter;
|
||||
use Rector\Testing\Fixture\FixtureTempFileDumper;
|
||||
use Rector\Testing\PHPUnit\Behavior\MovingFilesTrait;
|
||||
use SplFileInfo;
|
||||
use RectorPrefix202208\Symplify\EasyTesting\DataProvider\StaticFixtureUpdater;
|
||||
use RectorPrefix202208\Symplify\PackageBuilder\Parameter\ParameterProvider;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
abstract class AbstractRectorTestCase extends \Rector\Testing\PHPUnit\AbstractTestCase implements RectorTestInterface
|
||||
|
@ -149,7 +149,7 @@ abstract class AbstractRectorTestCase extends \Rector\Testing\PHPUnit\AbstractTe
|
|||
if (!$allowMatches) {
|
||||
throw $expectationFailedException;
|
||||
}
|
||||
StaticFixtureUpdater::updateFixtureContent($originalFileInfo, $changedContent, $fixtureFileInfo);
|
||||
FixtureFileUpdater::updateFixtureContent($originalFileInfo, $changedContent, $fixtureFileInfo);
|
||||
$contents = $expectedFileInfo->getContents();
|
||||
// make sure we don't get a diff in which every line is different (because of differences in EOL)
|
||||
$contents = $this->normalizeNewlines($contents);
|
||||
|
|
|
@ -17,12 +17,12 @@ final class VersionResolver
|
|||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '6db4c0e0ae74867ec12b2a4fa7cf934a4a60a742';
|
||||
public const PACKAGE_VERSION = '8ce5353f6217d9220edab09db656a51a3708dd8d';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2022-08-31 09:04:33';
|
||||
public const RELEASE_DATE = '2022-08-31 09:42:12';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
|
|
@ -238,7 +238,7 @@ CODE_SAMPLE;
|
|||
$refactoredNode->setAttribute(AttributeKey::PARENT_NODE, $node->getAttribute(AttributeKey::PARENT_NODE));
|
||||
$this->connectParentNodes($refactoredNode);
|
||||
}
|
||||
/** @var MutatingScope $currentScope */
|
||||
/** @var MutatingScope|null $currentScope */
|
||||
$currentScope = $originalNode->getAttribute(AttributeKey::SCOPE);
|
||||
$this->changedNodeScopeRefresher->refresh($refactoredNode, $currentScope, $this->file->getSmartFileInfo());
|
||||
// is equals node type? return node early
|
||||
|
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
|
@ -9,4 +9,4 @@ if (PHP_VERSION_ID < 50600) {
|
|||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInitc1cc5cd24cd4152a38120c2b0c19c808::getLoader();
|
||||
return ComposerAutoloaderInit610beb6d83e083d71cdc5a8fb8b0f409::getLoader();
|
||||
|
|
1
vendor/composer/autoload_classmap.php
vendored
1
vendor/composer/autoload_classmap.php
vendored
|
@ -2686,6 +2686,7 @@ return array(
|
|||
'Rector\\Symfony\\ValueObject\\ValidatorAssert\\PropertyAndAnnotation' => $vendorDir . '/rector/rector-symfony/src/ValueObject/ValidatorAssert/PropertyAndAnnotation.php',
|
||||
'Rector\\Testing\\Contract\\RectorTestInterface' => $baseDir . '/packages/Testing/Contract/RectorTestInterface.php',
|
||||
'Rector\\Testing\\Fixture\\FixtureFileFinder' => $baseDir . '/packages/Testing/Fixture/FixtureFileFinder.php',
|
||||
'Rector\\Testing\\Fixture\\FixtureFileUpdater' => $baseDir . '/packages/Testing/Fixture/FixtureFileUpdater.php',
|
||||
'Rector\\Testing\\Fixture\\FixtureSplitter' => $baseDir . '/packages/Testing/Fixture/FixtureSplitter.php',
|
||||
'Rector\\Testing\\Fixture\\FixtureTempFileDumper' => $baseDir . '/packages/Testing/Fixture/FixtureTempFileDumper.php',
|
||||
'Rector\\Testing\\PHPUnit\\AbstractRectorTestCase' => $baseDir . '/packages/Testing/PHPUnit/AbstractRectorTestCase.php',
|
||||
|
|
14
vendor/composer/autoload_real.php
vendored
14
vendor/composer/autoload_real.php
vendored
|
@ -2,7 +2,7 @@
|
|||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInitc1cc5cd24cd4152a38120c2b0c19c808
|
||||
class ComposerAutoloaderInit610beb6d83e083d71cdc5a8fb8b0f409
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,19 +22,19 @@ class ComposerAutoloaderInitc1cc5cd24cd4152a38120c2b0c19c808
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInitc1cc5cd24cd4152a38120c2b0c19c808', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit610beb6d83e083d71cdc5a8fb8b0f409', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitc1cc5cd24cd4152a38120c2b0c19c808', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit610beb6d83e083d71cdc5a8fb8b0f409', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitc1cc5cd24cd4152a38120c2b0c19c808::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit610beb6d83e083d71cdc5a8fb8b0f409::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInitc1cc5cd24cd4152a38120c2b0c19c808::$files;
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInit610beb6d83e083d71cdc5a8fb8b0f409::$files;
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequirec1cc5cd24cd4152a38120c2b0c19c808($fileIdentifier, $file);
|
||||
composerRequire610beb6d83e083d71cdc5a8fb8b0f409($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
|
@ -46,7 +46,7 @@ class ComposerAutoloaderInitc1cc5cd24cd4152a38120c2b0c19c808
|
|||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
function composerRequirec1cc5cd24cd4152a38120c2b0c19c808($fileIdentifier, $file)
|
||||
function composerRequire610beb6d83e083d71cdc5a8fb8b0f409($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
|
9
vendor/composer/autoload_static.php
vendored
9
vendor/composer/autoload_static.php
vendored
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInitc1cc5cd24cd4152a38120c2b0c19c808
|
||||
class ComposerStaticInit610beb6d83e083d71cdc5a8fb8b0f409
|
||||
{
|
||||
public static $files = array (
|
||||
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
|
||||
|
@ -2966,6 +2966,7 @@ class ComposerStaticInitc1cc5cd24cd4152a38120c2b0c19c808
|
|||
'Rector\\Symfony\\ValueObject\\ValidatorAssert\\PropertyAndAnnotation' => __DIR__ . '/..' . '/rector/rector-symfony/src/ValueObject/ValidatorAssert/PropertyAndAnnotation.php',
|
||||
'Rector\\Testing\\Contract\\RectorTestInterface' => __DIR__ . '/../..' . '/packages/Testing/Contract/RectorTestInterface.php',
|
||||
'Rector\\Testing\\Fixture\\FixtureFileFinder' => __DIR__ . '/../..' . '/packages/Testing/Fixture/FixtureFileFinder.php',
|
||||
'Rector\\Testing\\Fixture\\FixtureFileUpdater' => __DIR__ . '/../..' . '/packages/Testing/Fixture/FixtureFileUpdater.php',
|
||||
'Rector\\Testing\\Fixture\\FixtureSplitter' => __DIR__ . '/../..' . '/packages/Testing/Fixture/FixtureSplitter.php',
|
||||
'Rector\\Testing\\Fixture\\FixtureTempFileDumper' => __DIR__ . '/../..' . '/packages/Testing/Fixture/FixtureTempFileDumper.php',
|
||||
'Rector\\Testing\\PHPUnit\\AbstractRectorTestCase' => __DIR__ . '/../..' . '/packages/Testing/PHPUnit/AbstractRectorTestCase.php',
|
||||
|
@ -3172,9 +3173,9 @@ class ComposerStaticInitc1cc5cd24cd4152a38120c2b0c19c808
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitc1cc5cd24cd4152a38120c2b0c19c808::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitc1cc5cd24cd4152a38120c2b0c19c808::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitc1cc5cd24cd4152a38120c2b0c19c808::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit610beb6d83e083d71cdc5a8fb8b0f409::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit610beb6d83e083d71cdc5a8fb8b0f409::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit610beb6d83e083d71cdc5a8fb8b0f409::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user