symfony/symfony — Issue #2906: app/console doctrine:generate:entities error
Author: martinvium
Created: 2011-12-16 21:56:27+00:00
State: open

On line 85 in the following file a variable ($r) is accessed out of scope, causing a:

> Call to a member function getNamespacename() on a non-object

The fix is simple, move the following line inside the first if-class-exists-clause where it is always defined:

if (class_exists($class)) {
$r = $all[0]->getReflectionClass();
$path = $this->getBasePathForClass($class, $r->getNamespacename(), dirname($r->getFilename()));
$metadata->setNamespace($r->getNamespacename()); <-- line in question
} elseif (!$path) {
...
}

$metadata->setPath($path);
<-- line moved from here

The file in question:

https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/DoctrineBundle/Mapping/MetadataFactory.php