Le 18/10/2023 à 17:37, Robert Landers a écrit :
That is all I want whenever I think of Generics in PHP. The rest is
just complicated fluff in my humble opinion.

Where I respectfully disagree is about exactly this: you would appreciate array<string>, I would very much appreciate SomeDoctrineRepository<SomeEntity> so that my IDE would actually give me the right autocompletion.

There's also another use where it would get even better:

```

EntityManager::find(Query<T>): T

class SomeQuery implements Query<SomeEntity> {}

// Later in code:

$someEntity = $entityManager->get(new SomeQuery())

assert($someEntity instanceof T); // Is now useless, my IDE simply knows.

```

There are many simple use case that can make our life easier, outside of simply array, lists, vectors etc...

Even if type erasure is done and there no runtime checks, it would greatly help when correctly done at the right place by userland APIs. ORM's are one place, but there are many others.

Regards,

--

Pierre

Reply via email to