mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 10:07:12 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8418970624 | ||
|
|
0d38c84407 | ||
|
|
bfc443b40c | ||
|
|
4a9ddd15fe | ||
|
|
87ed522579 | ||
|
|
f01f8ea41d | ||
|
|
620b932272 | ||
|
|
beb96a487b | ||
|
|
7a03741e0b | ||
|
|
a79e4c174c | ||
|
|
be61012d74 | ||
|
|
99de44e96f | ||
|
|
b20c7da00b | ||
|
|
99054d341f | ||
|
|
9da4a65065 | ||
|
|
39faeec91d | ||
|
|
0c15eb99f5 | ||
|
|
21c36677ab | ||
|
|
ffcaa03337 | ||
|
|
37810ef836 | ||
|
|
587406073d | ||
|
|
aed654aa85 | ||
|
|
2812eac046 | ||
|
|
db20ae39fb | ||
|
|
cdaa97eb31 | ||
|
|
27bdc08a1e | ||
|
|
a18985a888 | ||
|
|
747e6d7cdf | ||
|
|
c2f692140f | ||
|
|
8eb596c1cc | ||
|
|
26e2eade91 | ||
|
|
1ac9106c48 | ||
|
|
1352ef56a6 | ||
|
|
6df31db139 | ||
|
|
829a92e5aa | ||
|
|
04936a7b39 | ||
|
|
ae82b8488f | ||
|
|
bae65d2afe | ||
|
|
28df2a4cd6 | ||
|
|
fedcd8cf49 | ||
|
|
a868c60f8e | ||
|
|
e6d2ec7c54 | ||
|
|
f19dac185a | ||
|
|
0ba0ad6b42 | ||
|
|
8b9591a7c5 | ||
|
|
082c9354d0 | ||
|
|
233e4b3ff7 | ||
|
|
d788b51755 | ||
|
|
bbd5775f1f | ||
|
|
044ebd68c9 | ||
|
|
e0a5a75364 | ||
|
|
607aa79601 | ||
|
|
a4107acb6d | ||
|
|
34eabb7d11 | ||
|
|
f07ab7eda0 | ||
|
|
d6119709ba | ||
|
|
21ec090933 | ||
|
|
ba1395e42d | ||
|
|
9a3c6f50ef | ||
|
|
009237bad2 |
+23
@@ -0,0 +1,23 @@
|
|||||||
|
language: php
|
||||||
|
php:
|
||||||
|
- 5.3.3
|
||||||
|
- 5.3
|
||||||
|
- 5.4
|
||||||
|
|
||||||
|
script:
|
||||||
|
- vendor/phpunit/phpunit/composer/bin/phpunit
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- sudo apt-get -qq update > /dev/null
|
||||||
|
- phpenv rehash > /dev/null
|
||||||
|
- composer selfupdate --quiet
|
||||||
|
- composer install --dev
|
||||||
|
- vendor/phpunit/phpunit/composer/bin/phpunit
|
||||||
|
- composer update --dev
|
||||||
|
|
||||||
|
notifications:
|
||||||
|
irc: "irc.freenode.org#phpdocumentor"
|
||||||
|
email:
|
||||||
|
- [email protected]
|
||||||
|
- [email protected]
|
||||||
|
- [email protected]
|
||||||
@@ -11,5 +11,8 @@
|
|||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-0": {"phpDocumentor": ["src/"]}
|
"psr-0": {"phpDocumentor": ["src/"]}
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "*@stable"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,4 +6,9 @@
|
|||||||
<directory>./tests/</directory>
|
<directory>./tests/</directory>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
|
<filter>
|
||||||
|
<whitelist>
|
||||||
|
<directory suffix=".php">./src/</directory>
|
||||||
|
</whitelist>
|
||||||
|
</filter>
|
||||||
</phpunit>
|
</phpunit>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* phpDocumentor
|
* phpDocumentor
|
||||||
*
|
*
|
||||||
* PHP Version 5
|
* PHP Version 5.3
|
||||||
*
|
*
|
||||||
* @author Mike van Riel <[email protected]>
|
* @author Mike van Riel <[email protected]>
|
||||||
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
||||||
@@ -12,12 +12,15 @@
|
|||||||
|
|
||||||
namespace phpDocumentor\Reflection;
|
namespace phpDocumentor\Reflection;
|
||||||
|
|
||||||
|
use phpDocumentor\Reflection\DocBlock\Context;
|
||||||
|
use phpDocumentor\Reflection\DocBlock\Location;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses the DocBlock for any structure.
|
* Parses the DocBlock for any structure.
|
||||||
*
|
*
|
||||||
* @author Mike van Riel <[email protected]>
|
* @author Mike van Riel <[email protected]>
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
* @link http://phpdoc.org
|
* @link http://phpdoc.org
|
||||||
*/
|
*/
|
||||||
class DocBlock implements \Reflector
|
class DocBlock implements \Reflector
|
||||||
{
|
{
|
||||||
@@ -25,46 +28,44 @@ class DocBlock implements \Reflector
|
|||||||
protected $short_description = '';
|
protected $short_description = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \phpDocumentor\Reflection\DocBlock\LongDescription The actual description
|
* @var \phpDocumentor\Reflection\DocBlock\LongDescription The actual
|
||||||
* for this docblock.
|
* description for this docblock.
|
||||||
*/
|
*/
|
||||||
protected $long_description = null;
|
protected $long_description = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \phpDocumentor\Reflection\DocBlock\Tags[] An array containing all the tags
|
* @var \phpDocumentor\Reflection\DocBlock\Tags[] An array containing all
|
||||||
* in this docblock; except inline.
|
* the tags in this docblock; except inline.
|
||||||
*/
|
*/
|
||||||
protected $tags = array();
|
protected $tags = array();
|
||||||
|
|
||||||
/** @var string the current namespace */
|
/** @var Context Information about the context of this DocBlock. */
|
||||||
protected $namespace = '\\';
|
protected $context = null;
|
||||||
|
|
||||||
/** @var string[] List of namespace aliases => Fully Qualified Namespace */
|
/** @var Location Information about the location of this DocBlock. */
|
||||||
protected $namespace_aliases = array();
|
protected $location = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses the given docblock and populates the member fields.
|
* Parses the given docblock and populates the member fields.
|
||||||
*
|
*
|
||||||
* The constructor may also receive namespace information such as the
|
* The constructor may also receive namespace information such as the
|
||||||
* current namespace and aliases. This information is used in the
|
* current namespace and aliases. This information is used by some tags
|
||||||
* {@link expandType()} method to transform a relative Type into a FQCN.
|
* (e.g. @return, @param, etc.) to turn a relative Type into a FQCN.
|
||||||
*
|
*
|
||||||
* For example the param and return tags use this to expand their type
|
* @param \Reflector|string $docblock A docblock comment (including
|
||||||
* information.
|
* asterisks) or reflector supporting the getDocComment method.
|
||||||
*
|
* @param Context $context The context in which the DocBlock
|
||||||
* @param \Reflector|string $docblock A docblock comment (including asterisks)
|
* occurs.
|
||||||
* or reflector supporting the getDocComment method.
|
* @param Location $location The location within the file that this
|
||||||
* @param string $namespace The namespace where this DocBlock resides in;
|
* DocBlock occurs in.
|
||||||
* defaults to `\`.
|
|
||||||
* @param string[] $namespace_aliases a list of namespace aliases as
|
|
||||||
* provided by the `use` keyword; the key of the array is the alias name
|
|
||||||
* or last part of the alias array if no alias name is provided.
|
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException if the given argument does not have the
|
* @throws \InvalidArgumentException if the given argument does not have the
|
||||||
* getDocComment method.
|
* getDocComment method.
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
$docblock, $namespace = '\\', $namespace_aliases = array()
|
$docblock,
|
||||||
|
Context $context = null,
|
||||||
|
Location $location = null
|
||||||
) {
|
) {
|
||||||
if (is_object($docblock)) {
|
if (is_object($docblock)) {
|
||||||
if (!method_exists($docblock, 'getDocComment')) {
|
if (!method_exists($docblock, 'getDocComment')) {
|
||||||
@@ -81,11 +82,11 @@ class DocBlock implements \Reflector
|
|||||||
|
|
||||||
list($short, $long, $tags) = $this->splitDocBlock($docblock);
|
list($short, $long, $tags) = $this->splitDocBlock($docblock);
|
||||||
$this->short_description = $short;
|
$this->short_description = $short;
|
||||||
$this->long_description = new DocBlock\LongDescription($long);
|
$this->long_description = new DocBlock\Description($long, $this);
|
||||||
$this->parseTags($tags);
|
$this->parseTags($tags);
|
||||||
|
|
||||||
$this->namespace = $namespace;
|
$this->context = $context;
|
||||||
$this->namespace_aliases = $namespace_aliases;
|
$this->location = $location;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -99,7 +100,9 @@ class DocBlock implements \Reflector
|
|||||||
{
|
{
|
||||||
$comment = trim(
|
$comment = trim(
|
||||||
preg_replace(
|
preg_replace(
|
||||||
'#[ \t]*(?:\/\*\*|\*\/|\*)?[ \t]{0,1}(.*)?#u', '$1', $comment
|
'#[ \t]*(?:\/\*\*|\*\/|\*)?[ \t]{0,1}(.*)?#u',
|
||||||
|
'$1',
|
||||||
|
$comment
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -121,7 +124,7 @@ class DocBlock implements \Reflector
|
|||||||
* @param string $comment Comment to split into the sub-parts.
|
* @param string $comment Comment to split into the sub-parts.
|
||||||
*
|
*
|
||||||
* @author RichardJ Special thanks to RichardJ for the regex responsible
|
* @author RichardJ Special thanks to RichardJ for the regex responsible
|
||||||
* for the split/
|
* for the split.
|
||||||
*
|
*
|
||||||
* @return string[] containing the short-, long description and an element
|
* @return string[] containing the short-, long description and an element
|
||||||
* containing the tags.
|
* containing the tags.
|
||||||
@@ -133,7 +136,7 @@ class DocBlock implements \Reflector
|
|||||||
} else {
|
} else {
|
||||||
// clears all extra horizontal whitespace from the line endings
|
// clears all extra horizontal whitespace from the line endings
|
||||||
// to prevent parsing issues
|
// to prevent parsing issues
|
||||||
$comment = preg_replace('~(?m)\h*$~u', '', $comment);
|
$comment = preg_replace('/\h*$/Sum', '', $comment);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Splits the docblock into a short description, long description and
|
* Splits the docblock into a short description, long description and
|
||||||
@@ -150,7 +153,7 @@ class DocBlock implements \Reflector
|
|||||||
* Big thanks to RichardJ for contributing this Regular Expression
|
* Big thanks to RichardJ for contributing this Regular Expression
|
||||||
*/
|
*/
|
||||||
preg_match(
|
preg_match(
|
||||||
'/(?x)
|
'/
|
||||||
\A (
|
\A (
|
||||||
[^\n.]+
|
[^\n.]+
|
||||||
(?:
|
(?:
|
||||||
@@ -173,7 +176,9 @@ class DocBlock implements \Reflector
|
|||||||
)
|
)
|
||||||
)?
|
)?
|
||||||
(\s+ [\s\S]*)? # everything that follows
|
(\s+ [\s\S]*)? # everything that follows
|
||||||
/u', $comment, $matches
|
/ux',
|
||||||
|
$comment,
|
||||||
|
$matches
|
||||||
);
|
);
|
||||||
array_shift($matches);
|
array_shift($matches);
|
||||||
}
|
}
|
||||||
@@ -194,30 +199,30 @@ class DocBlock implements \Reflector
|
|||||||
protected function parseTags($tags)
|
protected function parseTags($tags)
|
||||||
{
|
{
|
||||||
$result = array();
|
$result = array();
|
||||||
foreach (explode("\n", trim($tags)) as $tag_line) {
|
$tags = trim($tags);
|
||||||
if (trim($tag_line) === '') {
|
if ('' !== $tags) {
|
||||||
continue;
|
if ('@' !== $tags[0]) {
|
||||||
|
throw new \LogicException(
|
||||||
|
'A tag block started with text instead of an actual tag,'
|
||||||
|
. ' this makes the tag block invalid: ' . $tags
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
foreach (explode("\n", $tags) as $tag_line) {
|
||||||
if (isset($tag_line[0]) && ($tag_line[0] === '@')) {
|
if (trim($tag_line) === '') {
|
||||||
$result[] = $tag_line;
|
continue;
|
||||||
} else {
|
|
||||||
if (count($result) == 0) {
|
|
||||||
throw new \LogicException(
|
|
||||||
'A tag block started with text instead of an actual tag,'
|
|
||||||
. ' this makes the tag block invalid: ' . $tags
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$result[count($result) - 1] .= PHP_EOL . $tag_line;
|
if (isset($tag_line[0]) && ($tag_line[0] === '@')) {
|
||||||
|
$result[] = $tag_line;
|
||||||
|
} else {
|
||||||
|
$result[count($result) - 1] .= PHP_EOL . $tag_line;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// create proper Tag objects
|
// create proper Tag objects
|
||||||
foreach ($result as $key => $tag_line) {
|
foreach ($result as $key => $tag_line) {
|
||||||
$tag = DocBlock\Tag::createInstance($tag_line);
|
$result[$key] = DocBlock\Tag::createInstance($tag_line, $this);
|
||||||
$tag->setDocBlock($this);
|
}
|
||||||
$result[$key] = $tag;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->tags = $result;
|
$this->tags = $result;
|
||||||
@@ -243,6 +248,26 @@ class DocBlock implements \Reflector
|
|||||||
return $this->long_description;
|
return $this->long_description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current context.
|
||||||
|
*
|
||||||
|
* @return Context
|
||||||
|
*/
|
||||||
|
public function getContext()
|
||||||
|
{
|
||||||
|
return $this->context;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current location.
|
||||||
|
*
|
||||||
|
* @return Location
|
||||||
|
*/
|
||||||
|
public function getLocation()
|
||||||
|
{
|
||||||
|
return $this->location;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the tags for this DocBlock.
|
* Returns the tags for this DocBlock.
|
||||||
*
|
*
|
||||||
@@ -254,7 +279,7 @@ class DocBlock implements \Reflector
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array of tags matching the given name; if no tags are found
|
* Returns an array of tags matching the given name. If no tags are found
|
||||||
* an empty array is returned.
|
* an empty array is returned.
|
||||||
*
|
*
|
||||||
* @param string $name String to search by.
|
* @param string $name String to search by.
|
||||||
@@ -296,84 +321,6 @@ class DocBlock implements \Reflector
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Tries to expand a type to it's full namespaced equivalent (FQCN).
|
|
||||||
*
|
|
||||||
* This method will take the given type and examine the current namespace
|
|
||||||
* and namespace aliases to see whether it should expand it into a FQCN
|
|
||||||
* as defined by the rules in PHP.
|
|
||||||
*
|
|
||||||
* @param string $type Type to expand into full namespaced
|
|
||||||
* equivalent.
|
|
||||||
* @param string[] $ignore_keywords Whether to ignore given keywords, when
|
|
||||||
* null it will use the default keywords: 'string', 'int', 'integer',
|
|
||||||
* 'bool', 'boolean', 'float', 'double', 'object', 'mixed', 'array',
|
|
||||||
* 'resource', 'void', 'null', 'callback', 'false', 'true'.
|
|
||||||
* Default value for this parameter is null.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function expandType($type, $ignore_keywords = null)
|
|
||||||
{
|
|
||||||
if ($type === null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($ignore_keywords === null) {
|
|
||||||
$ignore_keywords = array(
|
|
||||||
'string', 'int', 'integer', 'bool', 'boolean', 'float', 'double',
|
|
||||||
'object', 'mixed', 'array', 'resource', 'void', 'null',
|
|
||||||
'callback', 'false', 'true', 'self', '$this', 'callable'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$namespace = '\\';
|
|
||||||
if ($this->namespace != 'default' && $this->namespace != 'global') {
|
|
||||||
$namespace = rtrim($this->namespace, '\\') . '\\';
|
|
||||||
}
|
|
||||||
|
|
||||||
$type = explode('|', $type);
|
|
||||||
foreach ($type as &$item) {
|
|
||||||
$item = trim($item);
|
|
||||||
|
|
||||||
// add support for array notation
|
|
||||||
$is_array = false;
|
|
||||||
if (substr($item, -2) == '[]') {
|
|
||||||
$item = substr($item, 0, -2);
|
|
||||||
$is_array = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((substr($item, 0, 1) != '\\')
|
|
||||||
&& (!in_array(strtolower($item), $ignore_keywords))
|
|
||||||
) {
|
|
||||||
$type_parts = explode('\\', $item);
|
|
||||||
|
|
||||||
// if the first segment is an alias; replace with full name
|
|
||||||
if (isset($this->namespace_aliases[$type_parts[0]])) {
|
|
||||||
$type_parts[0] = $this->namespace_aliases[$type_parts[0]];
|
|
||||||
$item = implode('\\', $type_parts);
|
|
||||||
} else {
|
|
||||||
// otherwise prepend the current namespace
|
|
||||||
$item = $namespace . $item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// full paths always start with a slash
|
|
||||||
if (isset($item[0]) && ($item[0] !== '\\')
|
|
||||||
&& (!in_array(strtolower($item), $ignore_keywords))
|
|
||||||
) {
|
|
||||||
$item = '\\' . $item;
|
|
||||||
}
|
|
||||||
|
|
||||||
// re-add the array notation markers
|
|
||||||
if ($is_array) {
|
|
||||||
$item .= '[]';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return implode('|', $type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds a string representation of this object.
|
* Builds a string representation of this object.
|
||||||
*
|
*
|
||||||
@@ -381,8 +328,9 @@ class DocBlock implements \Reflector
|
|||||||
* implement it.
|
* implement it.
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
|
* @codeCoverageIgnore Not yet implemented
|
||||||
*/
|
*/
|
||||||
static public function export()
|
public static function export()
|
||||||
{
|
{
|
||||||
throw new \Exception('Not yet implemented');
|
throw new \Exception('Not yet implemented');
|
||||||
}
|
}
|
||||||
@@ -392,22 +340,10 @@ class DocBlock implements \Reflector
|
|||||||
* BUT this throws an exception at this point).
|
* BUT this throws an exception at this point).
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
|
* @codeCoverageIgnore Not yet implemented
|
||||||
*/
|
*/
|
||||||
public function __toString()
|
public function __toString()
|
||||||
{
|
{
|
||||||
return 'Not yet implemented';
|
return 'Not yet implemented';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getNamespace()
|
|
||||||
{
|
|
||||||
return $this->namespace;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getNamespaceAliases()
|
|
||||||
{
|
|
||||||
return $this->namespace_aliases;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,154 @@
|
|||||||
|
<?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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The context in which a DocBlock occurs.
|
||||||
|
*
|
||||||
|
* @author Vasil Rangelov <[email protected]>
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
|
* @link http://phpdoc.org
|
||||||
|
*/
|
||||||
|
class Context
|
||||||
|
{
|
||||||
|
/** @var string The current namespace. */
|
||||||
|
protected $namespace = '';
|
||||||
|
|
||||||
|
/** @var array List of namespace aliases => Fully Qualified Namespace. */
|
||||||
|
protected $namespace_aliases = array();
|
||||||
|
|
||||||
|
/** @var string Name of the structural element, within the namespace. */
|
||||||
|
protected $lsen = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cteates a new context.
|
||||||
|
* @param string $namespace The namespace where this DocBlock
|
||||||
|
* resides in.
|
||||||
|
* @param array $namespace_aliases List of namespace aliases => Fully
|
||||||
|
* Qualified Namespace.
|
||||||
|
* @param string $lsen Name of the structural element, within
|
||||||
|
* the namespace.
|
||||||
|
*/
|
||||||
|
public function __construct(
|
||||||
|
$namespace = '',
|
||||||
|
array $namespace_aliases = array(),
|
||||||
|
$lsen = ''
|
||||||
|
) {
|
||||||
|
if (!empty($namespace)) {
|
||||||
|
$this->setNamespace($namespace);
|
||||||
|
}
|
||||||
|
$this->setNamespaceAliases($namespace_aliases);
|
||||||
|
$this->setLSEN($lsen);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string The namespace where this DocBlock resides in.
|
||||||
|
*/
|
||||||
|
public function getNamespace()
|
||||||
|
{
|
||||||
|
return $this->namespace;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array List of namespace aliases => Fully Qualified Namespace.
|
||||||
|
*/
|
||||||
|
public function getNamespaceAliases()
|
||||||
|
{
|
||||||
|
return $this->namespace_aliases;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Local Structural Element Name.
|
||||||
|
*
|
||||||
|
* @return string Name of the structural element, within the namespace.
|
||||||
|
*/
|
||||||
|
public function getLSEN()
|
||||||
|
{
|
||||||
|
return $this->lsen;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a new namespace.
|
||||||
|
*
|
||||||
|
* Sets a new namespace for the context. Leading and trailing slashes are
|
||||||
|
* trimmed, and the keywords "global" and "default" are treated as aliases
|
||||||
|
* to no namespace.
|
||||||
|
*
|
||||||
|
* @param string $namespace The new namespace to set.
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setNamespace($namespace)
|
||||||
|
{
|
||||||
|
if ('global' !== $namespace
|
||||||
|
&& 'default' !== $namespace
|
||||||
|
) {
|
||||||
|
// Srip leading and trailing slash
|
||||||
|
$this->namespace = trim((string)$namespace, '\\');
|
||||||
|
} else {
|
||||||
|
$this->namespace = '';
|
||||||
|
}
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the namespace aliases, replacing all previous ones.
|
||||||
|
*
|
||||||
|
* @param array $namespace_aliases List of namespace aliases => Fully
|
||||||
|
* Qualified Namespace.
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setNamespaceAliases(array $namespace_aliases)
|
||||||
|
{
|
||||||
|
$this->namespace_aliases = array();
|
||||||
|
foreach ($namespace_aliases as $alias => $fqnn) {
|
||||||
|
$this->setNamespaceAlias($alias, $fqnn);
|
||||||
|
}
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a namespace alias to the context.
|
||||||
|
*
|
||||||
|
* @param string $alias The alias name (the part after "as", or the last
|
||||||
|
* part of the Fully Qualified Namespace Name) to add.
|
||||||
|
* @param string $fqnn The Fully Qualified Namespace Name for this alias.
|
||||||
|
* Any form of leading/trailing slashes are accepted, but what will be
|
||||||
|
* stored is a name, prefixed with a slash, and no trailing slash.
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setNamespaceAlias($alias, $fqnn)
|
||||||
|
{
|
||||||
|
$this->namespace_aliases[$alias] = '\\' . trim((string)$fqnn, '\\');
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a new Local Structural Element Name.
|
||||||
|
*
|
||||||
|
* Sets a new Local Structural Element Name. A local name also contains
|
||||||
|
* punctuation determining the kind of structural element (e.g. trailing "("
|
||||||
|
* and ")" for functions and methods).
|
||||||
|
*
|
||||||
|
* @param string $lsen The new local name of a structural element.
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setLSEN($lsen)
|
||||||
|
{
|
||||||
|
$this->lsen = (string)$lsen;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,184 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* phpDocumentor
|
||||||
|
*
|
||||||
|
* PHP Version 5.3
|
||||||
|
*
|
||||||
|
* @author Mike van Riel <[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;
|
||||||
|
|
||||||
|
use phpDocumentor\Reflection\DocBlock;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses a Description of a DocBlock or tag.
|
||||||
|
*
|
||||||
|
* @author Mike van Riel <[email protected]>
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
|
* @link http://phpdoc.org
|
||||||
|
*/
|
||||||
|
class Description implements \Reflector
|
||||||
|
{
|
||||||
|
/** @var string */
|
||||||
|
protected $contents = '';
|
||||||
|
|
||||||
|
/** @var array The contents, as an array of strings and Tag objects. */
|
||||||
|
protected $parsedContents = null;
|
||||||
|
|
||||||
|
/** @var \phpDocumentor\Reflection\DocBlock\Tags[] */
|
||||||
|
protected $tags = array();
|
||||||
|
|
||||||
|
/** @var DocBlock The DocBlock which this description belongs to. */
|
||||||
|
protected $docblock = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Populates the fields of a description.
|
||||||
|
*
|
||||||
|
* @param string $content The DocBlock contents without asterisks.
|
||||||
|
* @param DocBlock $docblock The DocBlock which this description belongs to.
|
||||||
|
*/
|
||||||
|
public function __construct($content, DocBlock $docblock = null)
|
||||||
|
{
|
||||||
|
$this->contents = trim($content);
|
||||||
|
$this->docblock = $docblock;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the text of this description.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getContents()
|
||||||
|
{
|
||||||
|
return $this->contents;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the parsed text of this description.
|
||||||
|
*
|
||||||
|
* @return array An array of strings and tag objects, in the order they
|
||||||
|
* occur within the description.
|
||||||
|
*/
|
||||||
|
public function getParsedContents()
|
||||||
|
{
|
||||||
|
if (null === $this->parsedContents) {
|
||||||
|
$this->parsedContents = preg_split(
|
||||||
|
'/\{
|
||||||
|
# "{@}" is not a valid inline tag. This ensures that
|
||||||
|
# we do not treat it as one, but treat it literally.
|
||||||
|
(?!@\})
|
||||||
|
# We want to capture the whole tag line, but without the
|
||||||
|
# inline tag delimiters.
|
||||||
|
(\@
|
||||||
|
# Match everything up to the next delimiter.
|
||||||
|
[^{}]*
|
||||||
|
# Nested inline tag content should not be captured, or
|
||||||
|
# it will appear in the result separately.
|
||||||
|
(?:
|
||||||
|
# Match nested inline tags.
|
||||||
|
(?:
|
||||||
|
# Because we did not catch the tag delimiters
|
||||||
|
# earlier, we must be explicit with them here.
|
||||||
|
# Notice that this also matches "{}", as a way
|
||||||
|
# to later introduce it as an escape sequence.
|
||||||
|
\{(?1)?\}
|
||||||
|
|
|
||||||
|
# Make sure we match hanging "{".
|
||||||
|
\{
|
||||||
|
)
|
||||||
|
# Match content after the nested inline tag.
|
||||||
|
[^{}]*
|
||||||
|
)* # If there are more inline tags, match them as well.
|
||||||
|
# We use "*" since there may not be any nested inline
|
||||||
|
# tags.
|
||||||
|
)
|
||||||
|
\}/Sux',
|
||||||
|
$this->contents,
|
||||||
|
null,
|
||||||
|
PREG_SPLIT_DELIM_CAPTURE
|
||||||
|
);
|
||||||
|
for ($i=1, $l = count($this->parsedContents); $i<$l; $i += 2) {
|
||||||
|
$this->parsedContents[$i] = Tag::createInstance(
|
||||||
|
$this->parsedContents[$i],
|
||||||
|
$this->docblock
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//In order to allow "literal" inline tags, the otherwise invalid
|
||||||
|
//sequence "{@}" is changed to "@", and "{}" is changed to "}".
|
||||||
|
//See unit tests for examples.
|
||||||
|
for ($i=0, $l = count($this->parsedContents); $i<$l; $i += 2) {
|
||||||
|
$this->parsedContents[$i] = str_replace(
|
||||||
|
array('{@}', '{}'),
|
||||||
|
array('@', '}'),
|
||||||
|
$this->parsedContents[$i]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $this->parsedContents;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a formatted variant of the Long Description using MarkDown.
|
||||||
|
*
|
||||||
|
* @todo this should become a more intelligent piece of code where the
|
||||||
|
* configuration contains a setting what format long descriptions are.
|
||||||
|
*
|
||||||
|
* @codeCoverageIgnore Will be removed soon, in favor of adapters at
|
||||||
|
* PhpDocumentor itself that will process text in various formats.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getFormattedContents()
|
||||||
|
{
|
||||||
|
$result = $this->contents;
|
||||||
|
|
||||||
|
// if the long description contains a plain HTML <code> element, surround
|
||||||
|
// it with a pre element. Please note that we explicitly used str_replace
|
||||||
|
// and not preg_replace to gain performance
|
||||||
|
if (strpos($result, '<code>') !== false) {
|
||||||
|
$result = str_replace(
|
||||||
|
array('<code>', "<code>\r\n", "<code>\n", "<code>\r", '</code>'),
|
||||||
|
array('<pre><code>', '<code>', '<code>', '<code>', '</code></pre>'),
|
||||||
|
$result
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (class_exists('dflydev\markdown\MarkdownExtraParser')) {
|
||||||
|
$markdown = new \dflydev\markdown\MarkdownExtraParser();
|
||||||
|
$result = $markdown->transformMarkdown($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
return trim($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds a string representation of this object.
|
||||||
|
*
|
||||||
|
* @todo determine the exact format as used by PHP Reflection
|
||||||
|
* and implement it.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @codeCoverageIgnore Not yet implemented
|
||||||
|
*/
|
||||||
|
public static function export()
|
||||||
|
{
|
||||||
|
throw new \Exception('Not yet implemented');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the exported information (we should use the export static method
|
||||||
|
* BUT this throws an exception at this point).
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @codeCoverageIgnore Not yet implemented
|
||||||
|
*/
|
||||||
|
public function __toString()
|
||||||
|
{
|
||||||
|
return 'Not yet implemented';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
<?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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The location a DocBlock occurs within a file.
|
||||||
|
*
|
||||||
|
* @author Vasil Rangelov <[email protected]>
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
|
* @link http://phpdoc.org
|
||||||
|
*/
|
||||||
|
class Location
|
||||||
|
{
|
||||||
|
/** @var int Line where the DocBlock text starts. */
|
||||||
|
protected $line_number = 0;
|
||||||
|
|
||||||
|
/** @var int Column where the DocBlock text starts. */
|
||||||
|
protected $column_number = 0;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
$line_number = 0,
|
||||||
|
$column_number = 0
|
||||||
|
) {
|
||||||
|
$this->line_number = (int)$line_number;
|
||||||
|
$this->column_number = (int)$column_number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int Line where the DocBlock text starts.
|
||||||
|
*/
|
||||||
|
public function getLineNumber()
|
||||||
|
{
|
||||||
|
return $this->line_number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int Column where the DocBlock text starts.
|
||||||
|
*/
|
||||||
|
public function getColumnNumber()
|
||||||
|
{
|
||||||
|
return $this->column_number;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,129 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* phpDocumentor
|
|
||||||
*
|
|
||||||
* PHP Version 5.3
|
|
||||||
*
|
|
||||||
* @author Mike van Riel <[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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parses a Long Description of a DocBlock.
|
|
||||||
*
|
|
||||||
* @author Mike van Riel <[email protected]>
|
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
|
||||||
* @link http://phpdoc.org
|
|
||||||
*/
|
|
||||||
class LongDescription implements \Reflector
|
|
||||||
{
|
|
||||||
/** @var string */
|
|
||||||
protected $contents = '';
|
|
||||||
|
|
||||||
/** @var array The contents, as an array of strings and Tag objects. */
|
|
||||||
protected $parsedContents = null;
|
|
||||||
|
|
||||||
/** @var \phpDocumentor\Reflection\DocBlock\Tags[] */
|
|
||||||
protected $tags = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parses the string for inline tags and if the Markdown class is included;
|
|
||||||
* format the found text.
|
|
||||||
*
|
|
||||||
* @param string $content the DocBlock contents without asterisks.
|
|
||||||
*/
|
|
||||||
public function __construct($content)
|
|
||||||
{
|
|
||||||
$this->contents = trim($content);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the text of this description.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getContents()
|
|
||||||
{
|
|
||||||
return $this->contents;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Returns the parsed text of this description.
|
|
||||||
*
|
|
||||||
* @return array An array of strings and tag objects, in the order they
|
|
||||||
* occur within the description.
|
|
||||||
*/
|
|
||||||
public function getParsedContents()
|
|
||||||
{
|
|
||||||
if (null === $this->parsedContents) {
|
|
||||||
$this->parsedContents = preg_split(
|
|
||||||
'/\{(\@.*?)\}/uS', $this->contents,
|
|
||||||
null, PREG_SPLIT_DELIM_CAPTURE
|
|
||||||
);
|
|
||||||
for ($i=1, $l = count($this->parsedContents); $i<$l; $i += 2) {
|
|
||||||
$this->parsedContents[$i] = Tag::createInstance(
|
|
||||||
$this->parsedContents[$i]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $this->parsedContents;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a formatted variant of the Long Description using MarkDown.
|
|
||||||
*
|
|
||||||
* @todo this should become a more intelligent piece of code where the
|
|
||||||
* configuration contains a setting what format long descriptions are.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getFormattedContents()
|
|
||||||
{
|
|
||||||
$result = $this->contents;
|
|
||||||
|
|
||||||
// if the long description contains a plain HTML <code> element, surround
|
|
||||||
// it with a pre element. Please note that we explicitly used str_replace
|
|
||||||
// and not preg_replace to gain performance
|
|
||||||
if (strpos($result, '<code>') !== false) {
|
|
||||||
$result = str_replace(
|
|
||||||
array('<code>', "<code>\r\n", "<code>\n", "<code>\r", '</code>'),
|
|
||||||
array('<pre><code>', '<code>', '<code>', '<code>', '</code></pre>'),
|
|
||||||
$result
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (class_exists('dflydev\markdown\MarkdownExtraParser')) {
|
|
||||||
$md = new \dflydev\markdown\MarkdownExtraParser();
|
|
||||||
$result = $md->transformMarkdown($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
return trim($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds a string representation of this object.
|
|
||||||
*
|
|
||||||
* @todo determine the exact format as used by PHP Reflection and implement it.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
static public function export()
|
|
||||||
{
|
|
||||||
throw new \Exception('Not yet implemented');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the exported information (we should use the export static method
|
|
||||||
* BUT this throws an exception at this point).
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function __toString()
|
|
||||||
{
|
|
||||||
return 'Not yet implemented';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* phpDocumentor
|
* phpDocumentor
|
||||||
*
|
*
|
||||||
* PHP Version 5
|
* PHP Version 5.3
|
||||||
*
|
*
|
||||||
* @author Mike van Riel <[email protected]>
|
* @author Mike van Riel <[email protected]>
|
||||||
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
||||||
@@ -12,12 +12,14 @@
|
|||||||
|
|
||||||
namespace phpDocumentor\Reflection\DocBlock;
|
namespace phpDocumentor\Reflection\DocBlock;
|
||||||
|
|
||||||
|
use phpDocumentor\Reflection\DocBlock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses a tag definition for a DocBlock.
|
* Parses a tag definition for a DocBlock.
|
||||||
*
|
*
|
||||||
* @author Mike van Riel <[email protected]>
|
* @author Mike van Riel <[email protected]>
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
* @link http://phpdoc.org
|
* @link http://phpdoc.org
|
||||||
*/
|
*/
|
||||||
class Tag implements \Reflector
|
class Tag implements \Reflector
|
||||||
{
|
{
|
||||||
@@ -33,53 +35,160 @@ class Tag implements \Reflector
|
|||||||
/** @var array The description, as an array of strings and Tag objects. */
|
/** @var array The description, as an array of strings and Tag objects. */
|
||||||
protected $parsedDescription = null;
|
protected $parsedDescription = null;
|
||||||
|
|
||||||
/** @var int Line number of the tag */
|
/** @var Location Location of the tag. */
|
||||||
protected $line_number = 0;
|
protected $location = null;
|
||||||
|
|
||||||
/** @var \phpDocumentor\Reflection\DocBlock docblock class */
|
/** @var DocBlock The DocBlock which this tag belongs to. */
|
||||||
protected $docblock;
|
protected $docblock = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array An array with a tag as a key, and an FQCN to a class that
|
||||||
|
* handles it as an array value. The class is expected to inherit this
|
||||||
|
* class.
|
||||||
|
*/
|
||||||
|
private static $tagHandlerMappings = array(
|
||||||
|
'author'
|
||||||
|
=> '\phpDocumentor\Reflection\DocBlock\Tag\AuthorTag',
|
||||||
|
'covers'
|
||||||
|
=> '\phpDocumentor\Reflection\DocBlock\Tag\CoversTag',
|
||||||
|
'deprecated'
|
||||||
|
=> '\phpDocumentor\Reflection\DocBlock\Tag\DeprecatedTag',
|
||||||
|
'example'
|
||||||
|
=> '\phpDocumentor\Reflection\DocBlock\Tag\ExampleTag',
|
||||||
|
'link'
|
||||||
|
=> '\phpDocumentor\Reflection\DocBlock\Tag\LinkTag',
|
||||||
|
'method'
|
||||||
|
=> '\phpDocumentor\Reflection\DocBlock\Tag\MethodTag',
|
||||||
|
'param'
|
||||||
|
=> '\phpDocumentor\Reflection\DocBlock\Tag\ParamTag',
|
||||||
|
'property-read'
|
||||||
|
=> '\phpDocumentor\Reflection\DocBlock\Tag\PropertyReadTag',
|
||||||
|
'property'
|
||||||
|
=> '\phpDocumentor\Reflection\DocBlock\Tag\PropertyTag',
|
||||||
|
'property-write'
|
||||||
|
=> '\phpDocumentor\Reflection\DocBlock\Tag\PropertyWriteTag',
|
||||||
|
'return'
|
||||||
|
=> '\phpDocumentor\Reflection\DocBlock\Tag\ReturnTag',
|
||||||
|
'see'
|
||||||
|
=> '\phpDocumentor\Reflection\DocBlock\Tag\SeeTag',
|
||||||
|
'since'
|
||||||
|
=> '\phpDocumentor\Reflection\DocBlock\Tag\SinceTag',
|
||||||
|
'source'
|
||||||
|
=> '\phpDocumentor\Reflection\DocBlock\Tag\SourceTag',
|
||||||
|
'throw'
|
||||||
|
=> '\phpDocumentor\Reflection\DocBlock\Tag\ThrowsTag',
|
||||||
|
'throws'
|
||||||
|
=> '\phpDocumentor\Reflection\DocBlock\Tag\ThrowsTag',
|
||||||
|
'uses'
|
||||||
|
=> '\phpDocumentor\Reflection\DocBlock\Tag\UsesTag',
|
||||||
|
'var'
|
||||||
|
=> '\phpDocumentor\Reflection\DocBlock\Tag\VarTag',
|
||||||
|
'version'
|
||||||
|
=> '\phpDocumentor\Reflection\DocBlock\Tag\VersionTag'
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory method responsible for instantiating the correct sub type.
|
* Factory method responsible for instantiating the correct sub type.
|
||||||
*
|
*
|
||||||
* @param string $tag_line The text for this tag, including description.
|
* @param string $tag_line The text for this tag, including description.
|
||||||
|
* @param DocBlock $docblock The DocBlock which this tag belongs to.
|
||||||
|
* @param Location $location Location of the tag.
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException if an invalid tag line was presented.
|
* @throws \InvalidArgumentException if an invalid tag line was presented.
|
||||||
*
|
*
|
||||||
* @return \phpDocumentor\Reflection\DocBlock\Tag
|
* @return static A new tag object.
|
||||||
*/
|
*/
|
||||||
public static function createInstance($tag_line)
|
final public static function createInstance(
|
||||||
{
|
$tag_line,
|
||||||
|
DocBlock $docblock = null,
|
||||||
|
Location $location = null
|
||||||
|
) {
|
||||||
if (!preg_match(
|
if (!preg_match(
|
||||||
'/^@([\w\-\_\\\\]+)(?:\s*([^\s].*)|$)?/us', $tag_line, $matches
|
'/^@([\w\-\_\\\\]+)(?:\s*([^\s].*)|$)?/us',
|
||||||
|
$tag_line,
|
||||||
|
$matches
|
||||||
)) {
|
)) {
|
||||||
throw new \InvalidArgumentException(
|
throw new \InvalidArgumentException(
|
||||||
'Invalid tag_line detected: ' . $tag_line
|
'Invalid tag_line detected: ' . $tag_line
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// support hypphen separated tag names
|
$handler = __CLASS__;
|
||||||
$tag_name = str_replace(
|
if (isset(self::$tagHandlerMappings[$matches[1]])) {
|
||||||
' ', '', ucwords(str_replace('-', ' ', $matches[1]))
|
$handler = self::$tagHandlerMappings[$matches[1]];
|
||||||
).'Tag';
|
} elseif (isset($docblock)) {
|
||||||
$class_name = 'phpDocumentor\\Reflection\\DocBlock\\Tag\\' . $tag_name;
|
$tagName = (string)new Type\Collection(
|
||||||
|
array($matches[1]),
|
||||||
|
$docblock->getContext()
|
||||||
|
);
|
||||||
|
|
||||||
return (@class_exists($class_name))
|
if (isset(self::$tagHandlerMappings[$tagName])) {
|
||||||
? new $class_name($matches[1], isset($matches[2]) ? $matches[2] : '')
|
$handler = self::$tagHandlerMappings[$tagName];
|
||||||
: new self($matches[1], isset($matches[2]) ? $matches[2] : '');
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new $handler(
|
||||||
|
$matches[1],
|
||||||
|
isset($matches[2]) ? $matches[2] : '',
|
||||||
|
$docblock,
|
||||||
|
$location
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a handler for tags.
|
||||||
|
*
|
||||||
|
* Registers a handler for tags. The class specified is autoloaded if it's
|
||||||
|
* not available. It must inherit from this class.
|
||||||
|
*
|
||||||
|
* @param string $tag Name of tag to regiser a handler for. When
|
||||||
|
* registering a namespaced tag, the full name, along with a prefixing
|
||||||
|
* slash MUST be provided.
|
||||||
|
* @param string|null $handler FQCN of handler. Specifing NULL removes the
|
||||||
|
* handler for the specified tag, if any.
|
||||||
|
*
|
||||||
|
* @return bool TRUE on success, FALSE on failure.
|
||||||
|
*/
|
||||||
|
final public static function registerTagHandler($tag, $handler)
|
||||||
|
{
|
||||||
|
$tag = trim((string)$tag);
|
||||||
|
|
||||||
|
if (null === $handler) {
|
||||||
|
unset(self::$tagHandlerMappings[$tag]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('' !== $tag
|
||||||
|
&& class_exists($handler, true)
|
||||||
|
&& is_subclass_of($handler, __CLASS__)
|
||||||
|
&& !strpos($tag, '\\') //Accept no slash, and 1st slash at offset 0.
|
||||||
|
) {
|
||||||
|
self::$tagHandlerMappings[$tag] = $handler;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses a tag and populates the member variables.
|
* Parses a tag and populates the member variables.
|
||||||
*
|
*
|
||||||
* @param string $type Name of the tag.
|
* @param string $type Name of the tag.
|
||||||
* @param string $content The contents of the given tag.
|
* @param string $content The contents of the given tag.
|
||||||
|
* @param DocBlock $docblock The DocBlock which this tag belongs to.
|
||||||
|
* @param Location $location Location of the tag.
|
||||||
*/
|
*/
|
||||||
public function __construct($type, $content)
|
public function __construct(
|
||||||
{
|
$type,
|
||||||
$this->tag = $type;
|
$content,
|
||||||
$this->content = $content;
|
DocBlock $docblock = null,
|
||||||
$this->description = $content;
|
Location $location = null
|
||||||
|
) {
|
||||||
|
$this->tag = $type;
|
||||||
|
$this->content = $content;
|
||||||
|
$this->description = trim($content);
|
||||||
|
$this->docblock = $docblock;
|
||||||
|
$this->location = $location;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -112,55 +221,29 @@ class Tag implements \Reflector
|
|||||||
return $this->description;
|
return $this->description;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Returns the parsed text of this description.
|
* Returns the parsed text of this description.
|
||||||
*
|
*
|
||||||
* @return array An array of strings and tag objects, in the order they
|
* @return array An array of strings and tag objects, in the order they
|
||||||
* occur within the description.
|
* occur within the description.
|
||||||
*/
|
*/
|
||||||
public function getParsedDescription()
|
public function getParsedDescription()
|
||||||
{
|
{
|
||||||
if (null === $this->parsedDescription) {
|
if (null === $this->parsedDescription) {
|
||||||
$description = new LongDescription($this->description);
|
$description = new Description($this->description, $this->docblock);
|
||||||
$this->parsedDescription = $description->getParsedContents();
|
$this->parsedDescription = $description->getParsedContents();
|
||||||
}
|
}
|
||||||
return $this->parsedDescription;
|
return $this->parsedDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the tag line number
|
* Get the location of the tag.
|
||||||
*
|
*
|
||||||
* @param int $number the line number of the tag
|
* @return Location Tag's location.
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function setLineNumber($number)
|
public function getLocation()
|
||||||
{
|
{
|
||||||
$this->line_number = (int)$number;
|
return $this->location;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the line number of the tag
|
|
||||||
*
|
|
||||||
* @return int tag line number
|
|
||||||
*/
|
|
||||||
public function getLineNumber()
|
|
||||||
{
|
|
||||||
return $this->line_number;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Inject the docblock class
|
|
||||||
*
|
|
||||||
* This exposes some common functionality contained in the docblock abstract.
|
|
||||||
*
|
|
||||||
* @param object $docblock Object containing the DocBlock.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function setDocBlock($docblock)
|
|
||||||
{
|
|
||||||
$this->docblock = $docblock;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -169,8 +252,9 @@ class Tag implements \Reflector
|
|||||||
* @todo determine the exact format as used by PHP Reflection and implement it.
|
* @todo determine the exact format as used by PHP Reflection and implement it.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
|
* @codeCoverageIgnore Not yet implemented
|
||||||
*/
|
*/
|
||||||
static public function export()
|
public static function export()
|
||||||
{
|
{
|
||||||
throw new \Exception('Not yet implemented');
|
throw new \Exception('Not yet implemented');
|
||||||
}
|
}
|
||||||
@@ -180,10 +264,10 @@ class Tag implements \Reflector
|
|||||||
* BUT this throws an exception at this point).
|
* BUT this throws an exception at this point).
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
|
* @codeCoverageIgnore Not yet implemented
|
||||||
*/
|
*/
|
||||||
public function __toString()
|
public function __toString()
|
||||||
{
|
{
|
||||||
return 'Not yet implemented';
|
return 'Not yet implemented';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
/**
|
/**
|
||||||
* phpDocumentor
|
* phpDocumentor
|
||||||
*
|
*
|
||||||
* PHP Version 5
|
* PHP Version 5.3
|
||||||
*
|
*
|
||||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||||
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
* @link http://phpdoc.org
|
* @link http://phpdoc.org
|
||||||
@@ -12,14 +12,15 @@
|
|||||||
|
|
||||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
|
use phpDocumentor\Reflection\DocBlock;
|
||||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reflection class for an @author tag in a Docblock.
|
* Reflection class for an @author tag in a Docblock.
|
||||||
*
|
*
|
||||||
* @author Mike van Riel <[email protected]>
|
* @author Mike van Riel <[email protected]>
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
* @link http://phpdoc.org
|
* @link http://phpdoc.org
|
||||||
*/
|
*/
|
||||||
class AuthorTag extends Tag
|
class AuthorTag extends Tag
|
||||||
{
|
{
|
||||||
@@ -32,13 +33,23 @@ class AuthorTag extends Tag
|
|||||||
/**
|
/**
|
||||||
* Parses a tag and populates the member variables.
|
* Parses a tag and populates the member variables.
|
||||||
*
|
*
|
||||||
* @param string $type Name of the tag.
|
* @param string $type Tag identifier for this tag (should be 'author').
|
||||||
* @param string $content The contents of the given tag.
|
* @param string $content Contents for this tag.
|
||||||
|
* @param DocBlock $docblock The DocBlock which this tag belongs to.
|
||||||
|
* @param Location $location Location of the tag.
|
||||||
*/
|
*/
|
||||||
public function __construct($type, $content)
|
public function __construct(
|
||||||
{
|
$type,
|
||||||
parent::__construct($type, $content);
|
$content,
|
||||||
if (preg_match('/^([^\<]*)(\<([^\>]*)\>)?$/', $content, $matches)) {
|
DocBlock $docblock = null,
|
||||||
|
Location $location = null
|
||||||
|
) {
|
||||||
|
parent::__construct($type, $content, $docblock, $location);
|
||||||
|
if (preg_match(
|
||||||
|
'/^([^\<]*)(\<([^\>]*)\>)?$/',
|
||||||
|
$this->description,
|
||||||
|
$matches
|
||||||
|
)) {
|
||||||
$this->name = trim($matches[1]);
|
$this->name = trim($matches[1]);
|
||||||
if (isset($matches[3])) {
|
if (isset($matches[3])) {
|
||||||
$this->email = trim($matches[3]);
|
$this->email = trim($matches[3]);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* phpDocumentor
|
* phpDocumentor
|
||||||
*
|
*
|
||||||
* PHP Version 5
|
* PHP Version 5.3
|
||||||
*
|
*
|
||||||
* @author Mike van Riel <[email protected]>
|
* @author Mike van Riel <[email protected]>
|
||||||
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
||||||
@@ -15,11 +15,10 @@ namespace phpDocumentor\Reflection\DocBlock\Tag;
|
|||||||
/**
|
/**
|
||||||
* Reflection class for a @covers tag in a Docblock.
|
* Reflection class for a @covers tag in a Docblock.
|
||||||
*
|
*
|
||||||
* @author Mike van Riel <[email protected]>
|
* @author Mike van Riel <[email protected]>
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
* @link http://phpdoc.org
|
* @link http://phpdoc.org
|
||||||
*/
|
*/
|
||||||
class CoversTag extends SeeTag
|
class CoversTag extends SeeTag
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,91 @@
|
|||||||
|
<?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 @example tag in a Docblock.
|
||||||
|
*
|
||||||
|
* @author Vasil Rangelov <[email protected]>
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
|
* @link http://phpdoc.org
|
||||||
|
*/
|
||||||
|
class ExampleTag extends SourceTag
|
||||||
|
{
|
||||||
|
/** @var string Path to a file to use as an example. Can also be an URI. */
|
||||||
|
protected $filePath = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses a tag and populates the member variables.
|
||||||
|
*
|
||||||
|
* @param string $type Tag identifier for this tag (should be 'example').
|
||||||
|
* @param string $content Contents for this tag.
|
||||||
|
* @param DocBlock $docblock The DocBlock which this tag belongs to.
|
||||||
|
* @param Location $location Location of the tag.
|
||||||
|
*/
|
||||||
|
public function __construct(
|
||||||
|
$type,
|
||||||
|
$content,
|
||||||
|
DocBlock $docblock = null,
|
||||||
|
Location $location = null
|
||||||
|
) {
|
||||||
|
Tag::__construct($type, $content, $docblock, $location);
|
||||||
|
if (preg_match(
|
||||||
|
'/^
|
||||||
|
(?:
|
||||||
|
# File path in quotes
|
||||||
|
\"([^\"]+)\"
|
||||||
|
|
|
||||||
|
# File URI
|
||||||
|
(\S+)
|
||||||
|
)
|
||||||
|
# Remaining content (parsed by SourceTag)
|
||||||
|
(?:\s+(.*))?
|
||||||
|
$/sux',
|
||||||
|
$this->description,
|
||||||
|
$matches
|
||||||
|
)) {
|
||||||
|
if ('' !== $matches[1]) {
|
||||||
|
//Quoted file path.
|
||||||
|
$this->filePath = trim($matches[1]);
|
||||||
|
} elseif (false === strpos($matches[2], ':')) {
|
||||||
|
//Relative URL or a file path with no spaces in it.
|
||||||
|
$this->filePath = rawurldecode(
|
||||||
|
str_replace(array('/', '\\'), '%2F', $matches[2])
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
//Absolute URL or URI.
|
||||||
|
$this->filePath = $matches[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($matches[3])) {
|
||||||
|
parent::__construct($type, $matches[3]);
|
||||||
|
$this->content = $content;
|
||||||
|
} else {
|
||||||
|
$this->description = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the file path.
|
||||||
|
*
|
||||||
|
* @return string Path to a file to use as an example. Can also be an URI.
|
||||||
|
*/
|
||||||
|
public function getFilePath()
|
||||||
|
{
|
||||||
|
return $this->filePath;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* phpDocumentor
|
* phpDocumentor
|
||||||
*
|
*
|
||||||
* PHP Version 5
|
* PHP Version 5.3
|
||||||
*
|
*
|
||||||
* @author Ben Selby <[email protected]>
|
* @author Ben Selby <[email protected]>
|
||||||
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
||||||
@@ -11,14 +11,16 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
|
use phpDocumentor\Reflection\DocBlock;
|
||||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reflection class for a @link tag in a Docblock.
|
* Reflection class for a @link tag in a Docblock.
|
||||||
*
|
*
|
||||||
* @author Ben Selby <[email protected]>
|
* @author Ben Selby <[email protected]>
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
* @link http://phpdoc.org
|
* @link http://phpdoc.org
|
||||||
*/
|
*/
|
||||||
class LinkTag extends Tag
|
class LinkTag extends Tag
|
||||||
{
|
{
|
||||||
@@ -28,23 +30,24 @@ class LinkTag extends Tag
|
|||||||
/**
|
/**
|
||||||
* Parses a tag and populates the member variables.
|
* Parses a tag and populates the member variables.
|
||||||
*
|
*
|
||||||
* @param string $type Tag type
|
* @param string $type Tag identifier for this tag (should be 'link').
|
||||||
* @param string $content Content of the tag
|
* @param string $content Contents for this tag.
|
||||||
|
* @param DocBlock $docblock The DocBlock which this tag belongs to.
|
||||||
|
* @param Location $location Location of the tag.
|
||||||
*/
|
*/
|
||||||
public function __construct($type, $content)
|
public function __construct(
|
||||||
{
|
$type,
|
||||||
$this->tag = $type;
|
$content,
|
||||||
$pieces = explode(' ', $content);
|
DocBlock $docblock = null,
|
||||||
|
Location $location = null
|
||||||
|
) {
|
||||||
|
parent::__construct($type, $content, $docblock, $location);
|
||||||
|
$content = preg_split('/\s+/u', $this->description, 2);
|
||||||
|
|
||||||
if (count($pieces) > 1) {
|
// any output is considered a type
|
||||||
$this->link = array_shift($pieces);
|
$this->link = $content[0];
|
||||||
$this->description = implode(' ', $pieces);
|
|
||||||
} else {
|
|
||||||
$this->link = $content;
|
|
||||||
$this->description = $content;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->content = $content;
|
$this->description = isset($content[1]) ? $content[1] : $content[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* phpDocumentor
|
* phpDocumentor
|
||||||
*
|
*
|
||||||
* PHP Version 5
|
* PHP Version 5.3
|
||||||
*
|
*
|
||||||
* @author Mike van Riel <[email protected]>
|
* @author Mike van Riel <[email protected]>
|
||||||
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
||||||
@@ -12,14 +12,17 @@
|
|||||||
|
|
||||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
|
use phpDocumentor\Reflection\DocBlock;
|
||||||
|
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reflection class for a {@method} in a Docblock.
|
* Reflection class for a @method in a Docblock.
|
||||||
*
|
*
|
||||||
* @author Mike van Riel <[email protected]>
|
* @author Mike van Riel <[email protected]>
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
* @link http://phpdoc.org
|
* @link http://phpdoc.org
|
||||||
*/
|
*/
|
||||||
class MethodTag extends ParamTag
|
class MethodTag extends ReturnTag
|
||||||
{
|
{
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
@@ -31,13 +34,18 @@ class MethodTag extends ParamTag
|
|||||||
/**
|
/**
|
||||||
* Parses a tag and populates the member variables.
|
* Parses a tag and populates the member variables.
|
||||||
*
|
*
|
||||||
* @param string $type Tag identifier for this tag (should be 'return')
|
* @param string $type Tag identifier for this tag (should be 'method').
|
||||||
* @param string $content Contents for this tag.
|
* @param string $content Contents for this tag.
|
||||||
|
* @param DocBlock $docblock The DocBlock which this tag belongs to.
|
||||||
|
* @param Location $location Location of the tag.
|
||||||
*/
|
*/
|
||||||
public function __construct($type, $content)
|
public function __construct(
|
||||||
{
|
$type,
|
||||||
$this->tag = $type;
|
$content,
|
||||||
$this->content = $content;
|
DocBlock $docblock = null,
|
||||||
|
Location $location = null
|
||||||
|
) {
|
||||||
|
Tag::__construct($type, $content, $docblock, $location);
|
||||||
|
|
||||||
$matches = array();
|
$matches = array();
|
||||||
// 1. none or more whitespace
|
// 1. none or more whitespace
|
||||||
@@ -49,9 +57,25 @@ class MethodTag extends ParamTag
|
|||||||
// until a ) and whitespace : as method name with signature
|
// until a ) and whitespace : as method name with signature
|
||||||
// 5. any remaining text : as description
|
// 5. any remaining text : as description
|
||||||
if (preg_match(
|
if (preg_match(
|
||||||
'/^[\s]*(?:([\w\|_\\\\]+)[\s]+)?(?:[\w_]+\(\)[\s]+)?([\w\|_\\\\]+)\(([^\)]*)\)'
|
'/^
|
||||||
.'[\s]*(.*)/u',
|
# Return type
|
||||||
$content,
|
(?:
|
||||||
|
([\w\|_\\\\]+)
|
||||||
|
\s+
|
||||||
|
)?
|
||||||
|
# Legacy method name (not captured)
|
||||||
|
(?:
|
||||||
|
[\w_]+\(\)\s+
|
||||||
|
)?
|
||||||
|
# Method name
|
||||||
|
([\w\|_\\\\]+)
|
||||||
|
# Arguments
|
||||||
|
\(([^\)]*)\)
|
||||||
|
\s*
|
||||||
|
# Description
|
||||||
|
(.*)
|
||||||
|
$/sux',
|
||||||
|
$this->description,
|
||||||
$matches
|
$matches
|
||||||
)) {
|
)) {
|
||||||
list(
|
list(
|
||||||
@@ -61,8 +85,7 @@ class MethodTag extends ParamTag
|
|||||||
$this->arguments,
|
$this->arguments,
|
||||||
$this->description
|
$this->description
|
||||||
) = $matches;
|
) = $matches;
|
||||||
if (!$this->type)
|
if (!$this->type) {
|
||||||
{
|
|
||||||
$this->type = 'void';
|
$this->type = 'void';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -126,5 +149,4 @@ class MethodTag extends ParamTag
|
|||||||
|
|
||||||
return $arguments;
|
return $arguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* phpDocumentor
|
* phpDocumentor
|
||||||
*
|
*
|
||||||
* PHP Version 5
|
* PHP Version 5.3
|
||||||
*
|
*
|
||||||
* @author Mike van Riel <[email protected]>
|
* @author Mike van Riel <[email protected]>
|
||||||
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
||||||
@@ -11,20 +11,19 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
|
use phpDocumentor\Reflection\DocBlock;
|
||||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reflection class for a {@param} tag in a Docblock.
|
* Reflection class for a @param tag in a Docblock.
|
||||||
*
|
*
|
||||||
* @author Mike van Riel <[email protected]>
|
* @author Mike van Riel <[email protected]>
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
* @link http://phpdoc.org
|
* @link http://phpdoc.org
|
||||||
*/
|
*/
|
||||||
class ParamTag extends Tag
|
class ParamTag extends ReturnTag
|
||||||
{
|
{
|
||||||
/** @var string */
|
|
||||||
protected $type = '';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
@@ -33,52 +32,44 @@ class ParamTag extends Tag
|
|||||||
/**
|
/**
|
||||||
* Parses a tag and populates the member variables.
|
* Parses a tag and populates the member variables.
|
||||||
*
|
*
|
||||||
* @param string $type Tag identifier for this tag (should be 'param')
|
* @param string $type Tag identifier for this tag (should be 'param').
|
||||||
* @param string $content Contents for this tag.
|
* @param string $content Contents for this tag.
|
||||||
|
* @param DocBlock $docblock The DocBlock which this tag belongs to.
|
||||||
|
* @param Location $location Location of the tag.
|
||||||
*/
|
*/
|
||||||
public function __construct($type, $content)
|
public function __construct(
|
||||||
{
|
$type,
|
||||||
$this->tag = $type;
|
$content,
|
||||||
$this->content = $content;
|
DocBlock $docblock = null,
|
||||||
$content = preg_split('/\s+/u', $content);
|
Location $location = null
|
||||||
|
) {
|
||||||
|
Tag::__construct($type, $content, $docblock, $location);
|
||||||
|
$content = preg_split(
|
||||||
|
'/(\s+)/u',
|
||||||
|
$this->description,
|
||||||
|
3,
|
||||||
|
PREG_SPLIT_DELIM_CAPTURE
|
||||||
|
);
|
||||||
|
|
||||||
// if the first item that is encountered is not a variable; it is a type
|
// if the first item that is encountered is not a variable; it is a type
|
||||||
if (isset($content[0]) && (strlen($content[0]) > 0) && ($content[0][0] !== '$')) {
|
if (isset($content[0])
|
||||||
|
&& (strlen($content[0]) > 0)
|
||||||
|
&& ($content[0][0] !== '$')
|
||||||
|
) {
|
||||||
$this->type = array_shift($content);
|
$this->type = array_shift($content);
|
||||||
|
array_shift($content);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the next item starts with a $ it must be the variable name
|
// if the next item starts with a $ it must be the variable name
|
||||||
if (isset($content[0]) && (strlen($content[0]) > 0) && ($content[0][0] == '$')) {
|
if (isset($content[0])
|
||||||
|
&& (strlen($content[0]) > 0)
|
||||||
|
&& ($content[0][0] == '$')
|
||||||
|
) {
|
||||||
$this->variableName = array_shift($content);
|
$this->variableName = array_shift($content);
|
||||||
|
array_shift($content);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->description = implode(' ', $content);
|
$this->description = implode('', $content);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the unique types of the variable.
|
|
||||||
*
|
|
||||||
* @return string[]
|
|
||||||
*/
|
|
||||||
public function getTypes()
|
|
||||||
{
|
|
||||||
$types = new \phpDocumentor\Reflection\DocBlock\Type\Collection(
|
|
||||||
array($this->type),
|
|
||||||
$this->docblock ? $this->docblock->getNamespace() : null,
|
|
||||||
$this->docblock ? $this->docblock->getNamespaceAliases() : array()
|
|
||||||
);
|
|
||||||
|
|
||||||
return $types->getArrayCopy();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the type section of the variable.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getType()
|
|
||||||
{
|
|
||||||
return implode('|', $this->getTypes());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* phpDocumentor
|
* phpDocumentor
|
||||||
*
|
*
|
||||||
* PHP Version 5
|
* PHP Version 5.3
|
||||||
*
|
*
|
||||||
* @author Mike van Riel <[email protected]>
|
* @author Mike van Riel <[email protected]>
|
||||||
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
||||||
@@ -13,13 +13,12 @@
|
|||||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reflection class for a {@property} tag in a Docblock.
|
* Reflection class for a @property-read tag in a Docblock.
|
||||||
*
|
*
|
||||||
* @author Mike van Riel <[email protected]>
|
* @author Mike van Riel <[email protected]>
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
* @link http://phpdoc.org
|
* @link http://phpdoc.org
|
||||||
*/
|
*/
|
||||||
class PropertyReadTag extends PropertyTag
|
class PropertyReadTag extends PropertyTag
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* phpDocumentor
|
* phpDocumentor
|
||||||
*
|
*
|
||||||
* PHP Version 5
|
* PHP Version 5.3
|
||||||
*
|
*
|
||||||
* @author Mike van Riel <[email protected]>
|
* @author Mike van Riel <[email protected]>
|
||||||
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
||||||
@@ -13,13 +13,12 @@
|
|||||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reflection class for a {@property} tag in a Docblock.
|
* Reflection class for a @property tag in a Docblock.
|
||||||
*
|
*
|
||||||
* @author Mike van Riel <[email protected]>
|
* @author Mike van Riel <[email protected]>
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
* @link http://phpdoc.org
|
* @link http://phpdoc.org
|
||||||
*/
|
*/
|
||||||
class PropertyTag extends ParamTag
|
class PropertyTag extends ParamTag
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* phpDocumentor
|
* phpDocumentor
|
||||||
*
|
*
|
||||||
* PHP Version 5
|
* PHP Version 5.3
|
||||||
*
|
*
|
||||||
* @author Mike van Riel <[email protected]>
|
* @author Mike van Riel <[email protected]>
|
||||||
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
||||||
@@ -13,13 +13,12 @@
|
|||||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reflection class for a {@property} tag in a Docblock.
|
* Reflection class for a @property-write tag in a Docblock.
|
||||||
*
|
*
|
||||||
* @author Mike van Riel <[email protected]>
|
* @author Mike van Riel <[email protected]>
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
* @link http://phpdoc.org
|
* @link http://phpdoc.org
|
||||||
*/
|
*/
|
||||||
class PropertyWriteTag extends PropertyTag
|
class PropertyWriteTag extends PropertyTag
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* phpDocumentor
|
* phpDocumentor
|
||||||
*
|
*
|
||||||
* PHP Version 5
|
* PHP Version 5.3
|
||||||
*
|
*
|
||||||
* @author Mike van Riel <[email protected]>
|
* @author Mike van Riel <[email protected]>
|
||||||
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
||||||
@@ -12,35 +12,81 @@
|
|||||||
|
|
||||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
|
use phpDocumentor\Reflection\DocBlock;
|
||||||
|
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
use phpDocumentor\Reflection\DocBlock\Type\Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reflection class for a {@return} tag in a Docblock.
|
* Reflection class for a @return tag in a Docblock.
|
||||||
*
|
*
|
||||||
* @author Mike van Riel <[email protected]>
|
* @author Mike van Riel <[email protected]>
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
* @link http://phpdoc.org
|
* @link http://phpdoc.org
|
||||||
*/
|
*/
|
||||||
class ReturnTag extends ParamTag
|
class ReturnTag extends Tag
|
||||||
{
|
{
|
||||||
/** @var string */
|
/** @var string The raw type component. */
|
||||||
protected $type = null;
|
protected $type = '';
|
||||||
|
|
||||||
|
/** @var Collection The parsed type component. */
|
||||||
|
protected $types = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses a tag and populates the member variables.
|
* Parses a tag and populates the member variables.
|
||||||
*
|
*
|
||||||
* @param string $type Tag identifier for this tag (should be 'return')
|
* @param string $type Tag identifier for this tag (should be 'return').
|
||||||
* @param string $content Contents for this tag.
|
* @param string $content Contents for this tag.
|
||||||
|
* @param DocBlock $docblock The DocBlock which this tag belongs to.
|
||||||
|
* @param Location $location Location of the tag.
|
||||||
*/
|
*/
|
||||||
public function __construct($type, $content)
|
public function __construct(
|
||||||
{
|
$type,
|
||||||
$this->tag = $type;
|
$content,
|
||||||
$this->content = $content;
|
DocBlock $docblock = null,
|
||||||
|
Location $location = null
|
||||||
$content = preg_split('/[\ \t]+/u', $content, 2);
|
) {
|
||||||
|
parent::__construct($type, $content, $docblock, $location);
|
||||||
|
$content = preg_split('/\s+/u', $this->description, 2);
|
||||||
|
|
||||||
// any output is considered a type
|
// any output is considered a type
|
||||||
$this->type = array_shift($content);
|
$this->type = $content[0];
|
||||||
|
|
||||||
$this->description = implode(' ', $content);
|
$this->description = isset($content[1]) ? $content[1] : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the unique types of the variable.
|
||||||
|
*
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
|
public function getTypes()
|
||||||
|
{
|
||||||
|
return $this->getTypesCollection()->getArrayCopy();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the type section of the variable.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getType()
|
||||||
|
{
|
||||||
|
return (string) $this->getTypesCollection();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the type collection.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function getTypesCollection()
|
||||||
|
{
|
||||||
|
if (null === $this->types) {
|
||||||
|
$this->types = new Collection(
|
||||||
|
array($this->type),
|
||||||
|
$this->docblock ? $this->docblock->getContext() : null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return $this->types;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* phpDocumentor
|
* phpDocumentor
|
||||||
*
|
*
|
||||||
* PHP Version 5
|
* PHP Version 5.3
|
||||||
*
|
*
|
||||||
* @author Mike van Riel <[email protected]>
|
* @author Mike van Riel <[email protected]>
|
||||||
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
||||||
@@ -11,14 +11,16 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
|
use phpDocumentor\Reflection\DocBlock;
|
||||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reflection class for a {@see} tag in a Docblock.
|
* Reflection class for a @see tag in a Docblock.
|
||||||
*
|
*
|
||||||
* @author Mike van Riel <[email protected]>
|
* @author Mike van Riel <[email protected]>
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
* @link http://phpdoc.org
|
* @link http://phpdoc.org
|
||||||
*/
|
*/
|
||||||
class SeeTag extends Tag
|
class SeeTag extends Tag
|
||||||
{
|
{
|
||||||
@@ -28,19 +30,24 @@ class SeeTag extends Tag
|
|||||||
/**
|
/**
|
||||||
* Parses a tag and populates the member variables.
|
* Parses a tag and populates the member variables.
|
||||||
*
|
*
|
||||||
* @param string $type Tag identifier for this tag (should be 'return')
|
* @param string $type Tag identifier for this tag (should be 'see').
|
||||||
* @param string $content Contents for this tag.
|
* @param string $content Contents for this tag.
|
||||||
|
* @param DocBlock $docblock The DocBlock which this tag belongs to.
|
||||||
|
* @param Location $location Location of the tag.
|
||||||
*/
|
*/
|
||||||
public function __construct($type, $content)
|
public function __construct(
|
||||||
{
|
$type,
|
||||||
$this->tag = $type;
|
$content,
|
||||||
$this->content = $content;
|
DocBlock $docblock = null,
|
||||||
$content = preg_split('/\s+/u', $content);
|
Location $location = null
|
||||||
|
) {
|
||||||
|
parent::__construct($type, $content, $docblock, $location);
|
||||||
|
$content = preg_split('/\s+/u', $this->description, 2);
|
||||||
|
|
||||||
// any output is considered a type
|
// any output is considered a type
|
||||||
$this->refers = array_shift($content);
|
$this->refers = $content[0];
|
||||||
|
|
||||||
$this->description = implode(' ', $content);
|
$this->description = isset($content[1]) ? $content[1] : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -52,5 +59,4 @@ class SeeTag extends Tag
|
|||||||
{
|
{
|
||||||
return $this->refers;
|
return $this->refers;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,98 @@
|
|||||||
|
<?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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reflection class for a @source tag in a Docblock.
|
||||||
|
*
|
||||||
|
* @author Vasil Rangelov <[email protected]>
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
|
* @link http://phpdoc.org
|
||||||
|
*/
|
||||||
|
class SourceTag extends Tag
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var int The starting line, relative to the structural element's
|
||||||
|
* location.
|
||||||
|
*/
|
||||||
|
protected $startingLine = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int|null The number of lines, relative to the starting line. NULL
|
||||||
|
* means "to the end".
|
||||||
|
*/
|
||||||
|
protected $lineCount = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses a tag and populates the member variables.
|
||||||
|
*
|
||||||
|
* @param string $type Tag identifier for this tag (should be 'source').
|
||||||
|
* @param string $content Contents for this tag.
|
||||||
|
* @param DocBlock $docblock The DocBlock which this tag belongs to.
|
||||||
|
* @param Location $location Location of the tag.
|
||||||
|
*/
|
||||||
|
public function __construct(
|
||||||
|
$type,
|
||||||
|
$content,
|
||||||
|
DocBlock $docblock = null,
|
||||||
|
Location $location = null
|
||||||
|
) {
|
||||||
|
parent::__construct($type, $content, $docblock, $location);
|
||||||
|
if (preg_match(
|
||||||
|
'/^
|
||||||
|
# Starting line
|
||||||
|
([1-9]\d*)
|
||||||
|
\s*
|
||||||
|
# Number of lines
|
||||||
|
(?:
|
||||||
|
((?1))
|
||||||
|
\s+
|
||||||
|
)?
|
||||||
|
# Description
|
||||||
|
(.*)
|
||||||
|
$/sux',
|
||||||
|
$this->description,
|
||||||
|
$matches
|
||||||
|
)) {
|
||||||
|
$this->startingLine = (int)$matches[1];
|
||||||
|
if (isset($matches[2]) && '' !== $matches[2]) {
|
||||||
|
$this->lineCount = (int)$matches[2];
|
||||||
|
}
|
||||||
|
$this->description = $matches[3];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the starting line.
|
||||||
|
*
|
||||||
|
* @return int The starting line, relative to the structural element's
|
||||||
|
* location.
|
||||||
|
*/
|
||||||
|
public function getStartingLine()
|
||||||
|
{
|
||||||
|
return $this->startingLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of lines.
|
||||||
|
*
|
||||||
|
* @return int|null The number of lines, relative to the starting line. NULL
|
||||||
|
* means "to the end".
|
||||||
|
*/
|
||||||
|
public function getLineCount()
|
||||||
|
{
|
||||||
|
return $this->lineCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* phpDocumentor
|
|
||||||
*
|
|
||||||
* PHP Version 5
|
|
||||||
*
|
|
||||||
* @author Mike van Riel <[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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reflection class for a mistyped @throws tag called @throw in a Docblock.
|
|
||||||
*
|
|
||||||
* This is a very common error, so @throw is aliased to be @throws
|
|
||||||
*
|
|
||||||
* @author Mike van Riel <[email protected]>
|
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
|
||||||
* @link http://phpdoc.org
|
|
||||||
*/
|
|
||||||
class ThrowTag extends ThrowsTag
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Sets the type to {@throws} and lets parent parse the tag and populates the
|
|
||||||
* member variables.
|
|
||||||
*
|
|
||||||
* @param string $type Tag identifier for this tag (should be 'return')
|
|
||||||
* @param string $content Contents for this tag.
|
|
||||||
*/
|
|
||||||
public function __construct($type, $content)
|
|
||||||
{
|
|
||||||
if ('throw' !== $type) {
|
|
||||||
throw new \InvalidArgumentException(
|
|
||||||
'Internal error, ' . __CLASS__ . ' was called with ' . $type
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
parent::__construct('throws', $content);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* phpDocumentor
|
* phpDocumentor
|
||||||
*
|
*
|
||||||
* PHP Version 5
|
* PHP Version 5.3
|
||||||
*
|
*
|
||||||
* @author Mike van Riel <[email protected]>
|
* @author Mike van Riel <[email protected]>
|
||||||
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
||||||
@@ -13,13 +13,12 @@
|
|||||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reflection class for a {@throws} tag in a Docblock.
|
* Reflection class for a @throws tag in a Docblock.
|
||||||
*
|
*
|
||||||
* @author Mike van Riel <[email protected]>
|
* @author Mike van Riel <[email protected]>
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
* @link http://phpdoc.org
|
* @link http://phpdoc.org
|
||||||
*/
|
*/
|
||||||
class ThrowsTag extends ReturnTag
|
class ThrowsTag extends ReturnTag
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* phpDocumentor
|
* phpDocumentor
|
||||||
*
|
*
|
||||||
* PHP Version 5
|
* PHP Version 5.3
|
||||||
*
|
*
|
||||||
* @author Mike van Riel <[email protected]>
|
* @author Mike van Riel <[email protected]>
|
||||||
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
||||||
@@ -13,13 +13,12 @@
|
|||||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reflection class for a {@uses} tag in a Docblock.
|
* Reflection class for a @uses tag in a Docblock.
|
||||||
*
|
*
|
||||||
* @author Mike van Riel <[email protected]>
|
* @author Mike van Riel <[email protected]>
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
* @link http://phpdoc.org
|
* @link http://phpdoc.org
|
||||||
*/
|
*/
|
||||||
class UsesTag extends SeeTag
|
class UsesTag extends SeeTag
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* phpDocumentor
|
* phpDocumentor
|
||||||
*
|
*
|
||||||
* PHP Version 5
|
* PHP Version 5.3
|
||||||
*
|
*
|
||||||
* @author Mike van Riel <[email protected]>
|
* @author Mike van Riel <[email protected]>
|
||||||
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
||||||
@@ -12,26 +12,34 @@
|
|||||||
|
|
||||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
|
use phpDocumentor\Reflection\DocBlock;
|
||||||
|
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reflection class for a {@var} tag in a Docblock.
|
* Reflection class for a @var tag in a Docblock.
|
||||||
*
|
*
|
||||||
* @author Mike van Riel <[email protected]>
|
* @author Mike van Riel <[email protected]>
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||||
* @link http://phpdoc.org
|
* @link http://phpdoc.org
|
||||||
*/
|
*/
|
||||||
class VarTag extends ParamTag
|
class VarTag extends ParamTag
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Parses a tag and populates the member variables.
|
* Parses a tag and populates the member variables.
|
||||||
*
|
*
|
||||||
* @param string $type Tag identifier for this tag (should be 'return')
|
* @param string $type Tag identifier for this tag (should be 'var').
|
||||||
* @param string $content Contents for this tag.
|
* @param string $content Contents for this tag.
|
||||||
|
* @param DocBlock $docblock The DocBlock which this tag belongs to.
|
||||||
|
* @param Location $location Location of the tag.
|
||||||
*/
|
*/
|
||||||
public function __construct($type, $content)
|
public function __construct(
|
||||||
{
|
$type,
|
||||||
$this->tag = $type;
|
$content,
|
||||||
$this->content = $content;
|
DocBlock $docblock = null,
|
||||||
$content = preg_split('/\s+/u', $content);
|
Location $location = null
|
||||||
|
) {
|
||||||
|
Tag::__construct($type, $content, $docblock, $location);
|
||||||
|
$content = preg_split('/\s+/u', $this->description);
|
||||||
|
|
||||||
if (count($content) == 0) {
|
if (count($content) == 0) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -0,0 +1,81 @@
|
|||||||
|
<?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.
|
||||||
|
* @param Location $location Location of the tag.
|
||||||
|
*/
|
||||||
|
public function __construct(
|
||||||
|
$type,
|
||||||
|
$content,
|
||||||
|
DocBlock $docblock = null,
|
||||||
|
Location $location = null
|
||||||
|
) {
|
||||||
|
parent::__construct($type, $content, $docblock, $location);
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,27 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* phpDocumentor
|
||||||
|
*
|
||||||
|
* PHP Version 5.3
|
||||||
|
*
|
||||||
|
* @author Mike van Riel <[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\Type;
|
namespace phpDocumentor\Reflection\DocBlock\Type;
|
||||||
|
|
||||||
|
use phpDocumentor\Reflection\DocBlock\Context;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collection
|
||||||
|
*
|
||||||
|
* @author Mike van Riel <[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
|
||||||
|
*/
|
||||||
class Collection extends \ArrayObject
|
class Collection extends \ArrayObject
|
||||||
{
|
{
|
||||||
/** @var string Definition of the OR operator for types */
|
/** @var string Definition of the OR operator for types */
|
||||||
@@ -20,106 +41,42 @@ class Collection extends \ArrayObject
|
|||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Current namespace of the invoking location.
|
* Current invoking location.
|
||||||
*
|
*
|
||||||
* This string is used to prepend to type with a relative location.
|
* This is used to prepend to type with a relative location.
|
||||||
* May also be 'default' or 'global', in which case they are ignored.
|
* May also be 'default' or 'global', in which case they are ignored.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var Context
|
||||||
*/
|
*/
|
||||||
protected $namespace = '\\';
|
protected $context = null;
|
||||||
|
|
||||||
/**
|
|
||||||
* Associative array of alias => namespace pairs.
|
|
||||||
*
|
|
||||||
* @var string[]
|
|
||||||
*/
|
|
||||||
protected $namespace_aliases = array();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers the namespace and aliases; uses that to add and expand the
|
* Registers the namespace and aliases; uses that to add and expand the
|
||||||
* given types.
|
* given types.
|
||||||
*
|
*
|
||||||
* @param string[] $types Array containing a list of types
|
* @param string[] $types Array containing a list of types to add to this
|
||||||
* to add to this container.
|
* container.
|
||||||
* @param string|null $namespace The namespace where the types in
|
* @param Context $location The current invoking location.
|
||||||
* this container are relative to; used to expand any relative
|
|
||||||
* namespaces.
|
|
||||||
* @param string[] $namespace_aliases An array containing alias => FQNN
|
|
||||||
* pairs that are used in the resolving process.
|
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
array $types = array(), $namespace = null,
|
array $types = array(),
|
||||||
array $namespace_aliases = array()
|
Context $context = null
|
||||||
) {
|
) {
|
||||||
// only set the namespace if overridden
|
$this->context = null === $context ? new Context() : $context;
|
||||||
if (is_string($namespace)) {
|
|
||||||
$this->setNamespace($namespace);
|
|
||||||
}
|
|
||||||
$this->namespace_aliases = $namespace_aliases;
|
|
||||||
|
|
||||||
foreach($types as $type) {
|
foreach ($types as $type) {
|
||||||
$this->add($type);
|
$this->add($type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the namespace name used to expand relative namespaces with.
|
* Returns the current invoking location.
|
||||||
*
|
*
|
||||||
* @return string
|
* @return Context
|
||||||
*/
|
*/
|
||||||
public function getNamespace()
|
public function getContext()
|
||||||
{
|
{
|
||||||
return $this->namespace;
|
return $this->context;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the namespace which is used to resolve types with relative
|
|
||||||
* namespaces.
|
|
||||||
*
|
|
||||||
* Unless the name of the current namespace if default or global we make
|
|
||||||
* sure the namespace is succeeded with a '\'. This makes it clear for
|
|
||||||
* the processing functions that a leading slash is present.
|
|
||||||
*
|
|
||||||
* @param string $namespace
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function setNamespace($namespace)
|
|
||||||
{
|
|
||||||
if ($namespace != 'default' && $namespace != 'global') {
|
|
||||||
$namespace = self::OPERATOR_NAMESPACE
|
|
||||||
. trim($namespace, self::OPERATOR_NAMESPACE)
|
|
||||||
. self::OPERATOR_NAMESPACE;
|
|
||||||
} else {
|
|
||||||
$namespace = '\\';
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->namespace = $namespace;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the list of namespace aliases used to expand the typed with.
|
|
||||||
*
|
|
||||||
* @return string[] An associative array of Alias => Fully Qualified
|
|
||||||
* Namespace Names.
|
|
||||||
*/
|
|
||||||
public function getNamespaceAliases()
|
|
||||||
{
|
|
||||||
return $this->namespace_aliases;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the namespace aliases to expand the added types.
|
|
||||||
*
|
|
||||||
* @param string[] $namespace_aliases An associative array of Alias => Fully
|
|
||||||
* Qualified Namespace Names.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function setNamespaceAliases($namespace_aliases)
|
|
||||||
{
|
|
||||||
$this->namespace_aliases = $namespace_aliases;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -150,7 +107,7 @@ class Collection extends \ArrayObject
|
|||||||
|
|
||||||
// separate the type by the OR operator
|
// separate the type by the OR operator
|
||||||
$type_parts = explode(self::OPERATOR_OR, $type);
|
$type_parts = explode(self::OPERATOR_OR, $type);
|
||||||
foreach($type_parts as $part) {
|
foreach ($type_parts as $part) {
|
||||||
$expanded_type = $this->expand($part);
|
$expanded_type = $this->expand($part);
|
||||||
if ($expanded_type) {
|
if ($expanded_type) {
|
||||||
$this[] = $expanded_type;
|
$this[] = $expanded_type;
|
||||||
@@ -158,6 +115,17 @@ class Collection extends \ArrayObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a string representation of the collection.
|
||||||
|
*
|
||||||
|
* @return string The resolved types across the collection, separated with
|
||||||
|
* {@link self::OPERATOR_OR}.
|
||||||
|
*/
|
||||||
|
public function __toString()
|
||||||
|
{
|
||||||
|
return implode(self::OPERATOR_OR, $this->getArrayCopy());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Analyzes the given type and returns the FQCN variant.
|
* Analyzes the given type and returns the FQCN variant.
|
||||||
*
|
*
|
||||||
@@ -168,12 +136,12 @@ class Collection extends \ArrayObject
|
|||||||
* This method only works as expected if the namespace and aliases are set;
|
* This method only works as expected if the namespace and aliases are set;
|
||||||
* no dynamic reflection is being performed here.
|
* no dynamic reflection is being performed here.
|
||||||
*
|
*
|
||||||
|
* @param string $type The relative or absolute type.
|
||||||
|
*
|
||||||
* @uses getNamespace to determine with what to prefix the type name.
|
* @uses getNamespace to determine with what to prefix the type name.
|
||||||
* @uses getNamespaceAliases to check whether the first part of the relative
|
* @uses getNamespaceAliases to check whether the first part of the relative
|
||||||
* type name should not be replaced with another namespace.
|
* type name should not be replaced with another namespace.
|
||||||
*
|
*
|
||||||
* @param string $type The relative or absolute type.
|
|
||||||
*
|
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function expand($type)
|
protected function expand($type)
|
||||||
@@ -188,15 +156,20 @@ class Collection extends \ArrayObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this->isRelativeType($type) && !$this->isTypeAKeyword($type)) {
|
if ($this->isRelativeType($type) && !$this->isTypeAKeyword($type)) {
|
||||||
$type_parts = explode(self::OPERATOR_NAMESPACE, $type);
|
$type_parts = explode(self::OPERATOR_NAMESPACE, $type, 2);
|
||||||
|
|
||||||
|
$namespace_aliases = $this->context->getNamespaceAliases();
|
||||||
// if the first segment is not an alias; prepend namespace name and
|
// if the first segment is not an alias; prepend namespace name and
|
||||||
// return
|
// return
|
||||||
if (!isset($this->namespace_aliases[$type_parts[0]])) {
|
if (!isset($namespace_aliases[$type_parts[0]])) {
|
||||||
return $this->getNamespace() . $type;
|
$namespace = $this->context->getNamespace();
|
||||||
|
if ('' !== $namespace) {
|
||||||
|
$namespace .= self::OPERATOR_NAMESPACE;
|
||||||
|
}
|
||||||
|
return self::OPERATOR_NAMESPACE . $namespace . $type;
|
||||||
}
|
}
|
||||||
|
|
||||||
$type_parts[0] = $this->namespace_aliases[$type_parts[0]];
|
$type_parts[0] = $namespace_aliases[$type_parts[0]];
|
||||||
$type = implode(self::OPERATOR_NAMESPACE, $type_parts);
|
$type = implode(self::OPERATOR_NAMESPACE, $type_parts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,245 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* phpDocumentor Description Test
|
||||||
|
*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test class for \phpDocumentor\Reflection\DocBlock\Description
|
||||||
|
*
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
class DescriptionTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
public function testConstruct()
|
||||||
|
{
|
||||||
|
$fixture = <<<LONGDESC
|
||||||
|
This is text for a description.
|
||||||
|
LONGDESC;
|
||||||
|
$object = new Description($fixture);
|
||||||
|
$this->assertSame($fixture, $object->getContents());
|
||||||
|
|
||||||
|
$parsedContents = $object->getParsedContents();
|
||||||
|
$this->assertCount(1, $parsedContents);
|
||||||
|
$this->assertSame($fixture, $parsedContents[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testInlineTagParsing()
|
||||||
|
{
|
||||||
|
$fixture = <<<LONGDESC
|
||||||
|
This is text for a {@link http://phpdoc.org/ description} that uses inline
|
||||||
|
tags.
|
||||||
|
LONGDESC;
|
||||||
|
$object = new Description($fixture);
|
||||||
|
$this->assertSame($fixture, $object->getContents());
|
||||||
|
|
||||||
|
$parsedContents = $object->getParsedContents();
|
||||||
|
$this->assertCount(3, $parsedContents);
|
||||||
|
$this->assertSame('This is text for a ', $parsedContents[0]);
|
||||||
|
$this->assertInstanceOf(
|
||||||
|
__NAMESPACE__ . '\Tag\LinkTag',
|
||||||
|
$parsedContents[1]
|
||||||
|
);
|
||||||
|
$this->assertSame(
|
||||||
|
' that uses inline
|
||||||
|
tags.',
|
||||||
|
$parsedContents[2]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testInlineTagAtStartParsing()
|
||||||
|
{
|
||||||
|
$fixture = <<<LONGDESC
|
||||||
|
{@link http://phpdoc.org/ This} is text for a description that uses inline
|
||||||
|
tags.
|
||||||
|
LONGDESC;
|
||||||
|
$object = new Description($fixture);
|
||||||
|
$this->assertSame($fixture, $object->getContents());
|
||||||
|
|
||||||
|
$parsedContents = $object->getParsedContents();
|
||||||
|
$this->assertCount(3, $parsedContents);
|
||||||
|
|
||||||
|
$this->assertSame('', $parsedContents[0]);
|
||||||
|
$this->assertInstanceOf(
|
||||||
|
__NAMESPACE__ . '\Tag\LinkTag',
|
||||||
|
$parsedContents[1]
|
||||||
|
);
|
||||||
|
$this->assertSame(
|
||||||
|
' is text for a description that uses inline
|
||||||
|
tags.',
|
||||||
|
$parsedContents[2]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testNestedInlineTagParsing()
|
||||||
|
{
|
||||||
|
$fixture = <<<LONGDESC
|
||||||
|
This is text for a description with {@internal inline tag with
|
||||||
|
{@link http://phpdoc.org another inline tag} in it}.
|
||||||
|
LONGDESC;
|
||||||
|
$object = new Description($fixture);
|
||||||
|
$this->assertSame($fixture, $object->getContents());
|
||||||
|
|
||||||
|
$parsedContents = $object->getParsedContents();
|
||||||
|
$this->assertCount(3, $parsedContents);
|
||||||
|
|
||||||
|
$this->assertSame(
|
||||||
|
'This is text for a description with ',
|
||||||
|
$parsedContents[0]
|
||||||
|
);
|
||||||
|
$this->assertInstanceOf(
|
||||||
|
__NAMESPACE__ . '\Tag',
|
||||||
|
$parsedContents[1]
|
||||||
|
);
|
||||||
|
$this->assertSame('.', $parsedContents[2]);
|
||||||
|
|
||||||
|
$parsedDescription = $parsedContents[1]->getParsedDescription();
|
||||||
|
$this->assertCount(3, $parsedDescription);
|
||||||
|
$this->assertSame("inline tag with\n", $parsedDescription[0]);
|
||||||
|
$this->assertInstanceOf(
|
||||||
|
__NAMESPACE__ . '\Tag\LinkTag',
|
||||||
|
$parsedDescription[1]
|
||||||
|
);
|
||||||
|
$this->assertSame(' in it', $parsedDescription[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testLiteralOpeningDelimiter()
|
||||||
|
{
|
||||||
|
$fixture = <<<LONGDESC
|
||||||
|
This is text for a description containing { that is literal.
|
||||||
|
LONGDESC;
|
||||||
|
$object = new Description($fixture);
|
||||||
|
$this->assertSame($fixture, $object->getContents());
|
||||||
|
|
||||||
|
$parsedContents = $object->getParsedContents();
|
||||||
|
$this->assertCount(1, $parsedContents);
|
||||||
|
$this->assertSame($fixture, $parsedContents[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testNestedLiteralOpeningDelimiter()
|
||||||
|
{
|
||||||
|
$fixture = <<<LONGDESC
|
||||||
|
This is text for a description containing {@internal inline tag that has { that
|
||||||
|
is literal}.
|
||||||
|
LONGDESC;
|
||||||
|
$object = new Description($fixture);
|
||||||
|
$this->assertSame($fixture, $object->getContents());
|
||||||
|
|
||||||
|
$parsedContents = $object->getParsedContents();
|
||||||
|
$this->assertCount(3, $parsedContents);
|
||||||
|
$this->assertSame(
|
||||||
|
'This is text for a description containing ',
|
||||||
|
$parsedContents[0]
|
||||||
|
);
|
||||||
|
$this->assertInstanceOf(
|
||||||
|
__NAMESPACE__ . '\Tag',
|
||||||
|
$parsedContents[1]
|
||||||
|
);
|
||||||
|
$this->assertSame('.', $parsedContents[2]);
|
||||||
|
|
||||||
|
$this->assertSame(
|
||||||
|
array('inline tag that has { that
|
||||||
|
is literal'),
|
||||||
|
$parsedContents[1]->getParsedDescription()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testLiteralClosingDelimiter()
|
||||||
|
{
|
||||||
|
$fixture = <<<LONGDESC
|
||||||
|
This is text for a description with {} that is not a tag.
|
||||||
|
LONGDESC;
|
||||||
|
$object = new Description($fixture);
|
||||||
|
$this->assertSame($fixture, $object->getContents());
|
||||||
|
|
||||||
|
$parsedContents = $object->getParsedContents();
|
||||||
|
$this->assertCount(1, $parsedContents);
|
||||||
|
$this->assertSame(
|
||||||
|
'This is text for a description with } that is not a tag.',
|
||||||
|
$parsedContents[0]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testNestedLiteralClosingDelimiter()
|
||||||
|
{
|
||||||
|
$fixture = <<<LONGDESC
|
||||||
|
This is text for a description with {@internal inline tag with {} that is not an
|
||||||
|
inline tag}.
|
||||||
|
LONGDESC;
|
||||||
|
$object = new Description($fixture);
|
||||||
|
$this->assertSame($fixture, $object->getContents());
|
||||||
|
|
||||||
|
$parsedContents = $object->getParsedContents();
|
||||||
|
$this->assertCount(3, $parsedContents);
|
||||||
|
$this->assertSame(
|
||||||
|
'This is text for a description with ',
|
||||||
|
$parsedContents[0]
|
||||||
|
);
|
||||||
|
$this->assertInstanceOf(
|
||||||
|
__NAMESPACE__ . '\Tag',
|
||||||
|
$parsedContents[1]
|
||||||
|
);
|
||||||
|
$this->assertSame('.', $parsedContents[2]);
|
||||||
|
|
||||||
|
$this->assertSame(
|
||||||
|
array('inline tag with } that is not an
|
||||||
|
inline tag'),
|
||||||
|
$parsedContents[1]->getParsedDescription()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testInlineTagEscapingSequence()
|
||||||
|
{
|
||||||
|
$fixture = <<<LONGDESC
|
||||||
|
This is text for a description with literal {{@}link}.
|
||||||
|
LONGDESC;
|
||||||
|
$object = new Description($fixture);
|
||||||
|
$this->assertSame($fixture, $object->getContents());
|
||||||
|
|
||||||
|
$parsedContents = $object->getParsedContents();
|
||||||
|
$this->assertCount(1, $parsedContents);
|
||||||
|
$this->assertSame(
|
||||||
|
'This is text for a description with literal {@link}.',
|
||||||
|
$parsedContents[0]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testNestedInlineTagEscapingSequence()
|
||||||
|
{
|
||||||
|
$fixture = <<<LONGDESC
|
||||||
|
This is text for a description with an {@internal inline tag with literal
|
||||||
|
{{@}link{} in it}.
|
||||||
|
LONGDESC;
|
||||||
|
$object = new Description($fixture);
|
||||||
|
$this->assertSame($fixture, $object->getContents());
|
||||||
|
|
||||||
|
$parsedContents = $object->getParsedContents();
|
||||||
|
$this->assertCount(3, $parsedContents);
|
||||||
|
$this->assertSame(
|
||||||
|
'This is text for a description with an ',
|
||||||
|
$parsedContents[0]
|
||||||
|
);
|
||||||
|
$this->assertInstanceOf(
|
||||||
|
__NAMESPACE__ . '\Tag',
|
||||||
|
$parsedContents[1]
|
||||||
|
);
|
||||||
|
$this->assertSame('.', $parsedContents[2]);
|
||||||
|
|
||||||
|
$this->assertSame(
|
||||||
|
array('inline tag with literal
|
||||||
|
{@link} in it'),
|
||||||
|
$parsedContents[1]->getParsedDescription()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,50 +2,53 @@
|
|||||||
/**
|
/**
|
||||||
* phpDocumentor Covers Tag Test
|
* phpDocumentor Covers Tag Test
|
||||||
*
|
*
|
||||||
* @author Daniel O'Connor <[email protected]>
|
* PHP version 5.3
|
||||||
* @copyright Copyright (c) 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
*
|
||||||
|
* @author Daniel O'Connor <[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;
|
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class for phpDocumentor_Reflection_DocBlock_Tag_Covers
|
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\CoversTag
|
||||||
*
|
*
|
||||||
* @author Daniel O'Connor <[email protected]>
|
* @author Daniel O'Connor <[email protected]>
|
||||||
* @copyright Copyright (c) 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
* @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
|
||||||
*/
|
*/
|
||||||
class CoversTagTest extends \PHPUnit_Framework_TestCase
|
class CoversTagTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\Covers can create a link
|
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\CoversTag can create
|
||||||
* for the covers doc block
|
* a link for the covers doc block.
|
||||||
*
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @param string $content
|
* @param string $content
|
||||||
* @param string $exName
|
|
||||||
* @param string $exContent
|
* @param string $exContent
|
||||||
* @param string $exReference
|
* @param string $exReference
|
||||||
*
|
*
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\Covers::__construct
|
* @covers \phpDocumentor\Reflection\DocBlock\Tag\CoversTag
|
||||||
* @dataProvider provideDataForConstuctor
|
* @dataProvider provideDataForConstuctor
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testConstructorParesInputsIntoCorrectFields(
|
public function testConstructorParesInputsIntoCorrectFields(
|
||||||
$type, $content, $exName, $exContent, $exDescription, $exReference
|
$type,
|
||||||
)
|
$content,
|
||||||
{
|
$exContent,
|
||||||
|
$exDescription,
|
||||||
|
$exReference
|
||||||
|
) {
|
||||||
$tag = new CoversTag($type, $content);
|
$tag = new CoversTag($type, $content);
|
||||||
|
|
||||||
$actualName = $tag->getName();
|
$this->assertEquals($type, $tag->getName());
|
||||||
$actualContent = $tag->getContent();
|
$this->assertEquals($exContent, $tag->getContent());
|
||||||
$actualDescription = $tag->getDescription();
|
$this->assertEquals($exDescription, $tag->getDescription());
|
||||||
$actualReference = $tag->getReference();
|
$this->assertEquals($exReference, $tag->getReference());
|
||||||
|
|
||||||
$this->assertEquals($exName, $actualName);
|
|
||||||
$this->assertEquals($exContent, $actualContent);
|
|
||||||
$this->assertEquals($exDescription, $actualDescription);
|
|
||||||
$this->assertEquals($exReference, $actualReference);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -55,28 +58,25 @@ class CoversTagTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function provideDataForConstuctor()
|
public function provideDataForConstuctor()
|
||||||
{
|
{
|
||||||
// $type, $content, $exName, $exContent, $exDescription, $exReference
|
// $type, $content, $exContent, $exDescription, $exReference
|
||||||
return array(
|
return array(
|
||||||
array(
|
array(
|
||||||
'uses',
|
'covers',
|
||||||
'Foo::bar()',
|
'Foo::bar()',
|
||||||
'uses',
|
|
||||||
'Foo::bar()',
|
'Foo::bar()',
|
||||||
'',
|
'',
|
||||||
'Foo::bar()'
|
'Foo::bar()'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'uses',
|
'covers',
|
||||||
'Foo::bar() Testing',
|
'Foo::bar() Testing',
|
||||||
'uses',
|
|
||||||
'Foo::bar() Testing',
|
'Foo::bar() Testing',
|
||||||
'Testing',
|
'Testing',
|
||||||
'Foo::bar()',
|
'Foo::bar()',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'uses',
|
'covers',
|
||||||
'Foo::bar() Testing comments',
|
'Foo::bar() Testing comments',
|
||||||
'uses',
|
|
||||||
'Foo::bar() Testing comments',
|
'Foo::bar() Testing comments',
|
||||||
'Testing comments',
|
'Testing comments',
|
||||||
'Foo::bar()',
|
'Foo::bar()',
|
||||||
|
|||||||
@@ -0,0 +1,115 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* phpDocumentor Deprecated Tag Test
|
||||||
|
*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\DeprecatedTag
|
||||||
|
*
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
class DeprecatedTagTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\LinkTag can create
|
||||||
|
* a link for the @deprecated doc block.
|
||||||
|
*
|
||||||
|
* @param string $type
|
||||||
|
* @param string $content
|
||||||
|
* @param string $exContent
|
||||||
|
* @param string $exDescription
|
||||||
|
* @param string $exVersion
|
||||||
|
*
|
||||||
|
* @covers \phpDocumentor\Reflection\DocBlock\Tag\DeprecatedTag
|
||||||
|
* @dataProvider provideDataForConstuctor
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testConstructorParesInputsIntoCorrectFields(
|
||||||
|
$type,
|
||||||
|
$content,
|
||||||
|
$exContent,
|
||||||
|
$exDescription,
|
||||||
|
$exVersion
|
||||||
|
) {
|
||||||
|
$tag = new DeprecatedTag($type, $content);
|
||||||
|
|
||||||
|
$this->assertEquals($type, $tag->getName());
|
||||||
|
$this->assertEquals($exContent, $tag->getContent());
|
||||||
|
$this->assertEquals($exDescription, $tag->getDescription());
|
||||||
|
$this->assertEquals($exVersion, $tag->getVersion());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data provider for testConstructorParesInputsIntoCorrectFields
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function provideDataForConstuctor()
|
||||||
|
{
|
||||||
|
// $type, $content, $exContent, $exDescription, $exVersion
|
||||||
|
return array(
|
||||||
|
array(
|
||||||
|
'deprecated',
|
||||||
|
'1.0 First release.',
|
||||||
|
'1.0 First release.',
|
||||||
|
'First release.',
|
||||||
|
'1.0'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'deprecated',
|
||||||
|
"1.0\nFirst release.",
|
||||||
|
"1.0\nFirst release.",
|
||||||
|
'First release.',
|
||||||
|
'1.0'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'deprecated',
|
||||||
|
"1.0\nFirst\nrelease.",
|
||||||
|
"1.0\nFirst\nrelease.",
|
||||||
|
"First\nrelease.",
|
||||||
|
'1.0'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'deprecated',
|
||||||
|
'Unfinished release',
|
||||||
|
'Unfinished release',
|
||||||
|
'Unfinished release',
|
||||||
|
''
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'deprecated',
|
||||||
|
'1.0',
|
||||||
|
'1.0',
|
||||||
|
'',
|
||||||
|
'1.0'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'deprecated',
|
||||||
|
'GIT: $Id$',
|
||||||
|
'GIT: $Id$',
|
||||||
|
'',
|
||||||
|
'GIT: $Id$'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'deprecated',
|
||||||
|
'GIT: $Id$ Dev build',
|
||||||
|
'GIT: $Id$ Dev build',
|
||||||
|
'Dev build',
|
||||||
|
'GIT: $Id$'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,204 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* phpDocumentor Example Tag Test
|
||||||
|
*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\ExampleTag
|
||||||
|
*
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
class ExampleTagTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\SourceTag can
|
||||||
|
* understand the @source DocBlock.
|
||||||
|
*
|
||||||
|
* @param string $type
|
||||||
|
* @param string $content
|
||||||
|
* @param string $exContent
|
||||||
|
* @param string $exStartingLine
|
||||||
|
* @param string $exLineCount
|
||||||
|
* @param string $exFilepath
|
||||||
|
*
|
||||||
|
* @covers \phpDocumentor\Reflection\DocBlock\Tag\ExampleTag::__construct
|
||||||
|
* @covers \phpDocumentor\Reflection\DocBlock\Tag\ExampleTag::getFilePath
|
||||||
|
* @dataProvider provideDataForConstuctor
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testConstructorParesInputsIntoCorrectFields(
|
||||||
|
$type,
|
||||||
|
$content,
|
||||||
|
$exContent,
|
||||||
|
$exDescription,
|
||||||
|
$exStartingLine,
|
||||||
|
$exLineCount,
|
||||||
|
$exFilePath
|
||||||
|
) {
|
||||||
|
$tag = new ExampleTag($type, $content);
|
||||||
|
|
||||||
|
$this->assertEquals($type, $tag->getName());
|
||||||
|
$this->assertEquals($exContent, $tag->getContent());
|
||||||
|
$this->assertEquals($exDescription, $tag->getDescription());
|
||||||
|
$this->assertEquals($exStartingLine, $tag->getStartingLine());
|
||||||
|
$this->assertEquals($exLineCount, $tag->getLineCount());
|
||||||
|
$this->assertEquals($exFilePath, $tag->getFilePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data provider for testConstructorParesInputsIntoCorrectFields
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function provideDataForConstuctor()
|
||||||
|
{
|
||||||
|
// $type,
|
||||||
|
// $content,
|
||||||
|
// $exContent,
|
||||||
|
// $exDescription,
|
||||||
|
// $exStartingLine,
|
||||||
|
// $exLineCount,
|
||||||
|
// $exFilePath
|
||||||
|
return array(
|
||||||
|
array(
|
||||||
|
'example',
|
||||||
|
'file.php',
|
||||||
|
'file.php',
|
||||||
|
'',
|
||||||
|
1,
|
||||||
|
null,
|
||||||
|
'file.php'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'example',
|
||||||
|
'Testing comments',
|
||||||
|
'Testing comments',
|
||||||
|
'comments',
|
||||||
|
1,
|
||||||
|
null,
|
||||||
|
'Testing'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'example',
|
||||||
|
'file.php 2 Testing',
|
||||||
|
'file.php 2 Testing',
|
||||||
|
'Testing',
|
||||||
|
2,
|
||||||
|
null,
|
||||||
|
'file.php'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'example',
|
||||||
|
'file.php 2 3 Testing comments',
|
||||||
|
'file.php 2 3 Testing comments',
|
||||||
|
'Testing comments',
|
||||||
|
2,
|
||||||
|
3,
|
||||||
|
'file.php'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'example',
|
||||||
|
'file.php 2 -1 Testing comments',
|
||||||
|
'file.php 2 -1 Testing comments',
|
||||||
|
'-1 Testing comments',
|
||||||
|
2,
|
||||||
|
null,
|
||||||
|
'file.php'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'example',
|
||||||
|
'file.php -1 1 Testing comments',
|
||||||
|
'file.php -1 1 Testing comments',
|
||||||
|
'-1 1 Testing comments',
|
||||||
|
1,
|
||||||
|
null,
|
||||||
|
'file.php'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'example',
|
||||||
|
'"file with spaces.php" Testing comments',
|
||||||
|
'"file with spaces.php" Testing comments',
|
||||||
|
'Testing comments',
|
||||||
|
1,
|
||||||
|
null,
|
||||||
|
'file with spaces.php'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'example',
|
||||||
|
'"file with spaces.php" 2 Testing comments',
|
||||||
|
'"file with spaces.php" 2 Testing comments',
|
||||||
|
'Testing comments',
|
||||||
|
2,
|
||||||
|
null,
|
||||||
|
'file with spaces.php'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'example',
|
||||||
|
'"file with spaces.php" 2 3 Testing comments',
|
||||||
|
'"file with spaces.php" 2 3 Testing comments',
|
||||||
|
'Testing comments',
|
||||||
|
2,
|
||||||
|
3,
|
||||||
|
'file with spaces.php'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'example',
|
||||||
|
'"file with spaces.php" 2 -3 Testing comments',
|
||||||
|
'"file with spaces.php" 2 -3 Testing comments',
|
||||||
|
'-3 Testing comments',
|
||||||
|
2,
|
||||||
|
null,
|
||||||
|
'file with spaces.php'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'example',
|
||||||
|
'"file with spaces.php" -2 3 Testing comments',
|
||||||
|
'"file with spaces.php" -2 3 Testing comments',
|
||||||
|
'-2 3 Testing comments',
|
||||||
|
1,
|
||||||
|
null,
|
||||||
|
'file with spaces.php'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'example',
|
||||||
|
'file%20with%20spaces.php Testing comments',
|
||||||
|
'file%20with%20spaces.php Testing comments',
|
||||||
|
'Testing comments',
|
||||||
|
1,
|
||||||
|
null,
|
||||||
|
'file with spaces.php'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'example',
|
||||||
|
'folder/file%20with%20spaces.php Testing comments',
|
||||||
|
'folder/file%20with%20spaces.php Testing comments',
|
||||||
|
'Testing comments',
|
||||||
|
1,
|
||||||
|
null,
|
||||||
|
'folder/file with spaces.php'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'example',
|
||||||
|
'http://example.com/file%20with%20spaces.php Testing comments',
|
||||||
|
'http://example.com/file%20with%20spaces.php Testing comments',
|
||||||
|
'Testing comments',
|
||||||
|
1,
|
||||||
|
null,
|
||||||
|
'http://example.com/file%20with%20spaces.php'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,8 +2,12 @@
|
|||||||
/**
|
/**
|
||||||
* phpDocumentor Link Tag Test
|
* phpDocumentor Link Tag Test
|
||||||
*
|
*
|
||||||
* @author Ben Selby <[email protected]>
|
* PHP version 5.3
|
||||||
* @copyright Copyright (c) 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
*
|
||||||
|
* @author Ben Selby <[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;
|
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
@@ -11,42 +15,42 @@ namespace phpDocumentor\Reflection\DocBlock\Tag;
|
|||||||
/**
|
/**
|
||||||
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\LinkTag
|
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\LinkTag
|
||||||
*
|
*
|
||||||
* @author Ben Selby <[email protected]>
|
* @author Ben Selby <[email protected]>
|
||||||
* @copyright Copyright (c) 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
* @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
|
||||||
*/
|
*/
|
||||||
class LinkTagTest extends \PHPUnit_Framework_TestCase
|
class LinkTagTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\LinkTag can create
|
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\LinkTag can create
|
||||||
* a link for the @link doc block
|
* a link for the @link doc block.
|
||||||
*
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @param string $content
|
* @param string $content
|
||||||
* @param string $exName
|
|
||||||
* @param string $exContent
|
* @param string $exContent
|
||||||
* @param string $exDescription
|
* @param string $exDescription
|
||||||
* @param string $exLink
|
* @param string $exLink
|
||||||
*
|
*
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\LinkTag::__construct
|
* @covers \phpDocumentor\Reflection\DocBlock\Tag\LinkTag::__construct
|
||||||
|
* @covers \phpDocumentor\Reflection\DocBlock\Tag\LinkTag::getLink
|
||||||
* @dataProvider provideDataForConstuctor
|
* @dataProvider provideDataForConstuctor
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testConstructorParesInputsIntoCorrectFields(
|
public function testConstructorParesInputsIntoCorrectFields(
|
||||||
$type, $content, $exName, $exContent, $exDescription, $exLink
|
$type,
|
||||||
)
|
$content,
|
||||||
{
|
$exContent,
|
||||||
|
$exDescription,
|
||||||
|
$exLink
|
||||||
|
) {
|
||||||
$tag = new LinkTag($type, $content);
|
$tag = new LinkTag($type, $content);
|
||||||
|
|
||||||
$actualName = $tag->getName();
|
$this->assertEquals($type, $tag->getName());
|
||||||
$actualContent = $tag->getContent();
|
$this->assertEquals($exContent, $tag->getContent());
|
||||||
$actualDescription = $tag->getDescription();
|
$this->assertEquals($exDescription, $tag->getDescription());
|
||||||
$actualLink = $tag->getLink();
|
$this->assertEquals($exLink, $tag->getLink());
|
||||||
|
|
||||||
$this->assertEquals($exName, $actualName);
|
|
||||||
$this->assertEquals($exContent, $actualContent);
|
|
||||||
$this->assertEquals($exDescription, $actualDescription);
|
|
||||||
$this->assertEquals($exLink, $actualLink);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -56,12 +60,11 @@ class LinkTagTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function provideDataForConstuctor()
|
public function provideDataForConstuctor()
|
||||||
{
|
{
|
||||||
// $type, $content, $exName, $exContent, $exDescription, $exLink
|
// $type, $content, $exContent, $exDescription, $exLink
|
||||||
return array(
|
return array(
|
||||||
array(
|
array(
|
||||||
'link',
|
'link',
|
||||||
'http://www.phpdoc.org/',
|
'http://www.phpdoc.org/',
|
||||||
'link',
|
|
||||||
'http://www.phpdoc.org/',
|
'http://www.phpdoc.org/',
|
||||||
'http://www.phpdoc.org/',
|
'http://www.phpdoc.org/',
|
||||||
'http://www.phpdoc.org/'
|
'http://www.phpdoc.org/'
|
||||||
@@ -69,7 +72,6 @@ class LinkTagTest extends \PHPUnit_Framework_TestCase
|
|||||||
array(
|
array(
|
||||||
'link',
|
'link',
|
||||||
'http://www.phpdoc.org/ Testing',
|
'http://www.phpdoc.org/ Testing',
|
||||||
'link',
|
|
||||||
'http://www.phpdoc.org/ Testing',
|
'http://www.phpdoc.org/ Testing',
|
||||||
'Testing',
|
'Testing',
|
||||||
'http://www.phpdoc.org/'
|
'http://www.phpdoc.org/'
|
||||||
@@ -77,7 +79,6 @@ class LinkTagTest extends \PHPUnit_Framework_TestCase
|
|||||||
array(
|
array(
|
||||||
'link',
|
'link',
|
||||||
'http://www.phpdoc.org/ Testing comments',
|
'http://www.phpdoc.org/ Testing comments',
|
||||||
'link',
|
|
||||||
'http://www.phpdoc.org/ Testing comments',
|
'http://www.phpdoc.org/ Testing comments',
|
||||||
'Testing comments',
|
'Testing comments',
|
||||||
'http://www.phpdoc.org/'
|
'http://www.phpdoc.org/'
|
||||||
|
|||||||
@@ -2,8 +2,12 @@
|
|||||||
/**
|
/**
|
||||||
* phpDocumentor Method Tag Test
|
* phpDocumentor Method Tag Test
|
||||||
*
|
*
|
||||||
* @author Mike van Riel <[email protected]>
|
* PHP version 5.3
|
||||||
* @copyright Copyright (c) 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
*
|
||||||
|
* @author Mike van Riel <[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;
|
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
@@ -11,48 +15,59 @@ namespace phpDocumentor\Reflection\DocBlock\Tag;
|
|||||||
/**
|
/**
|
||||||
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\MethodTag
|
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\MethodTag
|
||||||
*
|
*
|
||||||
* @author Mike van Riel <[email protected]>
|
* @author Mike van Riel <[email protected]>
|
||||||
* @copyright Copyright (c) 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
* @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
|
||||||
*/
|
*/
|
||||||
class MethodTagTest extends \PHPUnit_Framework_TestCase
|
class MethodTagTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @dataProvider getTestSignatures
|
* @param string $signature The signature to test.
|
||||||
*
|
|
||||||
* @param string $signature The signature to test
|
|
||||||
* @param bool $valid Whether the given signature is expected to
|
* @param bool $valid Whether the given signature is expected to
|
||||||
* be valid.
|
* be valid.
|
||||||
* @param string $expected_name The method name that is expected from this
|
* @param string $expected_name The method name that is expected from this
|
||||||
* signature
|
* signature.
|
||||||
* @param string $expected_return The return type that is expected from this
|
* @param string $expected_return The return type that is expected from this
|
||||||
* signature
|
* signature.
|
||||||
* @param bool $has_params whether this signature features parameters.
|
* @param bool $paramCount Number of parameters in the signature.
|
||||||
* @param string $description The short description mentioned in the
|
* @param string $description The short description mentioned in the
|
||||||
* signature.
|
* signature.
|
||||||
*
|
*
|
||||||
|
* @covers \phpDocumentor\Reflection\DocBlock\Tag\MethodTag::__construct
|
||||||
|
* @covers \phpDocumentor\Reflection\DocBlock\Tag\MethodTag::getMethodName
|
||||||
|
* @covers \phpDocumentor\Reflection\DocBlock\Tag\MethodTag::getArguments
|
||||||
|
*
|
||||||
|
* @dataProvider getTestSignatures
|
||||||
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testConstruct($signature, $valid, $expected_name,
|
public function testConstruct(
|
||||||
$expected_return, $has_params, $description)
|
$signature,
|
||||||
{
|
$valid,
|
||||||
|
$expected_name,
|
||||||
|
$expected_return,
|
||||||
|
$paramCount,
|
||||||
|
$description
|
||||||
|
) {
|
||||||
ob_start();
|
ob_start();
|
||||||
$tag = new MethodTag('method', $signature);
|
$tag = new MethodTag('method', $signature);
|
||||||
$stdout = ob_get_clean();
|
$stdout = ob_get_clean();
|
||||||
|
|
||||||
$this->assertSame(
|
$this->assertSame(
|
||||||
$valid, empty($stdout),
|
$valid,
|
||||||
|
empty($stdout),
|
||||||
'No error should have been output if the signature is valid'
|
'No error should have been output if the signature is valid'
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!$valid) return;
|
if (!$valid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$this->assertEquals($expected_name, $tag->getMethodName());
|
$this->assertEquals($expected_name, $tag->getMethodName());
|
||||||
$this->assertEquals($expected_return, $tag->getType());
|
$this->assertEquals($expected_return, $tag->getType());
|
||||||
$this->assertEquals($description, $tag->getDescription());
|
$this->assertEquals($description, $tag->getDescription());
|
||||||
$this->assertSame(
|
$this->assertCount($paramCount, $tag->getArguments());
|
||||||
$has_params, (bool)(count($tag->getArguments()) > 0),
|
|
||||||
'Number of found arguments should exceed 0'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTestSignatures()
|
public function getTestSignatures()
|
||||||
@@ -60,55 +75,55 @@ class MethodTagTest extends \PHPUnit_Framework_TestCase
|
|||||||
return array(
|
return array(
|
||||||
array(
|
array(
|
||||||
'foo',
|
'foo',
|
||||||
false, 'foo', '', false, ''
|
false, 'foo', '', 0, ''
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'foo()',
|
'foo()',
|
||||||
true, 'foo', 'void', false, ''
|
true, 'foo', 'void', 0, ''
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'foo() description',
|
'foo() description',
|
||||||
true, 'foo', 'void', false, 'description'
|
true, 'foo', 'void', 0, 'description'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'int foo()',
|
'int foo()',
|
||||||
true, 'foo', 'int', false, ''
|
true, 'foo', 'int', 0, ''
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'int foo() description',
|
'int foo() description',
|
||||||
true, 'foo', 'int', false, 'description'
|
true, 'foo', 'int', 0, 'description'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'int foo($a, $b)',
|
'int foo($a, $b)',
|
||||||
true, 'foo', 'int', true, ''
|
true, 'foo', 'int', 2, ''
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'int foo() foo(int $a, int $b)',
|
'int foo() foo(int $a, int $b)',
|
||||||
true, 'foo', 'int', true, ''
|
true, 'foo', 'int', 2, ''
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'int foo(int $a, int $b)',
|
'int foo(int $a, int $b)',
|
||||||
true, 'foo', 'int', true, ''
|
true, 'foo', 'int', 2, ''
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'null|int foo(int $a, int $b)',
|
'null|int foo(int $a, int $b)',
|
||||||
true, 'foo', 'null|int', true, ''
|
true, 'foo', 'null|int', 2, ''
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'int foo(null|int $a, int $b)',
|
'int foo(null|int $a, int $b)',
|
||||||
true, 'foo', 'int', true, ''
|
true, 'foo', 'int', 2, ''
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'\Exception foo() foo(Exception $a, Exception $b)',
|
'\Exception foo() foo(Exception $a, Exception $b)',
|
||||||
true, 'foo', '\Exception', true, ''
|
true, 'foo', '\Exception', 2, ''
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'int foo() foo(Exception $a, Exception $b) description',
|
'int foo() foo(Exception $a, Exception $b) description',
|
||||||
true, 'foo', 'int', true, 'description'
|
true, 'foo', 'int', 2, 'description'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'int foo() foo(\Exception $a, \Exception $b) description',
|
'int foo() foo(\Exception $a, \Exception $b) description',
|
||||||
true, 'foo', 'int', true, 'description'
|
true, 'foo', 'int', 2, 'description'
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,45 +2,59 @@
|
|||||||
/**
|
/**
|
||||||
* phpDocumentor Param tag test.
|
* phpDocumentor Param tag test.
|
||||||
*
|
*
|
||||||
|
* PHP version 5.3
|
||||||
|
*
|
||||||
* @author Mike van Riel <[email protected]>
|
* @author Mike van Riel <[email protected]>
|
||||||
* @copyright Copyright (c) 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
* @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;
|
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class for phpDocumentor_Reflection_DocBlock_Param.
|
* Test class for \phpDocumentor\Reflection\DocBlock\ParamTag
|
||||||
*
|
*
|
||||||
* @author Mike van Riel <[email protected]>
|
* @author Mike van Riel <[email protected]>
|
||||||
* @copyright Copyright (c) 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
* @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
|
||||||
*/
|
*/
|
||||||
class ParamTagTest extends \PHPUnit_Framework_TestCase
|
class ParamTagTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\ParamTag can
|
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\ParamTag can
|
||||||
* understand the param DocBlock.
|
* understand the @param DocBlock.
|
||||||
*
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @param string $content
|
* @param string $content
|
||||||
* @param string $extracted_type
|
* @param string $extractedType
|
||||||
* @param string $extracted_variable_name
|
* @param string $extractedTypes
|
||||||
* @param string $extracted_description
|
* @param string $extractedVarName
|
||||||
|
* @param string $extractedDescription
|
||||||
*
|
*
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\ParamTag::__construct
|
* @covers \phpDocumentor\Reflection\DocBlock\Tag\ParamTag::__construct
|
||||||
|
* @covers \phpDocumentor\Reflection\DocBlock\Tag\ParamTag::getVariableName
|
||||||
*
|
*
|
||||||
* @dataProvider provideDataForConstructor
|
* @dataProvider provideDataForConstructor
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testConstructorParsesInputsIntoCorrectFields(
|
public function testConstructorParsesInputsIntoCorrectFields(
|
||||||
$type, $content, $extracted_type, $extracted_variable_name,
|
$type,
|
||||||
$extracted_description
|
$content,
|
||||||
|
$extractedType,
|
||||||
|
$extractedTypes,
|
||||||
|
$extractedVarName,
|
||||||
|
$extractedDescription
|
||||||
) {
|
) {
|
||||||
$tag = new ParamTag($type, $content);
|
$tag = new ParamTag($type, $content);
|
||||||
|
|
||||||
$this->assertEquals($extracted_type, $tag->getTypes());
|
$this->assertEquals($type, $tag->getName());
|
||||||
$this->assertEquals($extracted_variable_name, $tag->getVariableName());
|
$this->assertEquals($extractedType, $tag->getType());
|
||||||
$this->assertEquals($extracted_description, $tag->getDescription());
|
$this->assertEquals($extractedTypes, $tag->getTypes());
|
||||||
|
$this->assertEquals($extractedVarName, $tag->getVariableName());
|
||||||
|
$this->assertEquals($extractedDescription, $tag->getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -51,17 +65,56 @@ class ParamTagTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function provideDataForConstructor()
|
public function provideDataForConstructor()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
array('param', 'int', array('int'), '', ''),
|
array('param', 'int', 'int', array('int'), '', ''),
|
||||||
array('param', '$bob', array(), '$bob', ''),
|
array('param', '$bob', '', array(), '$bob', ''),
|
||||||
array(
|
array(
|
||||||
'param', 'int Number of bobs', array('int'), '',
|
'param',
|
||||||
|
'int Number of bobs',
|
||||||
|
'int',
|
||||||
|
array('int'),
|
||||||
|
'',
|
||||||
'Number of bobs'
|
'Number of bobs'
|
||||||
),
|
),
|
||||||
array('param', 'int $bob', array('int'), '$bob', ''),
|
|
||||||
array(
|
array(
|
||||||
'param', 'int $bob Number of bobs', array('int'), '$bob',
|
'param',
|
||||||
|
'int $bob',
|
||||||
|
'int',
|
||||||
|
array('int'),
|
||||||
|
'$bob',
|
||||||
|
''
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'param',
|
||||||
|
'int $bob Number of bobs',
|
||||||
|
'int',
|
||||||
|
array('int'),
|
||||||
|
'$bob',
|
||||||
'Number of bobs'
|
'Number of bobs'
|
||||||
),
|
),
|
||||||
|
array(
|
||||||
|
'param',
|
||||||
|
"int Description \n on multiple lines",
|
||||||
|
'int',
|
||||||
|
array('int'),
|
||||||
|
'',
|
||||||
|
"Description \n on multiple lines"
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'param',
|
||||||
|
"int \n\$bob Variable name on a new line",
|
||||||
|
'int',
|
||||||
|
array('int'),
|
||||||
|
'$bob',
|
||||||
|
"Variable name on a new line"
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'param',
|
||||||
|
"\nint \$bob Type on a new line",
|
||||||
|
'int',
|
||||||
|
array('int'),
|
||||||
|
'$bob',
|
||||||
|
"Type on a new line"
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,41 +2,55 @@
|
|||||||
/**
|
/**
|
||||||
* phpDocumentor Return tag test.
|
* phpDocumentor Return tag test.
|
||||||
*
|
*
|
||||||
|
* PHP version 5.3
|
||||||
|
*
|
||||||
* @author Mike van Riel <[email protected]>
|
* @author Mike van Riel <[email protected]>
|
||||||
* @copyright Copyright (c) 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
* @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;
|
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class for phpDocumentor_Reflection_DocBlock_ReturnTag.
|
* Test class for \phpDocumentor\Reflection\DocBlock\ReturnTag
|
||||||
*
|
*
|
||||||
* @author Mike van Riel <[email protected]>
|
* @author Mike van Riel <[email protected]>
|
||||||
* @copyright Copyright (c) 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
* @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
|
||||||
*/
|
*/
|
||||||
class ReturnTagTest extends ParamTagTest
|
class ReturnTagTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\ReturnTag can
|
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\ReturnTag can
|
||||||
* understand the Return DocBlock.
|
* understand the @return DocBlock.
|
||||||
*
|
*
|
||||||
|
* @param string $type
|
||||||
* @param string $content
|
* @param string $content
|
||||||
* @param string $extracted_type
|
* @param string $extractedType
|
||||||
* @param string $extracted_description
|
* @param string $extractedTypes
|
||||||
|
* @param string $extractedDescription
|
||||||
*
|
*
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\ReturnTag::__construct
|
* @covers \phpDocumentor\Reflection\DocBlock\Tag\ReturnTag
|
||||||
*
|
*
|
||||||
* @dataProvider provideDataForConstructor
|
* @dataProvider provideDataForConstructor
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testConstructorParsesInputsIntoCorrectFields(
|
public function testConstructorParsesInputsIntoCorrectFields(
|
||||||
$content, $extracted_type, $extracted_description
|
$type,
|
||||||
|
$content,
|
||||||
|
$extractedType,
|
||||||
|
$extractedTypes,
|
||||||
|
$extractedDescription
|
||||||
) {
|
) {
|
||||||
$tag = new ReturnTag('return', $content);
|
$tag = new ReturnTag($type, $content);
|
||||||
|
|
||||||
$this->assertEquals($extracted_type, $tag->getTypes());
|
$this->assertEquals($type, $tag->getName());
|
||||||
$this->assertEquals($extracted_description, $tag->getDescription());
|
$this->assertEquals($extractedType, $tag->getType());
|
||||||
|
$this->assertEquals($extractedTypes, $tag->getTypes());
|
||||||
|
$this->assertEquals($extractedDescription, $tag->getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -47,9 +61,43 @@ class ReturnTagTest extends ParamTagTest
|
|||||||
public function provideDataForConstructor()
|
public function provideDataForConstructor()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
array('', array(), ''),
|
array('return', '', '', array(), ''),
|
||||||
array('int', array('int'), ''),
|
array('return', 'int', 'int', array('int'), ''),
|
||||||
array('int Number of Bobs', array('int'), 'Number of Bobs'),
|
array(
|
||||||
|
'return',
|
||||||
|
'int Number of Bobs',
|
||||||
|
'int',
|
||||||
|
array('int'),
|
||||||
|
'Number of Bobs'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'return',
|
||||||
|
'int|double Number of Bobs',
|
||||||
|
'int|double',
|
||||||
|
array('int', 'double'),
|
||||||
|
'Number of Bobs'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'return',
|
||||||
|
"int Number of \n Bobs",
|
||||||
|
'int',
|
||||||
|
array('int'),
|
||||||
|
"Number of \n Bobs"
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'return',
|
||||||
|
" int Number of Bobs",
|
||||||
|
'int',
|
||||||
|
array('int'),
|
||||||
|
"Number of Bobs"
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'return',
|
||||||
|
"int\nNumber of Bobs",
|
||||||
|
'int',
|
||||||
|
array('int'),
|
||||||
|
"Number of Bobs"
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,50 +2,54 @@
|
|||||||
/**
|
/**
|
||||||
* phpDocumentor See Tag Test
|
* phpDocumentor See Tag Test
|
||||||
*
|
*
|
||||||
* @author Daniel O'Connor <[email protected]>
|
* PHP version 5.3
|
||||||
* @copyright Copyright (c) 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
*
|
||||||
|
* @author Daniel O'Connor <[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;
|
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class for phpDocumentor_Reflection_DocBlock_Tag_See
|
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\SeeTag
|
||||||
*
|
*
|
||||||
* @author Daniel O'Connor <[email protected]>
|
* @author Daniel O'Connor <[email protected]>
|
||||||
* @copyright Copyright (c) 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
* @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
|
||||||
*/
|
*/
|
||||||
class SeeTagTest extends \PHPUnit_Framework_TestCase
|
class SeeTagTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Test that the phpDocumentor_Reflection_DocBlock_Tag_See can create a link
|
* Test that the phpDocumentor_Reflection_DocBlock_Tag_See can create a link
|
||||||
* for the @see doc block
|
* for the @see doc block.
|
||||||
*
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @param string $content
|
* @param string $content
|
||||||
* @param string $exName
|
|
||||||
* @param string $exContent
|
* @param string $exContent
|
||||||
* @param string $exReference
|
* @param string $exReference
|
||||||
*
|
*
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\SeeTag::__construct
|
* @covers \phpDocumentor\Reflection\DocBlock\Tag\SeeTag::__construct
|
||||||
|
* @covers \phpDocumentor\Reflection\DocBlock\Tag\SeeTag::getReference
|
||||||
* @dataProvider provideDataForConstuctor
|
* @dataProvider provideDataForConstuctor
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testConstructorParesInputsIntoCorrectFields(
|
public function testConstructorParesInputsIntoCorrectFields(
|
||||||
$type, $content, $exName, $exContent, $exDescription, $exReference
|
$type,
|
||||||
)
|
$content,
|
||||||
{
|
$exContent,
|
||||||
|
$exDescription,
|
||||||
|
$exReference
|
||||||
|
) {
|
||||||
$tag = new SeeTag($type, $content);
|
$tag = new SeeTag($type, $content);
|
||||||
|
|
||||||
$actualName = $tag->getName();
|
$this->assertEquals($type, $tag->getName());
|
||||||
$actualContent = $tag->getContent();
|
$this->assertEquals($exContent, $tag->getContent());
|
||||||
$actualDescription = $tag->getDescription();
|
$this->assertEquals($exDescription, $tag->getDescription());
|
||||||
$actualReference = $tag->getReference();
|
$this->assertEquals($exReference, $tag->getReference());
|
||||||
|
|
||||||
$this->assertEquals($exName, $actualName);
|
|
||||||
$this->assertEquals($exContent, $actualContent);
|
|
||||||
$this->assertEquals($exDescription, $actualDescription);
|
|
||||||
$this->assertEquals($exReference, $actualReference);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -55,28 +59,25 @@ class SeeTagTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function provideDataForConstuctor()
|
public function provideDataForConstuctor()
|
||||||
{
|
{
|
||||||
// $type, $content, $exName, $exContent, $exDescription, $exReference
|
// $type, $content, $exContent, $exDescription, $exReference
|
||||||
return array(
|
return array(
|
||||||
array(
|
array(
|
||||||
'uses',
|
'see',
|
||||||
'Foo::bar()',
|
'Foo::bar()',
|
||||||
'uses',
|
|
||||||
'Foo::bar()',
|
'Foo::bar()',
|
||||||
'',
|
'',
|
||||||
'Foo::bar()'
|
'Foo::bar()'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'uses',
|
'see',
|
||||||
'Foo::bar() Testing',
|
'Foo::bar() Testing',
|
||||||
'uses',
|
|
||||||
'Foo::bar() Testing',
|
'Foo::bar() Testing',
|
||||||
'Testing',
|
'Testing',
|
||||||
'Foo::bar()',
|
'Foo::bar()',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'uses',
|
'see',
|
||||||
'Foo::bar() Testing comments',
|
'Foo::bar() Testing comments',
|
||||||
'uses',
|
|
||||||
'Foo::bar() Testing comments',
|
'Foo::bar() Testing comments',
|
||||||
'Testing comments',
|
'Testing comments',
|
||||||
'Foo::bar()',
|
'Foo::bar()',
|
||||||
|
|||||||
@@ -0,0 +1,115 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* phpDocumentor Since Tag Test
|
||||||
|
*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\SinceTag
|
||||||
|
*
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
class SinceTagTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\LinkTag can create
|
||||||
|
* a link for the @since doc block.
|
||||||
|
*
|
||||||
|
* @param string $type
|
||||||
|
* @param string $content
|
||||||
|
* @param string $exContent
|
||||||
|
* @param string $exDescription
|
||||||
|
* @param string $exVersion
|
||||||
|
*
|
||||||
|
* @covers \phpDocumentor\Reflection\DocBlock\Tag\SinceTag
|
||||||
|
* @dataProvider provideDataForConstuctor
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testConstructorParesInputsIntoCorrectFields(
|
||||||
|
$type,
|
||||||
|
$content,
|
||||||
|
$exContent,
|
||||||
|
$exDescription,
|
||||||
|
$exVersion
|
||||||
|
) {
|
||||||
|
$tag = new SinceTag($type, $content);
|
||||||
|
|
||||||
|
$this->assertEquals($type, $tag->getName());
|
||||||
|
$this->assertEquals($exContent, $tag->getContent());
|
||||||
|
$this->assertEquals($exDescription, $tag->getDescription());
|
||||||
|
$this->assertEquals($exVersion, $tag->getVersion());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data provider for testConstructorParesInputsIntoCorrectFields
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function provideDataForConstuctor()
|
||||||
|
{
|
||||||
|
// $type, $content, $exContent, $exDescription, $exVersion
|
||||||
|
return array(
|
||||||
|
array(
|
||||||
|
'since',
|
||||||
|
'1.0 First release.',
|
||||||
|
'1.0 First release.',
|
||||||
|
'First release.',
|
||||||
|
'1.0'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'since',
|
||||||
|
"1.0\nFirst release.",
|
||||||
|
"1.0\nFirst release.",
|
||||||
|
'First release.',
|
||||||
|
'1.0'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'since',
|
||||||
|
"1.0\nFirst\nrelease.",
|
||||||
|
"1.0\nFirst\nrelease.",
|
||||||
|
"First\nrelease.",
|
||||||
|
'1.0'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'since',
|
||||||
|
'Unfinished release',
|
||||||
|
'Unfinished release',
|
||||||
|
'Unfinished release',
|
||||||
|
''
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'since',
|
||||||
|
'1.0',
|
||||||
|
'1.0',
|
||||||
|
'',
|
||||||
|
'1.0'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'since',
|
||||||
|
'GIT: $Id$',
|
||||||
|
'GIT: $Id$',
|
||||||
|
'',
|
||||||
|
'GIT: $Id$'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'since',
|
||||||
|
'GIT: $Id$ Dev build',
|
||||||
|
'GIT: $Id$ Dev build',
|
||||||
|
'Dev build',
|
||||||
|
'GIT: $Id$'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,118 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* phpDocumentor Source Tag Test
|
||||||
|
*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\SourceTag
|
||||||
|
*
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
class SourceTagTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\SourceTag can
|
||||||
|
* understand the @source DocBlock.
|
||||||
|
*
|
||||||
|
* @param string $type
|
||||||
|
* @param string $content
|
||||||
|
* @param string $exContent
|
||||||
|
* @param string $exStartingLine
|
||||||
|
* @param string $exLineCount
|
||||||
|
*
|
||||||
|
* @covers \phpDocumentor\Reflection\DocBlock\Tag\SourceTag::__construct
|
||||||
|
* @covers \phpDocumentor\Reflection\DocBlock\Tag\SourceTag::getStartingLine
|
||||||
|
* @covers \phpDocumentor\Reflection\DocBlock\Tag\SourceTag::getLineCount
|
||||||
|
* @dataProvider provideDataForConstuctor
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testConstructorParesInputsIntoCorrectFields(
|
||||||
|
$type,
|
||||||
|
$content,
|
||||||
|
$exContent,
|
||||||
|
$exDescription,
|
||||||
|
$exStartingLine,
|
||||||
|
$exLineCount
|
||||||
|
) {
|
||||||
|
$tag = new SourceTag($type, $content);
|
||||||
|
|
||||||
|
$this->assertEquals($type, $tag->getName());
|
||||||
|
$this->assertEquals($exContent, $tag->getContent());
|
||||||
|
$this->assertEquals($exDescription, $tag->getDescription());
|
||||||
|
$this->assertEquals($exStartingLine, $tag->getStartingLine());
|
||||||
|
$this->assertEquals($exLineCount, $tag->getLineCount());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data provider for testConstructorParesInputsIntoCorrectFields
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function provideDataForConstuctor()
|
||||||
|
{
|
||||||
|
// $type, $content, $exContent, $exDescription, $exStartingLine, $exLineCount
|
||||||
|
return array(
|
||||||
|
array(
|
||||||
|
'source',
|
||||||
|
'2',
|
||||||
|
'2',
|
||||||
|
'',
|
||||||
|
2,
|
||||||
|
null
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'source',
|
||||||
|
'Testing',
|
||||||
|
'Testing',
|
||||||
|
'Testing',
|
||||||
|
1,
|
||||||
|
null
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'source',
|
||||||
|
'2 Testing',
|
||||||
|
'2 Testing',
|
||||||
|
'Testing',
|
||||||
|
2,
|
||||||
|
null
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'source',
|
||||||
|
'2 3 Testing comments',
|
||||||
|
'2 3 Testing comments',
|
||||||
|
'Testing comments',
|
||||||
|
2,
|
||||||
|
3
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'source',
|
||||||
|
'2 -1 Testing comments',
|
||||||
|
'2 -1 Testing comments',
|
||||||
|
'-1 Testing comments',
|
||||||
|
2,
|
||||||
|
null
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'source',
|
||||||
|
'-1 1 Testing comments',
|
||||||
|
'-1 1 Testing comments',
|
||||||
|
'-1 1 Testing comments',
|
||||||
|
1,
|
||||||
|
null
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* phpDocumentor Throws tag test.
|
||||||
|
*
|
||||||
|
* PHP version 5.3
|
||||||
|
*
|
||||||
|
* @author Mike van Riel <[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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test class for \phpDocumentor\Reflection\DocBlock\ThrowsTag
|
||||||
|
*
|
||||||
|
* @author Mike van Riel <[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
|
||||||
|
*/
|
||||||
|
class ThrowsTagTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\ThrowsTag can
|
||||||
|
* understand the @throws DocBlock.
|
||||||
|
*
|
||||||
|
* @param string $type
|
||||||
|
* @param string $content
|
||||||
|
* @param string $extractedType
|
||||||
|
* @param string $extractedTypes
|
||||||
|
* @param string $extractedDescription
|
||||||
|
*
|
||||||
|
* @covers \phpDocumentor\Reflection\DocBlock\Tag\ThrowsTag
|
||||||
|
*
|
||||||
|
* @dataProvider provideDataForConstructor
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testConstructorParsesInputsIntoCorrectFields(
|
||||||
|
$type,
|
||||||
|
$content,
|
||||||
|
$extractedType,
|
||||||
|
$extractedTypes,
|
||||||
|
$extractedDescription
|
||||||
|
) {
|
||||||
|
$tag = new ThrowsTag($type, $content);
|
||||||
|
|
||||||
|
$this->assertEquals($type, $tag->getName());
|
||||||
|
$this->assertEquals($extractedType, $tag->getType());
|
||||||
|
$this->assertEquals($extractedTypes, $tag->getTypes());
|
||||||
|
$this->assertEquals($extractedDescription, $tag->getDescription());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data provider for testConstructorParsesInputsIntoCorrectFields()
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function provideDataForConstructor()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
array('throws', '', '', array(), ''),
|
||||||
|
array('throws', 'int', 'int', array('int'), ''),
|
||||||
|
array(
|
||||||
|
'throws',
|
||||||
|
'int Number of Bobs',
|
||||||
|
'int',
|
||||||
|
array('int'),
|
||||||
|
'Number of Bobs'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'throws',
|
||||||
|
'int|double Number of Bobs',
|
||||||
|
'int|double',
|
||||||
|
array('int', 'double'),
|
||||||
|
'Number of Bobs'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'throws',
|
||||||
|
"int Number of \n Bobs",
|
||||||
|
'int',
|
||||||
|
array('int'),
|
||||||
|
"Number of \n Bobs"
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'throws',
|
||||||
|
" int Number of Bobs",
|
||||||
|
'int',
|
||||||
|
array('int'),
|
||||||
|
"Number of Bobs"
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'throws',
|
||||||
|
"int\nNumber of Bobs",
|
||||||
|
'int',
|
||||||
|
array('int'),
|
||||||
|
"Number of Bobs"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,50 +2,53 @@
|
|||||||
/**
|
/**
|
||||||
* phpDocumentor Uses Tag Test
|
* phpDocumentor Uses Tag Test
|
||||||
*
|
*
|
||||||
* @author Daniel O'Connor <[email protected]>
|
* PHP version 5.3
|
||||||
* @copyright Copyright (c) 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
*
|
||||||
|
* @author Daniel O'Connor <[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;
|
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class for phpDocumentor_Reflection_DocBlock_Tag_Uses
|
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\UsesTag
|
||||||
*
|
*
|
||||||
* @author Daniel O'Connor <[email protected]>
|
* @author Daniel O'Connor <[email protected]>
|
||||||
* @copyright Copyright (c) 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
* @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
|
||||||
*/
|
*/
|
||||||
class UsesTagTest extends \PHPUnit_Framework_TestCase
|
class UsesTagTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\UsesTag can create
|
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\UsesTag can create
|
||||||
* a link for the @uses doc block
|
* a link for the @uses doc block.
|
||||||
*
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @param string $content
|
* @param string $content
|
||||||
* @param string $exName
|
|
||||||
* @param string $exContent
|
* @param string $exContent
|
||||||
* @param string $exReference
|
* @param string $exReference
|
||||||
*
|
*
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\UsesTag::__construct
|
* @covers \phpDocumentor\Reflection\DocBlock\Tag\UsesTag
|
||||||
* @dataProvider provideDataForConstuctor
|
* @dataProvider provideDataForConstuctor
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testConstructorParesInputsIntoCorrectFields(
|
public function testConstructorParesInputsIntoCorrectFields(
|
||||||
$type, $content, $exName, $exContent, $exDescription, $exReference
|
$type,
|
||||||
)
|
$content,
|
||||||
{
|
$exContent,
|
||||||
|
$exDescription,
|
||||||
|
$exReference
|
||||||
|
) {
|
||||||
$tag = new UsesTag($type, $content);
|
$tag = new UsesTag($type, $content);
|
||||||
|
|
||||||
$actualName = $tag->getName();
|
$this->assertEquals($type, $tag->getName());
|
||||||
$actualContent = $tag->getContent();
|
$this->assertEquals($exContent, $tag->getContent());
|
||||||
$actualDescription = $tag->getDescription();
|
$this->assertEquals($exDescription, $tag->getDescription());
|
||||||
$actualReference = $tag->getReference();
|
$this->assertEquals($exReference, $tag->getReference());
|
||||||
|
|
||||||
$this->assertEquals($exName, $actualName);
|
|
||||||
$this->assertEquals($exContent, $actualContent);
|
|
||||||
$this->assertEquals($exDescription, $actualDescription);
|
|
||||||
$this->assertEquals($exReference, $actualReference);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -55,12 +58,11 @@ class UsesTagTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function provideDataForConstuctor()
|
public function provideDataForConstuctor()
|
||||||
{
|
{
|
||||||
// $type, $content, $exName, $exContent, $exDescription, $exReference
|
// $type, $content, $exContent, $exDescription, $exReference
|
||||||
return array(
|
return array(
|
||||||
array(
|
array(
|
||||||
'uses',
|
'uses',
|
||||||
'Foo::bar()',
|
'Foo::bar()',
|
||||||
'uses',
|
|
||||||
'Foo::bar()',
|
'Foo::bar()',
|
||||||
'',
|
'',
|
||||||
'Foo::bar()'
|
'Foo::bar()'
|
||||||
@@ -68,7 +70,6 @@ class UsesTagTest extends \PHPUnit_Framework_TestCase
|
|||||||
array(
|
array(
|
||||||
'uses',
|
'uses',
|
||||||
'Foo::bar() Testing',
|
'Foo::bar() Testing',
|
||||||
'uses',
|
|
||||||
'Foo::bar() Testing',
|
'Foo::bar() Testing',
|
||||||
'Testing',
|
'Testing',
|
||||||
'Foo::bar()',
|
'Foo::bar()',
|
||||||
@@ -76,7 +77,6 @@ class UsesTagTest extends \PHPUnit_Framework_TestCase
|
|||||||
array(
|
array(
|
||||||
'uses',
|
'uses',
|
||||||
'Foo::bar() Testing comments',
|
'Foo::bar() Testing comments',
|
||||||
'uses',
|
|
||||||
'Foo::bar() Testing comments',
|
'Foo::bar() Testing comments',
|
||||||
'Testing comments',
|
'Testing comments',
|
||||||
'Foo::bar()',
|
'Foo::bar()',
|
||||||
|
|||||||
@@ -2,23 +2,29 @@
|
|||||||
/**
|
/**
|
||||||
* phpDocumentor Var Tag Test
|
* phpDocumentor Var Tag Test
|
||||||
*
|
*
|
||||||
* @author Daniel O'Connor <[email protected]>
|
* PHP version 5.3
|
||||||
* @copyright Copyright (c) 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
*
|
||||||
|
* @author Daniel O'Connor <[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;
|
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class for phpDocumentor_Reflection_DocBlock_Tag_Link
|
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\VarTag
|
||||||
*
|
*
|
||||||
* @author Daniel O'Connor <[email protected]>
|
* @author Daniel O'Connor <[email protected]>
|
||||||
* @copyright Copyright (c) 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
* @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
|
||||||
*/
|
*/
|
||||||
class VarTagTest extends \PHPUnit_Framework_TestCase
|
class VarTagTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\VarTag can understand
|
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\VarTag can
|
||||||
* the @var doc block
|
* understand the @var doc block.
|
||||||
*
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @param string $content
|
* @param string $content
|
||||||
@@ -32,14 +38,18 @@ class VarTagTest extends \PHPUnit_Framework_TestCase
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testConstructorParesInputsIntoCorrectFields(
|
public function testConstructorParesInputsIntoCorrectFields(
|
||||||
$type, $content, $exType, $exVariable, $exDescription
|
$type,
|
||||||
)
|
$content,
|
||||||
{
|
$exType,
|
||||||
|
$exVariable,
|
||||||
|
$exDescription
|
||||||
|
) {
|
||||||
$tag = new VarTag($type, $content);
|
$tag = new VarTag($type, $content);
|
||||||
|
|
||||||
|
$this->assertEquals($type, $tag->getName());
|
||||||
$this->assertEquals($exType, $tag->getType());
|
$this->assertEquals($exType, $tag->getType());
|
||||||
$this->assertEquals($exVariable, $tag->getVariableName());
|
$this->assertEquals($exVariable, $tag->getVariableName());
|
||||||
$this->assertEquals($exDescription, $tag->getDescription());
|
$this->assertEquals($exDescription, $tag->getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -49,7 +59,7 @@ class VarTagTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function provideDataForConstuctor()
|
public function provideDataForConstuctor()
|
||||||
{
|
{
|
||||||
// $type, $content
|
// $type, $content, $exType, $exVariable, $exDescription
|
||||||
return array(
|
return array(
|
||||||
array(
|
array(
|
||||||
'var',
|
'var',
|
||||||
@@ -72,6 +82,13 @@ class VarTagTest extends \PHPUnit_Framework_TestCase
|
|||||||
'$bob',
|
'$bob',
|
||||||
'Number of bobs'
|
'Number of bobs'
|
||||||
),
|
),
|
||||||
|
array(
|
||||||
|
'var',
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
''
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,116 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* phpDocumentor Version Tag Test
|
||||||
|
*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\VersionTag
|
||||||
|
*
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
class VersionTagTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\LinkTag can create
|
||||||
|
* a link for the @version doc block.
|
||||||
|
*
|
||||||
|
* @param string $type
|
||||||
|
* @param string $content
|
||||||
|
* @param string $exContent
|
||||||
|
* @param string $exDescription
|
||||||
|
* @param string $exVersion
|
||||||
|
*
|
||||||
|
* @covers \phpDocumentor\Reflection\DocBlock\Tag\VersionTag::__construct
|
||||||
|
* @covers \phpDocumentor\Reflection\DocBlock\Tag\VersionTag::getVersion
|
||||||
|
* @dataProvider provideDataForConstuctor
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testConstructorParesInputsIntoCorrectFields(
|
||||||
|
$type,
|
||||||
|
$content,
|
||||||
|
$exContent,
|
||||||
|
$exDescription,
|
||||||
|
$exVersion
|
||||||
|
) {
|
||||||
|
$tag = new VersionTag($type, $content);
|
||||||
|
|
||||||
|
$this->assertEquals($type, $tag->getName());
|
||||||
|
$this->assertEquals($exContent, $tag->getContent());
|
||||||
|
$this->assertEquals($exDescription, $tag->getDescription());
|
||||||
|
$this->assertEquals($exVersion, $tag->getVersion());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data provider for testConstructorParesInputsIntoCorrectFields
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function provideDataForConstuctor()
|
||||||
|
{
|
||||||
|
// $type, $content, $exContent, $exDescription, $exVersion
|
||||||
|
return array(
|
||||||
|
array(
|
||||||
|
'version',
|
||||||
|
'1.0 First release.',
|
||||||
|
'1.0 First release.',
|
||||||
|
'First release.',
|
||||||
|
'1.0'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'version',
|
||||||
|
"1.0\nFirst release.",
|
||||||
|
"1.0\nFirst release.",
|
||||||
|
'First release.',
|
||||||
|
'1.0'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'version',
|
||||||
|
"1.0\nFirst\nrelease.",
|
||||||
|
"1.0\nFirst\nrelease.",
|
||||||
|
"First\nrelease.",
|
||||||
|
'1.0'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'version',
|
||||||
|
'Unfinished release',
|
||||||
|
'Unfinished release',
|
||||||
|
'Unfinished release',
|
||||||
|
''
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'version',
|
||||||
|
'1.0',
|
||||||
|
'1.0',
|
||||||
|
'',
|
||||||
|
'1.0'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'version',
|
||||||
|
'GIT: $Id$',
|
||||||
|
'GIT: $Id$',
|
||||||
|
'',
|
||||||
|
'GIT: $Id$'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'version',
|
||||||
|
'GIT: $Id$ Dev build',
|
||||||
|
'GIT: $Id$ Dev build',
|
||||||
|
'Dev build',
|
||||||
|
'GIT: $Id$'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,320 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* phpDocumentor Var Tag Test
|
||||||
|
*
|
||||||
|
* PHP version 5.3
|
||||||
|
*
|
||||||
|
* @author Daniel O'Connor <[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;
|
||||||
|
|
||||||
|
use phpDocumentor\Reflection\DocBlock;
|
||||||
|
use phpDocumentor\Reflection\DocBlock\Context;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\VarTag
|
||||||
|
*
|
||||||
|
* @author Daniel O'Connor <[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
|
||||||
|
*/
|
||||||
|
class TagTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \InvalidArgumentException
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testInvalidTagLine()
|
||||||
|
{
|
||||||
|
Tag::createInstance('Invalid tag line');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers \phpDocumentor\Reflection\DocBlock\Tag::registerTagHandler
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testTagHandlerUnregistration()
|
||||||
|
{
|
||||||
|
$currentHandler = __NAMESPACE__ . '\Tag\VarTag';
|
||||||
|
$tagPreUnreg = Tag::createInstance('@var mixed');
|
||||||
|
$this->assertInstanceOf(
|
||||||
|
$currentHandler,
|
||||||
|
$tagPreUnreg
|
||||||
|
);
|
||||||
|
$this->assertInstanceOf(
|
||||||
|
__NAMESPACE__ . '\Tag',
|
||||||
|
$tagPreUnreg
|
||||||
|
);
|
||||||
|
|
||||||
|
Tag::registerTagHandler('var', null);
|
||||||
|
|
||||||
|
$tagPostUnreg = Tag::createInstance('@var mixed');
|
||||||
|
$this->assertNotInstanceOf(
|
||||||
|
$currentHandler,
|
||||||
|
$tagPostUnreg
|
||||||
|
);
|
||||||
|
$this->assertInstanceOf(
|
||||||
|
__NAMESPACE__ . '\Tag',
|
||||||
|
$tagPostUnreg
|
||||||
|
);
|
||||||
|
|
||||||
|
Tag::registerTagHandler('var', $currentHandler);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers \phpDocumentor\Reflection\DocBlock\Tag::registerTagHandler
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testTagHandlerCorrectRegistration()
|
||||||
|
{
|
||||||
|
if (0 == ini_get('allow_url_include')) {
|
||||||
|
$this->markTestSkipped('"data" URIs for includes are required.');
|
||||||
|
}
|
||||||
|
$currentHandler = __NAMESPACE__ . '\Tag\VarTag';
|
||||||
|
$tagPreReg = Tag::createInstance('@var mixed');
|
||||||
|
$this->assertInstanceOf(
|
||||||
|
$currentHandler,
|
||||||
|
$tagPreReg
|
||||||
|
);
|
||||||
|
$this->assertInstanceOf(
|
||||||
|
__NAMESPACE__ . '\Tag',
|
||||||
|
$tagPreReg
|
||||||
|
);
|
||||||
|
|
||||||
|
include 'data:text/plain;base64,'. base64_encode(
|
||||||
|
<<<TAG_HANDLER
|
||||||
|
<?php
|
||||||
|
class MyTagHandler extends \phpDocumentor\Reflection\DocBlock\Tag {}
|
||||||
|
TAG_HANDLER
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertTrue(Tag::registerTagHandler('var', '\MyTagHandler'));
|
||||||
|
|
||||||
|
$tagPostReg = Tag::createInstance('@var mixed');
|
||||||
|
$this->assertNotInstanceOf(
|
||||||
|
$currentHandler,
|
||||||
|
$tagPostReg
|
||||||
|
);
|
||||||
|
$this->assertInstanceOf(
|
||||||
|
__NAMESPACE__ . '\Tag',
|
||||||
|
$tagPostReg
|
||||||
|
);
|
||||||
|
$this->assertInstanceOf(
|
||||||
|
'\MyTagHandler',
|
||||||
|
$tagPostReg
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertTrue(Tag::registerTagHandler('var', $currentHandler));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @depends testTagHandlerCorrectRegistration
|
||||||
|
* @covers \phpDocumentor\Reflection\DocBlock\Tag::registerTagHandler
|
||||||
|
* @covers \phpDocumentor\Reflection\DocBlock\Tag::createInstance
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testNamespacedTagHandlerCorrectRegistration()
|
||||||
|
{
|
||||||
|
$tagPreReg = Tag::createInstance('@T something');
|
||||||
|
$this->assertInstanceOf(
|
||||||
|
__NAMESPACE__ . '\Tag',
|
||||||
|
$tagPreReg
|
||||||
|
);
|
||||||
|
$this->assertNotInstanceOf(
|
||||||
|
'\MyTagHandler',
|
||||||
|
$tagPreReg
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertTrue(
|
||||||
|
Tag::registerTagHandler('\MyNamespace\MyTag', '\MyTagHandler')
|
||||||
|
);
|
||||||
|
|
||||||
|
$tagPostReg = Tag::createInstance(
|
||||||
|
'@T something',
|
||||||
|
new DocBlock(
|
||||||
|
'',
|
||||||
|
new Context('', array('T' => '\MyNamespace\MyTag'))
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$this->assertInstanceOf(
|
||||||
|
__NAMESPACE__ . '\Tag',
|
||||||
|
$tagPostReg
|
||||||
|
);
|
||||||
|
$this->assertInstanceOf(
|
||||||
|
'\MyTagHandler',
|
||||||
|
$tagPostReg
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertTrue(
|
||||||
|
Tag::registerTagHandler('\MyNamespace\MyTag', null)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @depends testTagHandlerCorrectRegistration
|
||||||
|
* @covers \phpDocumentor\Reflection\DocBlock\Tag::registerTagHandler
|
||||||
|
* @covers \phpDocumentor\Reflection\DocBlock\Tag::createInstance
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testNamespacedTagHandlerIncorrectRegistration()
|
||||||
|
{
|
||||||
|
$tagPreReg = Tag::createInstance('@T something');
|
||||||
|
$this->assertInstanceOf(
|
||||||
|
__NAMESPACE__ . '\Tag',
|
||||||
|
$tagPreReg
|
||||||
|
);
|
||||||
|
$this->assertNotInstanceOf(
|
||||||
|
'\MyTagHandler',
|
||||||
|
$tagPreReg
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertFalse(
|
||||||
|
Tag::registerTagHandler('MyNamespace\MyTag', '\MyTagHandler')
|
||||||
|
);
|
||||||
|
|
||||||
|
$tagPostReg = Tag::createInstance(
|
||||||
|
'@T something',
|
||||||
|
new DocBlock(
|
||||||
|
'',
|
||||||
|
new Context('', array('T' => '\MyNamespace\MyTag'))
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$this->assertInstanceOf(
|
||||||
|
__NAMESPACE__ . '\Tag',
|
||||||
|
$tagPostReg
|
||||||
|
);
|
||||||
|
$this->assertNotInstanceOf(
|
||||||
|
'\MyTagHandler',
|
||||||
|
$tagPostReg
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers \phpDocumentor\Reflection\DocBlock\Tag::registerTagHandler
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testNonExistentTagHandlerRegistration()
|
||||||
|
{
|
||||||
|
$currentHandler = __NAMESPACE__ . '\Tag\VarTag';
|
||||||
|
$tagPreReg = Tag::createInstance('@var mixed');
|
||||||
|
$this->assertInstanceOf(
|
||||||
|
$currentHandler,
|
||||||
|
$tagPreReg
|
||||||
|
);
|
||||||
|
$this->assertInstanceOf(
|
||||||
|
__NAMESPACE__ . '\Tag',
|
||||||
|
$tagPreReg
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertFalse(Tag::registerTagHandler('var', 'Non existent'));
|
||||||
|
|
||||||
|
$tagPostReg = Tag::createInstance('@var mixed');
|
||||||
|
$this->assertInstanceOf(
|
||||||
|
$currentHandler,
|
||||||
|
$tagPostReg
|
||||||
|
);
|
||||||
|
$this->assertInstanceOf(
|
||||||
|
__NAMESPACE__ . '\Tag',
|
||||||
|
$tagPostReg
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers \phpDocumentor\Reflection\DocBlock\Tag::registerTagHandler
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testIncompatibleTagHandlerRegistration()
|
||||||
|
{
|
||||||
|
$currentHandler = __NAMESPACE__ . '\Tag\VarTag';
|
||||||
|
$tagPreReg = Tag::createInstance('@var mixed');
|
||||||
|
$this->assertInstanceOf(
|
||||||
|
$currentHandler,
|
||||||
|
$tagPreReg
|
||||||
|
);
|
||||||
|
$this->assertInstanceOf(
|
||||||
|
__NAMESPACE__ . '\Tag',
|
||||||
|
$tagPreReg
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertFalse(
|
||||||
|
Tag::registerTagHandler('var', __NAMESPACE__ . '\TagTest')
|
||||||
|
);
|
||||||
|
|
||||||
|
$tagPostReg = Tag::createInstance('@var mixed');
|
||||||
|
$this->assertInstanceOf(
|
||||||
|
$currentHandler,
|
||||||
|
$tagPostReg
|
||||||
|
);
|
||||||
|
$this->assertInstanceOf(
|
||||||
|
__NAMESPACE__ . '\Tag',
|
||||||
|
$tagPostReg
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\VarTag can
|
||||||
|
* understand the @var doc block.
|
||||||
|
*
|
||||||
|
* @param string $type
|
||||||
|
* @param string $content
|
||||||
|
* @param string $exDescription
|
||||||
|
*
|
||||||
|
* @covers \phpDocumentor\Reflection\DocBlock\Tag::__construct
|
||||||
|
* @covers \phpDocumentor\Reflection\DocBlock\Tag::getDescription
|
||||||
|
* @covers \phpDocumentor\Reflection\DocBlock\Tag::getContent
|
||||||
|
* @dataProvider provideDataForConstuctor
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testConstructorParesInputsIntoCorrectFields(
|
||||||
|
$type,
|
||||||
|
$content,
|
||||||
|
$exDescription
|
||||||
|
) {
|
||||||
|
$tag = new Tag($type, $content);
|
||||||
|
|
||||||
|
$this->assertEquals($type, $tag->getName());
|
||||||
|
$this->assertEquals($content, $tag->getContent());
|
||||||
|
$this->assertEquals($exDescription, $tag->getDescription());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data provider for testConstructorParesInputsIntoCorrectFields
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function provideDataForConstuctor()
|
||||||
|
{
|
||||||
|
// $type, $content, $exDescription
|
||||||
|
return array(
|
||||||
|
array(
|
||||||
|
'unknown',
|
||||||
|
'some content',
|
||||||
|
'some content',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'unknown',
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'',
|
||||||
|
'unknown',
|
||||||
|
'unknown',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,27 +1,49 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* phpDocumentor Collection Test
|
||||||
|
*
|
||||||
|
* PHP version 5.3
|
||||||
|
*
|
||||||
|
* @author Mike van Riel <[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\Type;
|
namespace phpDocumentor\Reflection\DocBlock\Type;
|
||||||
|
|
||||||
|
use phpDocumentor\Reflection\DocBlock\Context;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class for phpDocumentor_Reflection_DocBlock
|
* Test class for \phpDocumentor\Reflection\DocBlock\Type\Collection
|
||||||
|
*
|
||||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection
|
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection
|
||||||
|
*
|
||||||
|
* @author Mike van Riel <[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
|
||||||
*/
|
*/
|
||||||
class CollectionTest extends \PHPUnit_Framework_TestCase
|
class CollectionTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::__construct
|
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::__construct
|
||||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::getNamespace
|
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::getContext
|
||||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::getNamespaceAliases
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testConstruct()
|
public function testConstruct()
|
||||||
{
|
{
|
||||||
$collection = new Collection();
|
$collection = new Collection();
|
||||||
$this->assertCount(0, $collection);
|
$this->assertCount(0, $collection);
|
||||||
$this->assertEquals('\\', $collection->getNamespace());
|
$this->assertEquals('', $collection->getContext()->getNamespace());
|
||||||
$this->assertCount(0, $collection->getNamespaceAliases());
|
$this->assertCount(0, $collection->getContext()->getNamespaceAliases());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::__construct
|
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::__construct
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testConstructWithTypes()
|
public function testConstructWithTypes()
|
||||||
{
|
{
|
||||||
@@ -31,91 +53,71 @@ class CollectionTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::__construct
|
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::__construct
|
||||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::getNamespace
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testConstructWithNamespace()
|
public function testConstructWithNamespace()
|
||||||
{
|
{
|
||||||
$collection = new Collection(array(), '\My\Space');
|
$collection = new Collection(array(), new Context('\My\Space'));
|
||||||
$this->assertEquals('\My\Space\\', $collection->getNamespace());
|
$this->assertEquals('My\Space', $collection->getContext()->getNamespace());
|
||||||
|
|
||||||
$collection = new Collection(array(), 'My\Space');
|
$collection = new Collection(array(), new Context('My\Space'));
|
||||||
$this->assertEquals('\My\Space\\', $collection->getNamespace());
|
$this->assertEquals('My\Space', $collection->getContext()->getNamespace());
|
||||||
|
|
||||||
$collection = new Collection(array(), null);
|
$collection = new Collection(array(), null);
|
||||||
$this->assertEquals('\\', $collection->getNamespace());
|
$this->assertEquals('', $collection->getContext()->getNamespace());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::__construct
|
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::__construct
|
||||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::getNamespaceAliases
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testConstructWithNamespaceAliases()
|
public function testConstructWithNamespaceAliases()
|
||||||
{
|
{
|
||||||
$fixture = array('a' => 'b');
|
$fixture = array('a' => 'b');
|
||||||
$collection = new Collection(array(), null, $fixture);
|
$collection = new Collection(array(), new Context(null, $fixture));
|
||||||
$this->assertEquals($fixture, $collection->getNamespaceAliases());
|
$this->assertEquals(
|
||||||
|
array('a' => '\b'),
|
||||||
|
$collection->getContext()->getNamespaceAliases()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::setNamespace
|
* @param string $fixture
|
||||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::getNamespace
|
* @param array $expected
|
||||||
*/
|
|
||||||
public function testSetAndGetNamespace()
|
|
||||||
{
|
|
||||||
$collection = new Collection();
|
|
||||||
$this->assertEquals('\\', $collection->getNamespace());
|
|
||||||
|
|
||||||
$collection->setNamespace('My');
|
|
||||||
$this->assertEquals('\My\\', $collection->getNamespace());
|
|
||||||
|
|
||||||
$collection->setNamespace('\My');
|
|
||||||
$this->assertEquals('\My\\', $collection->getNamespace());
|
|
||||||
|
|
||||||
$collection->setNamespace('\My\\');
|
|
||||||
$this->assertEquals('\My\\', $collection->getNamespace());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::setNamespaceAliases
|
|
||||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::getNamespaceAliases
|
|
||||||
*/
|
|
||||||
public function testSetAndGetNamespaceAliases()
|
|
||||||
{
|
|
||||||
$collection = new Collection();
|
|
||||||
$this->assertEmpty($collection->getNamespaceAliases());
|
|
||||||
|
|
||||||
$collection->setNamespaceAliases(array('My'));
|
|
||||||
$this->assertEquals(array('My'), $collection->getNamespaceAliases());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $fixture
|
|
||||||
* @param $expected
|
|
||||||
*
|
*
|
||||||
* @dataProvider provideTypesToExpand
|
* @dataProvider provideTypesToExpand
|
||||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::add
|
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::add
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testAdd($fixture, $expected)
|
public function testAdd($fixture, $expected)
|
||||||
{
|
{
|
||||||
$collection = new Collection();
|
$collection = new Collection(
|
||||||
$collection->setNamespace('\My\Space');
|
array(),
|
||||||
$collection->setNamespaceAliases(array('Alias' => '\My\Space\Aliasing'));
|
new Context('\My\Space', array('Alias' => '\My\Space\Aliasing'))
|
||||||
|
);
|
||||||
$collection->add($fixture);
|
$collection->add($fixture);
|
||||||
|
|
||||||
$this->assertSame($expected, $collection->getArrayCopy());
|
$this->assertSame($expected, $collection->getArrayCopy());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $fixture
|
* @param string $fixture
|
||||||
* @param $expected
|
* @param array $expected
|
||||||
*
|
*
|
||||||
* @dataProvider provideTypesToExpandWithoutNamespace
|
* @dataProvider provideTypesToExpandWithoutNamespace
|
||||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::add
|
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::add
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testAddWithoutNamespace($fixture, $expected)
|
public function testAddWithoutNamespace($fixture, $expected)
|
||||||
{
|
{
|
||||||
$collection = new Collection();
|
$collection = new Collection(
|
||||||
$collection->setNamespaceAliases(array('Alias' => '\My\Space\Aliasing'));
|
array(),
|
||||||
|
new Context(null, array('Alias' => '\My\Space\Aliasing'))
|
||||||
|
);
|
||||||
$collection->add($fixture);
|
$collection->add($fixture);
|
||||||
|
|
||||||
$this->assertSame($expected, $collection->getArrayCopy());
|
$this->assertSame($expected, $collection->getArrayCopy());
|
||||||
@@ -124,6 +126,8 @@ class CollectionTest extends \PHPUnit_Framework_TestCase
|
|||||||
/**
|
/**
|
||||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::add
|
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::add
|
||||||
* @expectedException InvalidArgumentException
|
* @expectedException InvalidArgumentException
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testAddWithInvalidArgument()
|
public function testAddWithInvalidArgument()
|
||||||
{
|
{
|
||||||
@@ -135,7 +139,7 @@ class CollectionTest extends \PHPUnit_Framework_TestCase
|
|||||||
* Returns the types and their expected values to test the retrieval of
|
* Returns the types and their expected values to test the retrieval of
|
||||||
* types.
|
* types.
|
||||||
*
|
*
|
||||||
* @param string $method Name of the method consuming this data provider.
|
* @param string $method Name of the method consuming this data provider.
|
||||||
* @param string $namespace Name of the namespace to user as basis.
|
* @param string $namespace Name of the namespace to user as basis.
|
||||||
*
|
*
|
||||||
* @return string[]
|
* @return string[]
|
||||||
@@ -181,7 +185,6 @@ class CollectionTest extends \PHPUnit_Framework_TestCase
|
|||||||
* types when no namespace is available.
|
* types when no namespace is available.
|
||||||
*
|
*
|
||||||
* @param string $method Name of the method consuming this data provider.
|
* @param string $method Name of the method consuming this data provider.
|
||||||
* @param string $namespace Name of the namespace to user as basis.
|
|
||||||
*
|
*
|
||||||
* @return string[]
|
* @return string[]
|
||||||
*/
|
*/
|
||||||
@@ -189,6 +192,4 @@ class CollectionTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
return $this->provideTypesToExpand($method, '\\');
|
return $this->provideTypesToExpand($method, '\\');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,22 +2,34 @@
|
|||||||
/**
|
/**
|
||||||
* phpDocumentor DocBlock Test
|
* phpDocumentor DocBlock Test
|
||||||
*
|
*
|
||||||
* PHP Version 5
|
* PHP Version 5.3
|
||||||
*
|
*
|
||||||
* @author Mike van Riel <[email protected]>
|
* @author Mike van Riel <[email protected]>
|
||||||
* @copyright Copyright (c) 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
* @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;
|
namespace phpDocumentor\Reflection;
|
||||||
|
|
||||||
|
use phpDocumentor\Reflection\DocBlock\Context;
|
||||||
|
use phpDocumentor\Reflection\DocBlock\Location;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class for phpDocumentor_Reflection_DocBlock
|
* Test class for phpDocumentor\Reflection\DocBlock
|
||||||
*
|
*
|
||||||
* @author Mike van Riel <[email protected]>
|
* @author Mike van Riel <[email protected]>
|
||||||
* @copyright Copyright (c) 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
* @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
|
||||||
*/
|
*/
|
||||||
class DocBlockTest extends \PHPUnit_Framework_TestCase
|
class DocBlockTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @covers \phpDocumentor\Reflection\DocBlock
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function testConstruct()
|
public function testConstruct()
|
||||||
{
|
{
|
||||||
$fixture = <<<DOCBLOCK
|
$fixture = <<<DOCBLOCK
|
||||||
@@ -30,17 +42,100 @@ class DocBlockTest extends \PHPUnit_Framework_TestCase
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
DOCBLOCK;
|
DOCBLOCK;
|
||||||
$object = new DocBlock($fixture);
|
$object = new DocBlock(
|
||||||
|
$fixture,
|
||||||
|
new Context('\MyNamespace', array('PHPDoc' => '\phpDocumentor')),
|
||||||
|
new Location(2)
|
||||||
|
);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'This is a short description.', $object->getShortDescription()
|
'This is a short description.',
|
||||||
|
$object->getShortDescription()
|
||||||
);
|
);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'This is a long description.',
|
'This is a long description.',
|
||||||
$object->getLongDescription()->getContents()
|
$object->getLongDescription()->getContents()
|
||||||
);
|
);
|
||||||
$this->assertEquals(2, count($object->getTags()));
|
$this->assertCount(2, $object->getTags());
|
||||||
$this->assertTrue($object->hasTag('see'));
|
$this->assertTrue($object->hasTag('see'));
|
||||||
$this->assertTrue($object->hasTag('return'));
|
$this->assertTrue($object->hasTag('return'));
|
||||||
|
$this->assertFalse($object->hasTag('category'));
|
||||||
|
|
||||||
|
$this->assertSame('MyNamespace', $object->getContext()->getNamespace());
|
||||||
|
$this->assertSame(
|
||||||
|
array('PHPDoc' => '\phpDocumentor'),
|
||||||
|
$object->getContext()->getNamespaceAliases()
|
||||||
|
);
|
||||||
|
$this->assertSame(2, $object->getLocation()->getLineNumber());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers \phpDocumentor\Reflection\DocBlock::splitDocBlock
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testConstructWithTagsOnly()
|
||||||
|
{
|
||||||
|
$fixture = <<<DOCBLOCK
|
||||||
|
/**
|
||||||
|
* @see \MyClass
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
DOCBLOCK;
|
||||||
|
$object = new DocBlock($fixture);
|
||||||
|
$this->assertEquals('', $object->getShortDescription());
|
||||||
|
$this->assertEquals('', $object->getLongDescription()->getContents());
|
||||||
|
$this->assertCount(2, $object->getTags());
|
||||||
|
$this->assertTrue($object->hasTag('see'));
|
||||||
|
$this->assertTrue($object->hasTag('return'));
|
||||||
|
$this->assertFalse($object->hasTag('category'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers \phpDocumentor\Reflection\DocBlock::cleanInput
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testConstructOneLiner()
|
||||||
|
{
|
||||||
|
$fixture = '/** Short description and nothing more. */';
|
||||||
|
$object = new DocBlock($fixture);
|
||||||
|
$this->assertEquals(
|
||||||
|
'Short description and nothing more.',
|
||||||
|
$object->getShortDescription()
|
||||||
|
);
|
||||||
|
$this->assertEquals('', $object->getLongDescription()->getContents());
|
||||||
|
$this->assertCount(0, $object->getTags());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers \phpDocumentor\Reflection\DocBlock::__construct
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testConstructFromReflector()
|
||||||
|
{
|
||||||
|
$object = new DocBlock(new \ReflectionClass($this));
|
||||||
|
$this->assertEquals(
|
||||||
|
'Test class for phpDocumentor\Reflection\DocBlock',
|
||||||
|
$object->getShortDescription()
|
||||||
|
);
|
||||||
|
$this->assertEquals('', $object->getLongDescription()->getContents());
|
||||||
|
$this->assertCount(4, $object->getTags());
|
||||||
|
$this->assertTrue($object->hasTag('author'));
|
||||||
|
$this->assertTrue($object->hasTag('copyright'));
|
||||||
|
$this->assertTrue($object->hasTag('license'));
|
||||||
|
$this->assertTrue($object->hasTag('link'));
|
||||||
|
$this->assertFalse($object->hasTag('category'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \InvalidArgumentException
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testExceptionOnInvalidObject()
|
||||||
|
{
|
||||||
|
new DocBlock($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDotSeperation()
|
public function testDotSeperation()
|
||||||
@@ -53,92 +148,150 @@ DOCBLOCK;
|
|||||||
DOCBLOCK;
|
DOCBLOCK;
|
||||||
$object = new DocBlock($fixture);
|
$object = new DocBlock($fixture);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'This is a short description.', $object->getShortDescription()
|
'This is a short description.',
|
||||||
|
$object->getShortDescription()
|
||||||
);
|
);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
"This is a long description.\nThis is a continuation of the long "
|
"This is a long description.\nThis is a continuation of the long "
|
||||||
."description.", $object->getLongDescription()->getContents()
|
."description.",
|
||||||
|
$object->getLongDescription()->getContents()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests whether a type is expanded with the given namespace and that a
|
* @covers \phpDocumentor\Reflection\DocBlock::parseTags
|
||||||
* keyword is not expanded.
|
* @expectedException \LogicException
|
||||||
*
|
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock::expandType()
|
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testExpandTypeUsingNamespace()
|
public function testInvalidTagBlock()
|
||||||
{
|
{
|
||||||
$docblock = new DocBlock('', '\My\Namespace');
|
if (0 == ini_get('allow_url_include')) {
|
||||||
$this->assertEquals('\My\Namespace\Mine', $docblock->expandType('Mine'));
|
$this->markTestSkipped('"data" URIs for includes are required.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
include 'data:text/plain;base64,'. base64_encode(
|
||||||
* Tests whether a type is expanded when no namespace is given.
|
<<<DOCBLOCK_EXTENSION
|
||||||
*
|
<?php
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock::expandType()
|
class MyReflectionDocBlock extends \phpDocumentor\Reflection\DocBlock {
|
||||||
*
|
protected function splitDocBlock(\$comment) {
|
||||||
* @return void
|
return array('', '', 'Invalid tag block');
|
||||||
*/
|
|
||||||
public function testExpandTypeWithoutNamespace()
|
|
||||||
{
|
|
||||||
$docblock = new DocBlock('');
|
|
||||||
$this->assertEquals('\Mine', $docblock->expandType('Mine'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests whether a type is expanded with the given namespace when an alias
|
|
||||||
* is provided.
|
|
||||||
*
|
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock::expandType()
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function testExpandTypeUsingNamespaceAlias()
|
|
||||||
{
|
|
||||||
$docblock = new DocBlock(
|
|
||||||
'', '\My\Namespace', array('Alias' => '\My\Namespace\Alias')
|
|
||||||
);
|
|
||||||
|
|
||||||
// first try a normal resolution without alias
|
|
||||||
$this->assertEquals(
|
|
||||||
'\My\Namespace\Al', $docblock->expandType('Al')
|
|
||||||
);
|
|
||||||
|
|
||||||
// try to use the alias
|
|
||||||
$this->assertEquals(
|
|
||||||
'\My\Namespace\Alias\Al', $docblock->expandType('Alias\Al')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests whether the keywords that should not be converted are not converted.
|
|
||||||
*
|
|
||||||
* @param string $keyword The keyword that is to be tested; this is provided
|
|
||||||
* by the dataprovider.
|
|
||||||
*
|
|
||||||
* @covers \phpDocumentor\Reflection\DocBlock::expandType()
|
|
||||||
*
|
|
||||||
* @dataProvider getNonExpandableKeywordsForExpandType
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function testThatExpandTypeDoesNotExpandAllKeywords($keyword)
|
|
||||||
{
|
|
||||||
$docblock = new DocBlock('', '\My\Namespace');
|
|
||||||
$this->assertEquals($keyword, $docblock->expandType($keyword));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getNonExpandableKeywordsForExpandType()
|
|
||||||
{
|
|
||||||
return array(
|
|
||||||
array('string'), array('int'), array('integer'), array('bool'),
|
|
||||||
array('boolean'), array('float'), array('double'), array('object'),
|
|
||||||
array('mixed'), array('array'), array('resource'), array('void'),
|
|
||||||
array('null'), array('callback'), array('false'), array('true')
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
DOCBLOCK_EXTENSION
|
||||||
|
);
|
||||||
|
new \MyReflectionDocBlock('');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testTagCaseSensitivity()
|
||||||
|
{
|
||||||
|
$fixture = <<<DOCBLOCK
|
||||||
|
/**
|
||||||
|
* This is a short description.
|
||||||
|
*
|
||||||
|
* This is a long description.
|
||||||
|
*
|
||||||
|
* @method null something()
|
||||||
|
* @Method({"GET", "POST"})
|
||||||
|
*/
|
||||||
|
DOCBLOCK;
|
||||||
|
$object = new DocBlock($fixture);
|
||||||
|
$this->assertEquals(
|
||||||
|
'This is a short description.',
|
||||||
|
$object->getShortDescription()
|
||||||
|
);
|
||||||
|
$this->assertEquals(
|
||||||
|
'This is a long description.',
|
||||||
|
$object->getLongDescription()->getContents()
|
||||||
|
);
|
||||||
|
$tags = $object->getTags();
|
||||||
|
$this->assertCount(2, $tags);
|
||||||
|
$this->assertTrue($object->hasTag('method'));
|
||||||
|
$this->assertTrue($object->hasTag('Method'));
|
||||||
|
$this->assertInstanceOf(
|
||||||
|
__NAMESPACE__ . '\DocBlock\Tag\MethodTag',
|
||||||
|
$tags[0]
|
||||||
|
);
|
||||||
|
$this->assertInstanceOf(
|
||||||
|
__NAMESPACE__ . '\DocBlock\Tag',
|
||||||
|
$tags[1]
|
||||||
|
);
|
||||||
|
$this->assertNotInstanceOf(
|
||||||
|
__NAMESPACE__ . '\DocBlock\Tag\MethodTag',
|
||||||
|
$tags[1]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @depends testConstructFromReflector
|
||||||
|
* @covers \phpDocumentor\Reflection\DocBlock::getTagsByName
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testGetTagsByNameZeroAndOneMatch()
|
||||||
|
{
|
||||||
|
$object = new DocBlock(new \ReflectionClass($this));
|
||||||
|
$this->assertEmpty($object->getTagsByName('category'));
|
||||||
|
$this->assertCount(1, $object->getTagsByName('author'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @depends testConstructWithTagsOnly
|
||||||
|
* @covers \phpDocumentor\Reflection\DocBlock::parseTags
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testParseMultilineTag()
|
||||||
|
{
|
||||||
|
$fixture = <<<DOCBLOCK
|
||||||
|
/**
|
||||||
|
* @return void Content on
|
||||||
|
* multiple lines.
|
||||||
|
*/
|
||||||
|
DOCBLOCK;
|
||||||
|
$object = new DocBlock($fixture);
|
||||||
|
$this->assertCount(1, $object->getTags());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @depends testConstructWithTagsOnly
|
||||||
|
* @covers \phpDocumentor\Reflection\DocBlock::parseTags
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testParseMultilineTagWithLineBreaks()
|
||||||
|
{
|
||||||
|
$fixture = <<<DOCBLOCK
|
||||||
|
/**
|
||||||
|
* @return void Content on
|
||||||
|
* multiple lines.
|
||||||
|
*
|
||||||
|
* One more, after the break.
|
||||||
|
*/
|
||||||
|
DOCBLOCK;
|
||||||
|
$object = new DocBlock($fixture);
|
||||||
|
$this->assertCount(1, $object->getTags());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @depends testConstructWithTagsOnly
|
||||||
|
* @covers \phpDocumentor\Reflection\DocBlock::getTagsByName
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testGetTagsByNameMultipleMatch()
|
||||||
|
{
|
||||||
|
$fixture = <<<DOCBLOCK
|
||||||
|
/**
|
||||||
|
* @param string
|
||||||
|
* @param int
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
DOCBLOCK;
|
||||||
|
$object = new DocBlock($fixture);
|
||||||
|
$this->assertEmpty($object->getTagsByName('category'));
|
||||||
|
$this->assertCount(1, $object->getTagsByName('return'));
|
||||||
|
$this->assertCount(2, $object->getTagsByName('param'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user