You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PHPDoc array shape is enforced as closed: an extra key is a compile error #538
A PHPDoc array shape is treated as closed: passing an array with an extra key is a compile error. PHP ignores the docblock, and PHPStan accepts extra keys in an array{...} shape unless it is sealed.
line 5: error: __main(): argument 1 to names() — element array{name:string,extra:string} given, array{name:string} expected: key extra is not in the shape
compile: front-end (parse/typeck/IR) returned null (rc=65)
Real code often passes a richer array to a function documented with fewer keys, so this stops otherwise valid libraries from compiling. Could extra keys be accepted here: dropped, kept in a bag, or reported as a warning? Related, but not the same: #157.
Manticore 0.17.0 (ghcr.io/manticorephp/compiler:latest, image built 2026-10-24, Linux x86_64). PHP reference: 8.5.4.
I consider this a bug for now. However, it was intentional. Annotations suggest to the compiler that the array shape has a stable structure.
But I believe the type check could be softened in such particular cases, and a warning could be produced at compile time. I feel we should have a flag to enforce strict shapes during compilation.
Activity
blacktrs commentedon Oct 30, 2026
I consider this a bug for now. However, it was intentional. Annotations suggest to the compiler that the array shape has a stable structure.
But I believe the type check could be softened in such particular cases, and a warning could be produced at compile time. I feel we should have a flag to enforce strict shapes during compilation.