Comment by Timon3
9 days ago
> PHP type system is lacking but I wouldn't call it minimal.
PHP still doesn't have generics, right? IMO any type system without higher-order types is definitely on the minimal side.
9 days ago
> PHP type system is lacking but I wouldn't call it minimal.
PHP still doesn't have generics, right? IMO any type system without higher-order types is definitely on the minimal side.
Natively: no. Via tools like phpstan and psalm: yes, per OP. Link to relevant docs: https://psalm.dev/docs/annotating_code/templated_annotations... or https://phpstan.org/blog/generics-by-examples
One can declare:
You can even bind a template by a generic type with "of":
Yeah, static analyzers have been filling this gap quite nicely for long time, but GP was explicitly excluding those, no?
yeah, it is a real pain in the ass. imagine if php 8 accepted the RFC for generics