ramsey / uuid-doctrine

:snowflake::file_cabinet: Allow the use of a ramsey/uuid UUID as Doctrine field type.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support other types of `EntityManagerInterface` too

NoelLH opened this issue · comments

Support any EntityManagerInterface

Background/problem

Currently, only EntityManager can be used for UUIDs, even though modern versions of Doctrine define and encourage use of an EntityManagerInterface which may be implemented by different subclasses too.

Proposal/solution

Support any EntityManagerInterface at least in new generateId() methods, mirroring those added in the base AbstractIdGenerator.

I suggest this targets a new major release, which also opens up the possibility of expanding the existing methods to the more general type (requires PHP 7.4+) and also providing modern apps with better type hinting, autocompletion etc. The PR I am working on would therefore drop support for older PHPs which are already out of security support.

Alternatives

The same but without making any changes to the generate() methods and possibly not deprecating them. This could allow for the continuation of support for old PHP versions even though they are out of security support.

Additional context

I am using our fork of uuid-doctrine temporarily in this PR, which shows why our latest use case necessitates support for a less strict EM type: thebiggive/matchbot#338

@NoelLH I merged in your PR (#180) and have released this as part of 2.0.0. Thanks!

@NoelLH I merged in your PR (#180) and have released this as part of 2.0.0. Thanks!

Nice, thanks @ramsey!