(RFC) Implement template default syntax#148
Conversation
71d2dac to
3c43569
Compare
|
/cc @orklah Does Psalm already have this / would you be interested too? |
|
Psalm doesn't have this but it could be interesting (especially because Psalm sometimes struggle to assign values to classes with templates that were never properly created) I doubt I'll be in position to implement this myself anytime soon though |
|
Alright, I'm fine with going ahead with this. But what the syntax should be? The issue proposes a separate How would the syntax proposed here for |
|
I've taken the syntax from TypeScript. At least C++ also uses this syntax, but I haven't looked at other languages. Because the default value is tightly coupled to the type parameter (just like the bound is), I don't think it's a good idea to have a separate tag for it. |
|
Nice, it makes sense to me. Could you also please submit a proof of concept to phpstan-src to make sure these are not released with a big time gap between them? :) Thank you. What we need to think about is modifying the rules here https://github.com/phpstan/phpstan-src/tree/1.8.x/src/Rules/Generics for this new feature:
|
96c7c66 to
f3e2a98
Compare
|
Thank you! |
|
Nice to see this merged. 🎉 🚀 |
Proof-of-concept implementation for template default syntax (for phpstan/phpstan#4801)