-
-
Notifications
You must be signed in to change notification settings - Fork 863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to type hint truly empty arrays #5159
Comments
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 but it was easy enough to implement it so I did it: phpstan/phpdoc-parser@ea0b174 + phpstan/phpstan-src@d36852a |
Thank you!
But it's not "always", see my example! Basically it's a legacy / idiotic behaviour 😼 to return |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
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: