Skip to content

Commit

Permalink
only check for traits when class exists
Browse files Browse the repository at this point in the history
  • Loading branch information
Padam87 committed Mar 26, 2013
1 parent 8e3e2e7 commit 8898c91
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions lib/Doctrine/ORM/Tools/EntityGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -710,11 +710,13 @@ protected function hasProperty($property, ClassMetadataInfo $metadata)
}

// 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;
}
}
}

Expand Down Expand Up @@ -742,11 +744,13 @@ protected function hasMethod($method, ClassMetadataInfo $metadata)
}

// 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;
}
}
}

Expand Down

0 comments on commit 8898c91

Please sign in to comment.