[php-src] PR #18260: [PoC] Associated types
| From: | Girgias | Date: | Sun, 06 Apr 2025 04:46:34 +0000 |
| Subject: | [php-src] PR #18260: [PoC] Associated types | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-31333@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/18260
Author: Girgias
This is a proof of concept for associated types which are resolved at compile time.
Although these are not generics, they do solve the case of template types in interfaces, as generic
types bound to an interface are isomorphic to associated types.
## Implementation
Depends on:
- #18257
- #18256
The implementation currently is very crude and basic, but it demonstrates the concept of it
nonetheless.
Currently, I am forcing the associated type to be invariant, as I haven't really though about
how sensible it would be to have different types and how to decide which one should be the bound
one.
This basic PoC also does not support anything relating to an interface extending another interface
that has associated types, although I have an idea how it should work.
## Benefits
This would bring somewhat better semantics for the new interfaces of my [Container/Offset
RFC](https://github.com/php/php-src/pull/14920)