From 3ebed101fdc6a0aeb32e26aca9bfd7f3bd9a3caa Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Mon, 4 Feb 2013 20:45:58 +0100 Subject: [PATCH 1/2] Strong typehinting to avoid incorrect constructor params --- lib/Doctrine/ORM/Event/OnClearEventArgs.php | 4 +++- lib/Doctrine/ORM/Event/OnFlushEventArgs.php | 3 ++- lib/Doctrine/ORM/Event/PreFlushEventArgs.php | 13 ++++++++----- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/Doctrine/ORM/Event/OnClearEventArgs.php b/lib/Doctrine/ORM/Event/OnClearEventArgs.php index 23520ed2a..3a29680f7 100644 --- a/lib/Doctrine/ORM/Event/OnClearEventArgs.php +++ b/lib/Doctrine/ORM/Event/OnClearEventArgs.php @@ -19,6 +19,8 @@ namespace Doctrine\ORM\Event; +use Doctrine\ORM\EntityManager; + /** * Provides event arguments for the onClear event. * @@ -46,7 +48,7 @@ class OnClearEventArgs extends \Doctrine\Common\EventArgs * @param \Doctrine\ORM\EntityManager $em * @param string|null $entityClass Optional entity class. */ - public function __construct($em, $entityClass = null) + public function __construct(EntityManager $em, $entityClass = null) { $this->em = $em; $this->entityClass = $entityClass; diff --git a/lib/Doctrine/ORM/Event/OnFlushEventArgs.php b/lib/Doctrine/ORM/Event/OnFlushEventArgs.php index 744ae18fe..ea5d0566e 100644 --- a/lib/Doctrine/ORM/Event/OnFlushEventArgs.php +++ b/lib/Doctrine/ORM/Event/OnFlushEventArgs.php @@ -19,6 +19,7 @@ namespace Doctrine\ORM\Event; +use Doctrine\Common\EventArgs; use Doctrine\ORM\EntityManager; /** @@ -30,7 +31,7 @@ use Doctrine\ORM\EntityManager; * @author Roman Borschel * @author Benjamin Eberlei */ -class OnFlushEventArgs extends \Doctrine\Common\EventArgs +class OnFlushEventArgs extends EventArgs { /** * @var \Doctrine\ORM\EntityManager diff --git a/lib/Doctrine/ORM/Event/PreFlushEventArgs.php b/lib/Doctrine/ORM/Event/PreFlushEventArgs.php index 02798e1a3..bfee5c76e 100644 --- a/lib/Doctrine/ORM/Event/PreFlushEventArgs.php +++ b/lib/Doctrine/ORM/Event/PreFlushEventArgs.php @@ -19,6 +19,9 @@ namespace Doctrine\ORM\Event; +use Doctrine\Common\EventArgs; +use Doctrine\ORM\EntityManager; + /** * Provides event arguments for the preFlush event. * @@ -28,21 +31,21 @@ namespace Doctrine\ORM\Event; * @author Roman Borschel * @author Benjamin Eberlei */ -class PreFlushEventArgs extends \Doctrine\Common\EventArgs +class PreFlushEventArgs extends EventArgs { /** * @var \Doctrine\ORM\EntityManager */ - private $_em; + private $em; /** * Constructor. * * @param \Doctrine\ORM\EntityManager $em */ - public function __construct($em) + public function __construct(EntityManager $em) { - $this->_em = $em; + $this->em = $em; } /** @@ -50,6 +53,6 @@ class PreFlushEventArgs extends \Doctrine\Common\EventArgs */ public function getEntityManager() { - return $this->_em; + return $this->em; } } From f281dbbf54fd6446c553e4d965e6242be34e6034 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Mon, 4 Feb 2013 20:46:51 +0100 Subject: [PATCH 2/2] Fixing incorrect constructor params for PreFlushEventArgs --- lib/Doctrine/ORM/UnitOfWork.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 1d2919611..cd1f69bf4 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -524,7 +524,7 @@ class UnitOfWork implements PropertyChangedListener $invoke = $this->listenersInvoker->getSubscribedSystems($class, Events::preFlush); if ($invoke !== ListenersInvoker::INVOKE_NONE) { - $this->listenersInvoker->invoke($class, Events::preFlush, $entity, new PreFlushEventArgs($entity, $this->em), $invoke); + $this->listenersInvoker->invoke($class, Events::preFlush, $entity, new PreFlushEventArgs($this->em), $invoke); } $actualData = array();