Apply new code style

This commit is contained in:
Jaapio
2019-09-20 10:54:12 +02:00
parent 8fcadfe5f8
commit aee984014b
71 changed files with 1661 additions and 1286 deletions
+60 -51
View File
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
@@ -6,8 +8,6 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright 2010-2018 Mike van Riel<[email protected]>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
@@ -21,30 +21,33 @@ use phpDocumentor\Reflection\DocBlock\TagFactory;
use phpDocumentor\Reflection\DocBlock\Tags\Param;
use phpDocumentor\Reflection\Types\Context;
use PHPUnit\Framework\TestCase;
use ReflectionClass;
/**
* @coversDefaultClass phpDocumentor\Reflection\DocBlockFactory
* @covers ::<private>
* @uses \Webmozart\Assert\Assert
* @uses phpDocumentor\Reflection\DocBlock
* @uses \phpDocumentor\Reflection\DocBlock
*
* @coversDefaultClass \phpDocumentor\Reflection\DocBlockFactory
* @covers ::<private>
*/
class DocBlockFactoryTest extends TestCase
{
/**
* Call Mockery::close after each test.
*/
public function tearDown(): void
public function tearDown() : void
{
m::close();
}
/**
* @covers ::__construct
* @covers ::createInstance
* @uses \phpDocumentor\Reflection\DocBlock\StandardTagFactory
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
*
* @covers ::__construct
* @covers ::createInstance
*/
public function testCreateFactoryUsingFactoryMethod(): void
public function testCreateFactoryUsingFactoryMethod() : void
{
$fixture = DocBlockFactory::createInstance();
@@ -52,16 +55,17 @@ class DocBlockFactoryTest extends TestCase
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Description
*
* @covers ::__construct
* @covers ::create
* @uses phpDocumentor\Reflection\DocBlock\Description
*/
public function testCreateDocBlockFromReflection(): void
public function testCreateDocBlockFromReflection() : void
{
$fixture = new DocBlockFactory(m::mock(DescriptionFactory::class), m::mock(TagFactory::class));
$docBlock = '/** This is a DocBlock */';
$classReflector = m::mock(\ReflectionClass::class);
$docBlock = '/** This is a DocBlock */';
$classReflector = m::mock(ReflectionClass::class);
$classReflector->shouldReceive('getDocComment')->andReturn($docBlock);
$docblock = $fixture->create($classReflector);
@@ -74,11 +78,12 @@ class DocBlockFactoryTest extends TestCase
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Description
*
* @covers ::__construct
* @covers ::create
* @uses phpDocumentor\Reflection\DocBlock\Description
*/
public function testCreateDocBlockFromStringWithDocComment(): void
public function testCreateDocBlockFromStringWithDocComment() : void
{
$fixture = new DocBlockFactory(m::mock(DescriptionFactory::class), m::mock(TagFactory::class));
@@ -93,11 +98,12 @@ class DocBlockFactoryTest extends TestCase
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\Description
*
* @covers ::create
* @covers ::__construct
* @uses phpDocumentor\Reflection\DocBlock\Description
*/
public function testCreateDocBlockFromStringWithoutDocComment(): void
public function testCreateDocBlockFromStringWithoutDocComment() : void
{
$fixture = new DocBlockFactory(m::mock(DescriptionFactory::class), m::mock(TagFactory::class));
@@ -112,16 +118,18 @@ class DocBlockFactoryTest extends TestCase
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses \phpDocumentor\Reflection\DocBlock\Description
*
* @covers ::__construct
* @covers ::create
* @uses phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses phpDocumentor\Reflection\DocBlock\Description
*
* @dataProvider provideSummaryAndDescriptions
*/
public function testSummaryAndDescriptionAreSeparated($given, $summary, $description): void
public function testSummaryAndDescriptionAreSeparated(string $given, string $summary, string $description) : void
{
$tagFactory = m::mock(TagFactory::class);
$fixture = new DocBlockFactory(new DescriptionFactory($tagFactory), $tagFactory);
$fixture = new DocBlockFactory(new DescriptionFactory($tagFactory), $tagFactory);
$docblock = $fixture->create($given);
@@ -130,15 +138,16 @@ class DocBlockFactoryTest extends TestCase
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses \phpDocumentor\Reflection\DocBlock\Description
*
* @covers ::__construct
* @covers ::create
* @uses phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses phpDocumentor\Reflection\DocBlock\Description
*/
public function testDescriptionsRetainFormatting(): void
public function testDescriptionsRetainFormatting() : void
{
$tagFactory = m::mock(TagFactory::class);
$fixture = new DocBlockFactory(new DescriptionFactory($tagFactory), $tagFactory);
$fixture = new DocBlockFactory(new DescriptionFactory($tagFactory), $tagFactory);
$given = <<<DOCBLOCK
/**
@@ -163,19 +172,20 @@ DESCRIPTION;
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses \phpDocumentor\Reflection\DocBlock\Description
*
* @covers ::__construct
* @covers ::create
* @uses phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses phpDocumentor\Reflection\DocBlock\Description
*/
public function testTagsAreInterpretedUsingFactory(): void
public function testTagsAreInterpretedUsingFactory() : void
{
$tagString = <<<TAG
@author Mike van Riel <[email protected]> This is with
multiline description.
TAG;
$tag = m::mock(Tag::class);
$tag = m::mock(Tag::class);
$tagFactory = m::mock(TagFactory::class);
$tagFactory->shouldReceive('create')->with($tagString, m::type(Context::class))->andReturn($tag);
@@ -195,7 +205,10 @@ DOCBLOCK;
$this->assertEquals([$tag], $docblock->getTags());
}
public function provideSummaryAndDescriptions()
/**
* @return string[]
*/
public function provideSummaryAndDescriptions() : array
{
return [
['This is a DocBlock', 'This is a DocBlock', ''],
@@ -208,8 +221,7 @@ DOCBLOCK;
<<<DOCBLOCK
This is a DocBlock.
This should be a Description.
DOCBLOCK
,
DOCBLOCK,
'This is a DocBlock.',
'This should be a Description.',
],
@@ -218,8 +230,7 @@ DOCBLOCK
This is a
multiline Summary.
This should be a Description.
DOCBLOCK
,
DOCBLOCK,
"This is a\nmultiline Summary.",
'This should be a Description.',
],
@@ -228,8 +239,7 @@ DOCBLOCK
This is a Summary without dot but with a whiteline
This should be a Description.
DOCBLOCK
,
DOCBLOCK,
'This is a Summary without dot but with a whiteline',
'This should be a Description.',
],
@@ -238,8 +248,7 @@ DOCBLOCK
This is a Summary with dot and with a whiteline.
This should be a Description.
DOCBLOCK
,
DOCBLOCK,
'This is a Summary with dot and with a whiteline.',
'This should be a Description.',
],
@@ -247,19 +256,19 @@ DOCBLOCK
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\Types\Context
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param
*
* @covers ::__construct
* @covers ::create
*
* @uses phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses phpDocumentor\Reflection\DocBlock\Description
* @uses phpDocumentor\Reflection\Types\Context
* @uses phpDocumentor\Reflection\DocBlock\Tags\Param
*/
public function testTagsWithContextNamespace(): void
public function testTagsWithContextNamespace() : void
{
$tagFactoryMock = m::mock(TagFactory::class);
$fixture = new DocBlockFactory(m::mock(DescriptionFactory::class), $tagFactoryMock);
$context = new Context('MyNamespace');
$fixture = new DocBlockFactory(m::mock(DescriptionFactory::class), $tagFactoryMock);
$context = new Context('MyNamespace');
$tagFactoryMock->shouldReceive('create')->with(m::any(), $context)->andReturn(new Param('param'));
$docblock = $fixture->create('/** @param MyType $param */', $context);
@@ -268,13 +277,13 @@ DOCBLOCK
}
/**
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses \phpDocumentor\Reflection\DocBlock\Description
*
* @covers ::__construct
* @covers ::create
*
* @uses phpDocumentor\Reflection\DocBlock\DescriptionFactory
* @uses phpDocumentor\Reflection\DocBlock\Description
*/
public function testTagsAreFilteredForNullValues(): void
public function testTagsAreFilteredForNullValues() : void
{
$tagString = <<<TAG
@author Mike van Riel <[email protected]> This is with