-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
Description
Bug report
After upgrading to phpstan 2.1.18, I get this error:
Property name for mixed must be a string, but 'example_one'|'example_two' was given.
🪪 property.nameNotString
example snippet:
...
$field = $condition ? 'example_one' : 'example_two';
$result = $object->$field;
I believe those are both strings. Probably it does not recognize specific literals as strings?
This happened in:
php: 8.4
phpstan: 2.1.18
level: 1
Code snippet that reproduces the problem
https://phpstan.org/r/1bc5bdd8-63ae-4f3f-8fd5-605998483ed1
Expected output
Both strings should be valid as strings, expected no error.
Did PHPStan help you today? Did it make you happy in any way?
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels