mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-22 19:05:10 +00:00
Updated Rector to commit 6cb63f3752012f33f691844906e56d1045c8bfcf
6cb63f3752
[DeadCode] Skip indirect variable definition on RemoveNonExistingVarAnnotationRector (#5152)
This commit is contained in:
parent
b1be6fd9fc
commit
970b701227
|
@ -4,6 +4,7 @@ declare (strict_types=1);
|
|||
namespace Rector\DeadCode\Rector\Node;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\Assign;
|
||||
use PhpParser\Node\Expr\CallLike;
|
||||
use PhpParser\Node\Expr\FuncCall;
|
||||
use PhpParser\Node\Expr\New_;
|
||||
|
@ -13,6 +14,7 @@ use PhpParser\Node\Stmt\Echo_;
|
|||
use PhpParser\Node\Stmt\Expression;
|
||||
use PhpParser\Node\Stmt\Foreach_;
|
||||
use PhpParser\Node\Stmt\If_;
|
||||
use PhpParser\Node\Stmt\InlineHTML;
|
||||
use PhpParser\Node\Stmt\Nop;
|
||||
use PhpParser\Node\Stmt\Return_;
|
||||
use PhpParser\Node\Stmt\Static_;
|
||||
|
@ -136,7 +138,7 @@ CODE_SAMPLE
|
|||
continue;
|
||||
}
|
||||
$variableName = \ltrim($varTagValueNode->variableName, '$');
|
||||
if ($variableName === '' && $this->isAnnotatableReturn($stmt)) {
|
||||
if ($variableName === '' && $this->isAllowedEmptyVariableName($stmt)) {
|
||||
continue;
|
||||
}
|
||||
if ($this->hasVariableName($stmt, $variableName)) {
|
||||
|
@ -172,7 +174,7 @@ CODE_SAMPLE
|
|||
return \true;
|
||||
}
|
||||
}
|
||||
return \false;
|
||||
return isset($stmtsAware->stmts[$key + 1]) && $stmtsAware->stmts[$key + 1] instanceof InlineHTML;
|
||||
}
|
||||
private function hasVariableName(Stmt $stmt, string $variableName) : bool
|
||||
{
|
||||
|
@ -200,8 +202,11 @@ CODE_SAMPLE
|
|||
}
|
||||
return \strpos($varTagValueNode->description, '}') !== \false;
|
||||
}
|
||||
private function isAnnotatableReturn(Stmt $stmt) : bool
|
||||
private function isAllowedEmptyVariableName(Stmt $stmt) : bool
|
||||
{
|
||||
return $stmt instanceof Return_ && $stmt->expr instanceof CallLike && !$stmt->expr instanceof New_;
|
||||
if ($stmt instanceof Return_ && $stmt->expr instanceof CallLike && !$stmt->expr instanceof New_) {
|
||||
return \true;
|
||||
}
|
||||
return $stmt instanceof Expression && $stmt->expr instanceof Assign && $stmt->expr->var instanceof Variable;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,12 +19,12 @@ final class VersionResolver
|
|||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'ee7e92ca7b3507a2903a21bb52b9f840ae3cc2e8';
|
||||
public const PACKAGE_VERSION = '6cb63f3752012f33f691844906e56d1045c8bfcf';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-10-10 15:29:10';
|
||||
public const RELEASE_DATE = '2023-10-10 17:42:30';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue
Block a user