Skip to content

Commit 392f090

Browse files
committed
These can be a native return type thanks to PHP 7.4 return type covariance
1 parent ec6fbe2 commit 392f090

27 files changed

+42
-118
lines changed

Diff for: src/Dependency/ExportedNode/ExportedAttributeNode.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@ public function equals(ExportedNode $node): bool
4545

4646
/**
4747
* @param mixed[] $properties
48-
* @return self
4948
*/
50-
public static function __set_state(array $properties): ExportedNode
49+
public static function __set_state(array $properties): self
5150
{
5251
return new self(
5352
$properties['name'],
@@ -72,9 +71,8 @@ public function jsonSerialize()
7271

7372
/**
7473
* @param mixed[] $data
75-
* @return self
7674
*/
77-
public static function decode(array $data): ExportedNode
75+
public static function decode(array $data): self
7876
{
7977
return new self(
8078
$data['name'],

Diff for: src/Dependency/ExportedNode/ExportedClassConstantNode.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@ public function equals(ExportedNode $node): bool
4545

4646
/**
4747
* @param mixed[] $properties
48-
* @return self
4948
*/
50-
public static function __set_state(array $properties): ExportedNode
49+
public static function __set_state(array $properties): self
5150
{
5251
return new self(
5352
$properties['name'],
@@ -58,9 +57,8 @@ public static function __set_state(array $properties): ExportedNode
5857

5958
/**
6059
* @param mixed[] $data
61-
* @return self
6260
*/
63-
public static function decode(array $data): ExportedNode
61+
public static function decode(array $data): self
6462
{
6563
return new self(
6664
$data['name'],

Diff for: src/Dependency/ExportedNode/ExportedClassConstantsNode.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,8 @@ public function equals(ExportedNode $node): bool
5454

5555
/**
5656
* @param mixed[] $properties
57-
* @return self
5857
*/
59-
public static function __set_state(array $properties): ExportedNode
58+
public static function __set_state(array $properties): self
6059
{
6160
return new self(
6261
$properties['constants'],
@@ -69,9 +68,8 @@ public static function __set_state(array $properties): ExportedNode
6968

7069
/**
7170
* @param mixed[] $data
72-
* @return self
7371
*/
74-
public static function decode(array $data): ExportedNode
72+
public static function decode(array $data): self
7573
{
7674
return new self(
7775
array_map(static function (array $constantData): ExportedClassConstantNode {

Diff for: src/Dependency/ExportedNode/ExportedClassNode.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,8 @@ public function equals(ExportedNode $node): bool
9696

9797
/**
9898
* @param mixed[] $properties
99-
* @return self
10099
*/
101-
public static function __set_state(array $properties): ExportedNode
100+
public static function __set_state(array $properties): self
102101
{
103102
return new self(
104103
$properties['name'],
@@ -139,9 +138,8 @@ public function jsonSerialize()
139138

140139
/**
141140
* @param mixed[] $data
142-
* @return self
143141
*/
144-
public static function decode(array $data): ExportedNode
142+
public static function decode(array $data): self
145143
{
146144
return new self(
147145
$data['name'],

Diff for: src/Dependency/ExportedNode/ExportedEnumCaseNode.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@ public function equals(ExportedNode $node): bool
3737

3838
/**
3939
* @param mixed[] $properties
40-
* @return self
4140
*/
42-
public static function __set_state(array $properties): ExportedNode
41+
public static function __set_state(array $properties): self
4342
{
4443
return new self(
4544
$properties['name'],
@@ -50,9 +49,8 @@ public static function __set_state(array $properties): ExportedNode
5049

5150
/**
5251
* @param mixed[] $data
53-
* @return self
5452
*/
55-
public static function decode(array $data): ExportedNode
53+
public static function decode(array $data): self
5654
{
5755
return new self(
5856
$data['name'],

Diff for: src/Dependency/ExportedNode/ExportedEnumNode.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,8 @@ public function equals(ExportedNode $node): bool
7676

7777
/**
7878
* @param mixed[] $properties
79-
* @return self
8079
*/
81-
public static function __set_state(array $properties): ExportedNode
80+
public static function __set_state(array $properties): self
8281
{
8382
return new self(
8483
$properties['name'],
@@ -111,9 +110,8 @@ public function jsonSerialize()
111110

112111
/**
113112
* @param mixed[] $data
114-
* @return self
115113
*/
116-
public static function decode(array $data): ExportedNode
114+
public static function decode(array $data): self
117115
{
118116
return new self(
119117
$data['name'],

Diff for: src/Dependency/ExportedNode/ExportedFunctionNode.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,8 @@ public function equals(ExportedNode $node): bool
7474

7575
/**
7676
* @param mixed[] $properties
77-
* @return self
7877
*/
79-
public static function __set_state(array $properties): ExportedNode
78+
public static function __set_state(array $properties): self
8079
{
8180
return new self(
8281
$properties['name'],
@@ -109,9 +108,8 @@ public function jsonSerialize()
109108

110109
/**
111110
* @param mixed[] $data
112-
* @return self
113111
*/
114-
public static function decode(array $data): ExportedNode
112+
public static function decode(array $data): self
115113
{
116114
return new self(
117115
$data['name'],

Diff for: src/Dependency/ExportedNode/ExportedInterfaceNode.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,8 @@ public function equals(ExportedNode $node): bool
5656

5757
/**
5858
* @param mixed[] $properties
59-
* @return self
6059
*/
61-
public static function __set_state(array $properties): ExportedNode
60+
public static function __set_state(array $properties): self
6261
{
6362
return new self(
6463
$properties['name'],
@@ -87,9 +86,8 @@ public function jsonSerialize()
8786

8887
/**
8988
* @param mixed[] $data
90-
* @return self
9189
*/
92-
public static function decode(array $data): ExportedNode
90+
public static function decode(array $data): self
9391
{
9492
return new self(
9593
$data['name'],

Diff for: src/Dependency/ExportedNode/ExportedMethodNode.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,8 @@ public function equals(ExportedNode $node): bool
8383

8484
/**
8585
* @param mixed[] $properties
86-
* @return self
8786
*/
88-
public static function __set_state(array $properties): ExportedNode
87+
public static function __set_state(array $properties): self
8988
{
9089
return new self(
9190
$properties['name'],
@@ -128,9 +127,8 @@ public function jsonSerialize()
128127

129128
/**
130129
* @param mixed[] $data
131-
* @return self
132130
*/
133-
public static function decode(array $data): ExportedNode
131+
public static function decode(array $data): self
134132
{
135133
return new self(
136134
$data['name'],

Diff for: src/Dependency/ExportedNode/ExportedParameterNode.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,8 @@ public function equals(ExportedNode $node): bool
5151

5252
/**
5353
* @param mixed[] $properties
54-
* @return self
5554
*/
56-
public static function __set_state(array $properties): ExportedNode
55+
public static function __set_state(array $properties): self
5756
{
5857
return new self(
5958
$properties['name'],
@@ -86,9 +85,8 @@ public function jsonSerialize()
8685

8786
/**
8887
* @param mixed[] $data
89-
* @return self
9088
*/
91-
public static function decode(array $data): ExportedNode
89+
public static function decode(array $data): self
9290
{
9391
return new self(
9492
$data['name'],

Diff for: src/Dependency/ExportedNode/ExportedPhpDocNode.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,16 @@ public function jsonSerialize()
4848

4949
/**
5050
* @param mixed[] $properties
51-
* @return self
5251
*/
53-
public static function __set_state(array $properties): ExportedNode
52+
public static function __set_state(array $properties): self
5453
{
5554
return new self($properties['phpDocString'], $properties['namespace'], $properties['uses'], $properties['constUses'] ?? []);
5655
}
5756

5857
/**
5958
* @param mixed[] $data
60-
* @return self
6159
*/
62-
public static function decode(array $data): ExportedNode
60+
public static function decode(array $data): self
6361
{
6462
return new self($data['phpDocString'], $data['namespace'], $data['uses'], $data['constUses'] ?? []);
6563
}

Diff for: src/Dependency/ExportedNode/ExportedPropertiesNode.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,8 @@ public function equals(ExportedNode $node): bool
7676

7777
/**
7878
* @param mixed[] $properties
79-
* @return self
8079
*/
81-
public static function __set_state(array $properties): ExportedNode
80+
public static function __set_state(array $properties): self
8281
{
8382
return new self(
8483
$properties['names'],
@@ -94,9 +93,8 @@ public static function __set_state(array $properties): ExportedNode
9493

9594
/**
9695
* @param mixed[] $data
97-
* @return self
9896
*/
99-
public static function decode(array $data): ExportedNode
97+
public static function decode(array $data): self
10098
{
10199
return new self(
102100
$data['names'],

Diff for: src/Dependency/ExportedNode/ExportedTraitNode.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,16 @@ public function equals(ExportedNode $node): bool
2121

2222
/**
2323
* @param mixed[] $properties
24-
* @return self
2524
*/
26-
public static function __set_state(array $properties): ExportedNode
25+
public static function __set_state(array $properties): self
2726
{
2827
return new self($properties['traitName']);
2928
}
3029

3130
/**
3231
* @param mixed[] $data
33-
* @return self
3432
*/
35-
public static function decode(array $data): ExportedNode
33+
public static function decode(array $data): self
3634
{
3735
return new self($data['traitName']);
3836
}

Diff for: src/Dependency/ExportedNode/ExportedTraitUseAdaptation.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,8 @@ public function equals(ExportedNode $node): bool
5959

6060
/**
6161
* @param mixed[] $properties
62-
* @return self
6362
*/
64-
public static function __set_state(array $properties): ExportedNode
63+
public static function __set_state(array $properties): self
6564
{
6665
return new self(
6766
$properties['traitName'],
@@ -74,9 +73,8 @@ public static function __set_state(array $properties): ExportedNode
7473

7574
/**
7675
* @param mixed[] $data
77-
* @return self
7876
*/
79-
public static function decode(array $data): ExportedNode
77+
public static function decode(array $data): self
8078
{
8179
return new self(
8280
$data['traitName'],

Diff for: src/PhpDoc/Tag/ParamClosureThisTag.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ public function getType(): Type
2121
return $this->type;
2222
}
2323

24-
/**
25-
* @return self
26-
*/
27-
public function withType(Type $type): TypedTag
24+
public function withType(Type $type): self
2825
{
2926
return new self($type);
3027
}

Diff for: src/PhpDoc/Tag/ParamOutTag.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ public function getType(): Type
1919
return $this->type;
2020
}
2121

22-
/**
23-
* @return self
24-
*/
25-
public function withType(Type $type): TypedTag
22+
public function withType(Type $type): self
2623
{
2724
return new self($type);
2825
}

Diff for: src/PhpDoc/Tag/ParamTag.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ public function isVariadic(): bool
2727
return $this->isVariadic;
2828
}
2929

30-
/**
31-
* @return self
32-
*/
33-
public function withType(Type $type): TypedTag
30+
public function withType(Type $type): self
3431
{
3532
return new self($type, $this->isVariadic);
3633
}

Diff for: src/PhpDoc/Tag/ReturnTag.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ public function isExplicit(): bool
2424
return $this->isExplicit;
2525
}
2626

27-
/**
28-
* @return self
29-
*/
30-
public function withType(Type $type): TypedTag
27+
public function withType(Type $type): self
3128
{
3229
return new self($type, $this->isExplicit);
3330
}

Diff for: src/PhpDoc/Tag/SelfOutTypeTag.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ public function getType(): Type
1919
return $this->type;
2020
}
2121

22-
/**
23-
* @return self
24-
*/
25-
public function withType(Type $type): TypedTag
22+
public function withType(Type $type): self
2623
{
2724
return new self($type);
2825
}

Diff for: src/PhpDoc/Tag/VarTag.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ public function getType(): Type
1919
return $this->type;
2020
}
2121

22-
/**
23-
* @return self
24-
*/
25-
public function withType(Type $type): TypedTag
22+
public function withType(Type $type): self
2623
{
2724
return new self($type);
2825
}

Diff for: src/Reflection/Annotations/AnnotationsMethodsClassReflectionExtension.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use PHPStan\PhpDoc\Tag\TemplateTag;
66
use PHPStan\Reflection\ClassReflection;
77
use PHPStan\Reflection\ExtendedMethodReflection;
8-
use PHPStan\Reflection\MethodReflection;
98
use PHPStan\Reflection\MethodsClassReflectionExtension;
109
use PHPStan\Type\Generic\TemplateTypeFactory;
1110
use PHPStan\Type\Generic\TemplateTypeHelper;
@@ -35,10 +34,7 @@ public function hasMethod(ClassReflection $classReflection, string $methodName):
3534
return isset($this->methods[$classReflection->getCacheKey()][$methodName]);
3635
}
3736

38-
/**
39-
* @return ExtendedMethodReflection
40-
*/
41-
public function getMethod(ClassReflection $classReflection, string $methodName): MethodReflection
37+
public function getMethod(ClassReflection $classReflection, string $methodName): ExtendedMethodReflection
4238
{
4339
return $this->methods[$classReflection->getCacheKey()][$methodName];
4440
}

0 commit comments

Comments
 (0)