-
-
Notifications
You must be signed in to change notification settings - Fork 942
Closed
phpstan/phpstan-src
#3965Description
Bug report
It looks like setting a new property value (after checking its value in an if) does not change the type that PHPStan expects it to be. On local variables works as expected.
if (! $this->code) {
$this->code = stringOrNull();
$otherVar = stringOrNull();
\PHPStan\dumpType($this->code);
// Dumped type: ''|'0'|null
\PHPStan\dumpType($otherVar);
// Dumped type: string|null
}Problem occurs in PHPStan 2.1.13. No problem in 2.1.12.
Code snippet that reproduces the problem
https://phpstan.org/r/17149323-3d3f-49e8-af7c-8548cbe95d3e
Expected output
Both dumped types should be the same - string|null
Did PHPStan help you today? Did it make you happy in any way?
PHPStan made our codebase a lot more pleasant to work with (and eliminated a lot of errors). It is a must have for all my projects. Thank you!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels