mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 01:57:13 +00:00
[cs] add and apply psr2
This commit is contained in:
committed by
Jaap van Otterdijk
parent
0294ce9b70
commit
a872e515bb
@@ -1,5 +1,6 @@
|
||||
includes:
|
||||
- temp/ecs/config/clean-code.neon
|
||||
- temp/ecs/config/psr2-checkers.neon
|
||||
|
||||
parameters:
|
||||
skip:
|
||||
|
||||
+1
-2
@@ -55,8 +55,7 @@ final class DocBlock
|
||||
Location $location = null,
|
||||
$isTemplateStart = false,
|
||||
$isTemplateEnd = false
|
||||
)
|
||||
{
|
||||
) {
|
||||
Assert::string($summary);
|
||||
Assert::boolean($isTemplateStart);
|
||||
Assert::boolean($isTemplateEnd);
|
||||
|
||||
@@ -98,6 +98,7 @@ class Description
|
||||
foreach ($this->tags as $tag) {
|
||||
$tags[] = '{' . $formatter->format($tag) . '}';
|
||||
}
|
||||
|
||||
return vsprintf($this->bodyTemplate, $tags);
|
||||
}
|
||||
|
||||
|
||||
@@ -188,5 +188,4 @@ class DescriptionFactory
|
||||
|
||||
return implode("\n", $lines);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -121,6 +121,7 @@ class Serializer
|
||||
$text = wordwrap($text, $wrapLength);
|
||||
return $text;
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
@@ -138,6 +139,7 @@ class Serializer
|
||||
if ($wrapLength !== null) {
|
||||
$tagText = wordwrap($tagText, $wrapLength);
|
||||
}
|
||||
|
||||
$tagText = str_replace("\n", "\n{$indent} * ", $tagText);
|
||||
|
||||
$comment .= "{$indent} * {$tagText}\n";
|
||||
|
||||
@@ -196,8 +196,7 @@ final class StandardTagFactory implements TagFactory
|
||||
$arguments = $this->getArgumentsForParametersFromWiring(
|
||||
$this->fetchParametersForHandlerFactoryMethod($handlerClassName),
|
||||
$this->getServiceLocatorWithDynamicParameters($context, $name, $body)
|
||||
)
|
||||
;
|
||||
);
|
||||
|
||||
return call_user_func_array([$handlerClassName, 'create'], $arguments);
|
||||
}
|
||||
|
||||
@@ -49,8 +49,7 @@ final class Covers extends BaseTag implements Factory\StaticMethod
|
||||
DescriptionFactory $descriptionFactory = null,
|
||||
FqsenResolver $resolver = null,
|
||||
TypeContext $context = null
|
||||
)
|
||||
{
|
||||
) {
|
||||
Assert::string($body);
|
||||
Assert::notEmpty($body);
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
||||
|
||||
if (is_string($arguments) && strlen($arguments) > 0) {
|
||||
$arguments = explode(',', $arguments);
|
||||
foreach($arguments as &$argument) {
|
||||
foreach ($arguments as &$argument) {
|
||||
$argument = explode(' ', self::stripRestArg(trim($argument)), 2);
|
||||
if ($argument[0][0] === '$') {
|
||||
$argumentName = substr($argument[0], 1);
|
||||
@@ -214,9 +214,11 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
||||
if (is_string($argument)) {
|
||||
$argument = [ 'name' => $argument ];
|
||||
}
|
||||
|
||||
if (! isset($argument['type'])) {
|
||||
$argument['type'] = new Void_();
|
||||
}
|
||||
|
||||
$keys = array_keys($argument);
|
||||
sort($keys);
|
||||
if ($keys !== [ 'name', 'type' ]) {
|
||||
|
||||
@@ -43,8 +43,7 @@ final class Return_ extends BaseTag implements Factory\StaticMethod
|
||||
TypeResolver $typeResolver = null,
|
||||
DescriptionFactory $descriptionFactory = null,
|
||||
TypeContext $context = null
|
||||
)
|
||||
{
|
||||
) {
|
||||
Assert::string($body);
|
||||
Assert::allNotNull([$typeResolver, $descriptionFactory]);
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@ final class Source extends BaseTag implements Factory\StaticMethod
|
||||
if (isset($matches[2]) && $matches[2] !== '') {
|
||||
$lineCount = (int)$matches[2];
|
||||
}
|
||||
|
||||
$description = $matches[3];
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
|
||||
return new DocBlock(
|
||||
$summary,
|
||||
$description ? $this->descriptionFactory->create($description, $context) : null,
|
||||
array_filter($this->parseTagBlock($tags, $context), function($tag) {
|
||||
array_filter($this->parseTagBlock($tags, $context), function ($tag) {
|
||||
return $tag instanceof Tag;
|
||||
}),
|
||||
$context,
|
||||
|
||||
@@ -78,7 +78,8 @@ DESCRIPTION;
|
||||
*/
|
||||
|
||||
include(__DIR__ . '/../../examples/playing-with-descriptions/02-escaping.php');
|
||||
$this->assertSame(<<<'DESCRIPTION'
|
||||
$this->assertSame(
|
||||
<<<'DESCRIPTION'
|
||||
You can escape the @-sign by surrounding it with braces, for example: @. And escape a closing brace within an
|
||||
inline tag by adding an opening brace in front of it like this: }.
|
||||
|
||||
@@ -91,7 +92,6 @@ Do note that an {@internal inline tag that has an opening brace ({) does not bre
|
||||
DESCRIPTION
|
||||
,
|
||||
$foundDescription
|
||||
)
|
||||
;
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
|
||||
namespace phpDocumentor\Reflection;
|
||||
|
||||
|
||||
/**
|
||||
* @coversNothing
|
||||
*/
|
||||
|
||||
@@ -73,8 +73,7 @@ class DescriptionFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
$tagFactory->shouldReceive('create')
|
||||
->once()
|
||||
->with('@link http://phpdoc.org/ description', $context)
|
||||
->andReturn(new Link('http://phpdoc.org/', new Description('description')))
|
||||
;
|
||||
->andReturn(new Link('http://phpdoc.org/', new Description('description')));
|
||||
|
||||
$factory = new DescriptionFactory($tagFactory);
|
||||
$description = $factory->create($contents, $context);
|
||||
@@ -99,8 +98,7 @@ class DescriptionFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
$tagFactory->shouldReceive('create')
|
||||
->once()
|
||||
->with('@link http://phpdoc.org/ This', $context)
|
||||
->andReturn(new Link('http://phpdoc.org/', new Description('This')))
|
||||
;
|
||||
->andReturn(new Link('http://phpdoc.org/', new Description('This')));
|
||||
|
||||
$factory = new DescriptionFactory($tagFactory);
|
||||
$description = $factory->create($contents, $context);
|
||||
|
||||
@@ -50,8 +50,7 @@ class StandardTagFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
->shouldReceive('create')
|
||||
->once()
|
||||
->with($expectedDescriptionText, $context)
|
||||
->andReturn($expectedDescription)
|
||||
;
|
||||
->andReturn($expectedDescription);
|
||||
|
||||
$tagFactory = new StandardTagFactory(m::mock(FqsenResolver::class));
|
||||
$tagFactory->addService($descriptionFactory, DescriptionFactory::class);
|
||||
@@ -99,8 +98,7 @@ class StandardTagFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
->shouldReceive('resolve')
|
||||
->with('Tag', m::type(Context::class))
|
||||
->andReturn(new Fqsen($fqsen))
|
||||
->getMock()
|
||||
;
|
||||
->getMock();
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
$descriptionFactory->shouldIgnoreMissing();
|
||||
|
||||
@@ -161,8 +159,7 @@ class StandardTagFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
[FqsenResolver::class => $resolver, 'myParam' => 'myValue'],
|
||||
'serviceLocator',
|
||||
$tagFactory
|
||||
)
|
||||
;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -181,8 +178,7 @@ class StandardTagFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
[FqsenResolver::class => $resolver, PassthroughFormatter::class => $service],
|
||||
'serviceLocator',
|
||||
$tagFactory
|
||||
)
|
||||
;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -202,8 +198,7 @@ class StandardTagFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
[FqsenResolver::class => $resolver, $interfaceName => $service],
|
||||
'serviceLocator',
|
||||
$tagFactory
|
||||
)
|
||||
;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -340,8 +335,7 @@ class StandardTagFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
->shouldReceive('create')
|
||||
->once()
|
||||
->with('', $context)
|
||||
->andReturn(new Description(''))
|
||||
;
|
||||
->andReturn(new Description(''));
|
||||
|
||||
$typeResolver = new TypeResolver();
|
||||
|
||||
|
||||
@@ -342,7 +342,8 @@ class MethodTest extends \PHPUnit_Framework_TestCase
|
||||
$expectedType,
|
||||
$expectedValueType = null,
|
||||
$expectedKeyType = null
|
||||
) { $resolver = new TypeResolver();
|
||||
) {
|
||||
$resolver = new TypeResolver();
|
||||
$descriptionFactory = m::mock(DescriptionFactory::class);
|
||||
$descriptionFactory->shouldReceive('create')->with('', null)->andReturn(new Description(''));
|
||||
|
||||
@@ -540,7 +541,8 @@ class MethodTest extends \PHPUnit_Framework_TestCase
|
||||
new Compound([
|
||||
new Array_(new Object_(new Fqsen('\MyClass'))),
|
||||
new Array_(new Integer()),
|
||||
])
|
||||
, $fixture->getReturnType());
|
||||
]),
|
||||
$fixture->getReturnType()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,8 +140,12 @@ class PropertyReadTest extends \PHPUnit_Framework_TestCase
|
||||
$description = new Description('My Description');
|
||||
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
|
||||
|
||||
$fixture = PropertyRead::create('string $myProperty My Description', $typeResolver, $descriptionFactory,
|
||||
$context);
|
||||
$fixture = PropertyRead::create(
|
||||
'string $myProperty My Description',
|
||||
$typeResolver,
|
||||
$descriptionFactory,
|
||||
$context
|
||||
);
|
||||
|
||||
$this->assertSame('string $myProperty My Description', (string)$fixture);
|
||||
$this->assertSame('myProperty', $fixture->getVariableName());
|
||||
|
||||
@@ -140,8 +140,12 @@ class PropertyWriteTest extends \PHPUnit_Framework_TestCase
|
||||
$description = new Description('My Description');
|
||||
$descriptionFactory->shouldReceive('create')->with('My Description', $context)->andReturn($description);
|
||||
|
||||
$fixture = PropertyWrite::create('string $myProperty My Description', $typeResolver, $descriptionFactory,
|
||||
$context);
|
||||
$fixture = PropertyWrite::create(
|
||||
'string $myProperty My Description',
|
||||
$typeResolver,
|
||||
$descriptionFactory,
|
||||
$context
|
||||
);
|
||||
|
||||
$this->assertSame('string $myProperty My Description', (string)$fixture);
|
||||
$this->assertSame('myProperty', $fixture->getVariableName());
|
||||
|
||||
@@ -125,8 +125,7 @@ class UsesTest extends \PHPUnit_Framework_TestCase
|
||||
$description = new Description('My Description');
|
||||
|
||||
$descriptionFactory
|
||||
->shouldReceive('create')->with('My Description', $context)->andReturn($description)
|
||||
;
|
||||
->shouldReceive('create')->with('My Description', $context)->andReturn($description);
|
||||
$resolver->shouldReceive('resolve')->with('DateTime', $context)->andReturn($fqsen);
|
||||
|
||||
$fixture = Uses::create('DateTime My Description', $resolver, $descriptionFactory, $context);
|
||||
|
||||
Reference in New Issue
Block a user