Clarifications on when array shapes are enforced #7004
-
Hi, I have pretty much a beginner question. This confused me the second time already :) Just showing a snippet is easier to understand, see https://phpstan.org/r/77a8e65b-dd07-4c4b-bc8c-76a32243d553 |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
I guess https://phpstan.org/writing-php-code/phpdoc-types#array-shapes
explains everything. God, but I think I fell the second time into the array shape inside general array trap :/ |
Beta Was this translation helpful? Give feedback.
-
looking for the same t the moment. defining nested array. not much examples found. not really willed defined exact matches of array which then not scale when adding or removing stuff because one has to update the annotations everywhere... hmm. may be we dont know better at the moment |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
Foo::fromArray1($data);
could/should report an error on level 9 but I guess that$data
consists of ArrayType with implicit MixedType, not explicit MixedType. It can be seen inIsArrayFunctionTypeSpecifyingExtension
. My bet is that if you modify that to return explicit MixedType, the error is going to be reported.