Skip to content

Breaks in if/elseif/else with value set should bleed into parent scope #1946

@muglug

Description

@muglug
$tag = null;
foreach (["a", "b", "c"] as $tag) {
	if ($tag === "a") {
		$tag = null;
		break;
	} else {
		$tag = null;
		break;
	}
}

echo strlen($tag);

Expected: Parameter #1 $string of function strlen expects string, null given
Actual: No issues (on level 1-6), complaint about string|null on level 7

https://phpstan.org/r/1a0e1498-6389-49fc-8d61-6ad930f6c3bc

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions