-
Notifications
You must be signed in to change notification settings - Fork 64
Add multiline generic support #44
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
Add multiline generic support #44
Conversation
@@ -3046,6 +3046,30 @@ public function provideRealWorldExampleData(): \Iterator | |||
), | |||
]), | |||
]; | |||
|
|||
yield [ |
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.
Please add these tests that check for:
- That trailing comma after last element is allowed
- That leading comma at the beginning of the line is also allowed (I know it's ugly but I've seen it in the wild).
Thank you, otherwise 👍
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.
Ah, sure thing. Will do 👍
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.
Just a quick question, trailing comma should not work at all am I right?
array<A, B,>
is not a correct notation
Where as the leading one should be fine, as long as there are two types given
array<
A
, B
>
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.
(Kotlin allows trailing comma in generic declarations since 1.4).
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.
Trailing commas are getting popular and even supported by PHP itself. Since this works: https://phpstan.org/r/e1c07184-7f6d-48ba-99cd-29dd41fe5349, I'm also fine if it will work in generics.
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.
We shouldn't support multiple trailing commas: A,B,,
- that should be an error, otherwise they're fine.
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.
Thanks for informations. Will add support for them then :)
Awesome, love it :) |
Released as 0.4.7, but will probably take a few days to be baked into the next release of PHPStan :) |
Thanks 🥳 |
Closes phpstan#46. Tests are basically copied and modified from phpstan#44
Closes phpstan#46. Tests are basically copied and modified from phpstan#44
Solve #42