Updated Rector to commit b45066c505a7bd3569819cee71706ebf0f763b6e

b45066c505 [dx] remove direct assigns (#2617)
This commit is contained in:
Tomas Votruba 2022-07-03 12:14:45 +00:00
parent 189f399cf2
commit fbcfb0e30f
23 changed files with 42 additions and 69 deletions

View File

@ -252,8 +252,7 @@ CODE_SAMPLE
} }
$param = new Param(new Variable($argumentName), BuilderHelpers::normalizeValue($defaultValue)); $param = new Param(new Variable($argumentName), BuilderHelpers::normalizeValue($defaultValue));
if ($type !== null) { if ($type !== null) {
$typeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($type, TypeKind::PARAM); $param->type = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($type, TypeKind::PARAM);
$param->type = $typeNode;
} }
$classMethod->params[$position] = $param; $classMethod->params[$position] = $param;
$this->haveArgumentsChanged = \true; $this->haveArgumentsChanged = \true;

View File

@ -112,8 +112,7 @@ final class LocalPropertyAnalyzer
if (!$parentFunctionLike instanceof ClassMethod) { if (!$parentFunctionLike instanceof ClassMethod) {
return null; return null;
} }
$propertyFetchType = $this->resolvePropertyFetchType($node); $fetchedLocalPropertyNameToTypes[$propertyName][] = $this->resolvePropertyFetchType($node);
$fetchedLocalPropertyNameToTypes[$propertyName][] = $propertyFetchType;
return null; return null;
}); });
return $this->normalizeToSingleType($fetchedLocalPropertyNameToTypes); return $this->normalizeToSingleType($fetchedLocalPropertyNameToTypes);

View File

@ -103,8 +103,7 @@ CODE_SAMPLE
if ($expectedArgOrParamOrder === null) { if ($expectedArgOrParamOrder === null) {
return null; return null;
} }
$newParams = $this->argumentSorter->sortArgsByExpectedParamOrder($classMethod->params, $expectedArgOrParamOrder); $classMethod->params = $this->argumentSorter->sortArgsByExpectedParamOrder($classMethod->params, $expectedArgOrParamOrder);
$classMethod->params = $newParams;
return $classMethod; return $classMethod;
} }
private function refactorNew(New_ $new) : ?New_ private function refactorNew(New_ $new) : ?New_

View File

@ -144,8 +144,7 @@ final class ShortNameResolver
if (\strpos($originalName->toString(), '\\') !== \false) { if (\strpos($originalName->toString(), '\\') !== \false) {
return null; return null;
} }
$fullyQualifiedName = $this->nodeNameResolver->getName($node); $shortNamesToFullyQualifiedNames[$originalName->toString()] = $this->nodeNameResolver->getName($node);
$shortNamesToFullyQualifiedNames[$originalName->toString()] = $fullyQualifiedName;
return null; return null;
}); });
$docBlockShortNamesToFullyQualifiedNames = $this->resolveFromStmtsDocBlocks($stmts); $docBlockShortNamesToFullyQualifiedNames = $this->resolveFromStmtsDocBlocks($stmts);

View File

@ -157,8 +157,7 @@ CODE_SAMPLE
if ($propertyType instanceof NullableType) { if ($propertyType instanceof NullableType) {
$propertyType = $propertyType->type; $propertyType = $propertyType->type;
} }
$param = new Param(new Variable($propertyName), null, $propertyType, \false, \false, [], $property->flags); $params[] = new Param(new Variable($propertyName), null, $propertyType, \false, \false, [], $property->flags);
$params[] = $param;
$propertyPhpDocInfo = $requiredPropertyWithPhpDocInfo->getPhpDocInfo(); $propertyPhpDocInfo = $requiredPropertyWithPhpDocInfo->getPhpDocInfo();
// remove required // remove required
$this->phpDocTagRemover->removeByName($propertyPhpDocInfo, 'Doctrine\\Common\\Annotations\\Annotation\\Required'); $this->phpDocTagRemover->removeByName($propertyPhpDocInfo, 'Doctrine\\Common\\Annotations\\Annotation\\Required');

View File

@ -76,8 +76,7 @@ CODE_SAMPLE
if ($livingCode === [$node->expr]) { if ($livingCode === [$node->expr]) {
return null; return null;
} }
$firstExpr = \array_shift($livingCode); $node->expr = \array_shift($livingCode);
$node->expr = $firstExpr;
$newNodes = []; $newNodes = [];
foreach ($livingCode as $singleLivingCode) { foreach ($livingCode as $singleLivingCode) {
$newNodes[] = new Expression($singleLivingCode); $newNodes[] = new Expression($singleLivingCode);

View File

@ -129,8 +129,7 @@ CODE_SAMPLE
$afterStmts = []; $afterStmts = [];
if (!$nextStmt instanceof Return_) { if (!$nextStmt instanceof Return_) {
$afterStmts[] = $stmt->stmts[0]; $afterStmts[] = $stmt->stmts[0];
$newStmts = \array_merge($newStmts, $this->processReplaceIfs($stmt, $booleanAndConditions, new Return_(), $afterStmts)); $node->stmts = \array_merge($newStmts, $this->processReplaceIfs($stmt, $booleanAndConditions, new Return_(), $afterStmts));
$node->stmts = $newStmts;
return $node; return $node;
} }
// remove next node // remove next node
@ -141,9 +140,8 @@ CODE_SAMPLE
$afterStmts[] = new Return_(); $afterStmts[] = new Return_();
} }
$changedStmts = $this->processReplaceIfs($stmt, $booleanAndConditions, $ifNextReturnClone, $afterStmts); $changedStmts = $this->processReplaceIfs($stmt, $booleanAndConditions, $ifNextReturnClone, $afterStmts);
$changedStmts = \array_merge($newStmts, $changedStmts);
// update stmts // update stmts
$node->stmts = $changedStmts; $node->stmts = \array_merge($newStmts, $changedStmts);
return $node; return $node;
} }
return null; return null;

View File

@ -51,8 +51,7 @@ final class ClosureNestedUsesDecorator
$parentOfParent = $this->betterNodeFinder->findParentType($parentOfParent, Closure::class); $parentOfParent = $this->betterNodeFinder->findParentType($parentOfParent, Closure::class);
} }
$uses = \array_merge($parent->uses, $uses); $uses = \array_merge($parent->uses, $uses);
$uses = $this->cleanClosureUses($uses); $parent->uses = $this->cleanClosureUses($uses);
$parent->uses = $uses;
$parent = $this->betterNodeFinder->findParentType($parent, Closure::class); $parent = $this->betterNodeFinder->findParentType($parent, Closure::class);
} }
return $anonymousFunctionNode; return $anonymousFunctionNode;

View File

@ -145,8 +145,7 @@ CODE_SAMPLE
$paramTagValueNode->setAttribute(PhpDocAttributeKey::ORIG_NODE, null); $paramTagValueNode->setAttribute(PhpDocAttributeKey::ORIG_NODE, null);
} }
// property name has higher priority // property name has higher priority
$propertyName = $this->getName($property); $param->var->name = $this->getName($property);
$param->var->name = $propertyName;
$param->flags = $property->flags; $param->flags = $property->flags;
// Copy over attributes of the "old" property // Copy over attributes of the "old" property
$param->attrGroups = $property->attrGroups; $param->attrGroups = $property->attrGroups;

View File

@ -70,8 +70,7 @@ final class PropertyFetchByMethodAnalyzer
if (!$this->isPropertyChanging($classMethod, $propertyName)) { if (!$this->isPropertyChanging($classMethod, $propertyName)) {
continue; continue;
} }
$classMethodName = $this->nodeNameResolver->getName($classMethod); $propertyUsageByMethods[$propertyName][] = $this->nodeNameResolver->getName($classMethod);
$propertyUsageByMethods[$propertyName][] = $classMethodName;
} }
} }
return $propertyUsageByMethods; return $propertyUsageByMethods;

View File

@ -127,8 +127,7 @@ CODE_SAMPLE
} }
private function addAllowDynamicPropertiesAttribute(Class_ $class) : Class_ private function addAllowDynamicPropertiesAttribute(Class_ $class) : Class_
{ {
$attributeGroup = $this->phpAttributeGroupFactory->createFromClass(self::ATTRIBUTE); $class->attrGroups[] = $this->phpAttributeGroupFactory->createFromClass(self::ATTRIBUTE);
$class->attrGroups[] = $attributeGroup;
return $class; return $class;
} }
private function shouldSkip(Class_ $class) : bool private function shouldSkip(Class_ $class) : bool

View File

@ -48,8 +48,7 @@ final class CallTypesResolver
if (!$arg instanceof Arg) { if (!$arg instanceof Arg) {
continue; continue;
} }
$argValueType = $this->resolveStrictArgValueType($arg); $staticTypesByArgumentPosition[$position][] = $this->resolveStrictArgValueType($arg);
$staticTypesByArgumentPosition[$position][] = $argValueType;
} }
} }
// unite to single type // unite to single type
@ -78,8 +77,7 @@ final class CallTypesResolver
foreach ($staticTypesByArgumentPosition as $position => $staticTypes) { foreach ($staticTypesByArgumentPosition as $position => $staticTypes) {
$unionedType = $this->typeFactory->createMixedPassedOrUnionType($staticTypes); $unionedType = $this->typeFactory->createMixedPassedOrUnionType($staticTypes);
// narrow parents to most child type // narrow parents to most child type
$unionedType = $this->narrowParentObjectTreeToSingleObjectChildType($unionedType); $staticTypeByArgumentPosition[$position] = $this->narrowParentObjectTreeToSingleObjectChildType($unionedType);
$staticTypeByArgumentPosition[$position] = $unionedType;
} }
if (\count($staticTypeByArgumentPosition) !== 1) { if (\count($staticTypeByArgumentPosition) !== 1) {
return $staticTypeByArgumentPosition; return $staticTypeByArgumentPosition;

View File

@ -128,8 +128,7 @@ CODE_SAMPLE
if ($this->shouldSkipType($classMethod, $newType)) { if ($this->shouldSkipType($classMethod, $newType)) {
return; return;
} }
$returnTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($newType, TypeKind::RETURN); $classMethod->returnType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($newType, TypeKind::RETURN);
$classMethod->returnType = $returnTypeNode;
$this->hasChanged = \true; $this->hasChanged = \true;
} }
private function shouldSkipType(ClassMethod $classMethod, Type $newType) : bool private function shouldSkipType(ClassMethod $classMethod, Type $newType) : bool

View File

@ -110,8 +110,7 @@ CODE_SAMPLE
$newTypes[] = $this->createObjectTypeFromNew($new); $newTypes[] = $this->createObjectTypeFromNew($new);
} }
$returnType = $this->typeFactory->createMixedPassedOrUnionType($newTypes); $returnType = $this->typeFactory->createMixedPassedOrUnionType($newTypes);
$returnTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($returnType, TypeKind::RETURN); $node->returnType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($returnType, TypeKind::RETURN);
$node->returnType = $returnTypeNode;
return $node; return $node;
} }
public function provideMinPhpVersion() : int public function provideMinPhpVersion() : int

View File

@ -136,8 +136,7 @@ CODE_SAMPLE
if ($this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::UNION_TYPES)) { if ($this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::UNION_TYPES)) {
/** @var PhpParserUnionType[] $returnedStrictTypes */ /** @var PhpParserUnionType[] $returnedStrictTypes */
$unwrappedTypes = $this->typeNodeUnwrapper->unwrapNullableUnionTypes($returnedStrictTypes); $unwrappedTypes = $this->typeNodeUnwrapper->unwrapNullableUnionTypes($returnedStrictTypes);
$returnType = new PhpParserUnionType($unwrappedTypes); $node->returnType = new PhpParserUnionType($unwrappedTypes);
$node->returnType = $returnType;
return $node; return $node;
} }
return null; return null;

View File

@ -17,12 +17,12 @@ final class VersionResolver
* @api * @api
* @var string * @var string
*/ */
public const PACKAGE_VERSION = '0660b21ecec553393226003c16432a626e20f8ec'; public const PACKAGE_VERSION = 'b45066c505a7bd3569819cee71706ebf0f763b6e';
/** /**
* @api * @api
* @var string * @var string
*/ */
public const RELEASE_DATE = '2022-07-03 13:35:02'; public const RELEASE_DATE = '2022-07-03 14:09:32';
/** /**
* @var int * @var int
*/ */

2
vendor/autoload.php vendored
View File

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

View File

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

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload; namespace Composer\Autoload;
class ComposerStaticInit962f084182d33365088c47167dbd9d4a class ComposerStaticInit5efc915aaba0ea1bf59e274752d51ea9
{ {
public static $files = array ( public static $files = array (
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php', '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
@ -3415,9 +3415,9 @@ class ComposerStaticInit962f084182d33365088c47167dbd9d4a
public static function getInitializer(ClassLoader $loader) public static function getInitializer(ClassLoader $loader)
{ {
return \Closure::bind(function () use ($loader) { return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit962f084182d33365088c47167dbd9d4a::$prefixLengthsPsr4; $loader->prefixLengthsPsr4 = ComposerStaticInit5efc915aaba0ea1bf59e274752d51ea9::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit962f084182d33365088c47167dbd9d4a::$prefixDirsPsr4; $loader->prefixDirsPsr4 = ComposerStaticInit5efc915aaba0ea1bf59e274752d51ea9::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit962f084182d33365088c47167dbd9d4a::$classMap; $loader->classMap = ComposerStaticInit5efc915aaba0ea1bf59e274752d51ea9::$classMap;
}, null, ClassLoader::class); }, null, ClassLoader::class);
} }

View File

@ -2202,12 +2202,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-nette.git", "url": "https:\/\/github.com\/rectorphp\/rector-nette.git",
"reference": "45ba400e07e360010f0702260ac32e602ec05535" "reference": "9489bdb38f8bea75bf7071f6313900363c5ae332"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-nette\/zipball\/45ba400e07e360010f0702260ac32e602ec05535", "url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-nette\/zipball\/9489bdb38f8bea75bf7071f6313900363c5ae332",
"reference": "45ba400e07e360010f0702260ac32e602ec05535", "reference": "9489bdb38f8bea75bf7071f6313900363c5ae332",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2239,7 +2239,7 @@
"symplify\/rule-doc-generator": "^11.0", "symplify\/rule-doc-generator": "^11.0",
"symplify\/vendor-patches": "^11.0" "symplify\/vendor-patches": "^11.0"
}, },
"time": "2022-07-01T09:37:34+00:00", "time": "2022-07-03T11:55:16+00:00",
"default-branch": true, "default-branch": true,
"type": "rector-extension", "type": "rector-extension",
"extra": { "extra": {
@ -2269,7 +2269,7 @@
"description": "Rector upgrades rules for Nette Framework", "description": "Rector upgrades rules for Nette Framework",
"support": { "support": {
"issues": "https:\/\/github.com\/rectorphp\/rector-nette\/issues", "issues": "https:\/\/github.com\/rectorphp\/rector-nette\/issues",
"source": "https:\/\/github.com\/rectorphp\/rector-nette\/tree\/main" "source": "https:\/\/github.com\/rectorphp\/rector-nette\/tree\/0.13.1"
}, },
"install-path": "..\/rector\/rector-nette" "install-path": "..\/rector\/rector-nette"
}, },

File diff suppressed because one or more lines are too long

View File

@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
*/ */
final class GeneratedConfig 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 86ab8c3'), '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 b177492'), '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 c857264'), '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 644d45b'), '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 7d3c734'), '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 45ba400'), '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 d826618'), '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 97b5397'), '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 d4e61a1')); 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 86ab8c3'), '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 b177492'), '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 c857264'), '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 644d45b'), '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 7d3c734'), '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 9489bdb'), '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 d826618'), '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 97b5397'), '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 d4e61a1'));
private function __construct() private function __construct()
{ {
} }

View File

@ -133,7 +133,7 @@ CODE_SAMPLE
if (!$this->staticCallAnalyzer->isParentCallNamed($staticCall, MethodName::CONSTRUCT)) { if (!$this->staticCallAnalyzer->isParentCallNamed($staticCall, MethodName::CONSTRUCT)) {
return null; return null;
} }
foreach ($staticCall->args as $staticCallArg) { foreach ($staticCall->args as $position => $staticCallArg) {
if (!$staticCallArg->value instanceof Variable) { if (!$staticCallArg->value instanceof Variable) {
continue; continue;
} }
@ -142,9 +142,9 @@ CODE_SAMPLE
if (!$this->isNames($variable, [self::NAME, self::PARENT])) { if (!$this->isNames($variable, [self::NAME, self::PARENT])) {
continue; continue;
} }
$this->removeNode($staticCallArg); unset($staticCall->args[$position]);
} }
if ($this->shouldRemoveEmptyCall($staticCall)) { if ($staticCall->args === []) {
$this->removeNode($staticCall); $this->removeNode($staticCall);
return null; return null;
} }
@ -171,7 +171,7 @@ CODE_SAMPLE
if (!\in_array($parameterName, [self::PARENT, self::NAME], \true)) { if (!\in_array($parameterName, [self::PARENT, self::NAME], \true)) {
continue; continue;
} }
$this->removeNode($arg); unset($new->args[$position]);
} }
} }
private function isInsideNetteComponentClass(Node $node) : bool private function isInsideNetteComponentClass(Node $node) : bool
@ -201,14 +201,4 @@ CODE_SAMPLE
} }
} }
} }
private function shouldRemoveEmptyCall(StaticCall $staticCall) : bool
{
foreach ($staticCall->args as $arg) {
if ($this->nodesToRemoveCollector->isNodeRemoved($arg)) {
continue;
}
return \false;
}
return \true;
}
} }