mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 01:57:13 +00:00
Made PSR2 related fixes that are compatible with the PEAR coding standard.
This commit is contained in:
@@ -64,7 +64,9 @@ class DocBlock implements \Reflector
|
|||||||
* getDocComment method.
|
* getDocComment method.
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
$docblock, $namespace = '\\', $namespace_aliases = array()
|
$docblock,
|
||||||
|
$namespace = '\\',
|
||||||
|
$namespace_aliases = array()
|
||||||
) {
|
) {
|
||||||
if (is_object($docblock)) {
|
if (is_object($docblock)) {
|
||||||
if (!method_exists($docblock, 'getDocComment')) {
|
if (!method_exists($docblock, 'getDocComment')) {
|
||||||
@@ -99,7 +101,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
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -173,7 +177,9 @@ class DocBlock implements \Reflector
|
|||||||
)
|
)
|
||||||
)?
|
)?
|
||||||
(\s+ [\s\S]*)? # everything that follows
|
(\s+ [\s\S]*)? # everything that follows
|
||||||
/u', $comment, $matches
|
/u',
|
||||||
|
$comment,
|
||||||
|
$matches
|
||||||
);
|
);
|
||||||
array_shift($matches);
|
array_shift($matches);
|
||||||
}
|
}
|
||||||
@@ -382,7 +388,7 @@ class DocBlock implements \Reflector
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
static public function export()
|
public static function export()
|
||||||
{
|
{
|
||||||
throw new \Exception('Not yet implemented');
|
throw new \Exception('Not yet implemented');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,8 +61,10 @@ class LongDescription implements \Reflector
|
|||||||
{
|
{
|
||||||
if (null === $this->parsedContents) {
|
if (null === $this->parsedContents) {
|
||||||
$this->parsedContents = preg_split(
|
$this->parsedContents = preg_split(
|
||||||
'/\{(\@.*?)\}/uS', $this->contents,
|
'/\{(\@.*?)\}/uS',
|
||||||
null, PREG_SPLIT_DELIM_CAPTURE
|
$this->contents,
|
||||||
|
null,
|
||||||
|
PREG_SPLIT_DELIM_CAPTURE
|
||||||
);
|
);
|
||||||
for ($i=1, $l = count($this->parsedContents); $i<$l; $i += 2) {
|
for ($i=1, $l = count($this->parsedContents); $i<$l; $i += 2) {
|
||||||
$this->parsedContents[$i] = Tag::createInstance(
|
$this->parsedContents[$i] = Tag::createInstance(
|
||||||
@@ -111,7 +113,7 @@ class LongDescription implements \Reflector
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
static public function export()
|
public static function export()
|
||||||
{
|
{
|
||||||
throw new \Exception('Not yet implemented');
|
throw new \Exception('Not yet implemented');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,9 @@ class Tag implements \Reflector
|
|||||||
public static function createInstance($tag_line)
|
public static function createInstance($tag_line)
|
||||||
{
|
{
|
||||||
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
|
||||||
@@ -60,7 +62,9 @@ class Tag implements \Reflector
|
|||||||
|
|
||||||
// support hypphen separated tag names
|
// support hypphen separated tag names
|
||||||
$tag_name = str_replace(
|
$tag_name = str_replace(
|
||||||
' ', '', ucwords(str_replace('-', ' ', $matches[1]))
|
' ',
|
||||||
|
'',
|
||||||
|
ucwords(str_replace('-', ' ', $matches[1]))
|
||||||
).'Tag';
|
).'Tag';
|
||||||
$class_name = 'phpDocumentor\\Reflection\\DocBlock\\Tag\\' . $tag_name;
|
$class_name = 'phpDocumentor\\Reflection\\DocBlock\\Tag\\' . $tag_name;
|
||||||
|
|
||||||
@@ -170,7 +174,7 @@ class Tag implements \Reflector
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
static public function export()
|
public static function export()
|
||||||
{
|
{
|
||||||
throw new \Exception('Not yet implemented');
|
throw new \Exception('Not yet implemented');
|
||||||
}
|
}
|
||||||
@@ -185,5 +189,4 @@ class Tag implements \Reflector
|
|||||||
{
|
{
|
||||||
return 'Not yet implemented';
|
return 'Not yet implemented';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,5 +21,4 @@ namespace phpDocumentor\Reflection\DocBlock\Tag;
|
|||||||
*/
|
*/
|
||||||
class CoversTag extends SeeTag
|
class CoversTag extends SeeTag
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -125,5 +125,4 @@ class MethodTag extends ParamTag
|
|||||||
|
|
||||||
return $arguments;
|
return $arguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -21,5 +21,4 @@ namespace phpDocumentor\Reflection\DocBlock\Tag;
|
|||||||
*/
|
*/
|
||||||
class PropertyReadTag extends PropertyTag
|
class PropertyReadTag extends PropertyTag
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,5 +21,4 @@ namespace phpDocumentor\Reflection\DocBlock\Tag;
|
|||||||
*/
|
*/
|
||||||
class PropertyTag extends ParamTag
|
class PropertyTag extends ParamTag
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,5 +21,4 @@ namespace phpDocumentor\Reflection\DocBlock\Tag;
|
|||||||
*/
|
*/
|
||||||
class PropertyWriteTag extends PropertyTag
|
class PropertyWriteTag extends PropertyTag
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,5 +42,4 @@ class ReturnTag extends ParamTag
|
|||||||
|
|
||||||
$this->description = implode(' ', $content);
|
$this->description = implode(' ', $content);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -52,5 +53,4 @@ class SeeTag extends Tag
|
|||||||
{
|
{
|
||||||
return $this->refers;
|
return $this->refers;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,5 +21,4 @@ namespace phpDocumentor\Reflection\DocBlock\Tag;
|
|||||||
*/
|
*/
|
||||||
class ThrowsTag extends ReturnTag
|
class ThrowsTag extends ReturnTag
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -21,5 +21,4 @@ namespace phpDocumentor\Reflection\DocBlock\Tag;
|
|||||||
*/
|
*/
|
||||||
class UsesTag extends SeeTag
|
class UsesTag extends SeeTag
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,8 @@ class Collection extends \ArrayObject
|
|||||||
* pairs that are used in the resolving process.
|
* pairs that are used in the resolving process.
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
array $types = array(), $namespace = null,
|
array $types = array(),
|
||||||
|
$namespace = null,
|
||||||
array $namespace_aliases = array()
|
array $namespace_aliases = array()
|
||||||
) {
|
) {
|
||||||
// only set the namespace if overridden
|
// only set the namespace if overridden
|
||||||
|
|||||||
@@ -38,7 +38,12 @@ class CoversTagTest extends \PHPUnit_Framework_TestCase
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testConstructorParesInputsIntoCorrectFields(
|
public function testConstructorParesInputsIntoCorrectFields(
|
||||||
$type, $content, $exName, $exContent, $exDescription, $exReference
|
$type,
|
||||||
|
$content,
|
||||||
|
$exName,
|
||||||
|
$exContent,
|
||||||
|
$exDescription,
|
||||||
|
$exReference
|
||||||
) {
|
) {
|
||||||
$tag = new CoversTag($type, $content);
|
$tag = new CoversTag($type, $content);
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,12 @@ class LinkTagTest extends \PHPUnit_Framework_TestCase
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testConstructorParesInputsIntoCorrectFields(
|
public function testConstructorParesInputsIntoCorrectFields(
|
||||||
$type, $content, $exName, $exContent, $exDescription, $exLink
|
$type,
|
||||||
|
$content,
|
||||||
|
$exName,
|
||||||
|
$exContent,
|
||||||
|
$exDescription,
|
||||||
|
$exLink
|
||||||
) {
|
) {
|
||||||
$tag = new LinkTag($type, $content);
|
$tag = new LinkTag($type, $content);
|
||||||
|
|
||||||
|
|||||||
@@ -38,15 +38,21 @@ class MethodTagTest extends \PHPUnit_Framework_TestCase
|
|||||||
*
|
*
|
||||||
* @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,
|
||||||
|
$has_params,
|
||||||
|
$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'
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -54,11 +60,12 @@ class MethodTagTest extends \PHPUnit_Framework_TestCase
|
|||||||
return;
|
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->assertSame(
|
||||||
$has_params, (bool)(count($tag->getArguments()) > 0),
|
$has_params,
|
||||||
|
(bool)(count($tag->getArguments()) > 0),
|
||||||
'Number of found arguments should exceed 0'
|
'Number of found arguments should exceed 0'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,14 +39,17 @@ class ParamTagTest extends \PHPUnit_Framework_TestCase
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testConstructorParsesInputsIntoCorrectFields(
|
public function testConstructorParsesInputsIntoCorrectFields(
|
||||||
$type, $content, $extracted_type, $extracted_variable_name,
|
$type,
|
||||||
|
$content,
|
||||||
|
$extracted_type,
|
||||||
|
$extracted_variable_name,
|
||||||
$extracted_description
|
$extracted_description
|
||||||
) {
|
) {
|
||||||
$tag = new ParamTag($type, $content);
|
$tag = new ParamTag($type, $content);
|
||||||
|
|
||||||
$this->assertEquals($extracted_type, $tag->getTypes());
|
$this->assertEquals($extracted_type, $tag->getTypes());
|
||||||
$this->assertEquals($extracted_variable_name, $tag->getVariableName());
|
$this->assertEquals($extracted_variable_name, $tag->getVariableName());
|
||||||
$this->assertEquals($extracted_description, $tag->getDescription());
|
$this->assertEquals($extracted_description, $tag->getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -37,12 +37,14 @@ class ReturnTagTest extends ParamTagTest
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testConstructorParsesInputsIntoCorrectFields(
|
public function testConstructorParsesInputsIntoCorrectFields(
|
||||||
$content, $extracted_type, $extracted_description
|
$content,
|
||||||
|
$extracted_type,
|
||||||
|
$extracted_description
|
||||||
) {
|
) {
|
||||||
$tag = new ReturnTag('return', $content);
|
$tag = new ReturnTag('return', $content);
|
||||||
|
|
||||||
$this->assertEquals($extracted_type, $tag->getTypes());
|
$this->assertEquals($extracted_type, $tag->getTypes());
|
||||||
$this->assertEquals($extracted_description, $tag->getDescription());
|
$this->assertEquals($extracted_description, $tag->getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -38,7 +38,12 @@ class SeeTagTest extends \PHPUnit_Framework_TestCase
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testConstructorParesInputsIntoCorrectFields(
|
public function testConstructorParesInputsIntoCorrectFields(
|
||||||
$type, $content, $exName, $exContent, $exDescription, $exReference
|
$type,
|
||||||
|
$content,
|
||||||
|
$exName,
|
||||||
|
$exContent,
|
||||||
|
$exDescription,
|
||||||
|
$exReference
|
||||||
) {
|
) {
|
||||||
$tag = new SeeTag($type, $content);
|
$tag = new SeeTag($type, $content);
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,12 @@ class UsesTagTest extends \PHPUnit_Framework_TestCase
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testConstructorParesInputsIntoCorrectFields(
|
public function testConstructorParesInputsIntoCorrectFields(
|
||||||
$type, $content, $exName, $exContent, $exDescription, $exReference
|
$type,
|
||||||
|
$content,
|
||||||
|
$exName,
|
||||||
|
$exContent,
|
||||||
|
$exDescription,
|
||||||
|
$exReference
|
||||||
) {
|
) {
|
||||||
$tag = new UsesTag($type, $content);
|
$tag = new UsesTag($type, $content);
|
||||||
|
|
||||||
|
|||||||
@@ -38,13 +38,17 @@ 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($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());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -223,6 +223,4 @@ class CollectionTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
return $this->provideTypesToExpand($method, '\\');
|
return $this->provideTypesToExpand($method, '\\');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ class DocBlockTest extends \PHPUnit_Framework_TestCase
|
|||||||
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.',
|
'This is a long description.',
|
||||||
@@ -57,11 +58,13 @@ 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()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,17 +106,21 @@ DOCBLOCK;
|
|||||||
public function testExpandTypeUsingNamespaceAlias()
|
public function testExpandTypeUsingNamespaceAlias()
|
||||||
{
|
{
|
||||||
$docblock = new DocBlock(
|
$docblock = new DocBlock(
|
||||||
'', '\My\Namespace', array('Alias' => '\My\Namespace\Alias')
|
'',
|
||||||
|
'\My\Namespace',
|
||||||
|
array('Alias' => '\My\Namespace\Alias')
|
||||||
);
|
);
|
||||||
|
|
||||||
// first try a normal resolution without alias
|
// first try a normal resolution without alias
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'\My\Namespace\Al', $docblock->expandType('Al')
|
'\My\Namespace\Al',
|
||||||
|
$docblock->expandType('Al')
|
||||||
);
|
);
|
||||||
|
|
||||||
// try to use the alias
|
// try to use the alias
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'\My\Namespace\Alias\Al', $docblock->expandType('Alias\Al')
|
'\My\Namespace\Alias\Al',
|
||||||
|
$docblock->expandType('Alias\Al')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,4 +152,3 @@ DOCBLOCK;
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user