Bug report
PHPStan is throwing a type mismatch error in a situation where I've made sure through the code that a variable will always be a string when it's supposed to.
Basically, I have a function that can return either a string or false based on some conditions. Then, in my code, I double-check: if it's false, I change it to a string before it goes anywhere else. Despite this, PHPStan still flags it as an error, saying I'm giving it a string|false when it only wants a string.
It looks like PHPStan isn't catching on to the fact that I've covered all bases to ensure it ends up as a string. Or maybe it's me that miss something ?
Code snippet that reproduces the problem
https://phpstan.org/r/66832249-9deb-42cf-af71-1d72850dcbc5
Expected output
Phpstan see it's a string
Did PHPStan help you today? Did it make you happy in any way?
Like always, it's a must have for all my php project. Thanks
Bug report
PHPStan is throwing a type mismatch error in a situation where I've made sure through the code that a variable will always be a string when it's supposed to.
Basically, I have a function that can return either a string or false based on some conditions. Then, in my code, I double-check: if it's false, I change it to a string before it goes anywhere else. Despite this, PHPStan still flags it as an error, saying I'm giving it a string|false when it only wants a string.
It looks like PHPStan isn't catching on to the fact that I've covered all bases to ensure it ends up as a string. Or maybe it's me that miss something ?
Code snippet that reproduces the problem
https://phpstan.org/r/66832249-9deb-42cf-af71-1d72850dcbc5
Expected output
Phpstan see it's a string
Did PHPStan help you today? Did it make you happy in any way?
Like always, it's a must have for all my php project. Thanks