Skip to content

Commit e45d003

Browse files
authored
Merge pull request #291 from jrfnl/feature/cs-update
CS update after upstream changes
2 parents dc7d72e + 19e9733 commit e45d003

Some content is hidden

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

72 files changed

+587
-533
lines changed

phpcs.xml.dist

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
11
<?xml version="1.0"?>
2-
<ruleset name="phpDocumentor">
3-
<description>The coding standard for phpDocumentor.</description>
2+
<ruleset name="ReflectionDocBlock">
3+
<description>The coding standard for this library.</description>
44

55
<file>src</file>
66
<file>tests/unit</file>
7-
<exclude-pattern>*/tests/unit/Types/ContextFactoryTest.php</exclude-pattern>
7+
<exclude-pattern>*/tests/unit/Types/ContextFactoryTest\.php</exclude-pattern>
88
<exclude-pattern>*/tests/unit/Assets/*</exclude-pattern>
99
<arg value="p"/>
1010

11+
<!-- Set the minimum PHP version for PHPCompatibility.
12+
This should be kept in sync with the requirements in the composer.json file. -->
13+
<config name="testVersion" value="7.2-"/>
14+
1115
<rule ref="phpDocumentor">
1216
<exclude name="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly.ReferencedGeneralException" />
17+
18+
<!-- Property type declarations are a PHP 7.4 feature. -->
19+
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingNativeTypeHint"/>
1320
</rule>
1421

1522
<rule ref="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming.SuperfluousPrefix">
16-
<exclude-pattern>*/src/*/Abstract*.php</exclude-pattern>
23+
<exclude-pattern>*/src/*/Abstract*\.php</exclude-pattern>
1724
</rule>
1825

1926
<rule ref="SlevomatCodingStandard.Classes.UnusedPrivateElements.UnusedMethod">
20-
<exclude-pattern>*/src/DocBlock/Tags/InvalidTag.php</exclude-pattern>
27+
<exclude-pattern>*/src/DocBlock/Tags/InvalidTag\.php</exclude-pattern>
2128
</rule>
2229
</ruleset>

src/DocBlock.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,28 +69,28 @@ public function __construct(
6969
$this->isTemplateStart = $isTemplateStart;
7070
}
7171

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

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

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

9090
/**
9191
* Returns the current location.
9292
*/
93-
public function getLocation() : ?Location
93+
public function getLocation(): ?Location
9494
{
9595
return $this->location;
9696
}
@@ -114,7 +114,7 @@ public function getLocation() : ?Location
114114
*
115115
* @see self::isTemplateEnd() for the check whether a closing marker was provided.
116116
*/
117-
public function isTemplateStart() : bool
117+
public function isTemplateStart(): bool
118118
{
119119
return $this->isTemplateStart;
120120
}
@@ -124,7 +124,7 @@ public function isTemplateStart() : bool
124124
*
125125
* @see self::isTemplateStart() for a more complete description of the Docblock Template functionality.
126126
*/
127-
public function isTemplateEnd() : bool
127+
public function isTemplateEnd(): bool
128128
{
129129
return $this->isTemplateEnd;
130130
}
@@ -134,7 +134,7 @@ public function isTemplateEnd() : bool
134134
*
135135
* @return Tag[]
136136
*/
137-
public function getTags() : array
137+
public function getTags(): array
138138
{
139139
return $this->tags;
140140
}
@@ -147,7 +147,7 @@ public function getTags() : array
147147
*
148148
* @return Tag[]
149149
*/
150-
public function getTagsByName(string $name) : array
150+
public function getTagsByName(string $name): array
151151
{
152152
$result = [];
153153

@@ -170,7 +170,7 @@ public function getTagsByName(string $name) : array
170170
*
171171
* @return TagWithType[]
172172
*/
173-
public function getTagsWithTypeByName(string $name) : array
173+
public function getTagsWithTypeByName(string $name): array
174174
{
175175
$result = [];
176176

@@ -190,7 +190,7 @@ public function getTagsWithTypeByName(string $name) : array
190190
*
191191
* @param string $name Tag name to check for.
192192
*/
193-
public function hasTag(string $name) : bool
193+
public function hasTag(string $name): bool
194194
{
195195
foreach ($this->getTags() as $tag) {
196196
if ($tag->getName() === $name) {
@@ -206,7 +206,7 @@ public function hasTag(string $name) : bool
206206
*
207207
* @param Tag $tagToRemove The tag to remove.
208208
*/
209-
public function removeTag(Tag $tagToRemove) : void
209+
public function removeTag(Tag $tagToRemove): void
210210
{
211211
foreach ($this->tags as $key => $tag) {
212212
if ($tag === $tagToRemove) {
@@ -221,7 +221,7 @@ public function removeTag(Tag $tagToRemove) : void
221221
*
222222
* @param Tag $tag The tag to add.
223223
*/
224-
private function addTag(Tag $tag) : void
224+
private function addTag(Tag $tag): void
225225
{
226226
$this->tags[] = $tag;
227227
}

src/DocBlock/Description.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

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

2021
/**
@@ -71,7 +72,7 @@ public function __construct(string $bodyTemplate, array $tags = [])
7172
/**
7273
* Returns the body template.
7374
*/
74-
public function getBodyTemplate() : string
75+
public function getBodyTemplate(): string
7576
{
7677
return $this->bodyTemplate;
7778
}
@@ -81,7 +82,7 @@ public function getBodyTemplate() : string
8182
*
8283
* @return Tag[]
8384
*/
84-
public function getTags() : array
85+
public function getTags(): array
8586
{
8687
return $this->tags;
8788
}
@@ -90,7 +91,7 @@ public function getTags() : array
9091
* Renders this description as a string where the provided formatter will format the tags in the expected string
9192
* format.
9293
*/
93-
public function render(?Formatter $formatter = null) : string
94+
public function render(?Formatter $formatter = null): string
9495
{
9596
if ($formatter === null) {
9697
$formatter = new PassthroughFormatter();
@@ -107,7 +108,7 @@ public function render(?Formatter $formatter = null) : string
107108
/**
108109
* Returns a plain string representation of this description.
109110
*/
110-
public function __toString() : string
111+
public function __toString(): string
111112
{
112113
return $this->render();
113114
}

src/DocBlock/DescriptionFactory.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
use phpDocumentor\Reflection\Types\Context as TypeContext;
1717
use phpDocumentor\Reflection\Utils;
18+
1819
use function count;
1920
use function explode;
2021
use function implode;
@@ -25,6 +26,7 @@
2526
use function strpos;
2627
use function substr;
2728
use function trim;
29+
2830
use const PREG_SPLIT_DELIM_CAPTURE;
2931

3032
/**
@@ -60,7 +62,7 @@ public function __construct(TagFactory $tagFactory)
6062
/**
6163
* Returns the parsed text of this description.
6264
*/
63-
public function create(string $contents, ?TypeContext $context = null) : Description
65+
public function create(string $contents, ?TypeContext $context = null): Description
6466
{
6567
$tokens = $this->lex($contents);
6668
$count = count($tokens);
@@ -88,7 +90,7 @@ public function create(string $contents, ?TypeContext $context = null) : Descrip
8890
*
8991
* @return string[] A series of tokens of which the description text is composed.
9092
*/
91-
private function lex(string $contents) : array
93+
private function lex(string $contents): array
9294
{
9395
$contents = $this->removeSuperfluousStartingWhitespace($contents);
9496

@@ -142,7 +144,7 @@ private function lex(string $contents) : array
142144
* If we do not normalize the indentation then we have superfluous whitespace on the second and subsequent
143145
* lines and this may cause rendering issues when, for example, using a Markdown converter.
144146
*/
145-
private function removeSuperfluousStartingWhitespace(string $contents) : string
147+
private function removeSuperfluousStartingWhitespace(string $contents): string
146148
{
147149
$lines = explode("\n", $contents);
148150

src/DocBlock/ExampleFinder.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
namespace phpDocumentor\Reflection\DocBlock;
1515

1616
use phpDocumentor\Reflection\DocBlock\Tags\Example;
17+
1718
use function array_slice;
1819
use function file;
1920
use function getcwd;
@@ -22,6 +23,7 @@
2223
use function rtrim;
2324
use function sprintf;
2425
use function trim;
26+
2527
use const DIRECTORY_SEPARATOR;
2628

2729
/**
@@ -38,7 +40,7 @@ class ExampleFinder
3840
/**
3941
* Attempts to find the example contents for the given descriptor.
4042
*/
41-
public function find(Example $example) : string
43+
public function find(Example $example): string
4244
{
4345
$filename = $example->getFilePath();
4446

@@ -53,15 +55,15 @@ public function find(Example $example) : string
5355
/**
5456
* Registers the project's root directory where an 'examples' folder can be expected.
5557
*/
56-
public function setSourceDirectory(string $directory = '') : void
58+
public function setSourceDirectory(string $directory = ''): void
5759
{
5860
$this->sourceDirectory = $directory;
5961
}
6062

6163
/**
6264
* Returns the project's root directory where an 'examples' folder can be expected.
6365
*/
64-
public function getSourceDirectory() : string
66+
public function getSourceDirectory(): string
6567
{
6668
return $this->sourceDirectory;
6769
}
@@ -71,7 +73,7 @@ public function getSourceDirectory() : string
7173
*
7274
* @param string[] $directories
7375
*/
74-
public function setExampleDirectories(array $directories) : void
76+
public function setExampleDirectories(array $directories): void
7577
{
7678
$this->exampleDirectories = $directories;
7779
}
@@ -81,7 +83,7 @@ public function setExampleDirectories(array $directories) : void
8183
*
8284
* @return string[]
8385
*/
84-
public function getExampleDirectories() : array
86+
public function getExampleDirectories(): array
8587
{
8688
return $this->exampleDirectories;
8789
}
@@ -99,7 +101,7 @@ public function getExampleDirectories() : array
99101
*
100102
* @return string[] all lines of the example file
101103
*/
102-
private function getExampleFileContents(string $filename) : ?array
104+
private function getExampleFileContents(string $filename): ?array
103105
{
104106
$normalizedPath = null;
105107

@@ -129,23 +131,23 @@ private function getExampleFileContents(string $filename) : ?array
129131
/**
130132
* Get example filepath based on the example directory inside your project.
131133
*/
132-
private function getExamplePathFromExampleDirectory(string $file) : string
134+
private function getExamplePathFromExampleDirectory(string $file): string
133135
{
134136
return getcwd() . DIRECTORY_SEPARATOR . 'examples' . DIRECTORY_SEPARATOR . $file;
135137
}
136138

137139
/**
138140
* Returns a path to the example file in the given directory..
139141
*/
140-
private function constructExamplePath(string $directory, string $file) : string
142+
private function constructExamplePath(string $directory, string $file): string
141143
{
142144
return rtrim($directory, '\\/') . DIRECTORY_SEPARATOR . $file;
143145
}
144146

145147
/**
146148
* Get example filepath based on sourcecode.
147149
*/
148-
private function getExamplePathFromSource(string $file) : string
150+
private function getExamplePathFromSource(string $file): string
149151
{
150152
return sprintf(
151153
'%s%s%s',

src/DocBlock/Serializer.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use phpDocumentor\Reflection\DocBlock;
1717
use phpDocumentor\Reflection\DocBlock\Tags\Formatter;
1818
use phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter;
19+
1920
use function sprintf;
2021
use function str_repeat;
2122
use function str_replace;
@@ -72,7 +73,7 @@ public function __construct(
7273
*
7374
* @return string The serialized doc block.
7475
*/
75-
public function getDocComment(DocBlock $docblock) : string
76+
public function getDocComment(DocBlock $docblock): string
7677
{
7778
$indent = str_repeat($this->indentString, $this->indent);
7879
$firstIndent = $this->isFirstLineIndented ? $indent : '';
@@ -98,7 +99,7 @@ public function getDocComment(DocBlock $docblock) : string
9899
return $comment . $indent . ' */';
99100
}
100101

101-
private function removeTrailingSpaces(string $indent, string $text) : string
102+
private function removeTrailingSpaces(string $indent, string $text): string
102103
{
103104
return str_replace(
104105
sprintf("\n%s * \n", $indent),
@@ -107,7 +108,7 @@ private function removeTrailingSpaces(string $indent, string $text) : string
107108
);
108109
}
109110

110-
private function addAsterisksForEachLine(string $indent, string $text) : string
111+
private function addAsterisksForEachLine(string $indent, string $text): string
111112
{
112113
return str_replace(
113114
"\n",
@@ -116,7 +117,7 @@ private function addAsterisksForEachLine(string $indent, string $text) : string
116117
);
117118
}
118119

119-
private function getSummaryAndDescriptionTextBlock(DocBlock $docblock, ?int $wrapLength) : string
120+
private function getSummaryAndDescriptionTextBlock(DocBlock $docblock, ?int $wrapLength): string
120121
{
121122
$text = $docblock->getSummary() . ((string) $docblock->getDescription() ? "\n\n" . $docblock->getDescription()
122123
: '');
@@ -129,7 +130,7 @@ private function getSummaryAndDescriptionTextBlock(DocBlock $docblock, ?int $wra
129130
return $text;
130131
}
131132

132-
private function addTagBlock(DocBlock $docblock, ?int $wrapLength, string $indent, string $comment) : string
133+
private function addTagBlock(DocBlock $docblock, ?int $wrapLength, string $indent, string $comment): string
133134
{
134135
foreach ($docblock->getTags() as $tag) {
135136
$tagText = $this->tagFormatter->format($tag);

0 commit comments

Comments
 (0)