Permalink
Browse files

Merge branch 'hotfix/3250' into develop

Forward port #3250
  • Loading branch information...
2 parents eacf415 + 2912c1a commit bcc6a91756429ef083386deaeac393fcb2080a33 @weierophinney weierophinney committed Dec 19, 2012
View
21 library/Zend/Code/Generator/DocBlock/Tag/LicenseTag.php
@@ -19,13 +19,28 @@
*/
class LicenseTag extends Tag
{
-
/**
* @var string
*/
protected $url = null;
/**
+ * @param array $options
+ */
+ public function __construct(array $options = array())
+ {
+ parent::__construct($options);
+
+ if (isset($options['url'])) {
+ $this->setUrl($options['url']);
+ }
+
+ if (empty($this->name)) {
+ $this->setName('license');
+ }
+ }
+
+ /**
* fromReflection()
*
* @param ReflectionDocBlockTag $reflectionTagLicense
@@ -71,7 +86,9 @@ public function getUrl()
*/
public function generate()
{
+ $output = '@' . $this->name
+ . (($this->url !== null) ? ' ' . $this->url : '')
+ . (($this->description !== null) ? ' ' . $this->description : '');
return $output;
}
-
}
View
13 tests/ZendTest/Code/Generator/DocBlockTagGeneratorTest.php
@@ -11,6 +11,7 @@
namespace ZendTest\Code\Generator;
use Zend\Code\Generator\DocBlock\Tag;
+use Zend\Code\Generator\DocBlock\Tag\LicenseTag;
/**
* @category Zend
@@ -47,6 +48,18 @@ public function testCanPassDescriptionToConstructor()
$this->assertEquals('Foo', $tag->getDescription());
}
+ public function testCanGenerateLicenseTag()
+ {
+ $tag = new LicenseTag(array(
+ 'url' => 'http://test.license.com',
+ 'description' => 'Test License',
+ ));
+ $this->assertEquals(
+ '@license http://test.license.com Test License',
+ $tag->generate()
+ );
+ }
+
public function testNameGetterAndSetterPersistValue()
{
$this->tag->setName('Foo');

0 comments on commit bcc6a91

Please sign in to comment.