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
One of the previously proposed solution was to make each key of the array optional: but this would mean it's legal to return a partial array which is not the intent here.
Another solution, as a workaround, was to declare it e.g. array{foo:string,bar:string,baz:string,daz:string}|array{dummy?:null}
But in the this begs the question: since we already have the great array shape type documentator:
Although myself I don't understand why do you need to typehint a function that always returns an empty array - at that point you know you can replace the call with []. Such function is of very little usefulness....
I don't understand why do you need to typehint a function that always returns an empty array
But it's not "always", see my example!
Basically it's a legacy / idiotic behaviour 😼 to return [] instead of e.g. null which obviously would be more idiomatic but, again, I'm talking about legacy code here.
Feature request
I brought this previously up #2739 but it was closed without action.
I would like to bring this up once more, the necessity to have:
array{foo:string,bar:string,baz:string,daz:string}
Example
One of the previously proposed solution was to make each key of the array optional: but this would mean it's legal to return a partial array which is not the intent here.
Another solution, as a workaround, was to declare it e.g.
array{foo:string,bar:string,baz:string,daz:string}
|
array{dummy?:null}
But in the this begs the question: since we already have the great array shape type documentator:
It seems it would fit it very nicely. This was suggested by @adaamz in #2739 (comment)
Thank you for reconsidering!
The text was updated successfully, but these errors were encountered: