From 8898c91dfc1c6a433fc6cb1de5235c35a46f25b7 Mon Sep 17 00:00:00 2001 From: Adam Prager Date: Tue, 26 Mar 2013 21:28:09 +0100 Subject: [PATCH] only check for traits when class exists --- lib/Doctrine/ORM/Tools/EntityGenerator.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/Doctrine/ORM/Tools/EntityGenerator.php b/lib/Doctrine/ORM/Tools/EntityGenerator.php index 945bbd935..2946935b3 100644 --- a/lib/Doctrine/ORM/Tools/EntityGenerator.php +++ b/lib/Doctrine/ORM/Tools/EntityGenerator.php @@ -710,11 +710,13 @@ public function __construct() } // check traits for existing property - $reflClass = new \ReflectionClass($metadata->name); + if (class_exists($metadata->name)) { + $reflClass = new \ReflectionClass($metadata->name); - foreach ($reflClass->getTraits() as $trait) { - if ($trait->hasProperty($property)) { - return true; + foreach ($reflClass->getTraits() as $trait) { + if ($trait->hasProperty($property)) { + return true; + } } } @@ -742,11 +744,13 @@ public function __construct() } // check traits for existing method - $reflClass = new \ReflectionClass($metadata->name); + if (class_exists($metadata->name)) { + $reflClass = new \ReflectionClass($metadata->name); - foreach ($reflClass->getTraits() as $trait) { - if ($trait->hasMethod($method)) { - return true; + foreach ($reflClass->getTraits() as $trait) { + if ($trait->hasMethod($method)) { + return true; + } } }