Skip to content

Commit

Permalink
Updated Rector to commit 203651aaf1c615c345620c5069c15755bde08227
Browse files Browse the repository at this point in the history
rectorphp/rector-src@203651a [CodeQuality] Skip else indirect return on SimplifyIfReturnBoolRector (#6371)
  • Loading branch information
TomasVotruba committed Oct 11, 2024
1 parent 43ea812 commit 1f93d1a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
16 changes: 12 additions & 4 deletions rules/CodeQuality/Rector/If_/SimplifyIfReturnBoolRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ private function shouldSkipIfAndReturn(If_ $if, Return_ $return) : bool
if ($if->elseifs !== []) {
return \true;
}
if ($this->isElseSeparatedThenIf($if)) {
if (!$this->isIfWithSingleReturnExpr($if)) {
return \true;
}
if (!$this->isIfWithSingleReturnExpr($if)) {
if ($this->isElseSeparatedThenIf($if)) {
return \true;
}
/** @var Return_ $ifInnerNode */
Expand Down Expand Up @@ -181,10 +181,18 @@ private function isElseSeparatedThenIf(If_ $if) : bool
return \false;
}
if (\count($if->else->stmts) !== 1) {
return \false;
return \true;
}
$onlyStmt = $if->else->stmts[0];
return $onlyStmt instanceof If_;
if (!$onlyStmt instanceof Return_ || !$onlyStmt->expr instanceof Expr) {
return \true;
}
if ($this->valueResolver->isTrueOrFalse($onlyStmt->expr)) {
/** @var Return_ $ifReturn */
$ifReturn = $if->stmts[0];
return $this->nodeComparator->areNodesEqual($onlyStmt->expr, $ifReturn->expr);
}
return \true;
}
private function isIfWithSingleReturnExpr(If_ $if) : bool
{
Expand Down
4 changes: 2 additions & 2 deletions src/Application/VersionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = 'cb4ccd650eba6b43ac07da13e53b816a4119fad1';
public const PACKAGE_VERSION = '203651aaf1c615c345620c5069c15755bde08227';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2024-10-11 08:57:33';
public const RELEASE_DATE = '2024-10-11 13:18:42';
/**
* @var int
*/
Expand Down

0 comments on commit 1f93d1a

Please sign in to comment.