Skip to content

Commit aee9840

Browse files
committed
Apply new code style
1 parent 8fcadfe commit aee9840

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1659
-1284
lines changed

phpcs.xml.dist

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="phpDocumentor">
3+
<description>The coding standard for phpDocumentor.</description>
4+
5+
<file>src</file>
6+
<file>tests/unit</file>
7+
<exclude-pattern>*/tests/unit/Types/ContextFactoryTest.php</exclude-pattern>
8+
<arg value="p"/>
9+
<rule ref="PSR2">
10+
<include-pattern>*\.php</include-pattern>
11+
</rule>
12+
13+
<rule ref="Doctrine">
14+
<exclude name="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint.UselessDocComment" />
15+
</rule>
16+
17+
<rule ref="Squiz.Classes.ValidClassName.NotCamelCaps">
18+
<exclude-pattern>*/src/*_.php</exclude-pattern>
19+
</rule>
20+
21+
<rule ref="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming.SuperfluousPrefix">
22+
<exclude-pattern>*/src/*/Abstract*.php</exclude-pattern>
23+
</rule>
24+
25+
<rule ref="Generic.Formatting.SpaceAfterNot">
26+
<properties>
27+
<property name="spacing" value="0" />
28+
</properties>
29+
</rule>
30+
</ruleset>

src/DocBlock.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
24

35
/**
46
* This file is part of phpDocumentor.
57
*
68
* For the full copyright and license information, please view the LICENSE
79
* file that was distributed with this source code.
810
*
9-
* @copyright 2010-2018 Mike van Riel<[email protected]>
10-
* @license http://www.opensource.org/licenses/mit-license.php MIT
1111
* @link http://phpdoc.org
1212
*/
1313

@@ -41,8 +41,8 @@ final class DocBlock
4141

4242
/**
4343
* @param DocBlock\Tag[] $tags
44-
* @param Types\Context $context The context in which the DocBlock occurs.
45-
* @param Location $location The location within the file that this DocBlock occurs in.
44+
* @param Types\Context $context The context in which the DocBlock occurs.
45+
* @param Location $location The location within the file that this DocBlock occurs in.
4646
*/
4747
public function __construct(
4848
string $summary = '',
@@ -55,41 +55,41 @@ public function __construct(
5555
) {
5656
Assert::allIsInstanceOf($tags, Tag::class);
5757

58-
$this->summary = $summary;
58+
$this->summary = $summary;
5959
$this->description = $description ?: new DocBlock\Description('');
6060
foreach ($tags as $tag) {
6161
$this->addTag($tag);
6262
}
6363

64-
$this->context = $context;
64+
$this->context = $context;
6565
$this->location = $location;
6666

67-
$this->isTemplateEnd = $isTemplateEnd;
67+
$this->isTemplateEnd = $isTemplateEnd;
6868
$this->isTemplateStart = $isTemplateStart;
6969
}
7070

71-
public function getSummary(): string
71+
public function getSummary() : string
7272
{
7373
return $this->summary;
7474
}
7575

76-
public function getDescription(): DocBlock\Description
76+
public function getDescription() : DocBlock\Description
7777
{
7878
return $this->description;
7979
}
8080

8181
/**
8282
* Returns the current context.
8383
*/
84-
public function getContext(): ?Types\Context
84+
public function getContext() : ?Types\Context
8585
{
8686
return $this->context;
8787
}
8888

8989
/**
9090
* Returns the current location.
9191
*/
92-
public function getLocation(): ?Location
92+
public function getLocation() : ?Location
9393
{
9494
return $this->location;
9595
}
@@ -113,7 +113,7 @@ public function getLocation(): ?Location
113113
*
114114
* @see self::isTemplateEnd() for the check whether a closing marker was provided.
115115
*/
116-
public function isTemplateStart(): bool
116+
public function isTemplateStart() : bool
117117
{
118118
return $this->isTemplateStart;
119119
}
@@ -123,7 +123,7 @@ public function isTemplateStart(): bool
123123
*
124124
* @see self::isTemplateStart() for a more complete description of the Docblock Template functionality.
125125
*/
126-
public function isTemplateEnd(): bool
126+
public function isTemplateEnd() : bool
127127
{
128128
return $this->isTemplateEnd;
129129
}
@@ -133,7 +133,7 @@ public function isTemplateEnd(): bool
133133
*
134134
* @return Tag[]
135135
*/
136-
public function getTags(): array
136+
public function getTags() : array
137137
{
138138
return $this->tags;
139139
}
@@ -146,7 +146,7 @@ public function getTags(): array
146146
*
147147
* @return Tag[]
148148
*/
149-
public function getTagsByName(string $name): array
149+
public function getTagsByName(string $name) : array
150150
{
151151
$result = [];
152152

@@ -167,7 +167,7 @@ public function getTagsByName(string $name): array
167167
*
168168
* @param string $name Tag name to check for.
169169
*/
170-
public function hasTag(string $name): bool
170+
public function hasTag(string $name) : bool
171171
{
172172
/** @var Tag $tag */
173173
foreach ($this->getTags() as $tag) {
@@ -184,7 +184,7 @@ public function hasTag(string $name): bool
184184
*
185185
* @param Tag $tagToRemove The tag to remove.
186186
*/
187-
public function removeTag(Tag $tagToRemove): void
187+
public function removeTag(Tag $tagToRemove) : void
188188
{
189189
foreach ($this->tags as $key => $tag) {
190190
if ($tag === $tagToRemove) {
@@ -199,7 +199,7 @@ public function removeTag(Tag $tagToRemove): void
199199
*
200200
* @param Tag $tag The tag to add.
201201
*/
202-
private function addTag(Tag $tag): void
202+
private function addTag(Tag $tag) : void
203203
{
204204
$this->tags[] = $tag;
205205
}

src/DocBlock/Description.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
24

35
/**
46
* This file is part of phpDocumentor.
57
*
68
* For the full copyright and license information, please view the LICENSE
79
* file that was distributed with this source code.
810
*
9-
* @copyright 2010-2018 Mike van Riel<[email protected]>
10-
* @license http://www.opensource.org/licenses/mit-license.php MIT
1111
* @link http://phpdoc.org
1212
*/
1313

1414
namespace phpDocumentor\Reflection\DocBlock;
1515

1616
use phpDocumentor\Reflection\DocBlock\Tags\Formatter;
1717
use phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter;
18+
use function vsprintf;
1819

1920
/**
2021
* Object representing to description for a DocBlock.
@@ -64,15 +65,15 @@ class Description
6465
public function __construct(string $bodyTemplate, array $tags = [])
6566
{
6667
$this->bodyTemplate = $bodyTemplate;
67-
$this->tags = $tags;
68+
$this->tags = $tags;
6869
}
6970

7071
/**
7172
* Returns the tags for this DocBlock.
7273
*
7374
* @return Tag[]
7475
*/
75-
public function getTags(): array
76+
public function getTags() : array
7677
{
7778
return $this->tags;
7879
}
@@ -81,7 +82,7 @@ public function getTags(): array
8182
* Renders this description as a string where the provided formatter will format the tags in the expected string
8283
* format.
8384
*/
84-
public function render(?Formatter $formatter = null): string
85+
public function render(?Formatter $formatter = null) : string
8586
{
8687
if ($formatter === null) {
8788
$formatter = new PassthroughFormatter();
@@ -98,7 +99,7 @@ public function render(?Formatter $formatter = null): string
9899
/**
99100
* Returns a plain string representation of this description.
100101
*/
101-
public function __toString(): string
102+
public function __toString() : string
102103
{
103104
return $this->render();
104105
}

src/DocBlock/DescriptionFactory.php

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,31 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
24

35
/**
46
* This file is part of phpDocumentor.
57
*
68
* For the full copyright and license information, please view the LICENSE
79
* file that was distributed with this source code.
810
*
9-
* @copyright 2010-2018 Mike van Riel<[email protected]>
10-
* @license http://www.opensource.org/licenses/mit-license.php MIT
1111
* @link http://phpdoc.org
1212
*/
1313

1414
namespace phpDocumentor\Reflection\DocBlock;
1515

1616
use phpDocumentor\Reflection\Types\Context as TypeContext;
17+
use const PREG_SPLIT_DELIM_CAPTURE;
18+
use function count;
19+
use function explode;
20+
use function implode;
21+
use function ltrim;
22+
use function min;
23+
use function preg_split;
24+
use function str_replace;
25+
use function strlen;
26+
use function strpos;
27+
use function substr;
28+
use function trim;
1729

1830
/**
1931
* Creates a new Description object given a body of text.
@@ -48,7 +60,7 @@ public function __construct(TagFactory $tagFactory)
4860
/**
4961
* Returns the parsed text of this description.
5062
*/
51-
public function create(string $contents, ?TypeContext $context = null): Description
63+
public function create(string $contents, ?TypeContext $context = null) : Description
5264
{
5365
[$text, $tags] = $this->parse($this->lex($contents), $context);
5466

@@ -58,10 +70,9 @@ public function create(string $contents, ?TypeContext $context = null): Descript
5870
/**
5971
* Strips the contents from superfluous whitespace and splits the description into a series of tokens.
6072
*
61-
*
6273
* @return string[] A series of tokens of which the description text is composed.
6374
*/
64-
private function lex(string $contents): array
75+
private function lex(string $contents) : array
6576
{
6677
$contents = $this->removeSuperfluousStartingWhitespace($contents);
6778

@@ -108,14 +119,14 @@ private function lex(string $contents): array
108119
*
109120
* @return string[]|Tag[]
110121
*/
111-
private function parse($tokens, ?TypeContext $context = null): array
122+
private function parse(array $tokens, ?TypeContext $context = null) : array
112123
{
113-
$count = count($tokens);
124+
$count = count($tokens);
114125
$tagCount = 0;
115-
$tags = [];
126+
$tags = [];
116127

117128
for ($i = 1; $i < $count; $i += 2) {
118-
$tags[] = $this->tagFactory->create($tokens[$i], $context);
129+
$tags[] = $this->tagFactory->create($tokens[$i], $context);
119130
$tokens[$i] = '%' . ++$tagCount . '$s';
120131
}
121132

@@ -144,7 +155,7 @@ private function parse($tokens, ?TypeContext $context = null): array
144155
* If we do not normalize the indentation then we have superfluous whitespace on the second and subsequent
145156
* lines and this may cause rendering issues when, for example, using a Markdown converter.
146157
*/
147-
private function removeSuperfluousStartingWhitespace(string $contents): string
158+
private function removeSuperfluousStartingWhitespace(string $contents) : string
148159
{
149160
$lines = explode("\n", $contents);
150161

0 commit comments

Comments
 (0)