Open stancl opened 5 years ago
So this is basically adding union types and type hinted arrays.
I am not sure I am such a big fan of the key value syntax. Writing
Product[string]
Doesn't seem so clear that string
is the key type. What about using the phpdoc way?
array<string, Product>
However I like your syntax when we don't use custom keys
I am not sure I am such a big fan of the key value syntax
Yeah, It's a bit confusing to read, since the key comes after the value. But I think it's some convention.
What about using the phpdoc way?
array<string, Product>
Is this the phpdoc way? I haven't seen this yet.
Some people also do this:
array[string]Product
@stancl sorry, it's the Psalm way. https://psalm.dev/docs/annotating_code/type_syntax/array_types/
I see. Psalm uses Foo[]
and array<Foo, Bar>
so it's already a bit standardized. I agree we should go with that. Updated my original comment.
|
in typehintsCollection
ofProduct
s" (so aCollection
with the first constructor argument being of typeProduct[]
), but I have no idea how that should be notated.