Updated Rector to commit 879feb8931f1465fa463d539e9ce99ebfae4e948

879feb8931 [CodeQuality] Handle do { } while maybe returned on ExplicitReturnNullRector (#5766)
This commit is contained in:
Tomas Votruba 2024-03-23 20:33:11 +00:00
parent e14c8a528b
commit 52addb1dde
2 changed files with 14 additions and 3 deletions

View File

@ -12,7 +12,9 @@ use PhpParser\Node\Expr\Yield_;
use PhpParser\Node\Expr\YieldFrom; use PhpParser\Node\Expr\YieldFrom;
use PhpParser\Node\FunctionLike; use PhpParser\Node\FunctionLike;
use PhpParser\Node\Stmt; use PhpParser\Node\Stmt;
use PhpParser\Node\Stmt\Break_;
use PhpParser\Node\Stmt\ClassMethod; use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Continue_;
use PhpParser\Node\Stmt\Do_; use PhpParser\Node\Stmt\Do_;
use PhpParser\Node\Stmt\Else_; use PhpParser\Node\Stmt\Else_;
use PhpParser\Node\Stmt\Expression; use PhpParser\Node\Stmt\Expression;
@ -90,12 +92,21 @@ final class SilentVoidResolver
if ($this->isIfReturn($stmt)) { if ($this->isIfReturn($stmt)) {
return \true; return \true;
} }
if ($stmt instanceof Do_ && $this->hasStmtsAlwaysReturnOrExit($stmt->stmts)) { if ($stmt instanceof Do_ && $this->isDoWithAlwaysReturnOrExit($stmt)) {
return \true; return \true;
} }
} }
return \false; return \false;
} }
private function isDoWithAlwaysReturnOrExit(Do_ $do) : bool
{
if (!$this->hasStmtsAlwaysReturnOrExit($do->stmts)) {
return \false;
}
return !(bool) $this->betterNodeFinder->findFirst($do->stmts, static function (Node $node) : bool {
return $node instanceof Break_ || $node instanceof Continue_;
});
}
/** /**
* @param \PhpParser\Node\Stmt|\PhpParser\Node\Expr $stmt * @param \PhpParser\Node\Stmt|\PhpParser\Node\Expr $stmt
*/ */

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api * @api
* @var string * @var string
*/ */
public const PACKAGE_VERSION = 'aac889be3d845974d3ab924ff7ad22784b9e3cb5'; public const PACKAGE_VERSION = '879feb8931f1465fa463d539e9ce99ebfae4e948';
/** /**
* @api * @api
* @var string * @var string
*/ */
public const RELEASE_DATE = '2024-03-23 23:47:25'; public const RELEASE_DATE = '2024-03-23 20:30:55';
/** /**
* @var int * @var int
*/ */