mirror of https://github.com/rectorphp/rector.git
Updated Rector to commit ca2988edc997d76a1d7d4b2c6a4f7226478cac7c
ca2988edc9
[CodeQuality] Skip increment variable on else on TernaryFalseExpressionToIfRector (#5867)
This commit is contained in:
parent
73eb63e4f9
commit
efb3c476c7
|
@ -6,10 +6,11 @@ namespace Rector\CodeQuality\Rector\Expression;
|
|||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\Ternary;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
use PhpParser\Node\Stmt\If_;
|
||||
use PHPStan\Analyser\Scope;
|
||||
use Rector\DeadCode\SideEffect\SideEffectNodeDetector;
|
||||
use Rector\NodeAnalyzer\ExprAnalyzer;
|
||||
use Rector\Rector\AbstractScopeAwareRector;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
|
@ -20,12 +21,12 @@ final class TernaryFalseExpressionToIfRector extends AbstractScopeAwareRector
|
|||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\DeadCode\SideEffect\SideEffectNodeDetector
|
||||
* @var \Rector\NodeAnalyzer\ExprAnalyzer
|
||||
*/
|
||||
private $sideEffectNodeDetector;
|
||||
public function __construct(SideEffectNodeDetector $sideEffectNodeDetector)
|
||||
private $exprAnalyzer;
|
||||
public function __construct(ExprAnalyzer $exprAnalyzer)
|
||||
{
|
||||
$this->sideEffectNodeDetector = $sideEffectNodeDetector;
|
||||
$this->exprAnalyzer = $exprAnalyzer;
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
|
@ -70,7 +71,7 @@ CODE_SAMPLE
|
|||
if (!$ternary->if instanceof Expr) {
|
||||
return null;
|
||||
}
|
||||
if ($this->sideEffectNodeDetector->detect($ternary->else, $scope) || $this->sideEffectNodeDetector->detectCallExpr($ternary->else, $scope)) {
|
||||
if (!$ternary->else instanceof Variable && $this->exprAnalyzer->isDynamicExpr($ternary->else)) {
|
||||
return null;
|
||||
}
|
||||
return new If_($ternary->cond, ['stmts' => [new Expression($ternary->if)]]);
|
||||
|
|
|
@ -19,12 +19,12 @@ final class VersionResolver
|
|||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '1.0.5';
|
||||
public const PACKAGE_VERSION = 'ca2988edc997d76a1d7d4b2c6a4f7226478cac7c';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2024-05-10 10:25:34';
|
||||
public const RELEASE_DATE = '2024-05-10 16:36:07';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue