1
0
mirror of synced 2024-12-13 22:56:04 +03:00

Fix DDC-2121

This commit is contained in:
Fabio B. Silva 2012-11-05 21:53:07 -02:00
parent ff80e99cc9
commit 2f7e970c5f
2 changed files with 26 additions and 3 deletions

View File

@ -915,9 +915,14 @@ public function __construct()
$var = sprintf('%sMethodTemplate', $type); $var = sprintf('%sMethodTemplate', $type);
$template = self::$$var; $template = self::$$var;
$methodTypeHint = null;
$types = Type::getTypesMap(); $types = Type::getTypesMap();
$variableType = $typeHint ? $this->getType($typeHint) . ' ' : null; $variableType = $typeHint ? $this->getType($typeHint) . ' ' : null;
$methodTypeHint = $typeHint && ! isset($types[$typeHint]) ? '\\' . $typeHint . ' ' : null;
if ($typeHint && ! isset($types[$typeHint])) {
$variableType = '\\' . ltrim($variableType, '\\');
$methodTypeHint = '\\' . $typeHint . ' ';
}
$replacements = array( $replacements = array(
'<description>' => ucfirst($type) . ' ' . $fieldName, '<description>' => ucfirst($type) . ' ' . $fieldName,
@ -997,9 +1002,9 @@ public function __construct()
$lines[] = $this->spaces . '/**'; $lines[] = $this->spaces . '/**';
if ($associationMapping['type'] & ClassMetadataInfo::TO_MANY) { if ($associationMapping['type'] & ClassMetadataInfo::TO_MANY) {
$lines[] = $this->spaces . ' * @var \Doctrine\Common\Collections\ArrayCollection'; $lines[] = $this->spaces . ' * @var \Doctrine\Common\Collections\Collection';
} else { } else {
$lines[] = $this->spaces . ' * @var ' . $associationMapping['targetEntity']; $lines[] = $this->spaces . ' * @var \\' . ltrim($associationMapping['targetEntity'], '\\');
} }
if ($this->generateAnnotations) { if ($this->generateAnnotations) {

View File

@ -167,6 +167,24 @@ class EntityGeneratorTest extends \Doctrine\Tests\OrmTestCase
$this->assertTrue($reflClass->getMethod('getTest')->isPublic(), "Check for public visibility of method 'getTest' failed."); $this->assertTrue($reflClass->getMethod('getTest')->isPublic(), "Check for public visibility of method 'getTest' failed.");
} }
/**
* @group DDC-2121
*/
public function testMethodDocBlockShouldStartWithBackSlash()
{
$metadata = $this->generateBookEntityFixture();
$book = $this->newInstance($metadata);
$this->assertPhpDocVarType('\Doctrine\Common\Collections\Collection', new \ReflectionProperty($book, 'comments'));
$this->assertPhpDocReturnType('\Doctrine\Common\Collections\Collection', new \ReflectionMethod($book, 'getComments'));
$this->assertPhpDocParamType('\Doctrine\Tests\ORM\Tools\EntityGeneratorComment', new \ReflectionMethod($book, 'addComment'));
$this->assertPhpDocParamType('\Doctrine\Tests\ORM\Tools\EntityGeneratorComment', new \ReflectionMethod($book, 'removeComment'));
$this->assertPhpDocVarType('\Doctrine\Tests\ORM\Tools\EntityGeneratorAuthor', new \ReflectionProperty($book, 'author'));
$this->assertPhpDocReturnType('\Doctrine\Tests\ORM\Tools\EntityGeneratorAuthor', new \ReflectionMethod($book, 'getAuthor'));
$this->assertPhpDocParamType('\Doctrine\Tests\ORM\Tools\EntityGeneratorAuthor', new \ReflectionMethod($book, 'setAuthor'));
}
public function testEntityExtendsStdClass() public function testEntityExtendsStdClass()
{ {
$this->_generator->setClassToExtend('stdClass'); $this->_generator->setClassToExtend('stdClass');