diff --git a/rules/TypeDeclaration/TypeInferer/SilentVoidResolver.php b/rules/TypeDeclaration/TypeInferer/SilentVoidResolver.php index 8c4181c48a0..228cd875603 100644 --- a/rules/TypeDeclaration/TypeInferer/SilentVoidResolver.php +++ b/rules/TypeDeclaration/TypeInferer/SilentVoidResolver.php @@ -12,7 +12,9 @@ use PhpParser\Node\Expr\Yield_; use PhpParser\Node\Expr\YieldFrom; use PhpParser\Node\FunctionLike; use PhpParser\Node\Stmt; +use PhpParser\Node\Stmt\Break_; use PhpParser\Node\Stmt\ClassMethod; +use PhpParser\Node\Stmt\Continue_; use PhpParser\Node\Stmt\Do_; use PhpParser\Node\Stmt\Else_; use PhpParser\Node\Stmt\Expression; @@ -90,12 +92,21 @@ final class SilentVoidResolver if ($this->isIfReturn($stmt)) { return \true; } - if ($stmt instanceof Do_ && $this->hasStmtsAlwaysReturnOrExit($stmt->stmts)) { + if ($stmt instanceof Do_ && $this->isDoWithAlwaysReturnOrExit($stmt)) { return \true; } } 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 */ diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 4b1c3635e26..6ddfc70b5a4 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -19,12 +19,12 @@ final class VersionResolver * @api * @var string */ - public const PACKAGE_VERSION = 'aac889be3d845974d3ab924ff7ad22784b9e3cb5'; + public const PACKAGE_VERSION = '879feb8931f1465fa463d539e9ce99ebfae4e948'; /** * @api * @var string */ - public const RELEASE_DATE = '2024-03-23 23:47:25'; + public const RELEASE_DATE = '2024-03-23 20:30:55'; /** * @var int */