mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 01:57:13 +00:00
apply coding standard to code
This commit is contained in:
@@ -156,7 +156,7 @@ class DescriptionFactory
|
|||||||
|
|
||||||
// determine how many whitespace characters need to be stripped
|
// determine how many whitespace characters need to be stripped
|
||||||
$startingSpaceCount = 9999999;
|
$startingSpaceCount = 9999999;
|
||||||
for ($i = 1; $i < count($lines); $i++) {
|
for ($i = 1; $i < count($lines); ++$i) {
|
||||||
// lines with a no length do not count as they are not indented at all
|
// lines with a no length do not count as they are not indented at all
|
||||||
if (strlen(trim($lines[$i])) === 0) {
|
if (strlen(trim($lines[$i])) === 0) {
|
||||||
continue;
|
continue;
|
||||||
@@ -169,7 +169,7 @@ class DescriptionFactory
|
|||||||
|
|
||||||
// strip the number of spaces from each line
|
// strip the number of spaces from each line
|
||||||
if ($startingSpaceCount > 0) {
|
if ($startingSpaceCount > 0) {
|
||||||
for ($i = 1; $i < count($lines); $i++) {
|
for ($i = 1; $i < count($lines); ++$i) {
|
||||||
$lines[$i] = substr($lines[$i], $startingSpaceCount);
|
$lines[$i] = substr($lines[$i], $startingSpaceCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ final class StandardTagFactory implements TagFactory
|
|||||||
'throws' => '\phpDocumentor\Reflection\DocBlock\Tags\Throws',
|
'throws' => '\phpDocumentor\Reflection\DocBlock\Tags\Throws',
|
||||||
'uses' => '\phpDocumentor\Reflection\DocBlock\Tags\Uses',
|
'uses' => '\phpDocumentor\Reflection\DocBlock\Tags\Uses',
|
||||||
'var' => '\phpDocumentor\Reflection\DocBlock\Tags\Var_',
|
'var' => '\phpDocumentor\Reflection\DocBlock\Tags\Var_',
|
||||||
'version' => '\phpDocumentor\Reflection\DocBlock\Tags\Version'
|
'version' => '\phpDocumentor\Reflection\DocBlock\Tags\Version',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -278,7 +278,7 @@ final class StandardTagFactory implements TagFactory
|
|||||||
[
|
[
|
||||||
'name' => $tagName,
|
'name' => $tagName,
|
||||||
'body' => $tagBody,
|
'body' => $tagBody,
|
||||||
TypeContext::class => $context
|
TypeContext::class => $context,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ final class Link extends BaseTag implements Factory\StaticMethod
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public static function create(string $body, ?DescriptionFactory $descriptionFactory = null, ?TypeContext $context = null): Link
|
public static function create(string $body, ?DescriptionFactory $descriptionFactory = null, ?TypeContext $context = null): self
|
||||||
{
|
{
|
||||||
Assert::notNull($descriptionFactory);
|
Assert::notNull($descriptionFactory);
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
|
|||||||
*
|
*
|
||||||
* @param string[] $additionalTags
|
* @param string[] $additionalTags
|
||||||
*/
|
*/
|
||||||
public static function createInstance(array $additionalTags = []): DocBlockFactory
|
public static function createInstance(array $additionalTags = []): self
|
||||||
{
|
{
|
||||||
$fqsenResolver = new FqsenResolver();
|
$fqsenResolver = new FqsenResolver();
|
||||||
$tagFactory = new StandardTagFactory($fqsenResolver);
|
$tagFactory = new StandardTagFactory($fqsenResolver);
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ DOCCOMMENT;
|
|||||||
'This is a summary',
|
'This is a summary',
|
||||||
new Description('This is a description'),
|
new Description('This is a description'),
|
||||||
[
|
[
|
||||||
new DocBlock\Tags\Generic('unknown-tag', new Description('Test description for the unknown tag'))
|
new DocBlock\Tags\Generic('unknown-tag', new Description('Test description for the unknown tag')),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ DOCCOMMENT;
|
|||||||
'This is a summary',
|
'This is a summary',
|
||||||
new Description('This is a description'),
|
new Description('This is a description'),
|
||||||
[
|
[
|
||||||
new DocBlock\Tags\Generic('unknown-tag', new Description('Test description for the unknown tag'))
|
new DocBlock\Tags\Generic('unknown-tag', new Description('Test description for the unknown tag')),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -126,7 +126,7 @@ DOCCOMMENT;
|
|||||||
'This is a summary',
|
'This is a summary',
|
||||||
new Description('This is a description'),
|
new Description('This is a description'),
|
||||||
[
|
[
|
||||||
new DocBlock\Tags\Generic('unknown-tag', new Description('Test description for the unknown tag'))
|
new DocBlock\Tags\Generic('unknown-tag', new Description('Test description for the unknown tag')),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -166,7 +166,7 @@ DOCCOMMENT;
|
|||||||
'This is a summary',
|
'This is a summary',
|
||||||
new Description('This is a description'),
|
new Description('This is a description'),
|
||||||
[
|
[
|
||||||
new DocBlock\Tags\Generic('unknown-tag', new Description('Test description for the unknown tag'))
|
new DocBlock\Tags\Generic('unknown-tag', new Description('Test description for the unknown tag')),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ use PHPUnit\Framework\TestCase;
|
|||||||
*/
|
*/
|
||||||
class StandardTagFactoryTest extends TestCase
|
class StandardTagFactoryTest extends TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call Mockery::close after each test.
|
* Call Mockery::close after each test.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ use PHPUnit\Framework\TestCase;
|
|||||||
*/
|
*/
|
||||||
class CoversTest extends TestCase
|
class CoversTest extends TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call Mockery::close after each test.
|
* Call Mockery::close after each test.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ use PHPUnit\Framework\TestCase;
|
|||||||
*/
|
*/
|
||||||
class ExampleTest extends TestCase
|
class ExampleTest extends TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call Mockery::close after each test.
|
* Call Mockery::close after each test.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -50,14 +50,14 @@ class AlignFormatterTest extends TestCase
|
|||||||
$tags = [
|
$tags = [
|
||||||
new Param('foobar', new String_()),
|
new Param('foobar', new String_()),
|
||||||
new Version('1.2.0'),
|
new Version('1.2.0'),
|
||||||
new Link('http://www.example.com', new Description('Examples'))
|
new Link('http://www.example.com', new Description('Examples')),
|
||||||
];
|
];
|
||||||
$fixture = new AlignFormatter($tags);
|
$fixture = new AlignFormatter($tags);
|
||||||
|
|
||||||
$expected = [
|
$expected = [
|
||||||
'@param string $foobar',
|
'@param string $foobar',
|
||||||
'@version 1.2.0',
|
'@version 1.2.0',
|
||||||
'@link http://www.example.com Examples'
|
'@link http://www.example.com Examples',
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($tags as $key => $tag) {
|
foreach ($tags as $key => $tag) {
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ class GenericTest extends TestCase
|
|||||||
{
|
{
|
||||||
m::close();
|
m::close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Generic::__construct
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Generic::__construct
|
||||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ class MethodTest extends TestCase
|
|||||||
{
|
{
|
||||||
$arguments = [
|
$arguments = [
|
||||||
['name' => 'argument1', 'type' => new String_()],
|
['name' => 'argument1', 'type' => new String_()],
|
||||||
['name' => 'argument2', 'type' => new Object_()]
|
['name' => 'argument2', 'type' => new Object_()],
|
||||||
];
|
];
|
||||||
$fixture = new Method('myMethod', $arguments, new Void_(), true, new Description('My Description'));
|
$fixture = new Method('myMethod', $arguments, new Void_(), true, new Description('My Description'));
|
||||||
|
|
||||||
@@ -111,7 +111,7 @@ class MethodTest extends TestCase
|
|||||||
public function testHasArguments(): void
|
public function testHasArguments(): void
|
||||||
{
|
{
|
||||||
$arguments = [
|
$arguments = [
|
||||||
[ 'name' => 'argument1', 'type' => new String_() ]
|
['name' => 'argument1', 'type' => new String_()],
|
||||||
];
|
];
|
||||||
|
|
||||||
$fixture = new Method('myMethod', $arguments);
|
$fixture = new Method('myMethod', $arguments);
|
||||||
@@ -127,7 +127,7 @@ class MethodTest extends TestCase
|
|||||||
{
|
{
|
||||||
$arguments = ['argument1'];
|
$arguments = ['argument1'];
|
||||||
$expected = [
|
$expected = [
|
||||||
[ 'name' => $arguments[0], 'type' => new Void_() ]
|
['name' => $arguments[0], 'type' => new Void_()],
|
||||||
];
|
];
|
||||||
|
|
||||||
$fixture = new Method('myMethod', $arguments);
|
$fixture = new Method('myMethod', $arguments);
|
||||||
@@ -143,7 +143,7 @@ class MethodTest extends TestCase
|
|||||||
{
|
{
|
||||||
$arguments = [['name' => 'argument1']];
|
$arguments = [['name' => 'argument1']];
|
||||||
$expected = [
|
$expected = [
|
||||||
[ 'name' => $arguments[0]['name'], 'type' => new Void_() ]
|
['name' => $arguments[0]['name'], 'type' => new Void_()],
|
||||||
];
|
];
|
||||||
|
|
||||||
$fixture = new Method('myMethod', $arguments);
|
$fixture = new Method('myMethod', $arguments);
|
||||||
@@ -244,7 +244,7 @@ class MethodTest extends TestCase
|
|||||||
{
|
{
|
||||||
$arguments = [
|
$arguments = [
|
||||||
['name' => 'argument1', 'type' => new String_()],
|
['name' => 'argument1', 'type' => new String_()],
|
||||||
['name' => 'argument2', 'type' => new Object_()]
|
['name' => 'argument2', 'type' => new Object_()],
|
||||||
];
|
];
|
||||||
$fixture = new Method('myMethod', $arguments, new Void_(), true, new Description('My Description'));
|
$fixture = new Method('myMethod', $arguments, new Void_(), true, new Description('My Description'));
|
||||||
|
|
||||||
@@ -272,7 +272,7 @@ class MethodTest extends TestCase
|
|||||||
$description = new Description('My Description');
|
$description = new Description('My Description');
|
||||||
$expectedArguments = [
|
$expectedArguments = [
|
||||||
['name' => 'argument1', 'type' => new String_()],
|
['name' => 'argument1', 'type' => new String_()],
|
||||||
[ 'name' => 'argument2', 'type' => new Void_() ]
|
['name' => 'argument2', 'type' => new Void_()],
|
||||||
];
|
];
|
||||||
|
|
||||||
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
|
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
|
||||||
@@ -334,15 +334,14 @@ class MethodTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* @dataProvider collectionReturnTypesProvider
|
* @dataProvider collectionReturnTypesProvider
|
||||||
* @covers ::create
|
* @covers ::create
|
||||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Method::<public>
|
* @uses phpDocumentor\Reflection\DocBlock\Tags\Method::<public>
|
||||||
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
* @uses phpDocumentor\Reflection\DocBlock\Description
|
||||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
* @uses phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||||
* @uses \phpDocumentor\Reflection\TypeResolver
|
* @uses phpDocumentor\Reflection\TypeResolver
|
||||||
* @uses \phpDocumentor\Reflection\Types\Array_
|
* @uses phpDocumentor\Reflection\Types\Array_
|
||||||
* @uses \phpDocumentor\Reflection\Types\Compound
|
* @uses phpDocumentor\Reflection\Types\Compound
|
||||||
* @uses \phpDocumentor\Reflection\Types\Integer
|
* @uses phpDocumentor\Reflection\Types\Integer
|
||||||
* @uses \phpDocumentor\Reflection\Types\Object_
|
* @uses phpDocumentor\Reflection\Types\Object_
|
||||||
* @param string null $expectedKeyType
|
|
||||||
*/
|
*/
|
||||||
public function testCollectionReturnTypes(
|
public function testCollectionReturnTypes(
|
||||||
string $returnType,
|
string $returnType,
|
||||||
@@ -354,7 +353,7 @@ class MethodTest extends TestCase
|
|||||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||||
$descriptionFactory->shouldReceive('create')->with('', null)->andReturn(new Description(''));
|
$descriptionFactory->shouldReceive('create')->with('', null)->andReturn(new Description(''));
|
||||||
|
|
||||||
$fixture = Method::create("$returnType myMethod(\$arg)", $resolver, $descriptionFactory);
|
$fixture = Method::create("${returnType} myMethod(\$arg)", $resolver, $descriptionFactory);
|
||||||
$returnType = $fixture->getReturnType();
|
$returnType = $fixture->getReturnType();
|
||||||
$this->assertInstanceOf($expectedType, $returnType);
|
$this->assertInstanceOf($expectedType, $returnType);
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ use PHPUnit\Framework\TestCase;
|
|||||||
*/
|
*/
|
||||||
class SinceTest extends TestCase
|
class SinceTest extends TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call Mockery::close after each test.
|
* Call Mockery::close after each test.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ DOCBLOCK;
|
|||||||
[
|
[
|
||||||
'This is a DocBlock. This should still be summary.',
|
'This is a DocBlock. This should still be summary.',
|
||||||
'This is a DocBlock. This should still be summary.',
|
'This is a DocBlock. This should still be summary.',
|
||||||
''
|
'',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
<<<DOCBLOCK
|
<<<DOCBLOCK
|
||||||
@@ -211,7 +211,7 @@ This should be a Description.
|
|||||||
DOCBLOCK
|
DOCBLOCK
|
||||||
,
|
,
|
||||||
'This is a DocBlock.',
|
'This is a DocBlock.',
|
||||||
'This should be a Description.'
|
'This should be a Description.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
<<<DOCBLOCK
|
<<<DOCBLOCK
|
||||||
@@ -221,7 +221,7 @@ This should be a Description.
|
|||||||
DOCBLOCK
|
DOCBLOCK
|
||||||
,
|
,
|
||||||
"This is a\nmultiline Summary.",
|
"This is a\nmultiline Summary.",
|
||||||
'This should be a Description.'
|
'This should be a Description.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
<<<DOCBLOCK
|
<<<DOCBLOCK
|
||||||
@@ -231,7 +231,7 @@ This should be a Description.
|
|||||||
DOCBLOCK
|
DOCBLOCK
|
||||||
,
|
,
|
||||||
'This is a Summary without dot but with a whiteline',
|
'This is a Summary without dot but with a whiteline',
|
||||||
'This should be a Description.'
|
'This should be a Description.',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
<<<DOCBLOCK
|
<<<DOCBLOCK
|
||||||
@@ -241,7 +241,7 @@ This should be a Description.
|
|||||||
DOCBLOCK
|
DOCBLOCK
|
||||||
,
|
,
|
||||||
'This is a Summary with dot and with a whiteline.',
|
'This is a Summary with dot and with a whiteline.',
|
||||||
'This should be a Description.'
|
'This should be a Description.',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ class DocBlockTest extends TestCase
|
|||||||
public function testDocBlockCanHaveTags(): void
|
public function testDocBlockCanHaveTags(): void
|
||||||
{
|
{
|
||||||
$tags = [
|
$tags = [
|
||||||
m::mock(DocBlock\Tag::class)
|
m::mock(DocBlock\Tag::class),
|
||||||
];
|
];
|
||||||
|
|
||||||
$fixture = new DocBlock('', null, $tags);
|
$fixture = new DocBlock('', null, $tags);
|
||||||
@@ -91,7 +91,7 @@ class DocBlockTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->expectException('InvalidArgumentException');
|
$this->expectException('InvalidArgumentException');
|
||||||
$tags = [
|
$tags = [
|
||||||
null
|
null,
|
||||||
];
|
];
|
||||||
$fixture = new DocBlock('', null, $tags);
|
$fixture = new DocBlock('', null, $tags);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user