Updated Rector to commit e7e8c5bfac8df0f605d6588c3612a05cca74b017

e7e8c5bfac [DeadCode] Skip key variable used in throw stmts in catch on RemoveUnusedForeachKeyRector (#6606)
This commit is contained in:
Tomas Votruba 2024-12-18 09:37:57 +00:00
parent de72a9244a
commit d257e68fbf
2 changed files with 10 additions and 2 deletions

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = 'd2298c6fd6fb233e4fcec5d3b69cd2eed52910e6';
public const PACKAGE_VERSION = 'e7e8c5bfac8df0f605d6588c3612a05cca74b017';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2024-12-18 13:44:24';
public const RELEASE_DATE = '2024-12-18 16:35:21';
/**
* @var int
*/

View File

@ -9,6 +9,8 @@ use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Stmt;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Expression;
use PhpParser\Node\Stmt\Finally_;
use PhpParser\Node\Stmt\TryCatch;
use Rector\Contract\PhpParser\Node\StmtsAwareInterface;
use Rector\DeadCode\NodeAnalyzer\ExprUsedInNodeAnalyzer;
use Rector\NodeTypeResolver\Node\AttributeKey;
@ -83,6 +85,12 @@ final class StmtsManipulator
return \false;
}
$stmts = \array_slice($stmtsAware instanceof StmtsAwareInterface ? $stmtsAware->stmts : $stmtsAware, $jumpToKey, null, \true);
if ($stmtsAware instanceof TryCatch) {
$stmts = \array_merge($stmts, $stmtsAware->catches);
if ($stmtsAware->finally instanceof Finally_) {
$stmts = \array_merge($stmts, $stmtsAware->finally->stmts);
}
}
$variable = new Variable($variableName);
return (bool) $this->betterNodeFinder->findFirst($stmts, fn(Node $subNode): bool => $this->exprUsedInNodeAnalyzer->isUsed($subNode, $variable));
}