phpstan / phpstan-symfony

Symfony extension for PHPStan
MIT License
698 stars 89 forks source link

Fix internal error when DIC param map has > 256 items #402

Closed janedbal closed 4 weeks ago

janedbal commented 1 month ago

The failure happened here.


Generally, this feels like a trap inside PHPStan. If any ConstantArrayType will fail when used in implode or just with any usage of TypeUtils::flattenTypes, it is just not safe to create it by constructor and the degradation logic in ConstantArrayTypeBuilder should be imo moved to ConstantArrayType constructor.

Or maybe just getAllArrays needs to be fixed? IDK where is the proper place to fix this.

ondrejmirtes commented 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.