Permalink
Browse files

Merge branch 'hotfix/docblock-generator-tags' of git://github.com/nee…

…ckeloo/zf2 into hotfix/3214

Conflicts:
	library/Zend/Code/Generator/DocBlockGenerator.php
  • Loading branch information...
2 parents c9eea75 + f43db4e commit 6965b0a5bce0ae399129097447abdb7d0c42da28 @weierophinney weierophinney committed Dec 13, 2012
@@ -19,7 +19,9 @@
*/
class Tag extends AbstractGenerator
{
-
+ /**
+ * @var array
+ */
protected static $typeFormats = array(
array(
'param',
@@ -50,18 +52,18 @@ class Tag extends AbstractGenerator
*/
public function __construct(array $options = array())
{
- if (array_key_exists('name', $options)) {
+ if (isset($options['name'])) {
$this->setName($options['name']);
}
- if (array_key_exists('description', $options)) {
+ if (isset($options['description'])) {
$this->setDescription($options['description']);
}
}
/**
- * fromReflection()
+ * Build a Tag generator object from a reflection object
*
- * @param ReflectionDocBlockTag $reflectionTag
+ * @param ReflectionDocBlockTag $reflectionTag
* @return Tag
*/
public static function fromReflection(ReflectionDocBlockTag $reflectionTag)
@@ -86,20 +88,17 @@ public static function fromReflection(ReflectionDocBlockTag $reflectionTag)
}
/**
- * setName()
- *
- * @param string $name
+ * @param string $name
* @return Tag
*/
public function setName($name)
{
$this->name = ltrim($name, '@');
+
return $this;
}
/**
- * getName()
- *
* @return string
*/
public function getName()
@@ -108,20 +107,17 @@ public function getName()
}
/**
- * setDescription()
- *
- * @param string $description
+ * @param string $description
* @return Tag
*/
public function setDescription($description)
{
$this->description = $description;
+
return $this;
}
/**
- * getDescription()
- *
* @return string
*/
public function getDescription()
@@ -130,14 +126,13 @@ public function getDescription()
}
/**
- * generate()
- *
* @return string
*/
public function generate()
{
$output = '@' . $this->name
. (($this->description != null) ? ' ' . $this->description : '');
+
return $output;
}
@@ -100,14 +100,14 @@ public static function fromArray(array $array)
*/
public function __construct($shortDescription = null, $longDescription = null, array $tags = array())
{
- if ($shortDescription !== null) {
+ if ($shortDescription) {
$this->setShortDescription($shortDescription);
}
- if ($longDescription !== null) {
+ if ($longDescription) {
$this->setLongDescription($longDescription);
}
- if ($this->tags !== array()) {
- $this->setTag($tags);
+ if (is_array($tags) && $tags) {
+ $this->setTags($tags);
}
}
@@ -184,7 +184,7 @@ public function setTag($tag)
}
/**
- * @return array
+ * @return DocBlock\Tag[]
*/
public function getTags()
{
@@ -33,6 +33,18 @@ protected function setUp()
$this->docBlockGenerator = $this->docBlockGenerator = new DocBlockGenerator();
}
+ public function testCanPassTagsToConstructor()
+ {
+ $docBlockGenerator = new DocBlockGenerator(null, null, array(
+ array('name' => 'foo')
+ ));
+
+ $tags = $docBlockGenerator->getTags();
+ $this->assertCount(1, $tags);
+
+ $this->assertEquals('foo', $tags[0]->getName());
+ }
+
public function testShortDescriptionGetterAndSetter()
{
$this->docBlockGenerator->setShortDescription('Short Description');

0 comments on commit 6965b0a

Please sign in to comment.