Forráskód Böngészése

Merge pull request #12 from dbu/check-mapping

add check and helpful exception message on inconsistent type situation
Johannes 12 éve
szülő
commit
29d466596e
1 módosított fájl, 3 hozzáadás és 0 törlés
  1. 3 0
      src/JMS/Serializer/NavigatorContext.php

+ 3 - 0
src/JMS/Serializer/NavigatorContext.php

@@ -58,6 +58,9 @@ class NavigatorContext
 
 
     public function isVisiting($object)
     public function isVisiting($object)
     {
     {
+        if (! is_object($object)) {
+            throw new \LogicException('Expected object but got ' . gettype($object) . '. Do you have the wrong @Type mapping or could this be a Doctrine many-to-many relation?');
+        }
         return $this->visitingSet->contains($object);
         return $this->visitingSet->contains($object);
     }
     }