mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-06 03:10:50 +00:00
Updated Rector to commit f32dff3ddb3bb8062fced070984017352f2b653a
f32dff3ddb
[DeadCode] Skip From docblock on ReduceAlwaysFalseIfOrRector (#5752)
This commit is contained in:
parent
c1338c4c07
commit
1a710b92cc
|
@ -5,8 +5,11 @@ namespace Rector\DeadCode\Rector\If_;
|
|||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\BinaryOp\BooleanOr;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Stmt\If_;
|
||||
use PHPStan\Type\Constant\ConstantBooleanType;
|
||||
use Rector\NodeAnalyzer\ExprAnalyzer;
|
||||
use Rector\PhpParser\Node\BetterNodeFinder;
|
||||
use Rector\Rector\AbstractRector;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
|
@ -15,6 +18,21 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
|||
*/
|
||||
final class ReduceAlwaysFalseIfOrRector extends AbstractRector
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\PhpParser\Node\BetterNodeFinder
|
||||
*/
|
||||
private $betterNodeFinder;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\NodeAnalyzer\ExprAnalyzer
|
||||
*/
|
||||
private $exprAnalyzer;
|
||||
public function __construct(BetterNodeFinder $betterNodeFinder, ExprAnalyzer $exprAnalyzer)
|
||||
{
|
||||
$this->betterNodeFinder = $betterNodeFinder;
|
||||
$this->exprAnalyzer = $exprAnalyzer;
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Reduce always false in a if ( || ) condition', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
|
@ -68,6 +86,12 @@ CODE_SAMPLE
|
|||
if ($conditionStaticType->getValue()) {
|
||||
return null;
|
||||
}
|
||||
$hasNonTypedFromParam = $this->betterNodeFinder->findFirst($booleanOr->left, function (Node $node) : bool {
|
||||
return $node instanceof Variable && $this->exprAnalyzer->isNonTypedFromParam($node);
|
||||
});
|
||||
if ($hasNonTypedFromParam instanceof Node) {
|
||||
return null;
|
||||
}
|
||||
$node->cond = $booleanOr->right;
|
||||
return $node;
|
||||
}
|
||||
|
|
|
@ -19,12 +19,12 @@ final class VersionResolver
|
|||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'aaf006c8f534230b1bbc4c4fb3747cd660305718';
|
||||
public const PACKAGE_VERSION = 'f32dff3ddb3bb8062fced070984017352f2b653a';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2024-03-21 11:35:06';
|
||||
public const RELEASE_DATE = '2024-03-21 12:52:23';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue
Block a user