Updated Rector to commit 98a2a6fd6c6d1e2db5c0143e3e66e8421904b428

98a2a6fd6c Add test fixture on boolean && in RemoveAlwaysTrueIfConditionRector (#5749)
This commit is contained in:
Tomas Votruba 2024-03-21 11:23:24 +00:00
parent c950e4d97b
commit 7a69e542ca
2 changed files with 23 additions and 3 deletions

View File

@ -6,6 +6,7 @@ namespace Rector\DeadCode\Rector\If_;
use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Expr\BinaryOp\BooleanAnd;
use PhpParser\Node\Expr\PropertyFetch;
use PhpParser\Node\Expr\StaticPropertyFetch;
use PhpParser\Node\Expr\Variable;
@ -84,10 +85,13 @@ CODE_SAMPLE
}
/**
* @param If_ $node
* @return int|null|Stmt[]
* @return int|null|Stmt[]|If_
*/
public function refactor(Node $node)
{
if ($node->cond instanceof BooleanAnd) {
return $this->refactorIfWithBooleanAnd($node);
}
if ($node->else instanceof Else_) {
return null;
}
@ -149,4 +153,20 @@ CODE_SAMPLE
}
return \false;
}
private function refactorIfWithBooleanAnd(If_ $if) : ?If_
{
if (!$if->cond instanceof BooleanAnd) {
return null;
}
$booleanAnd = $if->cond;
$leftType = $this->getType($booleanAnd->left);
if (!$leftType instanceof ConstantBooleanType) {
return null;
}
if (!$leftType->getValue()) {
return null;
}
$if->cond = $booleanAnd->right;
return $if;
}
}

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = 'da67bb97a141fd0feb2ab90f5576138489f2f67d';
public const PACKAGE_VERSION = '98a2a6fd6c6d1e2db5c0143e3e66e8421904b428';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2024-03-21 11:03:36';
public const RELEASE_DATE = '2024-03-21 12:21:09';
/**
* @var int
*/