mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-08 04:10:51 +00:00
Updated Rector to commit 566e171c36
566e171c36
[scoper] unprefix the exception in the code
This commit is contained in:
parent
dd426fc4a1
commit
1e0a943933
|
@ -1,13 +1,14 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Testing\PHPUnit;
|
||||
|
||||
use Iterator;
|
||||
use RectorPrefix20210512\Nette\Utils\Strings;
|
||||
use Nette\Utils\Strings;
|
||||
use PHPStan\Analyser\NodeScopeResolver;
|
||||
use RectorPrefix20210512\PHPUnit\Framework\ExpectationFailedException;
|
||||
use RectorPrefix20210512\Psr\Container\ContainerInterface;
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Rector\Core\Application\ApplicationFileProcessor;
|
||||
use Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector;
|
||||
use Rector\Core\Autoloading\AdditionalAutoloader;
|
||||
|
@ -19,118 +20,156 @@ use Rector\Core\ValueObject\Application\File;
|
|||
use Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocatorProvider\DynamicSourceLocatorProvider;
|
||||
use Rector\Testing\Contract\RectorTestInterface;
|
||||
use Rector\Testing\PHPUnit\Behavior\MovingFilesTrait;
|
||||
use RectorPrefix20210512\Symplify\EasyTesting\DataProvider\StaticFixtureFinder;
|
||||
use RectorPrefix20210512\Symplify\EasyTesting\DataProvider\StaticFixtureUpdater;
|
||||
use RectorPrefix20210512\Symplify\EasyTesting\StaticFixtureSplitter;
|
||||
use RectorPrefix20210512\Symplify\PackageBuilder\Parameter\ParameterProvider;
|
||||
use Symplify\EasyTesting\DataProvider\StaticFixtureFinder;
|
||||
use Symplify\EasyTesting\DataProvider\StaticFixtureUpdater;
|
||||
use Symplify\EasyTesting\StaticFixtureSplitter;
|
||||
use Symplify\PackageBuilder\Parameter\ParameterProvider;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
abstract class AbstractRectorTestCase extends \Rector\Testing\PHPUnit\AbstractTestCase implements \Rector\Testing\Contract\RectorTestInterface
|
||||
|
||||
abstract class AbstractRectorTestCase extends AbstractTestCase implements RectorTestInterface
|
||||
{
|
||||
use MovingFilesTrait;
|
||||
|
||||
/**
|
||||
* @var \Symplify\PackageBuilder\Parameter\ParameterProvider
|
||||
*/
|
||||
protected $parameterProvider;
|
||||
|
||||
/**
|
||||
* @var \Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector
|
||||
*/
|
||||
protected $removedAndAddedFilesCollector;
|
||||
|
||||
/**
|
||||
* @var \Symplify\SmartFileSystem\SmartFileInfo|null
|
||||
*/
|
||||
protected $originalTempFileInfo;
|
||||
|
||||
/**
|
||||
* @var \Psr\Container\ContainerInterface|null
|
||||
*/
|
||||
protected static $allRectorContainer;
|
||||
|
||||
/**
|
||||
* @var \Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocatorProvider\DynamicSourceLocatorProvider
|
||||
*/
|
||||
private $dynamicSourceLocatorProvider;
|
||||
|
||||
/**
|
||||
* @var \Rector\Core\Application\ApplicationFileProcessor
|
||||
*/
|
||||
private $applicationFileProcessor;
|
||||
protected function setUp() : void
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
// speed up
|
||||
@\ini_set('memory_limit', '-1');
|
||||
$configFileInfo = new \Symplify\SmartFileSystem\SmartFileInfo($this->provideConfigFilePath());
|
||||
$rectorConfigsResolver = new \Rector\Core\Bootstrap\RectorConfigsResolver();
|
||||
@ini_set('memory_limit', '-1');
|
||||
|
||||
$configFileInfo = new SmartFileInfo($this->provideConfigFilePath());
|
||||
$rectorConfigsResolver = new RectorConfigsResolver();
|
||||
|
||||
$configFileInfos = $rectorConfigsResolver->resolveFromConfigFileInfo($configFileInfo);
|
||||
$this->bootFromConfigFileInfos($configFileInfos);
|
||||
$this->applicationFileProcessor = $this->getService(\Rector\Core\Application\ApplicationFileProcessor::class);
|
||||
$this->parameterProvider = $this->getService(\RectorPrefix20210512\Symplify\PackageBuilder\Parameter\ParameterProvider::class);
|
||||
$this->dynamicSourceLocatorProvider = $this->getService(\Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocatorProvider\DynamicSourceLocatorProvider::class);
|
||||
$this->removedAndAddedFilesCollector = $this->getService(\Rector\Core\Application\FileSystem\RemovedAndAddedFilesCollector::class);
|
||||
|
||||
$this->applicationFileProcessor = $this->getService(ApplicationFileProcessor::class);
|
||||
$this->parameterProvider = $this->getService(ParameterProvider::class);
|
||||
$this->dynamicSourceLocatorProvider = $this->getService(DynamicSourceLocatorProvider::class);
|
||||
|
||||
$this->removedAndAddedFilesCollector = $this->getService(RemovedAndAddedFilesCollector::class);
|
||||
$this->removedAndAddedFilesCollector->reset();
|
||||
|
||||
/** @var AdditionalAutoloader $additionalAutoloader */
|
||||
$additionalAutoloader = $this->getService(\Rector\Core\Autoloading\AdditionalAutoloader::class);
|
||||
$additionalAutoloader = $this->getService(AdditionalAutoloader::class);
|
||||
$additionalAutoloader->autoloadPaths();
|
||||
|
||||
/** @var BootstrapFilesIncluder $bootstrapFilesIncluder */
|
||||
$bootstrapFilesIncluder = $this->getService(\Rector\Core\Autoloading\BootstrapFilesIncluder::class);
|
||||
$bootstrapFilesIncluder = $this->getService(BootstrapFilesIncluder::class);
|
||||
$bootstrapFilesIncluder->includeBootstrapFiles();
|
||||
|
||||
/** @var Configuration $configuration */
|
||||
$configuration = $this->getService(\Rector\Core\Configuration\Configuration::class);
|
||||
$configuration->setIsDryRun(\true);
|
||||
$configuration = $this->getService(Configuration::class);
|
||||
$configuration->setIsDryRun(true);
|
||||
}
|
||||
public function provideConfigFilePath() : string
|
||||
|
||||
public function provideConfigFilePath(): string
|
||||
{
|
||||
// must be implemented
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Iterator<SmartFileInfo>
|
||||
*/
|
||||
protected function yieldFilesFromDirectory(string $directory, string $suffix = '*.php.inc') : \Iterator
|
||||
protected function yieldFilesFromDirectory(string $directory, string $suffix = '*.php.inc'): Iterator
|
||||
{
|
||||
return \RectorPrefix20210512\Symplify\EasyTesting\DataProvider\StaticFixtureFinder::yieldDirectoryExclusively($directory, $suffix);
|
||||
return StaticFixtureFinder::yieldDirectoryExclusively($directory, $suffix);
|
||||
}
|
||||
protected function doTestFileInfo(\Symplify\SmartFileSystem\SmartFileInfo $fixtureFileInfo) : void
|
||||
|
||||
protected function doTestFileInfo(SmartFileInfo $fixtureFileInfo): void
|
||||
{
|
||||
$inputFileInfoAndExpectedFileInfo = \RectorPrefix20210512\Symplify\EasyTesting\StaticFixtureSplitter::splitFileInfoToLocalInputAndExpectedFileInfos($fixtureFileInfo);
|
||||
$inputFileInfoAndExpectedFileInfo = StaticFixtureSplitter::splitFileInfoToLocalInputAndExpectedFileInfos(
|
||||
$fixtureFileInfo
|
||||
);
|
||||
|
||||
$inputFileInfo = $inputFileInfoAndExpectedFileInfo->getInputFileInfo();
|
||||
$this->originalTempFileInfo = $inputFileInfo;
|
||||
|
||||
$expectedFileInfo = $inputFileInfoAndExpectedFileInfo->getExpectedFileInfo();
|
||||
$this->doTestFileMatchesExpectedContent($inputFileInfo, $expectedFileInfo, $fixtureFileInfo);
|
||||
}
|
||||
protected function getFixtureTempDirectory() : string
|
||||
|
||||
protected function getFixtureTempDirectory(): string
|
||||
{
|
||||
return \sys_get_temp_dir() . '/_temp_fixture_easy_testing';
|
||||
return sys_get_temp_dir() . '/_temp_fixture_easy_testing';
|
||||
}
|
||||
private function doTestFileMatchesExpectedContent(\Symplify\SmartFileSystem\SmartFileInfo $originalFileInfo, \Symplify\SmartFileSystem\SmartFileInfo $expectedFileInfo, \Symplify\SmartFileSystem\SmartFileInfo $fixtureFileInfo) : void
|
||||
{
|
||||
$this->parameterProvider->changeParameter(\Rector\Core\Configuration\Option::SOURCE, [$originalFileInfo->getRealPath()]);
|
||||
|
||||
private function doTestFileMatchesExpectedContent(
|
||||
SmartFileInfo $originalFileInfo,
|
||||
SmartFileInfo $expectedFileInfo,
|
||||
SmartFileInfo $fixtureFileInfo
|
||||
): void {
|
||||
$this->parameterProvider->changeParameter(Option::SOURCE, [$originalFileInfo->getRealPath()]);
|
||||
|
||||
$changedContent = $this->processFileInfo($originalFileInfo);
|
||||
|
||||
// file is removed, we cannot compare it
|
||||
if ($this->removedAndAddedFilesCollector->isFileRemoved($originalFileInfo)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$relativeFilePathFromCwd = $fixtureFileInfo->getRelativeFilePathFromCwd();
|
||||
|
||||
try {
|
||||
$this->assertStringEqualsFile($expectedFileInfo->getRealPath(), $changedContent, $relativeFilePathFromCwd);
|
||||
} catch (\RectorPrefix20210512\PHPUnit\Framework\ExpectationFailedException $expectationFailedException) {
|
||||
\RectorPrefix20210512\Symplify\EasyTesting\DataProvider\StaticFixtureUpdater::updateFixtureContent($originalFileInfo, $changedContent, $fixtureFileInfo);
|
||||
} catch (ExpectationFailedException $expectationFailedException) {
|
||||
StaticFixtureUpdater::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);
|
||||
|
||||
// if not exact match, check the regex version (useful for generated hashes/uuids in the code)
|
||||
$this->assertStringMatchesFormat($contents, $changedContent, $relativeFilePathFromCwd);
|
||||
}
|
||||
}
|
||||
private function normalizeNewlines(string $string) : string
|
||||
|
||||
private function normalizeNewlines(string $string): string
|
||||
{
|
||||
return \RectorPrefix20210512\Nette\Utils\Strings::replace($string, '#\\r\\n|\\r|\\n#', "\n");
|
||||
return Strings::replace($string, '#\r\n|\r|\n#', "\n");
|
||||
}
|
||||
private function processFileInfo(\Symplify\SmartFileSystem\SmartFileInfo $fileInfo) : string
|
||||
|
||||
private function processFileInfo(SmartFileInfo $fileInfo): string
|
||||
{
|
||||
$this->dynamicSourceLocatorProvider->setFileInfo($fileInfo);
|
||||
|
||||
// needed for PHPStan, because the analyzed file is just created in /temp - need for trait and similar deps
|
||||
/** @var NodeScopeResolver $nodeScopeResolver */
|
||||
$nodeScopeResolver = $this->getService(\PHPStan\Analyser\NodeScopeResolver::class);
|
||||
$nodeScopeResolver = $this->getService(NodeScopeResolver::class);
|
||||
$nodeScopeResolver->setAnalysedFiles([$fileInfo->getRealPath()]);
|
||||
$file = new \Rector\Core\ValueObject\Application\File($fileInfo, $fileInfo->getContents());
|
||||
|
||||
$file = new File($fileInfo, $fileInfo->getContents());
|
||||
$this->applicationFileProcessor->run([$file]);
|
||||
|
||||
return $file->getFileContent();
|
||||
}
|
||||
}
|
||||
|
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
|
@ -4,4 +4,4 @@
|
|||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit67691b0e4bf4f132444018fd007dea8e::getLoader();
|
||||
return ComposerAutoloaderInitbb70ce6978c336d451e273a62ba9fa9b::getLoader();
|
||||
|
|
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 ComposerAutoloaderInit67691b0e4bf4f132444018fd007dea8e
|
||||
class ComposerAutoloaderInitbb70ce6978c336d451e273a62ba9fa9b
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,15 +22,15 @@ class ComposerAutoloaderInit67691b0e4bf4f132444018fd007dea8e
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit67691b0e4bf4f132444018fd007dea8e', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInitbb70ce6978c336d451e273a62ba9fa9b', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit67691b0e4bf4f132444018fd007dea8e', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitbb70ce6978c336d451e273a62ba9fa9b', 'loadClassLoader'));
|
||||
|
||||
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
||||
if ($useStaticLoader) {
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit67691b0e4bf4f132444018fd007dea8e::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitbb70ce6978c336d451e273a62ba9fa9b::getInitializer($loader));
|
||||
} else {
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
|
@ -42,19 +42,19 @@ class ComposerAutoloaderInit67691b0e4bf4f132444018fd007dea8e
|
|||
$loader->register(true);
|
||||
|
||||
if ($useStaticLoader) {
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit67691b0e4bf4f132444018fd007dea8e::$files;
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInitbb70ce6978c336d451e273a62ba9fa9b::$files;
|
||||
} else {
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
}
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire67691b0e4bf4f132444018fd007dea8e($fileIdentifier, $file);
|
||||
composerRequirebb70ce6978c336d451e273a62ba9fa9b($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
|
||||
function composerRequire67691b0e4bf4f132444018fd007dea8e($fileIdentifier, $file)
|
||||
function composerRequirebb70ce6978c336d451e273a62ba9fa9b($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
require $file;
|
||||
|
|
8
vendor/composer/autoload_static.php
vendored
8
vendor/composer/autoload_static.php
vendored
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit67691b0e4bf4f132444018fd007dea8e
|
||||
class ComposerStaticInitbb70ce6978c336d451e273a62ba9fa9b
|
||||
{
|
||||
public static $files = array (
|
||||
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
|
||||
|
@ -3481,9 +3481,9 @@ class ComposerStaticInit67691b0e4bf4f132444018fd007dea8e
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit67691b0e4bf4f132444018fd007dea8e::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit67691b0e4bf4f132444018fd007dea8e::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit67691b0e4bf4f132444018fd007dea8e::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitbb70ce6978c336d451e273a62ba9fa9b::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitbb70ce6978c336d451e273a62ba9fa9b::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitbb70ce6978c336d451e273a62ba9fa9b::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
10
vendor/scoper-autoload.php
vendored
10
vendor/scoper-autoload.php
vendored
|
@ -21,8 +21,8 @@ if (!class_exists('SomeTestCase', false) && !interface_exists('SomeTestCase', fa
|
|||
if (!class_exists('CheckoutEntityFactory', false) && !interface_exists('CheckoutEntityFactory', false) && !trait_exists('CheckoutEntityFactory', false)) {
|
||||
spl_autoload_call('RectorPrefix20210512\CheckoutEntityFactory');
|
||||
}
|
||||
if (!class_exists('ComposerAutoloaderInit67691b0e4bf4f132444018fd007dea8e', false) && !interface_exists('ComposerAutoloaderInit67691b0e4bf4f132444018fd007dea8e', false) && !trait_exists('ComposerAutoloaderInit67691b0e4bf4f132444018fd007dea8e', false)) {
|
||||
spl_autoload_call('RectorPrefix20210512\ComposerAutoloaderInit67691b0e4bf4f132444018fd007dea8e');
|
||||
if (!class_exists('ComposerAutoloaderInitbb70ce6978c336d451e273a62ba9fa9b', false) && !interface_exists('ComposerAutoloaderInitbb70ce6978c336d451e273a62ba9fa9b', false) && !trait_exists('ComposerAutoloaderInitbb70ce6978c336d451e273a62ba9fa9b', false)) {
|
||||
spl_autoload_call('RectorPrefix20210512\ComposerAutoloaderInitbb70ce6978c336d451e273a62ba9fa9b');
|
||||
}
|
||||
if (!class_exists('Doctrine\Inflector\Inflector', false) && !interface_exists('Doctrine\Inflector\Inflector', false) && !trait_exists('Doctrine\Inflector\Inflector', false)) {
|
||||
spl_autoload_call('RectorPrefix20210512\Doctrine\Inflector\Inflector');
|
||||
|
@ -98,9 +98,9 @@ if (!function_exists('print_node')) {
|
|||
return \RectorPrefix20210512\print_node(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('composerRequire67691b0e4bf4f132444018fd007dea8e')) {
|
||||
function composerRequire67691b0e4bf4f132444018fd007dea8e() {
|
||||
return \RectorPrefix20210512\composerRequire67691b0e4bf4f132444018fd007dea8e(...func_get_args());
|
||||
if (!function_exists('composerRequirebb70ce6978c336d451e273a62ba9fa9b')) {
|
||||
function composerRequirebb70ce6978c336d451e273a62ba9fa9b() {
|
||||
return \RectorPrefix20210512\composerRequirebb70ce6978c336d451e273a62ba9fa9b(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('parseArgs')) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user