mirror of https://github.com/rectorphp/rector.git
Updated Rector to commit b4212ed99d3aadc3ce6371c984b644b54252752e
b4212ed99d
[Performance] Combine repetitive find() usage on RemoveUnusedVariableAssignRector (#5686)
This commit is contained in:
parent
105d14818d
commit
6fc08102f7
|
@ -95,10 +95,7 @@ CODE_SAMPLE
|
|||
return null;
|
||||
}
|
||||
// we cannot be sure here
|
||||
if ($this->containsCompactFuncCall($node)) {
|
||||
return null;
|
||||
}
|
||||
if ($this->containsFileIncludes($node)) {
|
||||
if ($this->shouldSkip($stmts)) {
|
||||
return null;
|
||||
}
|
||||
$assignedVariableNamesByStmtPosition = $this->resolvedAssignedVariablesByStmtPosition($stmts);
|
||||
|
@ -165,24 +162,19 @@ CODE_SAMPLE
|
|||
return \false;
|
||||
}
|
||||
/**
|
||||
* @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $functionLike
|
||||
* @param Stmt[] $stmts
|
||||
*/
|
||||
private function containsCompactFuncCall($functionLike) : bool
|
||||
private function shouldSkip(array $stmts) : bool
|
||||
{
|
||||
$compactFuncCall = $this->betterNodeFinder->findFirst($functionLike, function (Node $node) : bool {
|
||||
return (bool) $this->betterNodeFinder->findFirst($stmts, function (Node $node) : bool {
|
||||
if ($node instanceof Include_) {
|
||||
return \true;
|
||||
}
|
||||
if (!$node instanceof FuncCall) {
|
||||
return \false;
|
||||
}
|
||||
return $this->isName($node, 'compact');
|
||||
});
|
||||
return $compactFuncCall instanceof FuncCall;
|
||||
}
|
||||
/**
|
||||
* @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $functionLike
|
||||
*/
|
||||
private function containsFileIncludes($functionLike) : bool
|
||||
{
|
||||
return (bool) $this->betterNodeFinder->findInstancesOf($functionLike, [Include_::class]);
|
||||
}
|
||||
/**
|
||||
* @param array<int, Stmt> $stmts
|
||||
|
|
|
@ -19,12 +19,12 @@ final class VersionResolver
|
|||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'b523b734e052b47d756330e7deeaa68372fbd494';
|
||||
public const PACKAGE_VERSION = 'b4212ed99d3aadc3ce6371c984b644b54252752e';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2024-03-04 03:44:29';
|
||||
public const RELEASE_DATE = '2024-03-04 21:00:48';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue