Updated Rector to commit ddcc807ffcdf24c49889125682d1bcb223387d09

ddcc807ffc Make use of REMOVE_NODE return constant in refator() method (#4075)
This commit is contained in:
Tomas Votruba 2023-06-05 09:32:57 +00:00
parent ee021e37ea
commit 917ce32d7a
22 changed files with 111 additions and 128 deletions

View File

@ -5,6 +5,7 @@ namespace Rector\DeadCode\Rector\ClassConst;
use PhpParser\Node; use PhpParser\Node;
use PhpParser\Node\Stmt\ClassConst; use PhpParser\Node\Stmt\ClassConst;
use PhpParser\NodeTraverser;
use PHPStan\Reflection\ClassReflection; use PHPStan\Reflection\ClassReflection;
use Rector\Core\NodeAnalyzer\EnumAnalyzer; use Rector\Core\NodeAnalyzer\EnumAnalyzer;
use Rector\Core\NodeManipulator\ClassConstManipulator; use Rector\Core\NodeManipulator\ClassConstManipulator;
@ -70,7 +71,7 @@ CODE_SAMPLE
/** /**
* @param ClassConst $node * @param ClassConst $node
*/ */
public function refactor(Node $node) : ?Node public function refactor(Node $node) : ?int
{ {
if ($this->shouldSkipClassConst($node)) { if ($this->shouldSkipClassConst($node)) {
return null; return null;
@ -82,8 +83,7 @@ CODE_SAMPLE
if ($this->classConstManipulator->hasClassConstFetch($node, $classReflection)) { if ($this->classConstManipulator->hasClassConstFetch($node, $classReflection)) {
return null; return null;
} }
$this->removeNode($node); return NodeTraverser::REMOVE_NODE;
return null;
} }
private function shouldSkipClassConst(ClassConst $classConst) : bool private function shouldSkipClassConst(ClassConst $classConst) : bool
{ {

View File

@ -7,6 +7,7 @@ use PhpParser\Node;
use PhpParser\Node\Name\FullyQualified; use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Stmt\Class_; use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassMethod; use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\NodeTraverser;
use Rector\Core\NodeAnalyzer\ParamAnalyzer; use Rector\Core\NodeAnalyzer\ParamAnalyzer;
use Rector\Core\NodeManipulator\ClassMethodManipulator; use Rector\Core\NodeManipulator\ClassMethodManipulator;
use Rector\Core\Rector\AbstractRector; use Rector\Core\Rector\AbstractRector;
@ -67,7 +68,7 @@ CODE_SAMPLE
/** /**
* @param ClassMethod $node * @param ClassMethod $node
*/ */
public function refactor(Node $node) : ?Node public function refactor(Node $node) : ?int
{ {
$classLike = $this->betterNodeFinder->findParentType($node, Class_::class); $classLike = $this->betterNodeFinder->findParentType($node, Class_::class);
if (!$classLike instanceof Class_) { if (!$classLike instanceof Class_) {
@ -88,8 +89,7 @@ CODE_SAMPLE
if ($this->shouldSkipClassMethod($classLike, $node)) { if ($this->shouldSkipClassMethod($classLike, $node)) {
return null; return null;
} }
$this->removeNode($node); return NodeTraverser::REMOVE_NODE;
return null;
} }
private function shouldSkipNonFinalNonPrivateClassMethod(Class_ $class, ClassMethod $classMethod) : bool private function shouldSkipNonFinalNonPrivateClassMethod(Class_ $class, ClassMethod $classMethod) : bool
{ {

View File

@ -6,6 +6,7 @@ namespace Rector\DeadCode\Rector\Expression;
use PhpParser\Node; use PhpParser\Node;
use PhpParser\Node\Expr\Assign; use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Stmt\Expression; use PhpParser\Node\Stmt\Expression;
use PhpParser\NodeTraverser;
use Rector\Core\Rector\AbstractRector; use Rector\Core\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
@ -37,16 +38,15 @@ CODE_SAMPLE
/** /**
* @param Expression $node * @param Expression $node
*/ */
public function refactor(Node $node) : ?Node public function refactor(Node $node) : ?int
{ {
if (!$node->expr instanceof Assign) { if (!$node->expr instanceof Assign) {
return null; return null;
} }
/** @var Assign $assignNode */ $assign = $node->expr;
$assignNode = $node->expr; if (!$this->nodeComparator->areNodesEqual($assign->var, $assign->expr)) {
if ($this->nodeComparator->areNodesEqual($assignNode->var, $assignNode->expr)) { return null;
$this->removeNode($node);
} }
return null; return NodeTraverser::REMOVE_NODE;
} }
} }

View File

@ -11,7 +11,7 @@ use PhpParser\Node\Stmt\Else_;
use PhpParser\Node\Stmt\For_; use PhpParser\Node\Stmt\For_;
use PhpParser\Node\Stmt\Foreach_; use PhpParser\Node\Stmt\Foreach_;
use PhpParser\Node\Stmt\If_; use PhpParser\Node\Stmt\If_;
use Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface; use PhpParser\NodeTraverser;
use Rector\Core\Rector\AbstractRector; use Rector\Core\Rector\AbstractRector;
use Rector\EarlyReturn\NodeTransformer\ConditionInverter; use Rector\EarlyReturn\NodeTransformer\ConditionInverter;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
@ -63,50 +63,37 @@ CODE_SAMPLE
*/ */
public function getNodeTypes() : array public function getNodeTypes() : array
{ {
return [StmtsAwareInterface::class]; return [For_::class, If_::class, Foreach_::class];
} }
/** /**
* @param StmtsAwareInterface $node * @param For_|If_|Foreach_ $node
* @return \PhpParser\Node|null|int
*/ */
public function refactor(Node $node) : ?Node public function refactor(Node $node)
{ {
if ($node->stmts === null) { if ($node instanceof If_) {
return null; if ($node->stmts !== []) {
} return null;
$hasChanged = \false;
foreach ($node->stmts as $key => $stmt) {
if ($stmt instanceof If_) {
$if = $stmt;
if ($if->stmts !== []) {
continue;
}
if ($if->elseifs !== []) {
continue;
}
// useless if ()
if (!$if->else instanceof Else_) {
if ($this->hasNodeSideEffect($if->cond)) {
continue;
}
unset($node->stmts[$key]);
$hasChanged = \true;
continue;
}
$if->cond = $this->conditionInverter->createInvertedCondition($if->cond);
$if->stmts = $if->else->stmts;
$if->else = null;
$hasChanged = \true;
continue;
} }
// nothing to "for" if ($node->elseifs !== []) {
if (($stmt instanceof For_ || $stmt instanceof Foreach_) && $stmt->stmts === []) { return null;
unset($node->stmts[$key]);
$hasChanged = \true;
} }
} // useless if ()
if ($hasChanged) { if (!$node->else instanceof Else_) {
if ($this->hasNodeSideEffect($node->cond)) {
return null;
}
return NodeTraverser::REMOVE_NODE;
}
$node->cond = $this->conditionInverter->createInvertedCondition($node->cond);
$node->stmts = $node->else->stmts;
$node->else = null;
return $node; return $node;
} }
// nothing to "for"
if ($node->stmts === []) {
return NodeTraverser::REMOVE_NODE;
}
return null; return null;
} }
private function hasNodeSideEffect(Expr $expr) : bool private function hasNodeSideEffect(Expr $expr) : bool

View File

@ -8,6 +8,7 @@ use PhpParser\Node\Stmt\Do_;
use PhpParser\Node\Stmt\For_; use PhpParser\Node\Stmt\For_;
use PhpParser\Node\Stmt\Foreach_; use PhpParser\Node\Stmt\Foreach_;
use PhpParser\Node\Stmt\While_; use PhpParser\Node\Stmt\While_;
use PhpParser\NodeTraverser;
use Rector\Core\Rector\AbstractRector; use Rector\Core\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
@ -48,12 +49,11 @@ CODE_SAMPLE
/** /**
* @param Do_|For_|Foreach_|While_ $node * @param Do_|For_|Foreach_|While_ $node
*/ */
public function refactor(Node $node) : ?Node public function refactor(Node $node) : ?int
{ {
if ($node->stmts !== []) { if ($node->stmts !== []) {
return null; return null;
} }
$this->removeNode($node); return NodeTraverser::REMOVE_NODE;
return null;
} }
} }

View File

@ -12,6 +12,7 @@ use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Stmt; use PhpParser\Node\Stmt;
use PhpParser\Node\Stmt\Else_; use PhpParser\Node\Stmt\Else_;
use PhpParser\Node\Stmt\If_; use PhpParser\Node\Stmt\If_;
use PhpParser\NodeTraverser;
use PHPStan\Reflection\ClassReflection; use PHPStan\Reflection\ClassReflection;
use PHPStan\Type\Constant\ConstantBooleanType; use PHPStan\Type\Constant\ConstantBooleanType;
use Rector\Core\NodeAnalyzer\ExprAnalyzer; use Rector\Core\NodeAnalyzer\ExprAnalyzer;
@ -76,7 +77,7 @@ CODE_SAMPLE
} }
/** /**
* @param If_ $node * @param If_ $node
* @return If_|null|Stmt[] * @return int|null|Stmt[]
*/ */
public function refactor(Node $node) public function refactor(Node $node)
{ {
@ -105,8 +106,7 @@ CODE_SAMPLE
return null; return null;
} }
if ($node->stmts === []) { if ($node->stmts === []) {
$this->removeNode($node); return NodeTraverser::REMOVE_NODE;
return null;
} }
return $node->stmts; return $node->stmts;
} }

View File

@ -9,6 +9,7 @@ use PhpParser\Node\Stmt\Finally_;
use PhpParser\Node\Stmt\Nop; use PhpParser\Node\Stmt\Nop;
use PhpParser\Node\Stmt\Throw_; use PhpParser\Node\Stmt\Throw_;
use PhpParser\Node\Stmt\TryCatch; use PhpParser\Node\Stmt\TryCatch;
use PhpParser\NodeTraverser;
use Rector\Core\Rector\AbstractRector; use Rector\Core\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
@ -52,7 +53,7 @@ CODE_SAMPLE
} }
/** /**
* @param TryCatch $node * @param TryCatch $node
* @return Stmt[]|null|TryCatch * @return Stmt[]|null|TryCatch|int
*/ */
public function refactor(Node $node) public function refactor(Node $node)
{ {
@ -62,8 +63,7 @@ CODE_SAMPLE
return null; return null;
} }
if ($this->isEmpty($node->stmts)) { if ($this->isEmpty($node->stmts)) {
$this->removeNode($node); return NodeTraverser::REMOVE_NODE;
return null;
} }
if (\count($node->catches) !== 1) { if (\count($node->catches) !== 1) {
return null; return null;

View File

@ -6,6 +6,7 @@ namespace Rector\Php70\Rector\Break_;
use PhpParser\Node; use PhpParser\Node;
use PhpParser\Node\Stmt\Break_; use PhpParser\Node\Stmt\Break_;
use PhpParser\Node\Stmt\Return_; use PhpParser\Node\Stmt\Return_;
use PhpParser\NodeTraverser;
use Rector\Core\Rector\AbstractRector; use Rector\Core\Rector\AbstractRector;
use Rector\Core\ValueObject\PhpVersionFeature; use Rector\Core\ValueObject\PhpVersionFeature;
use Rector\NodeNestingScope\ContextAnalyzer; use Rector\NodeNestingScope\ContextAnalyzer;
@ -72,8 +73,9 @@ CODE_SAMPLE
} }
/** /**
* @param Break_ $node * @param Break_ $node
* @return \PhpParser\Node\Stmt\Return_|null|int
*/ */
public function refactor(Node $node) : ?Node public function refactor(Node $node)
{ {
if ($this->contextAnalyzer->isInLoop($node)) { if ($this->contextAnalyzer->isInLoop($node)) {
return null; return null;
@ -84,7 +86,6 @@ CODE_SAMPLE
if ($this->contextAnalyzer->isInIf($node)) { if ($this->contextAnalyzer->isInIf($node)) {
return new Return_(); return new Return_();
} }
$this->removeNode($node); return NodeTraverser::REMOVE_NODE;
return null;
} }
} }

View File

@ -12,6 +12,7 @@ use PhpParser\Node\Name;
use PhpParser\Node\Stmt\Class_; use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassMethod; use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Expression; use PhpParser\Node\Stmt\Expression;
use PhpParser\NodeTraverser;
use PHPStan\Analyser\Scope; use PHPStan\Analyser\Scope;
use PHPStan\Reflection\ClassReflection; use PHPStan\Reflection\ClassReflection;
use Rector\Core\Enum\ObjectReference; use Rector\Core\Enum\ObjectReference;
@ -77,8 +78,9 @@ CODE_SAMPLE
} }
/** /**
* @param ClassMethod $node * @param ClassMethod $node
* @return \PhpParser\Node\Stmt\ClassMethod|int|null
*/ */
public function refactorWithScope(Node $node, Scope $scope) : ?Node public function refactorWithScope(Node $node, Scope $scope)
{ {
if (!$this->php4ConstructorClassMethodAnalyzer->detect($node, $scope)) { if (!$this->php4ConstructorClassMethodAnalyzer->detect($node, $scope)) {
return null; return null;
@ -98,19 +100,17 @@ CODE_SAMPLE
if (!$classMethod instanceof ClassMethod) { if (!$classMethod instanceof ClassMethod) {
$node->name = new Identifier(MethodName::CONSTRUCT); $node->name = new Identifier(MethodName::CONSTRUCT);
} }
$stmts = $node->stmts; $classMethodStmts = $node->stmts;
if ($stmts === null) { if ($classMethodStmts === null) {
return null; return null;
} }
if (\count($stmts) === 1) { if (\count($classMethodStmts) === 1) {
/** @var Expression|Expr $stmt */ $stmt = $node->stmts[0];
$stmt = $stmts[0];
if (!$stmt instanceof Expression) { if (!$stmt instanceof Expression) {
return null; return null;
} }
if ($this->isLocalMethodCallNamed($stmt->expr, MethodName::CONSTRUCT)) { if ($this->isLocalMethodCallNamed($stmt->expr, MethodName::CONSTRUCT)) {
$this->removeNode($node); return NodeTraverser::REMOVE_NODE;
return null;
} }
} }
return $node; return $node;

View File

@ -8,6 +8,7 @@ use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Expr\Cast\Unset_; use PhpParser\Node\Expr\Cast\Unset_;
use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Stmt\Expression; use PhpParser\Node\Stmt\Expression;
use PhpParser\NodeTraverser;
use Rector\Core\Rector\AbstractRector; use Rector\Core\Rector\AbstractRector;
use Rector\Core\ValueObject\PhpVersionFeature; use Rector\Core\ValueObject\PhpVersionFeature;
use Rector\VersionBonding\Contract\MinPhpVersionInterface; use Rector\VersionBonding\Contract\MinPhpVersionInterface;
@ -45,8 +46,9 @@ CODE_SAMPLE
} }
/** /**
* @param Unset_|Assign|Expression $node * @param Unset_|Assign|Expression $node
* @return int|null|\PhpParser\Node
*/ */
public function refactor(Node $node) : ?Node public function refactor(Node $node)
{ {
if ($node instanceof Assign) { if ($node instanceof Assign) {
return $this->refactorAssign($node); return $this->refactorAssign($node);
@ -55,8 +57,7 @@ CODE_SAMPLE
if (!$node->expr instanceof Unset_) { if (!$node->expr instanceof Unset_) {
return null; return null;
} }
$this->removeNode($node); return NodeTraverser::REMOVE_NODE;
return null;
} }
return $this->nodeFactory->createNull(); return $this->nodeFactory->createNull();
} }

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api * @api
* @var string * @var string
*/ */
public const PACKAGE_VERSION = '21d43cfb3d62563f3f73424d2bdf36136056617d'; public const PACKAGE_VERSION = 'ddcc807ffcdf24c49889125682d1bcb223387d09';
/** /**
* @api * @api
* @var string * @var string
*/ */
public const RELEASE_DATE = '2023-06-05 08:56:05'; public const RELEASE_DATE = '2023-06-05 10:27:38';
/** /**
* @var int * @var int
*/ */

View File

@ -243,6 +243,9 @@ CODE_SAMPLE;
// @see NodeTraverser::* codes, e.g. removal of node of stopping the traversing // @see NodeTraverser::* codes, e.g. removal of node of stopping the traversing
if ($refactoredNode === NodeTraverser::REMOVE_NODE && $originalNode instanceof Node) { if ($refactoredNode === NodeTraverser::REMOVE_NODE && $originalNode instanceof Node) {
$this->toBeRemovedNodeHash = \spl_object_hash($originalNode); $this->toBeRemovedNodeHash = \spl_object_hash($originalNode);
// notify this rule changing code
$rectorWithLineChange = new RectorWithLineChange(static::class, $originalNode->getLine());
$this->file->addRectorClassWithLine($rectorWithLineChange);
return $originalNode; return $originalNode;
} }
if (\is_int($refactoredNode)) { if (\is_int($refactoredNode)) {
@ -341,9 +344,6 @@ CODE_SAMPLE;
private function postRefactorProcess(?\PhpParser\Node $originalNode, Node $node, $refactoredNode) : Node private function postRefactorProcess(?\PhpParser\Node $originalNode, Node $node, $refactoredNode) : Node
{ {
// node is removed, nothing to post process // node is removed, nothing to post process
if (\is_int($refactoredNode)) {
return $originalNode ?? $node;
}
$originalNode = $originalNode ?? $node; $originalNode = $originalNode ?? $node;
/** @var non-empty-array<Node>|Node $refactoredNode */ /** @var non-empty-array<Node>|Node $refactoredNode */
$this->createdByRuleDecorator->decorate($refactoredNode, $originalNode, static::class); $this->createdByRuleDecorator->decorate($refactoredNode, $originalNode, static::class);

2
vendor/autoload.php vendored
View File

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

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer // autoload_real.php @generated by Composer
class ComposerAutoloaderInitc1019df5d720869a172df67523ac7cf2 class ComposerAutoloaderInit8f0749b307bce8ea67d885494e87a8b0
{ {
private static $loader; private static $loader;
@ -22,17 +22,17 @@ class ComposerAutoloaderInitc1019df5d720869a172df67523ac7cf2
return self::$loader; return self::$loader;
} }
spl_autoload_register(array('ComposerAutoloaderInitc1019df5d720869a172df67523ac7cf2', 'loadClassLoader'), true, true); spl_autoload_register(array('ComposerAutoloaderInit8f0749b307bce8ea67d885494e87a8b0', '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('ComposerAutoloaderInitc1019df5d720869a172df67523ac7cf2', 'loadClassLoader')); spl_autoload_unregister(array('ComposerAutoloaderInit8f0749b307bce8ea67d885494e87a8b0', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php'; require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitc1019df5d720869a172df67523ac7cf2::getInitializer($loader)); call_user_func(\Composer\Autoload\ComposerStaticInit8f0749b307bce8ea67d885494e87a8b0::getInitializer($loader));
$loader->setClassMapAuthoritative(true); $loader->setClassMapAuthoritative(true);
$loader->register(true); $loader->register(true);
$filesToLoad = \Composer\Autoload\ComposerStaticInitc1019df5d720869a172df67523ac7cf2::$files; $filesToLoad = \Composer\Autoload\ComposerStaticInit8f0749b307bce8ea67d885494e87a8b0::$files;
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) { $requireFile = \Closure::bind(static function ($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 ComposerStaticInitc1019df5d720869a172df67523ac7cf2 class ComposerStaticInit8f0749b307bce8ea67d885494e87a8b0
{ {
public static $files = array ( public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php', 'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -3053,9 +3053,9 @@ class ComposerStaticInitc1019df5d720869a172df67523ac7cf2
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 = ComposerStaticInitc1019df5d720869a172df67523ac7cf2::$prefixLengthsPsr4; $loader->prefixLengthsPsr4 = ComposerStaticInit8f0749b307bce8ea67d885494e87a8b0::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitc1019df5d720869a172df67523ac7cf2::$prefixDirsPsr4; $loader->prefixDirsPsr4 = ComposerStaticInit8f0749b307bce8ea67d885494e87a8b0::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitc1019df5d720869a172df67523ac7cf2::$classMap; $loader->classMap = ComposerStaticInit8f0749b307bce8ea67d885494e87a8b0::$classMap;
}, null, ClassLoader::class); }, null, ClassLoader::class);
} }

View File

@ -871,17 +871,17 @@
}, },
{ {
"name": "phpstan\/phpstan", "name": "phpstan\/phpstan",
"version": "1.10.15", "version": "1.10.16",
"version_normalized": "1.10.15.0", "version_normalized": "1.10.16.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https:\/\/github.com\/phpstan\/phpstan.git", "url": "https:\/\/github.com\/phpstan\/phpstan.git",
"reference": "762c4dac4da6f8756eebb80e528c3a47855da9bd" "reference": "352bdbb960bb523e3d71b834862589f910921c23"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https:\/\/api.github.com\/repos\/phpstan\/phpstan\/zipball\/762c4dac4da6f8756eebb80e528c3a47855da9bd", "url": "https:\/\/api.github.com\/repos\/phpstan\/phpstan\/zipball\/352bdbb960bb523e3d71b834862589f910921c23",
"reference": "762c4dac4da6f8756eebb80e528c3a47855da9bd", "reference": "352bdbb960bb523e3d71b834862589f910921c23",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -890,7 +890,7 @@
"conflict": { "conflict": {
"phpstan\/phpstan-shim": "*" "phpstan\/phpstan-shim": "*"
}, },
"time": "2023-05-09T15:28:01+00:00", "time": "2023-06-05T08:21:46+00:00",
"bin": [ "bin": [
"phpstan", "phpstan",
"phpstan.phar" "phpstan.phar"
@ -1852,12 +1852,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-doctrine.git", "url": "https:\/\/github.com\/rectorphp\/rector-doctrine.git",
"reference": "c6666a43f71d4922da41a5da42770f2523844286" "reference": "08503e7da4f587cb27211ecc3f0726a6ac367998"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/c6666a43f71d4922da41a5da42770f2523844286", "url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/08503e7da4f587cb27211ecc3f0726a6ac367998",
"reference": "c6666a43f71d4922da41a5da42770f2523844286", "reference": "08503e7da4f587cb27211ecc3f0726a6ac367998",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1882,7 +1882,7 @@
"tomasvotruba\/type-coverage": "^0.2", "tomasvotruba\/type-coverage": "^0.2",
"tomasvotruba\/unused-public": "^0.1" "tomasvotruba\/unused-public": "^0.1"
}, },
"time": "2023-06-04T10:42:02+00:00", "time": "2023-06-05T09:07:54+00:00",
"default-branch": true, "default-branch": true,
"type": "rector-extension", "type": "rector-extension",
"extra": { "extra": {
@ -2056,12 +2056,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-symfony.git", "url": "https:\/\/github.com\/rectorphp\/rector-symfony.git",
"reference": "5c0d61c8c0563057f01cf88998465e480d536747" "reference": "1ad0ae7d9cc161537963a79af2add5d81d3436f2"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/5c0d61c8c0563057f01cf88998465e480d536747", "url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/1ad0ae7d9cc161537963a79af2add5d81d3436f2",
"reference": "5c0d61c8c0563057f01cf88998465e480d536747", "reference": "1ad0ae7d9cc161537963a79af2add5d81d3436f2",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2091,7 +2091,7 @@
"tomasvotruba\/type-coverage": "^0.2", "tomasvotruba\/type-coverage": "^0.2",
"tomasvotruba\/unused-public": "^0.1" "tomasvotruba\/unused-public": "^0.1"
}, },
"time": "2023-06-02T09:45:32+00:00", "time": "2023-06-05T09:03:48+00:00",
"default-branch": true, "default-branch": true,
"type": "rector-extension", "type": "rector-extension",
"extra": { "extra": {

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -1,16 +1,16 @@
-----BEGIN PGP SIGNATURE----- -----BEGIN PGP SIGNATURE-----
iQIzBAABCgAdFiEEynwsejDI6OEnSoR2UcZzBf/C5cAFAmRaZmcACgkQUcZzBf/C iQIzBAABCgAdFiEEynwsejDI6OEnSoR2UcZzBf/C5cAFAmR9mvoACgkQUcZzBf/C
5cAn/Q//fbWiR/qaSvlHpk73KH7iDfoHwNvRrHSQODZdMa4PGiEbL+SXsKnRxFDo 5cBp9w//cyJrRuqBNKAP8F/pwAOJlXhUCgxCL75USO9nEHaUr6S2br8zoQzKlA/u
kEJZwgU5qi3WMflt7Ml3dYDlQDgoDerdaiySYFoBcv1NXDWKoF7+Egy1AHxpfNq+ JOppHlnYMgoElvVqmeXp4NQguHEBLXFty7l/dxEFpRvjYY4RbCbSIt2aWdF4u6CV
FMCkZNR2ulSaYUCofM4GkTNap4yVkPCy289ZU6yUmRnJxF+hh/CFfdVPAPbwh/a6 yDR6pEcQd/nXczgUKJGutX7UPT+m6so5Pg3kto115m/vcwjxsvouBOuy2pML/uki
UqV3R2ENJZSbtA1pzSTBpUPQGQ9qcsqngKyNyxk1hEd9opdMg2eSFvO1e1ZZm/Tk EfzC1v83goGbd28z63/QnP3vsuNvS2BeZgF4REeIl7LHEIVtroo0g/7HGCKhkgw9
Kgh5wCbsbSJuRPGO4vbiybTeO/qXPDlHV6oA5SHnjJ4H24phCsHdyJHHvLQmrUeR Dkm0lj39tU/KYYfVp5UJ/PltTo9ZVuqMNop8e2yvEZXQUmr3UpMuMaaUznWCcOrk
BKHgnH1y/b5J9cgr9OgEQJK9TMHHd6dii9//Qp+0rUZIDZ4Ym2lDSA/Vn/D9GoV3 5f5POqayM142hVfVMcuGYPFaAwQ6k2Fq1WTz8ZsdQ3znYFs9qooC969NXZgyiQV5
zo4QYzW3TvE3QMdnLcX/ZtaLliPdDYIaYUXOiyaYwLFGVxSWZWOC5IN0G0bLJb39 scp8cvCGSUdZO/RFS/KEUm1Vl9pa0hIqhEqFppx252qHmqaXa/Y9rZQT0xS6IZGd
Ca/z839nkWdMqg68q/oHC2Nk/v/KZnKg1RlRjYhj53T6nr0JDEiaYMyETSOIFsVX n+UdytMVjXb2tYaC20vh2jfu030IZNcfbYCSaKiw/JhWaPq0L8CWpVh87aJFJEzh
AcCQnLLwMndUAibJAyORDnTk+ipg0SecFoPvvhea1BtlTfhSDIlrT4OPKZ5nExzd QMRX+/clsq4yrgHxBZ8bD0Mknr9Vtf0y8aZQsAtUfib9s2j+pfIO4Lrq3oAuLhYF
nR/zGbIH8lCvsBc+hq+Kgodtfs5nauwEOwlVUwet26xL1YKOd0jxz+Zp6tgk0wba 9FQP4jBntlGZ7P2Wj8QniyMcrW7Ndd+AzYFSoCs6S+YyeQ6M3WNAXugdn0+uhP9z
cMf5L9fm85j83DQYr7Ukaaj81kmMujRWDo/dRojKhUlJUrNnjXA= EoT0jspS1t3Vq6zOVog2H95pzhI/f8n5x3ZgWbUuWGgHs3fjqTQ=
=jTtX =cnwf
-----END PGP SIGNATURE----- -----END PGP SIGNATURE-----

View File

@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
*/ */
final class GeneratedConfig final class GeneratedConfig
{ {
public const EXTENSIONS = array('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 c6666a4'), '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 7e64cfd'), '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 71fabfb'), '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 5c0d61c')); public const EXTENSIONS = array('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 08503e7'), '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 7e64cfd'), '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 71fabfb'), '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 1ad0ae7'));
private function __construct() private function __construct()
{ {
} }

View File

@ -47,14 +47,11 @@ final class ConstructorAssignPropertyAnalyzer
} }
/** @var string $propertyName */ /** @var string $propertyName */
$propertyName = $this->nodeNameResolver->getName($property); $propertyName = $this->nodeNameResolver->getName($property);
return $this->betterNodeFinder->findFirst((array) $constructClassMethod->stmts, function (Node $node) use($propertyName) : ?Assign { return $this->betterNodeFinder->findFirst((array) $constructClassMethod->stmts, function (Node $node) use($propertyName) : bool {
if (!$node instanceof Assign) { if (!$node instanceof Assign) {
return null; return \false;
} }
if (!$this->propertyFetchAnalyzer->isLocalPropertyFetchName($node->var, $propertyName)) { return $this->propertyFetchAnalyzer->isLocalPropertyFetchName($node->var, $propertyName);
return null;
}
return $node;
}); });
} }
} }

View File

@ -156,14 +156,11 @@ CODE_SAMPLE
private function findPreviousNodeAssign(Node $node, Expr $firstArgumentExpr) : ?Assign private function findPreviousNodeAssign(Node $node, Expr $firstArgumentExpr) : ?Assign
{ {
/** @var Assign|null $assign */ /** @var Assign|null $assign */
$assign = $this->betterNodeFinder->findFirstPrevious($node, function (Node $checkedNode) use($firstArgumentExpr) : ?Assign { $assign = $this->betterNodeFinder->findFirstPrevious($node, function (Node $checkedNode) use($firstArgumentExpr) : bool {
if (!$checkedNode instanceof Assign) { if (!$checkedNode instanceof Assign) {
return null; return \false;
} }
if (!$this->nodeComparator->areNodesEqual($checkedNode->var, $firstArgumentExpr)) { return $this->nodeComparator->areNodesEqual($checkedNode->var, $firstArgumentExpr);
return null;
}
return $checkedNode;
}); });
return $assign; return $assign;
} }