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.
|
||||
*/
|
||||
public function __construct(
|
||||
$docblock, $namespace = '\\', $namespace_aliases = array()
|
||||
$docblock,
|
||||
$namespace = '\\',
|
||||
$namespace_aliases = array()
|
||||
) {
|
||||
if (is_object($docblock)) {
|
||||
if (!method_exists($docblock, 'getDocComment')) {
|
||||
@@ -99,7 +101,9 @@ class DocBlock implements \Reflector
|
||||
{
|
||||
$comment = trim(
|
||||
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
|
||||
/u', $comment, $matches
|
||||
/u',
|
||||
$comment,
|
||||
$matches
|
||||
);
|
||||
array_shift($matches);
|
||||
}
|
||||
@@ -382,7 +388,7 @@ class DocBlock implements \Reflector
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
static public function export()
|
||||
public static function export()
|
||||
{
|
||||
throw new \Exception('Not yet implemented');
|
||||
}
|
||||
|
||||
@@ -61,8 +61,10 @@ class LongDescription implements \Reflector
|
||||
{
|
||||
if (null === $this->parsedContents) {
|
||||
$this->parsedContents = preg_split(
|
||||
'/\{(\@.*?)\}/uS', $this->contents,
|
||||
null, PREG_SPLIT_DELIM_CAPTURE
|
||||
'/\{(\@.*?)\}/uS',
|
||||
$this->contents,
|
||||
null,
|
||||
PREG_SPLIT_DELIM_CAPTURE
|
||||
);
|
||||
for ($i=1, $l = count($this->parsedContents); $i<$l; $i += 2) {
|
||||
$this->parsedContents[$i] = Tag::createInstance(
|
||||
@@ -111,7 +113,7 @@ class LongDescription implements \Reflector
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
static public function export()
|
||||
public static function export()
|
||||
{
|
||||
throw new \Exception('Not yet implemented');
|
||||
}
|
||||
@@ -126,4 +128,4 @@ class LongDescription implements \Reflector
|
||||
{
|
||||
return 'Not yet implemented';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class Tag implements \Reflector
|
||||
|
||||
/** @var string Description of the content of this tag */
|
||||
protected $description = '';
|
||||
|
||||
|
||||
/** @var array The description, as an array of strings and Tag objects. */
|
||||
protected $parsedDescription = null;
|
||||
|
||||
@@ -51,7 +51,9 @@ class Tag implements \Reflector
|
||||
public static function createInstance($tag_line)
|
||||
{
|
||||
if (!preg_match(
|
||||
'/^@([\w\-\_\\\\]+)(?:\s*([^\s].*)|$)?/us', $tag_line, $matches
|
||||
'/^@([\w\-\_\\\\]+)(?:\s*([^\s].*)|$)?/us',
|
||||
$tag_line,
|
||||
$matches
|
||||
)) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Invalid tag_line detected: ' . $tag_line
|
||||
@@ -60,7 +62,9 @@ class Tag implements \Reflector
|
||||
|
||||
// support hypphen separated tag names
|
||||
$tag_name = str_replace(
|
||||
' ', '', ucwords(str_replace('-', ' ', $matches[1]))
|
||||
' ',
|
||||
'',
|
||||
ucwords(str_replace('-', ' ', $matches[1]))
|
||||
).'Tag';
|
||||
$class_name = 'phpDocumentor\\Reflection\\DocBlock\\Tag\\' . $tag_name;
|
||||
|
||||
@@ -111,7 +115,7 @@ class Tag implements \Reflector
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the parsed text of this description.
|
||||
*
|
||||
@@ -170,7 +174,7 @@ class Tag implements \Reflector
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
static public function export()
|
||||
public static function export()
|
||||
{
|
||||
throw new \Exception('Not yet implemented');
|
||||
}
|
||||
@@ -185,5 +189,4 @@ class Tag implements \Reflector
|
||||
{
|
||||
return 'Not yet implemented';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,10 +25,10 @@ class AuthorTag extends Tag
|
||||
{
|
||||
/** @var string The name of the author */
|
||||
protected $name = '';
|
||||
|
||||
|
||||
/** @var string The email of the author */
|
||||
protected $email = '';
|
||||
|
||||
|
||||
/**
|
||||
* Parses a tag and populates the member variables.
|
||||
*
|
||||
@@ -45,7 +45,7 @@ class AuthorTag extends Tag
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the author's name.
|
||||
*
|
||||
@@ -55,7 +55,7 @@ class AuthorTag extends Tag
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the author's email.
|
||||
*
|
||||
|
||||
@@ -21,5 +21,4 @@ namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
*/
|
||||
class CoversTag extends SeeTag
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||
|
||||
/**
|
||||
|
||||
@@ -125,5 +125,4 @@ class MethodTag extends ParamTag
|
||||
|
||||
return $arguments;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,5 +21,4 @@ namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
*/
|
||||
class PropertyReadTag extends PropertyTag
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -21,5 +21,4 @@ namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
*/
|
||||
class PropertyTag extends ParamTag
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -21,5 +21,4 @@ namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
*/
|
||||
class PropertyWriteTag extends PropertyTag
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -42,5 +42,4 @@ class ReturnTag extends ParamTag
|
||||
|
||||
$this->description = implode(' ', $content);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||
|
||||
/**
|
||||
@@ -52,5 +53,4 @@ class SeeTag extends Tag
|
||||
{
|
||||
return $this->refers;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -40,4 +40,4 @@ class ThrowTag extends ThrowsTag
|
||||
|
||||
parent::__construct('throws', $content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,5 +21,4 @@ namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
*/
|
||||
class ThrowsTag extends ReturnTag
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,5 +21,4 @@ namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
*/
|
||||
class UsesTag extends SeeTag
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -68,7 +68,8 @@ class Collection extends \ArrayObject
|
||||
* pairs that are used in the resolving process.
|
||||
*/
|
||||
public function __construct(
|
||||
array $types = array(), $namespace = null,
|
||||
array $types = array(),
|
||||
$namespace = null,
|
||||
array $namespace_aliases = array()
|
||||
) {
|
||||
// only set the namespace if overridden
|
||||
@@ -264,4 +265,4 @@ class Collection extends \ArrayObject
|
||||
return ($type[0] !== self::OPERATOR_NAMESPACE)
|
||||
|| $this->isTypeAKeyword($type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,12 @@ class CoversTagTest extends \PHPUnit_Framework_TestCase
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructorParesInputsIntoCorrectFields(
|
||||
$type, $content, $exName, $exContent, $exDescription, $exReference
|
||||
$type,
|
||||
$content,
|
||||
$exName,
|
||||
$exContent,
|
||||
$exDescription,
|
||||
$exReference
|
||||
) {
|
||||
$tag = new CoversTag($type, $content);
|
||||
|
||||
|
||||
@@ -39,7 +39,12 @@ class LinkTagTest extends \PHPUnit_Framework_TestCase
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructorParesInputsIntoCorrectFields(
|
||||
$type, $content, $exName, $exContent, $exDescription, $exLink
|
||||
$type,
|
||||
$content,
|
||||
$exName,
|
||||
$exContent,
|
||||
$exDescription,
|
||||
$exLink
|
||||
) {
|
||||
$tag = new LinkTag($type, $content);
|
||||
|
||||
@@ -89,4 +94,4 @@ class LinkTagTest extends \PHPUnit_Framework_TestCase
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,15 +38,21 @@ class MethodTagTest extends \PHPUnit_Framework_TestCase
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstruct($signature, $valid, $expected_name,
|
||||
$expected_return, $has_params, $description
|
||||
public function testConstruct(
|
||||
$signature,
|
||||
$valid,
|
||||
$expected_name,
|
||||
$expected_return,
|
||||
$has_params,
|
||||
$description
|
||||
) {
|
||||
ob_start();
|
||||
$tag = new MethodTag('method', $signature);
|
||||
$stdout = ob_get_clean();
|
||||
|
||||
$this->assertSame(
|
||||
$valid, empty($stdout),
|
||||
$valid,
|
||||
empty($stdout),
|
||||
'No error should have been output if the signature is valid'
|
||||
);
|
||||
|
||||
@@ -54,11 +60,12 @@ class MethodTagTest extends \PHPUnit_Framework_TestCase
|
||||
return;
|
||||
}
|
||||
|
||||
$this->assertEquals($expected_name, $tag->getMethodName());
|
||||
$this->assertEquals($expected_name, $tag->getMethodName());
|
||||
$this->assertEquals($expected_return, $tag->getType());
|
||||
$this->assertEquals($description, $tag->getDescription());
|
||||
$this->assertEquals($description, $tag->getDescription());
|
||||
$this->assertSame(
|
||||
$has_params, (bool)(count($tag->getArguments()) > 0),
|
||||
$has_params,
|
||||
(bool)(count($tag->getArguments()) > 0),
|
||||
'Number of found arguments should exceed 0'
|
||||
);
|
||||
}
|
||||
@@ -120,4 +127,4 @@ class MethodTagTest extends \PHPUnit_Framework_TestCase
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,14 +39,17 @@ class ParamTagTest extends \PHPUnit_Framework_TestCase
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructorParsesInputsIntoCorrectFields(
|
||||
$type, $content, $extracted_type, $extracted_variable_name,
|
||||
$type,
|
||||
$content,
|
||||
$extracted_type,
|
||||
$extracted_variable_name,
|
||||
$extracted_description
|
||||
) {
|
||||
$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_description, $tag->getDescription());
|
||||
$this->assertEquals($extracted_description, $tag->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -37,12 +37,14 @@ class ReturnTagTest extends ParamTagTest
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructorParsesInputsIntoCorrectFields(
|
||||
$content, $extracted_type, $extracted_description
|
||||
$content,
|
||||
$extracted_type,
|
||||
$extracted_description
|
||||
) {
|
||||
$tag = new ReturnTag('return', $content);
|
||||
|
||||
$this->assertEquals($extracted_type, $tag->getTypes());
|
||||
$this->assertEquals($extracted_description, $tag->getDescription());
|
||||
$this->assertEquals($extracted_type, $tag->getTypes());
|
||||
$this->assertEquals($extracted_description, $tag->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -38,7 +38,12 @@ class SeeTagTest extends \PHPUnit_Framework_TestCase
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructorParesInputsIntoCorrectFields(
|
||||
$type, $content, $exName, $exContent, $exDescription, $exReference
|
||||
$type,
|
||||
$content,
|
||||
$exName,
|
||||
$exContent,
|
||||
$exDescription,
|
||||
$exReference
|
||||
) {
|
||||
$tag = new SeeTag($type, $content);
|
||||
|
||||
|
||||
@@ -38,7 +38,12 @@ class UsesTagTest extends \PHPUnit_Framework_TestCase
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructorParesInputsIntoCorrectFields(
|
||||
$type, $content, $exName, $exContent, $exDescription, $exReference
|
||||
$type,
|
||||
$content,
|
||||
$exName,
|
||||
$exContent,
|
||||
$exDescription,
|
||||
$exReference
|
||||
) {
|
||||
$tag = new UsesTag($type, $content);
|
||||
|
||||
|
||||
@@ -38,13 +38,17 @@ class VarTagTest extends \PHPUnit_Framework_TestCase
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructorParesInputsIntoCorrectFields(
|
||||
$type, $content, $exType, $exVariable, $exDescription
|
||||
$type,
|
||||
$content,
|
||||
$exType,
|
||||
$exVariable,
|
||||
$exDescription
|
||||
) {
|
||||
$tag = new VarTag($type, $content);
|
||||
|
||||
$this->assertEquals($exType, $tag->getType());
|
||||
$this->assertEquals($exVariable, $tag->getVariableName());
|
||||
$this->assertEquals($exDescription, $tag->getDescription());
|
||||
$this->assertEquals($exVariable, $tag->getVariableName());
|
||||
$this->assertEquals($exDescription, $tag->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -223,6 +223,4 @@ class CollectionTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
return $this->provideTypesToExpand($method, '\\');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,8 @@ class DocBlockTest extends \PHPUnit_Framework_TestCase
|
||||
DOCBLOCK;
|
||||
$object = new DocBlock($fixture);
|
||||
$this->assertEquals(
|
||||
'This is a short description.', $object->getShortDescription()
|
||||
'This is a short description.',
|
||||
$object->getShortDescription()
|
||||
);
|
||||
$this->assertEquals(
|
||||
'This is a long description.',
|
||||
@@ -57,11 +58,13 @@ DOCBLOCK;
|
||||
DOCBLOCK;
|
||||
$object = new DocBlock($fixture);
|
||||
$this->assertEquals(
|
||||
'This is a short description.', $object->getShortDescription()
|
||||
'This is a short description.',
|
||||
$object->getShortDescription()
|
||||
);
|
||||
$this->assertEquals(
|
||||
"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()
|
||||
{
|
||||
$docblock = new DocBlock(
|
||||
'', '\My\Namespace', array('Alias' => '\My\Namespace\Alias')
|
||||
'',
|
||||
'\My\Namespace',
|
||||
array('Alias' => '\My\Namespace\Alias')
|
||||
);
|
||||
|
||||
// first try a normal resolution without alias
|
||||
$this->assertEquals(
|
||||
'\My\Namespace\Al', $docblock->expandType('Al')
|
||||
'\My\Namespace\Al',
|
||||
$docblock->expandType('Al')
|
||||
);
|
||||
|
||||
// try to use the alias
|
||||
$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