Bug report
In this test case, we know that assigning anything that isn't a string to $this->name will throw a TypeError, or coerce it to the correct type.
Therefore, the type inference by PHPStan is behaving wrongly, as if the property didn't have a static type.
Code snippet that reproduces the problem
https://phpstan.org/r/8018a918-f830-4b9a-8b1e-315958276fef
Expected output
No errors should be reported. $this->name is guaranteed to be some subtype of string (or uninitialized) no matter what inputs are given to the function, since PHP will bail out if the type is wrong.
Did PHPStan help you today? Did it make you happy in any way?
No response