Updated Rector to commit e7caae2a5c

e7caae2a5c Improve BetterNodeFinder::findFirstPrevious() to work without statements (#2136)
This commit is contained in:
Tomas Votruba 2022-04-23 12:56:55 +00:00
parent 28d0d1c997
commit 81086d15be
22 changed files with 91 additions and 71 deletions

View File

@ -137,9 +137,8 @@ final class TypeFactory
$flattenKeyTypes = \PHPStan\Type\TypeUtils::flattenTypes($constantArrayType->getKeyType());
$flattenItemTypes = \PHPStan\Type\TypeUtils::flattenTypes($constantArrayType->getItemType());
foreach ($flattenItemTypes as $position => $nestedFlattenItemType) {
/** @var Type|null $nestedFlattenKeyType */
$nestedFlattenKeyType = $flattenKeyTypes[$position] ?? null;
if ($nestedFlattenKeyType === null) {
if (!$nestedFlattenKeyType instanceof \PHPStan\Type\Type) {
$nestedFlattenKeyType = new \PHPStan\Type\MixedType();
}
$unwrappedTypes[] = new \PHPStan\Type\ArrayType($nestedFlattenKeyType, $nestedFlattenItemType);

View File

@ -119,7 +119,7 @@ CODE_SAMPLE
return \false;
}
return $this->isObjectType($node->expr, new \PHPStan\Type\ObjectType('mysqli'));
});
}, $this->file);
if (!$connectionAssign instanceof \PhpParser\Node\Expr\Assign) {
return null;
}

View File

@ -158,7 +158,7 @@ CODE_SAMPLE
private function printNewNodes(\PhpParser\Node\Stmt\ClassLike $classLike, $mainNode) : void
{
$smartFileInfo = $this->file->getSmartFileInfo();
$this->neighbourClassLikePrinter->printClassLike($classLike, $mainNode, $smartFileInfo);
$this->neighbourClassLikePrinter->printClassLike($classLike, $mainNode, $smartFileInfo, $this->file);
}
/**
* @return ClassLike[]

View File

@ -132,7 +132,7 @@ CODE_SAMPLE
if ($this->isFoundByRefParam($classMethod)) {
return [];
}
$readOnlyVariableAssignScalarVariables = $this->classMethodAssignManipulator->collectReadyOnlyAssignScalarVariables($classMethod);
$readOnlyVariableAssignScalarVariables = $this->classMethodAssignManipulator->collectReadyOnlyAssignScalarVariables($classMethod, $this->file);
$readOnlyVariables = \array_merge($readOnlyVariables, $readOnlyVariableAssignScalarVariables);
}
return $readOnlyVariables;

View File

@ -26,6 +26,7 @@ use Rector\BetterPhpDocParser\ValueObject\NodeTypes;
use Rector\CodingStyle\Naming\ClassNaming;
use Rector\Core\Configuration\Option;
use Rector\Core\PhpParser\Node\BetterNodeFinder;
use Rector\Core\ValueObject\Application\File;
use Rector\NodeNameResolver\NodeNameResolver;
use Rector\NodeRemoval\NodeRemover;
use Rector\NodeTypeResolver\Node\AttributeKey;
@ -106,7 +107,7 @@ final class ClassRenamer
/**
* @param array<string, string> $oldToNewClasses
*/
public function renameNode(\PhpParser\Node $node, array $oldToNewClasses) : ?\PhpParser\Node
public function renameNode(\PhpParser\Node $node, array $oldToNewClasses, ?\Rector\Core\ValueObject\Application\File $file = null) : ?\PhpParser\Node
{
$oldToNewTypes = [];
foreach ($oldToNewClasses as $oldClass => $newClass) {
@ -114,7 +115,7 @@ final class ClassRenamer
}
$this->refactorPhpDoc($node, $oldToNewTypes, $oldToNewClasses);
if ($node instanceof \PhpParser\Node\Name) {
return $this->refactorName($node, $oldToNewClasses);
return $this->refactorName($node, $oldToNewClasses, $file);
}
if ($node instanceof \PhpParser\Node\Stmt\Namespace_) {
return $this->refactorNamespace($node, $oldToNewClasses);
@ -170,7 +171,7 @@ final class ClassRenamer
/**
* @param array<string, string> $oldToNewClasses
*/
private function refactorName(\PhpParser\Node\Name $name, array $oldToNewClasses) : ?\PhpParser\Node\Name
private function refactorName(\PhpParser\Node\Name $name, array $oldToNewClasses, ?\Rector\Core\ValueObject\Application\File $file = null) : ?\PhpParser\Node\Name
{
$stringName = $this->nodeNameResolver->getName($name);
$newName = $oldToNewClasses[$stringName] ?? null;
@ -195,15 +196,15 @@ final class ClassRenamer
$newNameLastName = $newFullyQualified->getLast();
$importNames = $this->parameterProvider->provideBoolParameter(\Rector\Core\Configuration\Option::AUTO_IMPORT_NAMES);
if ($this->shouldRemoveUseName($last, $newNameLastName, $importNames)) {
$this->removeUseName($name);
$this->removeUseName($name, $file);
}
return new \PhpParser\Node\Name\FullyQualified($newName);
}
private function removeUseName(\PhpParser\Node\Name $oldName) : void
private function removeUseName(\PhpParser\Node\Name $oldName, ?\Rector\Core\ValueObject\Application\File $file = null) : void
{
$uses = $this->betterNodeFinder->findFirstPrevious($oldName, function (\PhpParser\Node $node) use($oldName) : bool {
return $node instanceof \PhpParser\Node\Stmt\UseUse && $this->nodeNameResolver->areNamesEqual($node, $oldName);
});
}, $file);
if (!$uses instanceof \PhpParser\Node\Stmt\UseUse) {
return;
}

View File

@ -83,7 +83,7 @@ CODE_SAMPLE
{
$oldToNewClasses = $this->renamedClassesDataCollector->getOldToNewClasses();
if (!$node instanceof \PhpParser\Node\Stmt\Use_) {
return $this->classRenamer->renameNode($node, $oldToNewClasses);
return $this->classRenamer->renameNode($node, $oldToNewClasses, $this->file);
}
if (!$this->parameterProvider->provideBoolParameter(\Rector\Core\Configuration\Option::AUTO_IMPORT_NAMES)) {
return null;

View File

@ -16,11 +16,11 @@ final class VersionResolver
/**
* @var string
*/
public const PACKAGE_VERSION = '6fe4de3eae59b8457d12e3eac3bbd93da12fbef3';
public const PACKAGE_VERSION = 'e7caae2a5ca85ac9d909f4d66bbad361d72c1482';
/**
* @var string
*/
public const RELEASE_DATE = '2022-04-23 13:57:18';
public const RELEASE_DATE = '2022-04-23 14:49:07';
/**
* @var string
*/

View File

@ -23,6 +23,7 @@ use Rector\Core\PhpParser\Comparing\NodeComparator;
use Rector\Core\PhpParser\Node\BetterNodeFinder;
use Rector\Core\PhpParser\Node\NodeFactory;
use Rector\Core\Reflection\ReflectionResolver;
use Rector\Core\ValueObject\Application\File;
use Rector\DeadCode\NodeAnalyzer\ExprUsedInNextNodeAnalyzer;
use Rector\NodeNameResolver\NodeNameResolver;
use Rector\NodeTypeResolver\Node\AttributeKey;
@ -86,7 +87,7 @@ final class ClassMethodAssignManipulator
/**
* @return Assign[]
*/
public function collectReadyOnlyAssignScalarVariables(\PhpParser\Node\Stmt\ClassMethod $classMethod) : array
public function collectReadyOnlyAssignScalarVariables(\PhpParser\Node\Stmt\ClassMethod $classMethod, \Rector\Core\ValueObject\Application\File $file) : array
{
$assignsOfScalarOrArrayToVariable = $this->variableManipulator->collectScalarOrArrayAssignsOfVariable($classMethod);
// filter out [$value] = $array, array destructing
@ -225,7 +226,7 @@ final class ClassMethodAssignManipulator
private function findParentForeach(\PhpParser\Node\Expr\Assign $assign) : ?\PhpParser\Node\Stmt\Foreach_
{
/** @var Foreach_|FunctionLike|null $foundNode */
$foundNode = $this->betterNodeFinder->findFirstPreviousOfTypes($assign, [\PhpParser\Node\Stmt\Foreach_::class, \PhpParser\Node\FunctionLike::class]);
$foundNode = $this->betterNodeFinder->findParentByTypes($assign, [\PhpParser\Node\Stmt\Foreach_::class, \PhpParser\Node\FunctionLike::class]);
if (!$foundNode instanceof \PhpParser\Node\Stmt\Foreach_) {
return null;
}

View File

@ -21,8 +21,10 @@ use PhpParser\Node\Stmt\Namespace_;
use PhpParser\Node\Stmt\Property;
use PhpParser\Node\Stmt\Return_;
use PhpParser\NodeFinder;
use Rector\Core\Exception\ShouldNotHappenException;
use Rector\Core\NodeAnalyzer\ClassAnalyzer;
use Rector\Core\PhpParser\Comparing\NodeComparator;
use Rector\Core\ValueObject\Application\File;
use Rector\NodeNameResolver\NodeNameResolver;
use Rector\NodeTypeResolver\Node\AttributeKey;
use RectorPrefix20220423\Symplify\PackageBuilder\Php\TypeChecker;
@ -294,37 +296,40 @@ final class BetterNodeFinder
/**
* @param callable(Node $node): bool $filter
*/
public function findFirstPrevious(\PhpParser\Node $node, callable $filter) : ?\PhpParser\Node
public function findFirstPrevious(\PhpParser\Node $node, callable $filter, ?\Rector\Core\ValueObject\Application\File $file = null) : ?\PhpParser\Node
{
$node = $node instanceof \PhpParser\Node\Stmt\Expression ? $node : $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::CURRENT_STATEMENT);
if (!$node instanceof \PhpParser\Node) {
$currentStmt = $this->resolveCurrentStatement($node);
if (!$currentStmt instanceof \PhpParser\Node) {
return null;
}
$foundNode = $this->findFirst([$node], $filter);
// we found what we need
if ($foundNode instanceof \PhpParser\Node) {
return $foundNode;
$parentStmtIterator = $currentStmt->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE);
// @todo add root virtual node for namespace-less nodes
if ($parentStmtIterator instanceof \PhpParser\Node) {
// @todo assert iteratble interface that will be added in vendor patch
$parentStmts = $parentStmtIterator->stmts;
} else {
// fallback to parent stmts iterator
if (!$file instanceof \Rector\Core\ValueObject\Application\File) {
$errorMessage = \sprintf('File argument is missing in "%s()" method', __METHOD__);
throw new \Rector\Core\Exception\ShouldNotHappenException($errorMessage);
}
$parentStmts = $file->getNewStmts();
}
// move to previous expression
$previousStatement = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PREVIOUS_STATEMENT);
if ($previousStatement instanceof \PhpParser\Node) {
return $this->findFirstPrevious($previousStatement, $filter);
}
$parent = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE);
if (!$parent instanceof \PhpParser\Node) {
if ($parentStmts === null) {
return null;
}
return $this->findFirstPrevious($parent, $filter);
// @todo we don't need the first one; maybe find first above current node... check for positions...?
return $this->findFirst($parentStmts, $filter);
}
/**
* @template T of Node
* @param array<class-string<T>> $types
*/
public function findFirstPreviousOfTypes(\PhpParser\Node $mainNode, array $types) : ?\PhpParser\Node
public function findFirstPreviousOfTypes(\PhpParser\Node $mainNode, array $types, ?\Rector\Core\ValueObject\Application\File $file = null) : ?\PhpParser\Node
{
return $this->findFirstPrevious($mainNode, function (\PhpParser\Node $node) use($types) : bool {
return $this->typeChecker->isInstanceOf($node, $types);
});
}, $file);
}
/**
* @param callable(Node $node): bool $filter
@ -458,6 +463,22 @@ final class BetterNodeFinder
}
return $foundNode;
}
private function resolveCurrentStatement(\PhpParser\Node $node) : ?\PhpParser\Node\Stmt
{
if ($node instanceof \PhpParser\Node\Stmt) {
return $node;
}
$currentStmt = $node;
while ($currentStmt = $currentStmt->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE)) {
if ($currentStmt instanceof \PhpParser\Node\Stmt) {
return $currentStmt;
}
if (!$currentStmt instanceof \PhpParser\Node) {
return null;
}
}
return null;
}
/**
* @template T of Node
* @param mixed[]|\PhpParser\Node $nodes

2
vendor/autoload.php vendored
View File

@ -9,4 +9,4 @@ if (PHP_VERSION_ID < 50600) {
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInitc5d3c9009b597fbb3ccffd9198c12bc1::getLoader();
return ComposerAutoloaderInit0fd5d180cb4747cb259cba59295f6529::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitc5d3c9009b597fbb3ccffd9198c12bc1
class ComposerAutoloaderInit0fd5d180cb4747cb259cba59295f6529
{
private static $loader;
@ -22,19 +22,19 @@ class ComposerAutoloaderInitc5d3c9009b597fbb3ccffd9198c12bc1
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitc5d3c9009b597fbb3ccffd9198c12bc1', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit0fd5d180cb4747cb259cba59295f6529', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInitc5d3c9009b597fbb3ccffd9198c12bc1', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit0fd5d180cb4747cb259cba59295f6529', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitc5d3c9009b597fbb3ccffd9198c12bc1::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit0fd5d180cb4747cb259cba59295f6529::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$includeFiles = \Composer\Autoload\ComposerStaticInitc5d3c9009b597fbb3ccffd9198c12bc1::$files;
$includeFiles = \Composer\Autoload\ComposerStaticInit0fd5d180cb4747cb259cba59295f6529::$files;
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequirec5d3c9009b597fbb3ccffd9198c12bc1($fileIdentifier, $file);
composerRequire0fd5d180cb4747cb259cba59295f6529($fileIdentifier, $file);
}
return $loader;
@ -46,7 +46,7 @@ class ComposerAutoloaderInitc5d3c9009b597fbb3ccffd9198c12bc1
* @param string $file
* @return void
*/
function composerRequirec5d3c9009b597fbb3ccffd9198c12bc1($fileIdentifier, $file)
function composerRequire0fd5d180cb4747cb259cba59295f6529($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInitc5d3c9009b597fbb3ccffd9198c12bc1
class ComposerStaticInit0fd5d180cb4747cb259cba59295f6529
{
public static $files = array (
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
@ -3867,9 +3867,9 @@ class ComposerStaticInitc5d3c9009b597fbb3ccffd9198c12bc1
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitc5d3c9009b597fbb3ccffd9198c12bc1::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitc5d3c9009b597fbb3ccffd9198c12bc1::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitc5d3c9009b597fbb3ccffd9198c12bc1::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit0fd5d180cb4747cb259cba59295f6529::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit0fd5d180cb4747cb259cba59295f6529::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit0fd5d180cb4747cb259cba59295f6529::$classMap;
}, null, ClassLoader::class);
}

View File

@ -2627,12 +2627,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-symfony.git",
"reference": "7a567c7bb2e338fbb8f238bf5a40decd15a91210"
"reference": "9694784aefad71ab3336fdec06045627aeb25b87"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/7a567c7bb2e338fbb8f238bf5a40decd15a91210",
"reference": "7a567c7bb2e338fbb8f238bf5a40decd15a91210",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/9694784aefad71ab3336fdec06045627aeb25b87",
"reference": "9694784aefad71ab3336fdec06045627aeb25b87",
"shasum": ""
},
"require": {
@ -2650,7 +2650,7 @@
"phpstan\/phpstan-webmozart-assert": "^1.0",
"phpunit\/phpunit": "^9.5",
"rector\/phpstan-rules": "^0.4.4",
"rector\/rector-src": "dev-main#69ba529",
"rector\/rector-src": "dev-main",
"symfony\/security-core": "^5.4",
"symfony\/security-http": "^5.4",
"symplify\/easy-coding-standard": "^10.0",
@ -2660,7 +2660,7 @@
"symplify\/rule-doc-generator": "^10.0",
"symplify\/vendor-patches": "^10.0"
},
"time": "2022-04-23T11:16:23+00:00",
"time": "2022-04-23T12:07:09+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {
@ -2767,12 +2767,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/sabbelasichon\/typo3-rector.git",
"reference": "7b11cdde3478a77e70f1350de64c61d7a4d2fcd4"
"reference": "ca364be41879be5659cda4627d697d6ba756dbc5"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/sabbelasichon\/typo3-rector\/zipball\/7b11cdde3478a77e70f1350de64c61d7a4d2fcd4",
"reference": "7b11cdde3478a77e70f1350de64c61d7a4d2fcd4",
"url": "https:\/\/api.github.com\/repos\/sabbelasichon\/typo3-rector\/zipball\/ca364be41879be5659cda4627d697d6ba756dbc5",
"reference": "ca364be41879be5659cda4627d697d6ba756dbc5",
"shasum": ""
},
"require": {
@ -2802,7 +2802,7 @@
"symplify\/vendor-patches": "^10.1",
"tracy\/tracy": "^2.8"
},
"time": "2022-04-20T15:02:18+00:00",
"time": "2022-04-23T12:20:13+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {

File diff suppressed because one or more lines are too long

View File

@ -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 dc4fbb8'), '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 3f5c267'), 'rector/rector-generator' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-generator', 'relative_install_path' => '../../rector-generator', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 5d945fb'), '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 b794171'), 'rector/rector-nette' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-nette', 'relative_install_path' => '../../rector-nette', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 0b5a94c'), '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 01fa90c'), '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 a9d0d93'), '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 7a567c7'), 'ssch/typo3-rector' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/ssch/typo3-rector', 'relative_install_path' => '../../../ssch/typo3-rector', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 7b11cdd'));
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 dc4fbb8'), '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 3f5c267'), 'rector/rector-generator' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-generator', 'relative_install_path' => '../../rector-generator', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 5d945fb'), '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 b794171'), 'rector/rector-nette' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-nette', 'relative_install_path' => '../../rector-nette', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 0b5a94c'), '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 01fa90c'), '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 a9d0d93'), '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 9694784'), 'ssch/typo3-rector' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/ssch/typo3-rector', 'relative_install_path' => '../../../ssch/typo3-rector', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main ca364be'));
private function __construct()
{
}

View File

@ -11,7 +11,7 @@
"require-dev": {
"phpunit\/phpunit": "^9.5",
"phpstan\/phpstan": "^1.3",
"rector\/rector-src": "dev-main#69ba529",
"rector\/rector-src": "dev-main",
"symplify\/phpstan-rules": "^10.0",
"symfony\/security-core": "^5.4",
"symfony\/security-http": "^5.4",

View File

@ -9,8 +9,8 @@ $loader = require_once __DIR__.'/autoload.php';
if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) {
spl_autoload_call('RectorPrefix20220423\AutoloadIncluder');
}
if (!class_exists('ComposerAutoloaderInitc5d3c9009b597fbb3ccffd9198c12bc1', false) && !interface_exists('ComposerAutoloaderInitc5d3c9009b597fbb3ccffd9198c12bc1', false) && !trait_exists('ComposerAutoloaderInitc5d3c9009b597fbb3ccffd9198c12bc1', false)) {
spl_autoload_call('RectorPrefix20220423\ComposerAutoloaderInitc5d3c9009b597fbb3ccffd9198c12bc1');
if (!class_exists('ComposerAutoloaderInit0fd5d180cb4747cb259cba59295f6529', false) && !interface_exists('ComposerAutoloaderInit0fd5d180cb4747cb259cba59295f6529', false) && !trait_exists('ComposerAutoloaderInit0fd5d180cb4747cb259cba59295f6529', false)) {
spl_autoload_call('RectorPrefix20220423\ComposerAutoloaderInit0fd5d180cb4747cb259cba59295f6529');
}
if (!class_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !interface_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !trait_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false)) {
spl_autoload_call('RectorPrefix20220423\Helmich\TypoScriptParser\Parser\AST\Statement');
@ -59,9 +59,9 @@ if (!function_exists('print_node')) {
return \RectorPrefix20220423\print_node(...func_get_args());
}
}
if (!function_exists('composerRequirec5d3c9009b597fbb3ccffd9198c12bc1')) {
function composerRequirec5d3c9009b597fbb3ccffd9198c12bc1() {
return \RectorPrefix20220423\composerRequirec5d3c9009b597fbb3ccffd9198c12bc1(...func_get_args());
if (!function_exists('composerRequire0fd5d180cb4747cb259cba59295f6529')) {
function composerRequire0fd5d180cb4747cb259cba59295f6529() {
return \RectorPrefix20220423\composerRequire0fd5d180cb4747cb259cba59295f6529(...func_get_args());
}
}
if (!function_exists('scanPath')) {

View File

@ -33,9 +33,7 @@ final class ImportExtbaseAnnotationIfMissingFactory
}
public function addExtbaseAliasAnnotationIfMissing(\PhpParser\Node $node) : void
{
$namespace = $this->betterNodeFinder->findFirstPrevious($node, function (\PhpParser\Node $node) : bool {
return $node instanceof \PhpParser\Node\Stmt\Namespace_;
});
$namespace = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Namespace_::class);
$completeImportForPartialAnnotation = new \Rector\Restoration\ValueObject\CompleteImportForPartialAnnotation('TYPO3\\CMS\\Extbase\\Annotation', 'Extbase');
if ($namespace instanceof \PhpParser\Node\Stmt\Namespace_ && $this->isImportMissing($namespace, $completeImportForPartialAnnotation)) {
$this->useNodesToAddCollector->addUseImport(new \Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType('Extbase', 'TYPO3\\CMS\\Extbase\\Annotation'));

View File

@ -104,7 +104,7 @@ CODE_SAMPLE
if ($node instanceof \PhpParser\Node\Scalar\String_) {
return $this->stringClassNameToClassConstantRectorIfPossible($node);
}
return $this->classRenamer->renameNode($node, $this->oldToNewClasses);
return $this->classRenamer->renameNode($node, $this->oldToNewClasses, $this->file);
}
/**
* @param mixed[] $configuration

View File

@ -200,7 +200,7 @@ CODE_SAMPLE
if ([] !== $additionalConfigItems) {
$this->hasAstBeenChanged = \true;
$config = $this->extractArrayItemByKey($columnItem->value, 'config');
if (null === $config) {
if (!$config instanceof \PhpParser\Node\Expr\ArrayItem) {
$config = new \PhpParser\Node\Expr\ArrayItem(new \PhpParser\Node\Expr\Array_(), new \PhpParser\Node\Scalar\String_('config'));
$columnItem->value->items[] = $config;
}

View File

@ -121,12 +121,12 @@ CODE_SAMPLE
$newDefaultExtras = \implode(':', $newDefaultExtras);
if ('' !== $newDefaultExtras) {
$columnsOverrides = $this->extractSubArrayByKey($typeConfiguration, 'columnsOverrides');
if (null === $columnsOverrides) {
if (!$columnsOverrides instanceof \PhpParser\Node\Expr\Array_) {
$columnsOverrides = new \PhpParser\Node\Expr\Array_([]);
$typeConfiguration->items[] = new \PhpParser\Node\Expr\ArrayItem($columnsOverrides, new \PhpParser\Node\Scalar\String_('columnsOverrides'));
}
$columnOverride = $this->extractSubArrayByKey($columnsOverrides, $fieldName);
if (null === $columnOverride) {
if (!$columnOverride instanceof \PhpParser\Node\Expr\Array_) {
$columnOverride = new \PhpParser\Node\Expr\Array_([]);
$columnsOverrides->items[] = new \PhpParser\Node\Expr\ArrayItem($columnOverride, new \PhpParser\Node\Scalar\String_($fieldName));
}

View File

@ -123,7 +123,7 @@ CODE_SAMPLE
continue;
}
$foreignSelector = null !== $foreignSelectorNode ? $foreignSelectorNode->value : null;
if (null === $overrideChildTcaNode) {
if (!$overrideChildTcaNode instanceof \PhpParser\Node\Expr\Array_) {
$overrideChildTcaNode = new \PhpParser\Node\Expr\Array_();
$columnConfig->items[] = new \PhpParser\Node\Expr\ArrayItem($overrideChildTcaNode, new \PhpParser\Node\Scalar\String_(self::OVERRIDE_CHILD_TCA));
}
@ -176,7 +176,7 @@ CODE_SAMPLE
private function injectOverrideChildTca(\PhpParser\Node\Expr\Array_ $overrideChildTcaNode, string $overrideKey, \PhpParser\Node\Expr\Array_ $overrideValue) : void
{
$newOverrideChildTcaSetting = $this->extractArrayItemByKey($overrideChildTcaNode, $overrideKey);
if (null === $newOverrideChildTcaSetting) {
if (!$newOverrideChildTcaSetting instanceof \PhpParser\Node\Expr\ArrayItem) {
$newOverrideChildTcaSetting = new \PhpParser\Node\Expr\ArrayItem($overrideValue, new \PhpParser\Node\Scalar\String_($overrideKey));
$overrideChildTcaNode->items[] = $newOverrideChildTcaSetting;
} else {