Closed janedbal closed 4 weeks ago
I feel like we should make a rule in PHPStan so that ConstantArrayTypeBuilder is used instead of new ConstantArrayType
when the size of the created array is unknown. Because:
should be imo moved to ConstantArrayType constructor.
That's too late, you can't return a different type from a class constructor.
Otherwise I think this is the right fix. Thank you.
The failure happened here.
Generally, this feels like a trap inside PHPStan. If any
ConstantArrayType
will fail when used inimplode
or just with any usage ofTypeUtils::flattenTypes
, it is just not safe to create it by constructor and the degradation logic inConstantArrayTypeBuilder
should be imo moved toConstantArrayType
constructor.Or maybe just
getAllArrays
needs to be fixed? IDK where is the proper place to fix this.