Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make *EventArgs generic #273

Merged
merged 1 commit into from
Apr 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/Persistence/Event/LifecycleEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,23 @@
/**
* 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 */
private $object;

/**
* @param object $object
* @psalm-param TObjectManager $objectManager
*/
public function __construct($object, ObjectManager $objectManager)
{
Expand Down Expand Up @@ -52,6 +58,7 @@ public function getObject()
* Retrieves the associated ObjectManager.
*
* @return ObjectManager
* @psalm-return TObjectManager
*/
public function getObjectManager()
{
Expand Down
17 changes: 12 additions & 5 deletions src/Persistence/Event/LoadClassMetadataEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,27 @@

/**
* Class that holds event arguments for a loadMetadata event.
*
* @template TClassMetadata of ClassMetadata<object>
* @template TObjectManager of ObjectManager
*/
class LoadClassMetadataEventArgs extends EventArgs
{
/**
* @var ClassMetadata
* @psalm-var ClassMetadata<object>
* @psalm-var TClassMetadata
*/
private $classMetadata;

/** @var ObjectManager */
/**
* @var ObjectManager
* @psalm-var TObjectManager
*/
private $objectManager;

/**
* @psalm-param ClassMetadata<object> $classMetadata
* @psalm-param TClassMetadata $classMetadata
* @psalm-param TObjectManager $objectManager
*/
public function __construct(ClassMetadata $classMetadata, ObjectManager $objectManager)
{
Expand All @@ -33,7 +40,7 @@ public function __construct(ClassMetadata $classMetadata, ObjectManager $objectM
* Retrieves the associated ClassMetadata.
*
* @return ClassMetadata
* @psalm-return ClassMetadata<object>
* @psalm-return TClassMetadata
*/
public function getClassMetadata()
{
Expand All @@ -43,7 +50,7 @@ public function getClassMetadata()
/**
* Retrieves the associated ObjectManager.
*
* @return ObjectManager
* @return TObjectManager
*/
public function getObjectManager()
{
Expand Down
11 changes: 10 additions & 1 deletion src/Persistence/Event/ManagerEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -22,6 +30,7 @@ public function __construct(ObjectManager $objectManager)
* Retrieves the associated ObjectManager.
*
* @return ObjectManager
* @psalm-return TObjectManager
*/
public function getObjectManager()
{
Expand Down
9 changes: 8 additions & 1 deletion src/Persistence/Event/OnClearEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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)
{
Expand All @@ -42,6 +48,7 @@ public function __construct($objectManager, $entityClass = null)
* Retrieves the associated ObjectManager.
*
* @return ObjectManager
* @psalm-return TObjectManager
*/
public function getObjectManager()
{
Expand Down
4 changes: 4 additions & 0 deletions src/Persistence/Event/PreUpdateEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

/**
* Class that holds event arguments for a preUpdate event.
*
* @template TObjectManager of ObjectManager
* @extends LifecycleEventArgs<TObjectManager>
*/
class PreUpdateEventArgs extends LifecycleEventArgs
{
Expand All @@ -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)
{
Expand Down