Replies: 1 comment
-
I don't think Taylor will be a big fan of those as it adds maintenance and the requirement of making a toArray method for each new method that returns a new collection instance with the modified data. Also, there are more places where type hinting gets lost in the Collection method chaining. Looking at the code, the collect method on the Enumerable interface and EnumeratesValues class both use <TKey, TValue>, can't we just do the same with toArray on at least the Collection class? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Currently, some methods within the Collection class have their return types defined with generics in PHPDoc, which allows static analysis tools to recognize the specific data structures within the returned Collection. However, once the
toArray()
method is called, these data structures are transformed intoarray<Tkey, mixed>
, resulting in the loss of the originally recognizable structure information. My idea is to add somexxxToArray()
methods and accurately annotate them in PHPDoc, to avoid the need for manually adding inline PHPDoc in the code to indicate the array structure.Example:
Beta Was this translation helpful? Give feedback.
All reactions