From 56cedc5d4f74043e6466b5491c1a4a82258c0ff7 Mon Sep 17 00:00:00 2001
From: Marco Pivetta <ocramius@gmail.com>
Date: Wed, 15 Jul 2015 20:35:21 +0100
Subject: [PATCH] DDC-3683 - #1380 - reverting BC break, annotating correct
 types, cs fixes

---
 .../ORM/Event/LoadClassMetadataEventArgs.php  | 37 +++----------------
 .../EventListener/CacheMetadataListener.php   | 19 +++++-----
 2 files changed, 14 insertions(+), 42 deletions(-)

diff --git a/lib/Doctrine/ORM/Event/LoadClassMetadataEventArgs.php b/lib/Doctrine/ORM/Event/LoadClassMetadataEventArgs.php
index c9d4c1fe6..95e75616e 100644
--- a/lib/Doctrine/ORM/Event/LoadClassMetadataEventArgs.php
+++ b/lib/Doctrine/ORM/Event/LoadClassMetadataEventArgs.php
@@ -20,33 +20,20 @@
 namespace Doctrine\ORM\Event;
 
 use Doctrine\Common\Persistence\Event\LoadClassMetadataEventArgs as BaseLoadClassMetadataEventArgs;
-use Doctrine\ORM\Mapping\ClassMetadata;
-use Doctrine\ORM\EntityManager;
 
 /**
  * Class that holds event arguments for a loadMetadata event.
  *
  * @author Jonathan H. Wage <jonwage@gmail.com>
  * @since  2.0
+ *
+ * Note: method annotations are used instead of method overrides (due to BC policy)
+ *
+ * @method __construct(\Doctrine\ORM\Mapping\ClassMetadata $classMetadata, \Doctrine\ORM\EntityManager $objectManager)
+ * @method \Doctrine\ORM\EntityManager getClassMetadata()
  */
 class LoadClassMetadataEventArgs extends BaseLoadClassMetadataEventArgs
 {
-    /**
-     * @param ClassMetadata $classMetadata
-     * @param EntityManager $entityManager
-     */
-    function __construct(ClassMetadata $classMetadata, EntityManager $entityManager)
-    {
-        /*
-        We use our own constructor here to enforce type-hinting requirements,
-        since both inputs are specialized subclasses compared to what the super-
-        class is willing to accept.
-
-        In particular, we want to have EntityManager rather than ObjectManager.
-        */
-        parent::__construct($classMetadata, $entityManager);
-    }
-
     /**
      * Retrieve associated EntityManager.
      *
@@ -54,20 +41,6 @@ class LoadClassMetadataEventArgs extends BaseLoadClassMetadataEventArgs
      */
     public function getEntityManager()
     {
-        /*
-        We can safely assume our ObjectManager is also an EventManager due to
-        our restrictions in the constructor.
-        */
         return $this->getObjectManager();
     }
-
-    /**
-     * Retrieves the associated ClassMetadata.
-     *
-     * @return \Doctrine\ORM\Mapping\ClassMetadata
-     */
-    public function getClassMetadata()
-    {
-        return parent::getClassMetadata();
-    }
 }
diff --git a/tests/Doctrine/Tests/EventListener/CacheMetadataListener.php b/tests/Doctrine/Tests/EventListener/CacheMetadataListener.php
index 82a4f0db6..7a7caf18e 100644
--- a/tests/Doctrine/Tests/EventListener/CacheMetadataListener.php
+++ b/tests/Doctrine/Tests/EventListener/CacheMetadataListener.php
@@ -3,7 +3,6 @@
 namespace Doctrine\Tests\EventListener;
 
 use Doctrine\Common\Persistence\Event\LoadClassMetadataEventArgs;
-use Doctrine\Common\Persistence\ObjectManager;
 use Doctrine\ORM\EntityManager;
 use Doctrine\ORM\Mapping\ClassMetadata;
 
@@ -38,16 +37,19 @@ class CacheMetadataListener
 
     /**
      * @param ClassMetadata $metadata
+     *
      * @return bool
      */
-    private function isVisited(ClassMetaData $metadata) {
+    private function isVisited(ClassMetaData $metadata)
+    {
         return isset($this->enabledItems[$metadata->getName()]);
     }
 
     /**
      * @param ClassMetadata $metadata
      */
-    private function recordVisit(ClassMetaData $metadata) {
+    private function recordVisit(ClassMetaData $metadata)
+    {
         $this->enabledItems[$metadata->getName()] = true;
     }
 
@@ -55,8 +57,8 @@ class CacheMetadataListener
      * @param ClassMetadata $metadata
      * @param EntityManager $em
      */
-    protected function enableCaching(ClassMetadata $metadata, EntityManager $em) {
-
+    protected function enableCaching(ClassMetadata $metadata, EntityManager $em)
+    {
         if ($this->isVisited($metadata)) {
             return; // Already handled in the past
         }
@@ -73,12 +75,9 @@ class CacheMetadataListener
 
         $this->recordVisit($metadata);
 
-        /*
-         * Only enable association-caching when the target has already been
-         * given caching settings
-         */
+        // only enable association-caching when the target has already been
+        // given caching settings
         foreach ($metadata->associationMappings as $mapping) {
-
             $targetMeta = $em->getClassMetadata($mapping['targetEntity']);
             $this->enableCaching($targetMeta, $em);