Skip to content

Switch with continue doesn't define type below #1945

@muglug

Description

@muglug
foreach (["a", "b", "c"] as $letter) {
	switch ($letter) {
		case "b":
			$foo = 1;
			break;
		case "c":
			$foo = 2;
			break;
		default:
			continue 2;
	}

	$moo = $foo;
}

Expected: No issue
Actual: Variable $foo might not be defined

https://phpstan.org/r/154c430f-fbd1-4e5e-9fd5-6f3b403b5e2e

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions