mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-31 12:42:05 +01:00
Updated Rector to commit bb3ced496fe923594d4af178fdf61328dd731608
bb3ced496f
[DX] Cleanup of text file processor, unused MultipleFilesChangedTrait and misc (#2861)
This commit is contained in:
parent
ab9b0db366
commit
f251f578f6
@ -17,7 +17,6 @@ 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 Rector\Testing\PHPUnit\Behavior\MultipleFilesChangedTrait;
|
||||
use RectorPrefix202208\Symplify\EasyTesting\DataProvider\StaticFixtureFinder;
|
||||
use RectorPrefix202208\Symplify\EasyTesting\DataProvider\StaticFixtureUpdater;
|
||||
use RectorPrefix202208\Symplify\EasyTesting\StaticFixtureSplitter;
|
||||
@ -26,7 +25,6 @@ use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
abstract class AbstractRectorTestCase extends \Rector\Testing\PHPUnit\AbstractTestCase implements RectorTestInterface
|
||||
{
|
||||
use MovingFilesTrait;
|
||||
use MultipleFilesChangedTrait;
|
||||
/**
|
||||
* @var \Symplify\PackageBuilder\Parameter\ParameterProvider
|
||||
*/
|
||||
|
@ -1,87 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Testing\PHPUnit\Behavior;
|
||||
|
||||
use RectorPrefix202208\Nette\Utils\FileSystem;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
trait MultipleFilesChangedTrait
|
||||
{
|
||||
protected function doTestFileInfoWithAdditionalChanges(SmartFileInfo $fixtureFileInfo, bool $allowMatches = \true) : void
|
||||
{
|
||||
$separator = '-----';
|
||||
[$originalContent, $expectedContent, $additionalInfo] = \explode($separator, $fixtureFileInfo->getContents(), 3);
|
||||
$additionalChanges = \explode($separator, $additionalInfo);
|
||||
/** @var array<array{0: ?string, 1: ?string, 2: ?string}> $additionalFileChanges */
|
||||
$additionalFileChanges = \array_chunk($additionalChanges, 3);
|
||||
$expectedFileChanges = $this->prepareAdditionalChangedFiles($additionalFileChanges);
|
||||
$fixturePath = $this->getFixtureTempDirectory() . '/' . $fixtureFileInfo->getFilename();
|
||||
$this->createFixtureDir($fixturePath);
|
||||
$fixtureContent = $originalContent;
|
||||
/** @var string $expectedContent */
|
||||
$trimmedExpectedContent = \trim($expectedContent);
|
||||
if ($trimmedExpectedContent !== '') {
|
||||
$fixtureContent .= $separator . $expectedContent;
|
||||
}
|
||||
FileSystem::write($fixturePath, $fixtureContent);
|
||||
$newFileInfo = new SmartFileInfo($fixturePath);
|
||||
$this->doTestFileInfo($newFileInfo, $allowMatches);
|
||||
$this->checkAdditionalChanges($expectedFileChanges);
|
||||
if (\file_exists($fixturePath)) {
|
||||
FileSystem::delete($fixturePath);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param array<array{0: ?string, 1: ?string, 2: ?string}> $additionalFileChanges
|
||||
* @return array<string, string>
|
||||
*/
|
||||
private function prepareAdditionalChangedFiles(array $additionalFileChanges) : array
|
||||
{
|
||||
$expectedFileChanges = [];
|
||||
foreach ($additionalFileChanges as $additionalFileChange) {
|
||||
$path = isset($additionalFileChange[0]) ? \trim($additionalFileChange[0]) : null;
|
||||
if ($path === null) {
|
||||
throw new ShouldNotHappenException('Path for additional change must be set');
|
||||
}
|
||||
$fullPath = $this->getFixtureTempDirectory() . '/' . $path;
|
||||
$input = isset($additionalFileChange[1]) ? \trim($additionalFileChange[1]) : null;
|
||||
if ($input) {
|
||||
$this->createFixtureDir($fullPath);
|
||||
FileSystem::write($fullPath, $input);
|
||||
}
|
||||
$expectedFileChanges[$fullPath] = isset($additionalFileChange[2]) ? \trim($additionalFileChange[2]) : '';
|
||||
}
|
||||
return $expectedFileChanges;
|
||||
}
|
||||
/**
|
||||
* @param array<string, string> $expectedFileChanges
|
||||
*/
|
||||
private function checkAdditionalChanges(array $expectedFileChanges) : void
|
||||
{
|
||||
$addedFilesWithContent = $this->removedAndAddedFilesCollector->getAddedFilesWithContent();
|
||||
$addedFiles = [];
|
||||
foreach ($addedFilesWithContent as $addedFileWithContent) {
|
||||
[, $addedFilePathWithContentFilePath] = \explode('_temp_fixture_easy_testing', $addedFileWithContent->getFilePath());
|
||||
$addedFiles[$addedFilePathWithContentFilePath] = $addedFileWithContent;
|
||||
}
|
||||
foreach ($expectedFileChanges as $path => $expectedFileChange) {
|
||||
[, $relativePath] = \explode('_temp_fixture_easy_testing', $path);
|
||||
$addedFile = $addedFiles[$relativePath] ?? null;
|
||||
[, $addedFilePathWithContentFilePath] = $addedFile ? \explode('_temp_fixture_easy_testing', $addedFile->getFilePath()) : null;
|
||||
$this->assertSame($relativePath, $addedFilePathWithContentFilePath);
|
||||
$realFileContent = $addedFile ? \trim($addedFile->getFileContent()) : null;
|
||||
$this->assertSame($expectedFileChange, $realFileContent);
|
||||
if (\file_exists($path)) {
|
||||
FileSystem::delete($path);
|
||||
}
|
||||
}
|
||||
}
|
||||
private function createFixtureDir(string $fileName) : void
|
||||
{
|
||||
$dirName = \dirname($fileName);
|
||||
if (!\file_exists($dirName)) {
|
||||
\mkdir($dirName, 0777, \true);
|
||||
}
|
||||
}
|
||||
}
|
@ -17,12 +17,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'cf65fcab69af90371b4a803e6b8cab8eb621c964';
|
||||
public const PACKAGE_VERSION = 'bb3ced496fe923594d4af178fdf61328dd731608';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2022-08-30 09:48:49';
|
||||
public const RELEASE_DATE = '2022-08-30 14:14:36';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
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 ComposerAutoloaderInit287f5651788722dc0fd5a4a8f85dbd80::getLoader();
|
||||
return ComposerAutoloaderInit559da89fc514d48ba131cb908f0738e7::getLoader();
|
||||
|
1
vendor/composer/autoload_classmap.php
vendored
1
vendor/composer/autoload_classmap.php
vendored
@ -2706,7 +2706,6 @@ return array(
|
||||
'Rector\\Testing\\PHPUnit\\AbstractRectorTestCase' => $baseDir . '/packages/Testing/PHPUnit/AbstractRectorTestCase.php',
|
||||
'Rector\\Testing\\PHPUnit\\AbstractTestCase' => $baseDir . '/packages/Testing/PHPUnit/AbstractTestCase.php',
|
||||
'Rector\\Testing\\PHPUnit\\Behavior\\MovingFilesTrait' => $baseDir . '/packages/Testing/PHPUnit/Behavior/MovingFilesTrait.php',
|
||||
'Rector\\Testing\\PHPUnit\\Behavior\\MultipleFilesChangedTrait' => $baseDir . '/packages/Testing/PHPUnit/Behavior/MultipleFilesChangedTrait.php',
|
||||
'Rector\\Testing\\PHPUnit\\StaticPHPUnitEnvironment' => $baseDir . '/packages/Testing/PHPUnit/StaticPHPUnitEnvironment.php',
|
||||
'Rector\\Testing\\TestingParser\\TestingParser' => $baseDir . '/packages/Testing/TestingParser/TestingParser.php',
|
||||
'Rector\\Transform\\Contract\\ValueObject\\ArgumentFuncCallToMethodCallInterface' => $baseDir . '/rules/Transform/Contract/ValueObject/ArgumentFuncCallToMethodCallInterface.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 ComposerAutoloaderInit287f5651788722dc0fd5a4a8f85dbd80
|
||||
class ComposerAutoloaderInit559da89fc514d48ba131cb908f0738e7
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,19 +22,19 @@ class ComposerAutoloaderInit287f5651788722dc0fd5a4a8f85dbd80
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit287f5651788722dc0fd5a4a8f85dbd80', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit559da89fc514d48ba131cb908f0738e7', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit287f5651788722dc0fd5a4a8f85dbd80', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit559da89fc514d48ba131cb908f0738e7', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit287f5651788722dc0fd5a4a8f85dbd80::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit559da89fc514d48ba131cb908f0738e7::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInit287f5651788722dc0fd5a4a8f85dbd80::$files;
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInit559da89fc514d48ba131cb908f0738e7::$files;
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire287f5651788722dc0fd5a4a8f85dbd80($fileIdentifier, $file);
|
||||
composerRequire559da89fc514d48ba131cb908f0738e7($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
@ -46,7 +46,7 @@ class ComposerAutoloaderInit287f5651788722dc0fd5a4a8f85dbd80
|
||||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
function composerRequire287f5651788722dc0fd5a4a8f85dbd80($fileIdentifier, $file)
|
||||
function composerRequire559da89fc514d48ba131cb908f0738e7($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 ComposerStaticInit287f5651788722dc0fd5a4a8f85dbd80
|
||||
class ComposerStaticInit559da89fc514d48ba131cb908f0738e7
|
||||
{
|
||||
public static $files = array (
|
||||
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
|
||||
@ -2991,7 +2991,6 @@ class ComposerStaticInit287f5651788722dc0fd5a4a8f85dbd80
|
||||
'Rector\\Testing\\PHPUnit\\AbstractRectorTestCase' => __DIR__ . '/../..' . '/packages/Testing/PHPUnit/AbstractRectorTestCase.php',
|
||||
'Rector\\Testing\\PHPUnit\\AbstractTestCase' => __DIR__ . '/../..' . '/packages/Testing/PHPUnit/AbstractTestCase.php',
|
||||
'Rector\\Testing\\PHPUnit\\Behavior\\MovingFilesTrait' => __DIR__ . '/../..' . '/packages/Testing/PHPUnit/Behavior/MovingFilesTrait.php',
|
||||
'Rector\\Testing\\PHPUnit\\Behavior\\MultipleFilesChangedTrait' => __DIR__ . '/../..' . '/packages/Testing/PHPUnit/Behavior/MultipleFilesChangedTrait.php',
|
||||
'Rector\\Testing\\PHPUnit\\StaticPHPUnitEnvironment' => __DIR__ . '/../..' . '/packages/Testing/PHPUnit/StaticPHPUnitEnvironment.php',
|
||||
'Rector\\Testing\\TestingParser\\TestingParser' => __DIR__ . '/../..' . '/packages/Testing/TestingParser/TestingParser.php',
|
||||
'Rector\\Transform\\Contract\\ValueObject\\ArgumentFuncCallToMethodCallInterface' => __DIR__ . '/../..' . '/rules/Transform/Contract/ValueObject/ArgumentFuncCallToMethodCallInterface.php',
|
||||
@ -3193,9 +3192,9 @@ class ComposerStaticInit287f5651788722dc0fd5a4a8f85dbd80
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit287f5651788722dc0fd5a4a8f85dbd80::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit287f5651788722dc0fd5a4a8f85dbd80::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit287f5651788722dc0fd5a4a8f85dbd80::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit559da89fc514d48ba131cb908f0738e7::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit559da89fc514d48ba131cb908f0738e7::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit559da89fc514d48ba131cb908f0738e7::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
8
vendor/composer/installed.json
vendored
8
vendor/composer/installed.json
vendored
@ -1995,12 +1995,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-laravel.git",
|
||||
"reference": "10e44210e4e7c9c88964f7e0e5e07b7be995865c"
|
||||
"reference": "23ab8cdb72410ae9b340588131cca02fc5ad263e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-laravel\/zipball\/10e44210e4e7c9c88964f7e0e5e07b7be995865c",
|
||||
"reference": "10e44210e4e7c9c88964f7e0e5e07b7be995865c",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-laravel\/zipball\/23ab8cdb72410ae9b340588131cca02fc5ad263e",
|
||||
"reference": "23ab8cdb72410ae9b340588131cca02fc5ad263e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -2025,7 +2025,7 @@
|
||||
"symplify\/rule-doc-generator": "^11.0",
|
||||
"symplify\/vendor-patches": "^11.0"
|
||||
},
|
||||
"time": "2022-08-30T07:49:00+00:00",
|
||||
"time": "2022-08-30T10:25:09+00:00",
|
||||
"default-branch": true,
|
||||
"type": "rector-extension",
|
||||
"extra": {
|
||||
|
2
vendor/composer/installed.php
vendored
2
vendor/composer/installed.php
vendored
File diff suppressed because one or more lines are too long
@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
|
||||
*/
|
||||
final class GeneratedConfig
|
||||
{
|
||||
public const EXTENSIONS = array('rector/rector-cakephp' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-cakephp', 'relative_install_path' => '../../rector-cakephp', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main c488293'), 'rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 48e7abd'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 7c25144'), 'rector/rector-laravel' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-laravel', 'relative_install_path' => '../../rector-laravel', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 10e4421'), 'rector/rector-phpoffice' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpoffice', 'relative_install_path' => '../../rector-phpoffice', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main f6ba59e'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 3d3da1a'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main de62e7e'));
|
||||
public const EXTENSIONS = array('rector/rector-cakephp' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-cakephp', 'relative_install_path' => '../../rector-cakephp', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main c488293'), 'rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 48e7abd'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 7c25144'), 'rector/rector-laravel' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-laravel', 'relative_install_path' => '../../rector-laravel', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 23ab8cd'), 'rector/rector-phpoffice' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpoffice', 'relative_install_path' => '../../rector-phpoffice', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main f6ba59e'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 3d3da1a'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main de62e7e'));
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Expr\StaticCall;
|
||||
use PhpParser\Node\Identifier;
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use PHPStan\Analyser\Scope;
|
||||
use PHPStan\Reflection\Php\PhpMethodReflection;
|
||||
use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
|
||||
@ -109,6 +110,9 @@ CODE_SAMPLE
|
||||
return null;
|
||||
}
|
||||
$node->args[$position]->value = $this->nodeFactory->createArray([$this->nodeFactory->createClassConstReference($segments[0]), $segments[1]]);
|
||||
if (\is_array($argValue)) {
|
||||
return new MethodCall($node, 'name', [new Arg(new String_($argValue['as']))]);
|
||||
}
|
||||
return $node;
|
||||
}
|
||||
/**
|
||||
@ -134,8 +138,8 @@ CODE_SAMPLE
|
||||
if (!$this->isActionString($action)) {
|
||||
return null;
|
||||
}
|
||||
/** @var string $action */
|
||||
$segments = \explode('@', $action);
|
||||
/** @var string|array<string, string> $action */
|
||||
$segments = \is_string($action) ? \explode('@', $action) : \explode('@', $action['uses']);
|
||||
if (\count($segments) !== 2) {
|
||||
return null;
|
||||
}
|
||||
@ -165,7 +169,12 @@ CODE_SAMPLE
|
||||
private function isActionString($action) : bool
|
||||
{
|
||||
if (!\is_string($action)) {
|
||||
return \false;
|
||||
if (!\is_array($action)) {
|
||||
return \false;
|
||||
}
|
||||
$keys = \array_keys($action);
|
||||
\sort($keys);
|
||||
return $keys === ['as', 'uses'];
|
||||
}
|
||||
return \strpos($action, '@') !== \false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user