Re: Blog post: If we can get partial generics, should we?
| From: | Vinicius Dias | Date: | Mon, 04 Aug 2025 17:02:07 +0000 |
| Subject: | Re: Blog post: If we can get partial generics, should we? | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-128387@lists.php.net to get a copy of this message | ||
I'm not a voter nor part of the internals, but I'd say "yes", for sure.
One thing that came to mind while reading the article (keep in mind
that I don't have any knowledge on the internals of PHP, so if it's a
dumb question, sorry about that):
Would it be possible to transform (in compile-time), the first option
(that isn't supported) into the second one?
```
// Turning this:
$blogPostRepository = new BaseRepository<BlogPost>();
// Into this:
$blogPostRepository = new class extends BaseRepository<BlogPost> { };
```
If this is possible, although I know it's not ideal, it would allow us
to have that syntax and we wouldn't need to manually create "empty
extending classes".