Skip to content

Dynamic property fetch is smartish but could be smarter #12398

@rudiedirkx

Description

@rudiedirkx

Bug report

Phpstan is super smart about combined strings, and that dynamic string as a property name, see 👍 in example. But then when I ask it what the type is, Phpstan goes with mixed? Come ooon, you know the property, you know if it exists, you know the possible types!

Code snippet that reproduces the problem

https://phpstan.org/r/5da6f64c-15d7-44bd-82a8-3cf3ec370130

Expected output

That should be a union type. In this example not even, because they're all int. Pretty smart, but it could be a little smarter. Maybe it's too expensive to do multiple property type checks? No idea what this would entail, but I feel it could be smarter.

Did PHPStan help you today? Did it make you happy in any way?

Stan keeps surprising me with its smartness, I love it. "Could it understand this?" Yep! (Except sometimes ;))

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions