diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 598c1832162..b43f40f15a2 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 = '33d12b758ef5726ae7cc174ef7fcac627cc71dea'; + public const PACKAGE_VERSION = 'bf5270a8456ec1c6e45bbcaa8ad2aab6b5a4dfb6'; /** * @api * @var string */ - public const RELEASE_DATE = '2024-12-11 23:43:12'; + public const RELEASE_DATE = '2024-12-12 00:08:37'; /** * @var int */ diff --git a/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php b/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php index ae869aee1f9..bb8ff228ff7 100644 --- a/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php +++ b/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php @@ -63,7 +63,9 @@ use PhpParser\Node\Stmt\Class_; use PhpParser\Node\Stmt\ClassConst; use PhpParser\Node\Stmt\ClassLike; use PhpParser\Node\Stmt\ClassMethod; +use PhpParser\Node\Stmt\Do_; use PhpParser\Node\Stmt\Echo_; +use PhpParser\Node\Stmt\ElseIf_; use PhpParser\Node\Stmt\Enum_; use PhpParser\Node\Stmt\EnumCase; use PhpParser\Node\Stmt\Expression; @@ -71,6 +73,7 @@ use PhpParser\Node\Stmt\Finally_; use PhpParser\Node\Stmt\For_; use PhpParser\Node\Stmt\Foreach_; use PhpParser\Node\Stmt\Function_; +use PhpParser\Node\Stmt\If_; use PhpParser\Node\Stmt\Interface_; use PhpParser\Node\Stmt\Property; use PhpParser\Node\Stmt\Return_; @@ -78,6 +81,7 @@ use PhpParser\Node\Stmt\Switch_; use PhpParser\Node\Stmt\Trait_; use PhpParser\Node\Stmt\TryCatch; use PhpParser\Node\Stmt\Unset_; +use PhpParser\Node\Stmt\While_; use PhpParser\Node\UnionType; use PhpParser\NodeTraverser; use PHPStan\Analyser\MutatingScope; @@ -319,6 +323,10 @@ final class PHPStanNodeScopeResolver $this->processEcho($node, $mutatingScope); return; } + if ($node instanceof If_ || $node instanceof ElseIf_ || $node instanceof Do_ || $node instanceof While_) { + $node->cond->setAttribute(AttributeKey::SCOPE, $mutatingScope); + return; + } }; try { $this->nodeScopeResolverProcessNodes($stmts, $scope, $nodeCallback); @@ -452,6 +460,7 @@ final class PHPStanNodeScopeResolver } private function processSwitch(Switch_ $switch, MutatingScope $mutatingScope) : void { + $switch->cond->setAttribute(AttributeKey::SCOPE, $mutatingScope); // decorate value as well foreach ($switch->cases as $case) { $case->setAttribute(AttributeKey::SCOPE, $mutatingScope);