Merge pull request #11 from boenrobot/version-and-derivatives

Reflections for @version, @since and @deprecated
This commit is contained in:
Vasil Rangelov
2012-11-17 05:13:04 -08:00
7 changed files with 481 additions and 1 deletions
@@ -51,6 +51,8 @@ class Tag implements \Reflector
=> '\phpDocumentor\Reflection\DocBlock\Tag\AuthorTag',
'covers'
=> '\phpDocumentor\Reflection\DocBlock\Tag\CoversTag',
'deprecated'
=> '\phpDocumentor\Reflection\DocBlock\Tag\DeprecatedTag',
'link'
=> '\phpDocumentor\Reflection\DocBlock\Tag\LinkTag',
'method'
@@ -67,6 +69,8 @@ class Tag implements \Reflector
=> '\phpDocumentor\Reflection\DocBlock\Tag\ReturnTag',
'see'
=> '\phpDocumentor\Reflection\DocBlock\Tag\SeeTag',
'since'
=> '\phpDocumentor\Reflection\DocBlock\Tag\SinceTag',
'throw'
=> '\phpDocumentor\Reflection\DocBlock\Tag\ThrowsTag',
'throws'
@@ -74,7 +78,9 @@ class Tag implements \Reflector
'uses'
=> '\phpDocumentor\Reflection\DocBlock\Tag\UsesTag',
'var'
=> '\phpDocumentor\Reflection\DocBlock\Tag\VarTag'
=> '\phpDocumentor\Reflection\DocBlock\Tag\VarTag',
'version'
=> '\phpDocumentor\Reflection\DocBlock\Tag\VersionTag'
);
/**
@@ -0,0 +1,26 @@
<?php
/**
* phpDocumentor
*
* PHP Version 5.3
*
* @author Vasil Rangelov <[email protected]>
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\DocBlock\Tag\VersionTag;
/**
* Reflection class for a @deprecated tag in a Docblock.
*
* @author Vasil Rangelov <[email protected]>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
class DeprecatedTag extends VersionTag
{
}
@@ -0,0 +1,26 @@
<?php
/**
* phpDocumentor
*
* PHP Version 5.3
*
* @author Vasil Rangelov <[email protected]>
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\DocBlock\Tag\VersionTag;
/**
* Reflection class for a @since tag in a Docblock.
*
* @author Vasil Rangelov <[email protected]>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
class SinceTag extends VersionTag
{
}
@@ -0,0 +1,76 @@
<?php
/**
* phpDocumentor
*
* PHP Version 5.3
*
* @author Vasil Rangelov <[email protected]>
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\DocBlock;
use phpDocumentor\Reflection\DocBlock\Tag;
/**
* Reflection class for a @version tag in a Docblock.
*
* @author Vasil Rangelov <[email protected]>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
class VersionTag extends Tag
{
/** @var string The version vector. */
protected $version = '';
/**
* Parses a tag and populates the member variables.
*
* @param string $type Tag identifier for this tag (should be 'version').
* @param string $content Contents for this tag.
* @param DocBlock $docblock The DocBlock which this tag belongs to.
*/
public function __construct($type, $content, DocBlock $docblock = null)
{
parent::__construct($type, $content, $docblock);
if (preg_match(
'/^
# The version vector
((?:
# Normal release vectors.
\d\S*
|
# VCS version vectors. Per PHPCS, they are expected to
# follow the form of the VCS name, followed by ":", followed
# by the version vector itself.
# By convention, popular VCSes like CVS, SVN and GIT use "$"
# around the actual version vector.
[^\s\:]+\:\s*\$[^\$]+\$
))
\s*
# The description
(.+)?
$/sux',
$this->description,
$matches
)) {
$this->version = $matches[1];
$this->description = isset($matches[2]) ? $matches[2] : '';
}
}
/**
* Returns the version section of the tag.
*
* @return string The version section of the tag.
*/
public function getVersion()
{
return $this->version;
}
}