From d9befc093eb26bbc97117c46baeb3b1c6f8fb68a Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Mon, 4 Apr 2022 23:04:01 +0200 Subject: [PATCH] Make *EventArgs generic --- src/Persistence/Event/LifecycleEventArgs.php | 9 ++++++++- .../Event/LoadClassMetadataEventArgs.php | 17 ++++++++++++----- src/Persistence/Event/ManagerEventArgs.php | 11 ++++++++++- src/Persistence/Event/OnClearEventArgs.php | 9 ++++++++- src/Persistence/Event/PreUpdateEventArgs.php | 4 ++++ 5 files changed, 42 insertions(+), 8 deletions(-) diff --git a/src/Persistence/Event/LifecycleEventArgs.php b/src/Persistence/Event/LifecycleEventArgs.php index a8630cff..e96097f1 100644 --- a/src/Persistence/Event/LifecycleEventArgs.php +++ b/src/Persistence/Event/LifecycleEventArgs.php @@ -8,10 +8,15 @@ /** * Lifecycle Events are triggered by the UnitOfWork during lifecycle transitions * of entities. + * + * @template TObjectManager of ObjectManager */ class LifecycleEventArgs extends EventArgs { - /** @var ObjectManager */ + /** + * @var ObjectManager + * @psalm-var TObjectManager + */ private $objectManager; /** @var object */ @@ -19,6 +24,7 @@ class LifecycleEventArgs extends EventArgs /** * @param object $object + * @psalm-param TObjectManager $objectManager */ public function __construct($object, ObjectManager $objectManager) { @@ -52,6 +58,7 @@ public function getObject() * Retrieves the associated ObjectManager. * * @return ObjectManager + * @psalm-return TObjectManager */ public function getObjectManager() { diff --git a/src/Persistence/Event/LoadClassMetadataEventArgs.php b/src/Persistence/Event/LoadClassMetadataEventArgs.php index 642d20b3..617b2905 100644 --- a/src/Persistence/Event/LoadClassMetadataEventArgs.php +++ b/src/Persistence/Event/LoadClassMetadataEventArgs.php @@ -8,20 +8,27 @@ /** * Class that holds event arguments for a loadMetadata event. + * + * @template TClassMetadata of ClassMetadata + * @template TObjectManager of ObjectManager */ class LoadClassMetadataEventArgs extends EventArgs { /** * @var ClassMetadata - * @psalm-var ClassMetadata + * @psalm-var TClassMetadata */ private $classMetadata; - /** @var ObjectManager */ + /** + * @var ObjectManager + * @psalm-var TObjectManager + */ private $objectManager; /** - * @psalm-param ClassMetadata $classMetadata + * @psalm-param TClassMetadata $classMetadata + * @psalm-param TObjectManager $objectManager */ public function __construct(ClassMetadata $classMetadata, ObjectManager $objectManager) { @@ -33,7 +40,7 @@ public function __construct(ClassMetadata $classMetadata, ObjectManager $objectM * Retrieves the associated ClassMetadata. * * @return ClassMetadata - * @psalm-return ClassMetadata + * @psalm-return TClassMetadata */ public function getClassMetadata() { @@ -43,7 +50,7 @@ public function getClassMetadata() /** * Retrieves the associated ObjectManager. * - * @return ObjectManager + * @return TObjectManager */ public function getObjectManager() { diff --git a/src/Persistence/Event/ManagerEventArgs.php b/src/Persistence/Event/ManagerEventArgs.php index 510aff27..cde3ab9d 100644 --- a/src/Persistence/Event/ManagerEventArgs.php +++ b/src/Persistence/Event/ManagerEventArgs.php @@ -7,12 +7,20 @@ /** * Provides event arguments for the preFlush event. + * + * @template TObjectManager of ObjectManager */ class ManagerEventArgs extends EventArgs { - /** @var ObjectManager */ + /** + * @var ObjectManager + * @psalm-var TObjectManager + */ private $objectManager; + /** + * @psalm-param TObjectManager $objectManager + */ public function __construct(ObjectManager $objectManager) { $this->objectManager = $objectManager; @@ -22,6 +30,7 @@ public function __construct(ObjectManager $objectManager) * Retrieves the associated ObjectManager. * * @return ObjectManager + * @psalm-return TObjectManager */ public function getObjectManager() { diff --git a/src/Persistence/Event/OnClearEventArgs.php b/src/Persistence/Event/OnClearEventArgs.php index 97991f95..e3809e27 100644 --- a/src/Persistence/Event/OnClearEventArgs.php +++ b/src/Persistence/Event/OnClearEventArgs.php @@ -10,10 +10,15 @@ /** * Provides event arguments for the onClear event. + * + * @template TObjectManager of ObjectManager */ class OnClearEventArgs extends EventArgs { - /** @var ObjectManager */ + /** + * @var ObjectManager + * @psalm-var TObjectManager + */ private $objectManager; /** @var string|null */ @@ -22,6 +27,7 @@ class OnClearEventArgs extends EventArgs /** * @param ObjectManager $objectManager The object manager. * @param string|null $entityClass The optional entity class. + * @psalm-param TObjectManager $objectManager */ public function __construct($objectManager, $entityClass = null) { @@ -42,6 +48,7 @@ public function __construct($objectManager, $entityClass = null) * Retrieves the associated ObjectManager. * * @return ObjectManager + * @psalm-return TObjectManager */ public function getObjectManager() { diff --git a/src/Persistence/Event/PreUpdateEventArgs.php b/src/Persistence/Event/PreUpdateEventArgs.php index 177d9445..dc8a244c 100644 --- a/src/Persistence/Event/PreUpdateEventArgs.php +++ b/src/Persistence/Event/PreUpdateEventArgs.php @@ -10,6 +10,9 @@ /** * Class that holds event arguments for a preUpdate event. + * + * @template TObjectManager of ObjectManager + * @extends LifecycleEventArgs */ class PreUpdateEventArgs extends LifecycleEventArgs { @@ -19,6 +22,7 @@ class PreUpdateEventArgs extends LifecycleEventArgs /** * @param object $entity * @param mixed[][] $changeSet + * @psalm-param TObjectManager $objectManager */ public function __construct($entity, ObjectManager $objectManager, array &$changeSet) {