Skip to content

Commit 6946f85

Browse files
authored
Merge pull request #152 from ashnazg/strict
Strict Updates
2 parents cd3bee0 + cc0998e commit 6946f85

22 files changed

+30
-32
lines changed

src/DocBlock.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public function isTemplateEnd(): bool
133133
*
134134
* @return Tag[]
135135
*/
136-
public function getTags()
136+
public function getTags(): array
137137
{
138138
return $this->tags;
139139
}
@@ -146,7 +146,7 @@ public function getTags()
146146
*
147147
* @return Tag[]
148148
*/
149-
public function getTagsByName(string $name)
149+
public function getTagsByName(string $name): array
150150
{
151151
$result = [];
152152

src/DocBlock/Description.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function __construct(string $bodyTemplate, array $tags = [])
7272
*
7373
* @return Tag[]
7474
*/
75-
public function getTags()
75+
public function getTags(): array
7676
{
7777
return $this->tags;
7878
}

src/DocBlock/DescriptionFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function create(string $contents, ?TypeContext $context = null): Descript
6161
*
6262
* @return string[] A series of tokens of which the description text is composed.
6363
*/
64-
private function lex(string $contents)
64+
private function lex(string $contents): array
6565
{
6666
$contents = $this->removeSuperfluousStartingWhitespace($contents);
6767

src/DocBlock/StandardTagFactory.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public function registerTagHandler(string $tagName, string $handler): void
163163
*
164164
* @return string[]
165165
*/
166-
private function extractTagParts(string $tagLine)
166+
private function extractTagParts(string $tagLine): array
167167
{
168168
$matches = [];
169169
if (! preg_match('/^@(' . self::REGEX_TAGNAME . ')(?:\s*([^\s].*)|$)/us', $tagLine, $matches)) {
@@ -222,7 +222,7 @@ private function findHandlerClassName(string $tagName, TypeContext $context): st
222222
* @return mixed[] A series of values that can be passed to the Factory Method of the tag whose parameters
223223
* is provided with this method.
224224
*/
225-
private function getArgumentsForParametersFromWiring($parameters, $locator)
225+
private function getArgumentsForParametersFromWiring($parameters, $locator): array
226226
{
227227
$arguments = [];
228228
foreach ($parameters as $index => $parameter) {
@@ -251,7 +251,7 @@ private function getArgumentsForParametersFromWiring($parameters, $locator)
251251
*
252252
* @return \ReflectionParameter[]
253253
*/
254-
private function fetchParametersForHandlerFactoryMethod(string $handlerClassName)
254+
private function fetchParametersForHandlerFactoryMethod(string $handlerClassName): array
255255
{
256256
if (! isset($this->tagHandlerParameterCache[$handlerClassName])) {
257257
$methodReflection = new \ReflectionMethod($handlerClassName, 'create');
@@ -271,7 +271,7 @@ private function fetchParametersForHandlerFactoryMethod(string $handlerClassName
271271
*
272272
* @return mixed[]
273273
*/
274-
private function getServiceLocatorWithDynamicParameters(TypeContext $context, string $tagName, string $tagBody)
274+
private function getServiceLocatorWithDynamicParameters(TypeContext $context, string $tagName, string $tagBody): array
275275
{
276276
$locator = array_merge(
277277
$this->serviceLocator,

src/DocBlock/Tags/Covers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static function create(
4747
?DescriptionFactory $descriptionFactory = null,
4848
?FqsenResolver $resolver = null,
4949
?TypeContext $context = null
50-
) {
50+
): self {
5151
Assert::notEmpty($body);
5252

5353
$parts = preg_split('/\s+/Su', $body, 2);

src/DocBlock/Tags/Deprecated.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public static function create(
5959
?string $body,
6060
?DescriptionFactory $descriptionFactory = null,
6161
?TypeContext $context = null
62-
) {
62+
): self {
6363
if (empty($body)) {
6464
return new static();
6565
}

src/DocBlock/Tags/Example.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
namespace phpDocumentor\Reflection\DocBlock\Tags;
1515

16-
use phpDocumentor\Reflection\DocBlock\Description;
1716
use phpDocumentor\Reflection\DocBlock\Tag;
1817
use Webmozart\Assert\Assert;
1918

@@ -81,7 +80,7 @@ public function getContent()
8180
/**
8281
* {@inheritdoc}
8382
*/
84-
public static function create(string $body)
83+
public static function create(string $body): ?Tag
8584
{
8685
// File component: File path in quotes or File URI / Source information
8786
if (! preg_match('/^(?:\"([^\"]+)\"|(\S+))(?:\s+(.*))?$/sux', $body, $matches)) {

src/DocBlock/Tags/Generic.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public static function create(
4949
string $name = '',
5050
?DescriptionFactory $descriptionFactory = null,
5151
?TypeContext $context = null
52-
) {
52+
): self {
5353
Assert::stringNotEmpty($name);
5454
Assert::notNull($descriptionFactory);
5555

src/DocBlock/Tags/Method.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ public static function create(
9292
)?
9393
# Return type
9494
(?:
95-
(
95+
(
9696
(?:[\w\|_\\\\]*\$this[\w\|_\\\\]*)
9797
|
9898
(?:
9999
(?:[\w\|_\\\\]+)
100-
# array notation
100+
# array notation
101101
(?:\[\])*
102102
)*
103103
)
@@ -170,7 +170,7 @@ public function getMethodName(): string
170170
/**
171171
* @return string[]
172172
*/
173-
public function getArguments()
173+
public function getArguments(): array
174174
{
175175
return $this->arguments;
176176
}
@@ -204,7 +204,7 @@ public function __toString(): string
204204
. ($this->description ? ' ' . $this->description->render() : ''));
205205
}
206206

207-
private function filterArguments($arguments)
207+
private function filterArguments(array $arguments = []): array
208208
{
209209
foreach ($arguments as &$argument) {
210210
if (is_string($argument)) {
@@ -227,7 +227,7 @@ private function filterArguments($arguments)
227227
return $arguments;
228228
}
229229

230-
private static function stripRestArg($argument)
230+
private static function stripRestArg(string $argument): string
231231
{
232232
if (strpos($argument, '...') === 0) {
233233
$argument = trim(substr($argument, 3));

src/DocBlock/Tags/Param.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public static function create(
5353
?TypeResolver $typeResolver = null,
5454
?DescriptionFactory $descriptionFactory = null,
5555
?TypeContext $context = null
56-
) {
56+
): self {
5757
Assert::stringNotEmpty($body);
5858
Assert::allNotNull([$typeResolver, $descriptionFactory]);
5959

src/DocBlock/Tags/Property.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public static function create(
4949
?TypeResolver $typeResolver = null,
5050
?DescriptionFactory $descriptionFactory = null,
5151
?TypeContext $context = null
52-
) {
52+
): self {
5353
Assert::stringNotEmpty($body);
5454
Assert::allNotNull([$typeResolver, $descriptionFactory]);
5555

src/DocBlock/Tags/PropertyRead.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public static function create(
4949
?TypeResolver $typeResolver = null,
5050
?DescriptionFactory $descriptionFactory = null,
5151
?TypeContext $context = null
52-
) {
52+
): self {
5353
Assert::stringNotEmpty($body);
5454
Assert::allNotNull([$typeResolver, $descriptionFactory]);
5555

src/DocBlock/Tags/PropertyWrite.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public static function create(
4949
?TypeResolver $typeResolver = null,
5050
?DescriptionFactory $descriptionFactory = null,
5151
?TypeContext $context = null
52-
) {
52+
): self {
5353
Assert::stringNotEmpty($body);
5454
Assert::allNotNull([$typeResolver, $descriptionFactory]);
5555

src/DocBlock/Tags/Reference/Url.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ final class Url implements Reference
2828
/**
2929
* Url constructor.
3030
*/
31-
public function __construct($uri)
31+
public function __construct(string $uri)
3232
{
3333
Assert::stringNotEmpty($uri);
3434
$this->uri = $uri;

src/DocBlock/Tags/Return_.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public static function create(
4444
?TypeResolver $typeResolver = null,
4545
?DescriptionFactory $descriptionFactory = null,
4646
?TypeContext $context = null
47-
) {
47+
): self {
4848
Assert::allNotNull([$typeResolver, $descriptionFactory]);
4949

5050
$parts = preg_split('/\s+/Su', $body, 2);

src/DocBlock/Tags/See.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public static function create(
4949
?FqsenResolver $resolver = null,
5050
?DescriptionFactory $descriptionFactory = null,
5151
?TypeContext $context = null
52-
) {
52+
): self {
5353
Assert::allNotNull([$resolver, $descriptionFactory]);
5454

5555
$parts = preg_split('/\s+/Su', $body, 2);

src/DocBlock/Tags/Since.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
use phpDocumentor\Reflection\DocBlock\Description;
1717
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
18-
use phpDocumentor\Reflection\DocBlock\Tag;
1918
use phpDocumentor\Reflection\Types\Context as TypeContext;
2019
use Webmozart\Assert\Assert;
2120

src/DocBlock/Tags/Source.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public static function create(
4949
string $body,
5050
?DescriptionFactory $descriptionFactory = null,
5151
?TypeContext $context = null
52-
) {
52+
): self {
5353
Assert::stringNotEmpty($body);
5454
Assert::notNull($descriptionFactory);
5555

src/DocBlock/Tags/Throws.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public static function create(
4444
?TypeResolver $typeResolver = null,
4545
?DescriptionFactory $descriptionFactory = null,
4646
?TypeContext $context = null
47-
) {
47+
): self {
4848
Assert::allNotNull([$typeResolver, $descriptionFactory]);
4949

5050
$parts = preg_split('/\s+/Su', $body, 2);

src/DocBlock/Tags/Uses.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static function create(
4747
?FqsenResolver $resolver = null,
4848
?DescriptionFactory $descriptionFactory = null,
4949
?TypeContext $context = null
50-
) {
50+
): self {
5151
Assert::allNotNull([$resolver, $descriptionFactory]);
5252

5353
$parts = preg_split('/\s+/Su', $body, 2);

src/DocBlock/Tags/Var_.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public static function create(
4949
?TypeResolver $typeResolver = null,
5050
?DescriptionFactory $descriptionFactory = null,
5151
?TypeContext $context = null
52-
) {
52+
): self {
5353
Assert::stringNotEmpty($body);
5454
Assert::allNotNull([$typeResolver, $descriptionFactory]);
5555

src/DocBlockFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ private function stripDocComment(string $comment): string
127127
*
128128
* @return string[] containing the template marker (if any), summary, description and a string containing the tags.
129129
*/
130-
private function splitDocBlock(string $comment)
130+
private function splitDocBlock(string $comment): array
131131
{
132132
// Performance improvement cheat: if the first character is an @ then only tags are in this DocBlock. This
133133
// method does not split tags so we return this verbatim as the fourth result (tags). This saves us the
@@ -227,7 +227,7 @@ private function parseTagBlock(string $tags, Types\Context $context): array
227227
/**
228228
* @return string[]
229229
*/
230-
private function splitTagBlockIntoTagLines(string $tags)
230+
private function splitTagBlockIntoTagLines(string $tags): array
231231
{
232232
$result = [];
233233
foreach (explode("\n", $tags) as $tag_line) {

0 commit comments

Comments
 (0)