Introduce EventManagerInterface

In theory, having small interfaces is great, but in practice, migrating
the ORM to them would involve DNF types, which are not available with
PHP 8.1, for use in e.g. the constructor of EntityManager.

    public function __construct(
        private Connection $conn,
        private Configuration $config,
-       EventManager|null $eventManager = null,
+       (EventListenerIntrospector&EventListenerRegistry&EventSubscriberRegistry)|null $eventManager = null,
    ) {
This commit is contained in:
Grégoire Paris
2026-01-24 14:23:43 +01:00
parent c1132f38e6
commit b77c5c8980
3 changed files with 18 additions and 4 deletions

View File

@@ -17,6 +17,10 @@
<rule ref="Doctrine" />
<rule ref="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming.SuperfluousSuffix">
<exclude-pattern>src/EventManagerInterface.php</exclude-pattern>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint">
<!-- This interface is commonly implemented by userland code.
We omit the return type to ease the migration to 2.0 -->

View File

@@ -11,10 +11,7 @@ use function spl_object_id;
* Listeners are registered on the manager and events are dispatched through the
* manager.
*/
class EventManager implements
EventListenerIntrospector,
EventListenerRegistry,
EventSubscriberRegistry
class EventManager implements EventManagerInterface
{
/**
* Map of registered listeners.

View File

@@ -0,0 +1,13 @@
<?php
declare(strict_types=1);
namespace Doctrine\Common;
/** Provided for convenience, but consider using the individual interfaces directly. */
interface EventManagerInterface extends
EventListenerIntrospector,
EventListenerRegistry,
EventSubscriberRegistry
{
}