-
Notifications
You must be signed in to change notification settings - Fork 23
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
Change array<int...> to list<...> in PHP doc #114
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
parameters: | ||
level: 9 | ||
phpVersion: 70430 # PHP 7.4.30 | ||
typeAliases: | ||
IntervalStatus: 'array{0:string, 1:boolean}' | ||
Comment on lines
+4
to
+5
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @staabm I found that I could not use a local type alias because of:
So I made a global type alias. That works everywhere. But will doing that be an issue for consumers of this? They will use PHPstan to analyse their use of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The older issue is phpstan/phpstan#9164 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the global type aliases will not work for library consumers. not sure this is worth it since the functions/methods involved with this type are the actual api surface of our package. I think we should stop using it until phpstan supports using the local alias properly for functions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
ignoreErrors: | ||
- | ||
message: "#^If condition is always true.$#" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure this will work with named arguments. do we have a test-case for that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I change to
array<int|string, mixed>
then phpstan complains:phpstan thinks that the PHP function
call_user_func_array
must be passed just a "list" array (int keys).But https://w ww.php.net/manual/en/function.call-user-func-array.php says:
"If any keys of args are strings, those elements will be passed to callback as named arguments, with the name given by the key."
Maybe phpstan needs to be adjusted so that it knows what can be passed to
call_user_func_array
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests only have cases with a single unnamed argument. Named arguments only became a thing in PHP 8.0 (I think). So that will be why there are no test cases for it.
Hmmm - so maybe the phpstan thing in comment above is because I am running phpstan on PHP 7.4.
I think that the code will "just work". But annotations and test case(s) will have to apply only for PHP 8.
Should we try to add official support for named arguments now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember working on this topic in phpstan/phpstan-src#2501 months ago
its a open issue: phpstan/phpstan#5934