Made PSR2 related fixes that are compatible with the PEAR coding standard.

This commit is contained in:
Vasil Rangelov
2012-11-04 16:02:57 +02:00
parent 9ea3275389
commit bb189b87bd
27 changed files with 107 additions and 61 deletions
+10 -4
View File
@@ -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');
}
@@ -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;
@@ -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';
}
}
@@ -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;
}
}
@@ -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
@@ -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);
@@ -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'
);
@@ -58,7 +64,8 @@ class MethodTagTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($expected_return, $tag->getType());
$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'
);
}
@@ -39,7 +39,10 @@ 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);
@@ -37,7 +37,9 @@ class ReturnTagTest extends ParamTagTest
* @return void
*/
public function testConstructorParsesInputsIntoCorrectFields(
$content, $extracted_type, $extracted_description
$content,
$extracted_type,
$extracted_description
) {
$tag = new ReturnTag('return', $content);
@@ -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,7 +38,11 @@ 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);
@@ -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;
);
}
}