Skip to content

Commit dfe226c

Browse files
committed
Improved internal types
1 parent b18fe56 commit dfe226c

File tree

74 files changed

+292
-307
lines changed

Some content is hidden

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

74 files changed

+292
-307
lines changed

SlevomatCodingStandard/Helpers/Annotation/MethodAnnotation.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function getMethodReturnType(): ?TypeNode
8383
}
8484

8585
/**
86-
* @return TemplateTagValueNode[]
86+
* @return list<TemplateTagValueNode>
8787
*/
8888
public function getMethodTemplateTypes(): array
8989
{
@@ -93,7 +93,7 @@ public function getMethodTemplateTypes(): array
9393
}
9494

9595
/**
96-
* @return MethodTagValueParameterNode[]
96+
* @return list<MethodTagValueParameterNode>
9797
*/
9898
public function getMethodParameters(): array
9999
{

SlevomatCodingStandard/Helpers/AnnotationHelper.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class AnnotationHelper
9898

9999
/**
100100
* @param VariableAnnotation|ParameterAnnotation|ReturnAnnotation|ThrowsAnnotation|PropertyAnnotation|MethodAnnotation|TemplateAnnotation|ExtendsAnnotation|ImplementsAnnotation|UseAnnotation|MixinAnnotation|TypeAliasAnnotation|TypeImportAnnotation|AssertAnnotation|ParameterOutAnnotation|SelfOutAnnotation $annotation
101-
* @return TypeNode[]
101+
* @return list<TypeNode>
102102
*/
103103
public static function getAnnotationTypes(Annotation $annotation): array
104104
{
@@ -141,7 +141,7 @@ public static function getAnnotationTypes(Annotation $annotation): array
141141

142142
/**
143143
* @param VariableAnnotation|ParameterAnnotation|ReturnAnnotation|ThrowsAnnotation|PropertyAnnotation|MethodAnnotation|TemplateAnnotation|ExtendsAnnotation|ImplementsAnnotation|UseAnnotation|MixinAnnotation|AssertAnnotation|ParameterOutAnnotation|SelfOutAnnotation $annotation
144-
* @return ConstExprNode[]
144+
* @return list<ConstExprNode>
145145
*/
146146
public static function getAnnotationConstantExpressions(Annotation $annotation): array
147147
{
@@ -233,7 +233,7 @@ public static function fixAnnotationConstantFetchNode(
233233
}
234234

235235
/**
236-
* @return (VariableAnnotation|ParameterAnnotation|ReturnAnnotation|ThrowsAnnotation|PropertyAnnotation|MethodAnnotation|TemplateAnnotation|ExtendsAnnotation|ImplementsAnnotation|UseAnnotation|MixinAnnotation|AssertAnnotation|GenericAnnotation|ParameterOutAnnotation|SelfOutAnnotation)[]
236+
* @return list<VariableAnnotation|ParameterAnnotation|ReturnAnnotation|ThrowsAnnotation|PropertyAnnotation|MethodAnnotation|TemplateAnnotation|ExtendsAnnotation|ImplementsAnnotation|UseAnnotation|MixinAnnotation|AssertAnnotation|GenericAnnotation|ParameterOutAnnotation|SelfOutAnnotation>
237237
*/
238238
public static function getAnnotationsByName(File $phpcsFile, int $pointer, string $annotationName): array
239239
{
@@ -243,7 +243,7 @@ public static function getAnnotationsByName(File $phpcsFile, int $pointer, strin
243243
}
244244

245245
/**
246-
* @return (VariableAnnotation|ParameterAnnotation|ReturnAnnotation|ThrowsAnnotation|PropertyAnnotation|MethodAnnotation|TemplateAnnotation|ExtendsAnnotation|ImplementsAnnotation|UseAnnotation|MixinAnnotation|AssertAnnotation|GenericAnnotation|ParameterOutAnnotation|SelfOutAnnotation)[][]
246+
* @return array<string, list<VariableAnnotation|ParameterAnnotation|ReturnAnnotation|ThrowsAnnotation|PropertyAnnotation|MethodAnnotation|TemplateAnnotation|ExtendsAnnotation|ImplementsAnnotation|UseAnnotation|MixinAnnotation|AssertAnnotation|GenericAnnotation|ParameterOutAnnotation|SelfOutAnnotation>>
247247
*/
248248
public static function getAnnotations(File $phpcsFile, int $pointer): array
249249
{

SlevomatCodingStandard/Helpers/AnnotationTypeHelper.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class AnnotationTypeHelper
3939
{
4040

4141
/**
42-
* @return IdentifierTypeNode[]|ThisTypeNode[]
42+
* @return list<IdentifierTypeNode>|list<ThisTypeNode>
4343
*/
4444
public static function getIdentifierTypeNodes(TypeNode $typeNode): array
4545
{
@@ -120,7 +120,7 @@ public static function getIdentifierTypeNodes(TypeNode $typeNode): array
120120
}
121121

122122
/**
123-
* @return ConstTypeNode[]
123+
* @return list<ConstTypeNode>
124124
*/
125125
public static function getConstantTypeNodes(TypeNode $typeNode): array
126126
{
@@ -199,7 +199,7 @@ public static function getConstantTypeNodes(TypeNode $typeNode): array
199199
}
200200

201201
/**
202-
* @return UnionTypeNode[]
202+
* @return list<UnionTypeNode>
203203
*/
204204
public static function getUnionTypeNodes(TypeNode $typeNode): array
205205
{
@@ -275,7 +275,7 @@ public static function getUnionTypeNodes(TypeNode $typeNode): array
275275
}
276276

277277
/**
278-
* @return ArrayTypeNode[]
278+
* @return list<ArrayTypeNode>
279279
*/
280280
public static function getArrayTypeNodes(TypeNode $typeNode): array
281281
{
@@ -831,7 +831,7 @@ public static function getTypeHintFromOneType(
831831
/**
832832
* @param UnionTypeNode|IntersectionTypeNode $typeNode
833833
* @param array<int, string> $traversableTypeHints
834-
* @return string[]
834+
* @return list<string>
835835
*/
836836
public static function getTraversableTypeHintsFromType(
837837
TypeNode $typeNode,

SlevomatCodingStandard/Helpers/ArrayHelper.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class ArrayHelper
2525
protected static $tokens;
2626

2727
/**
28-
* @return ArrayKeyValue[]
28+
* @return list<ArrayKeyValue>
2929
*/
3030
public static function parse(File $phpcsFile, int $pointer): array
3131
{
@@ -109,7 +109,7 @@ public static function parse(File $phpcsFile, int $pointer): array
109109
}
110110

111111
/**
112-
* @param ArrayKeyValue[] $keyValues
112+
* @param list<ArrayKeyValue> $keyValues
113113
*/
114114
public static function getIndentation(array $keyValues): ?string
115115
{
@@ -128,7 +128,7 @@ public static function getIndentation(array $keyValues): ?string
128128
}
129129

130130
/**
131-
* @param ArrayKeyValue[] $keyValues
131+
* @param list<ArrayKeyValue> $keyValues
132132
*/
133133
public static function isKeyed(array $keyValues): bool
134134
{
@@ -141,7 +141,7 @@ public static function isKeyed(array $keyValues): bool
141141
}
142142

143143
/**
144-
* @param ArrayKeyValue[] $keyValues
144+
* @param list<ArrayKeyValue> $keyValues
145145
*/
146146
public static function isKeyedAll(array $keyValues): bool
147147
{
@@ -183,7 +183,7 @@ public static function isNotEmpty(File $phpcsFile, int $pointer): bool
183183
}
184184

185185
/**
186-
* @param ArrayKeyValue[] $keyValues
186+
* @param list<ArrayKeyValue> $keyValues
187187
*/
188188
public static function isSortedByKey(array $keyValues): bool
189189
{

SlevomatCodingStandard/Helpers/CatchHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public static function getTryEndPointer(File $phpcsFile, int $catchPointer): int
3737

3838
/**
3939
* @param array<string, array<int, int|string>|int|string> $catchToken
40-
* @return string[]
40+
* @return list<string>
4141
*/
4242
public static function findCatchedTypesInCatch(File $phpcsFile, array $catchToken): array
4343
{

SlevomatCodingStandard/Helpers/ClassHelper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public static function getAllNames(File $phpcsFile): array
8282
}
8383

8484
/**
85-
* @return int[]
85+
* @return list<int>
8686
*/
8787
public static function getTraitUsePointers(File $phpcsFile, int $classPointer): array
8888
{
@@ -107,7 +107,7 @@ public static function getTraitUsePointers(File $phpcsFile, int $classPointer):
107107
}
108108

109109
/**
110-
* @return array<int>
110+
* @return list<int>
111111
*/
112112
private static function getAllClassPointers(File $phpcsFile): array
113113
{

SlevomatCodingStandard/Helpers/ConstantHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public static function getFullyQualifiedName(File $phpcsFile, int $constantPoint
3636
}
3737

3838
/**
39-
* @return string[]
39+
* @return list<string>
4040
*/
4141
public static function getAllNames(File $phpcsFile): array
4242
{

SlevomatCodingStandard/Helpers/DocCommentHelper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public static function getDocComment(File $phpcsFile, int $pointer): ?string
6464
}
6565

6666
/**
67-
* @return Comment[]|null
67+
* @return list<Comment>|null
6868
*/
6969
public static function getDocCommentDescription(File $phpcsFile, int $pointer): ?array
7070
{
@@ -97,7 +97,7 @@ public static function getDocCommentDescription(File $phpcsFile, int $pointer):
9797
$tokens[$docCommentOpenPointer]['comment_closer'] + 1
9898
);
9999

100-
/** @var Comment[] $comments */
100+
/** @var list<Comment> $comments */
101101
$comments = [];
102102
for ($i = $descriptionStartPointer; $i < $tokenAfterDescriptionPointer; $i++) {
103103
if ($tokens[$i]['code'] !== T_DOC_COMMENT_STRING) {

SlevomatCodingStandard/Helpers/FunctionHelper.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public static function findClassPointer(File $phpcsFile, int $functionPointer):
178178
}
179179

180180
/**
181-
* @return string[]
181+
* @return list<string>
182182
*/
183183
public static function getParametersNames(File $phpcsFile, int $functionPointer): array
184184
{
@@ -197,7 +197,7 @@ public static function getParametersNames(File $phpcsFile, int $functionPointer)
197197
}
198198

199199
/**
200-
* @return (TypeHint|null)[]
200+
* @return array<string, TypeHint|null>
201201
*/
202202
public static function getParametersTypeHints(File $phpcsFile, int $functionPointer): array
203203
{
@@ -324,11 +324,11 @@ public static function hasReturnTypeHint(File $phpcsFile, int $functionPointer):
324324
}
325325

326326
/**
327-
* @return ParameterAnnotation[]
327+
* @return list<ParameterAnnotation>
328328
*/
329329
public static function getParametersAnnotations(File $phpcsFile, int $functionPointer): array
330330
{
331-
/** @var ParameterAnnotation[] $parametersAnnotations */
331+
/** @var list<ParameterAnnotation> $parametersAnnotations */
332332
$parametersAnnotations = AnnotationHelper::getAnnotationsByName($phpcsFile, $functionPointer, '@param');
333333
return $parametersAnnotations;
334334
}
@@ -348,7 +348,7 @@ public static function getValidParametersAnnotations(File $phpcsFile, int $funct
348348
continue;
349349
}
350350

351-
/** @var VariableAnnotation[] $varAnnotations */
351+
/** @var list<VariableAnnotation> $varAnnotations */
352352
$varAnnotations = AnnotationHelper::getAnnotationsByName($phpcsFile, $i, '@var');
353353
if ($varAnnotations === []) {
354354
continue;
@@ -388,7 +388,7 @@ public static function getValidPrefixedParametersAnnotations(File $phpcsFile, in
388388
continue;
389389
}
390390

391-
/** @var VariableAnnotation[] $varAnnotations */
391+
/** @var list<VariableAnnotation> $varAnnotations */
392392
$varAnnotations = AnnotationHelper::getAnnotationsByName($phpcsFile, $i, sprintf('@%s-var', $prefix));
393393
if ($varAnnotations === []) {
394394
continue;
@@ -398,7 +398,7 @@ public static function getValidPrefixedParametersAnnotations(File $phpcsFile, in
398398
}
399399
}
400400

401-
/** @var ParameterAnnotation[] $annotations */
401+
/** @var list<ParameterAnnotation> $annotations */
402402
$annotations = AnnotationHelper::getAnnotationsByName($phpcsFile, $functionPointer, sprintf('@%s-param', $prefix));
403403
foreach ($annotations as $parameterAnnotation) {
404404
if ($parameterAnnotation->getContent() === null) {
@@ -418,7 +418,7 @@ public static function getValidPrefixedParametersAnnotations(File $phpcsFile, in
418418

419419
public static function findReturnAnnotation(File $phpcsFile, int $functionPointer): ?ReturnAnnotation
420420
{
421-
/** @var ReturnAnnotation[] $returnAnnotations */
421+
/** @var list<ReturnAnnotation> $returnAnnotations */
422422
$returnAnnotations = AnnotationHelper::getAnnotationsByName($phpcsFile, $functionPointer, '@return');
423423

424424
if (count($returnAnnotations) === 0) {
@@ -429,14 +429,14 @@ public static function findReturnAnnotation(File $phpcsFile, int $functionPointe
429429
}
430430

431431
/**
432-
* @return ReturnAnnotation[]
432+
* @return list<ReturnAnnotation>
433433
*/
434434
public static function getValidPrefixedReturnAnnotations(File $phpcsFile, int $functionPointer): array
435435
{
436436
$returnAnnotations = [];
437437

438438
foreach (AnnotationHelper::STATIC_ANALYSIS_PREFIXES as $prefix) {
439-
/** @var ReturnAnnotation[] $annotations */
439+
/** @var list<ReturnAnnotation> $annotations */
440440
$annotations = AnnotationHelper::getAnnotationsByName($phpcsFile, $functionPointer, sprintf('@%s-return', $prefix));
441441
foreach ($annotations as $annotation) {
442442
if (!$annotation->isInvalid()) {
@@ -450,7 +450,7 @@ public static function getValidPrefixedReturnAnnotations(File $phpcsFile, int $f
450450
}
451451

452452
/**
453-
* @return string[]
453+
* @return list<string>
454454
*/
455455
public static function getAllFunctionNames(File $phpcsFile): array
456456
{

SlevomatCodingStandard/Helpers/IndentationHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public static function getOneIndentationLevel(string $identation): string
4848
}
4949

5050
/**
51-
* @param int[] $codePointers
51+
* @param list<int> $codePointers
5252
*/
5353
public static function fixIndentation(File $phpcsFile, array $codePointers, string $defaultIndentation): string
5454
{

0 commit comments

Comments
 (0)