Skip to content

Commit 50d0c8e

Browse files
committed
Bleeding edge - checkMissingIterableValueType: false no longer does anything
This setting stopped being useful a while ago thanks to this commit: 0808a89 The effect of this commit was: phpstan/phpstan@e733d1b While checking missing iterable value type continues to be useful for arrays, it no longer does anything for objects. Instead, first party classes will continue to report missing `@implements` for IteratorAggregate interface etc.
1 parent f88ec43 commit 50d0c8e

18 files changed

+40
-33
lines changed

conf/bleedingEdge.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ parameters:
1010
nodeConnectingVisitorRule: true
1111
disableRuntimeReflectionProvider: true
1212
illegalConstructorMethodCall: true
13+
disableCheckMissingIterableValueType: true

conf/config.neon

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ parameters:
3434
nodeConnectingVisitorCompatibility: true
3535
nodeConnectingVisitorRule: false
3636
illegalConstructorMethodCall: false
37+
disableCheckMissingIterableValueType: false
3738
fileExtensions:
3839
- php
3940
checkAdvancedIsset: false
@@ -223,6 +224,7 @@ parametersSchema:
223224
nodeConnectingVisitorCompatibility: bool(),
224225
nodeConnectingVisitorRule: bool(),
225226
illegalConstructorMethodCall: bool(),
227+
disableCheckMissingIterableValueType: bool(),
226228
])
227229
fileExtensions: listOf(string())
228230
checkAdvancedIsset: bool()
@@ -907,6 +909,7 @@ services:
907909
class: PHPStan\Rules\MissingTypehintCheck
908910
arguments:
909911
checkMissingIterableValueType: %checkMissingIterableValueType%
912+
disableCheckMissingIterableValueType: %featureToggles.disableCheckMissingIterableValueType%
910913
checkGenericClassInNonGenericObjectType: %checkGenericClassInNonGenericObjectType%
911914
checkMissingCallableSignature: %checkMissingCallableSignature%
912915
skipCheckGenericClasses: %featureToggles.skipCheckGenericClasses%

src/Rules/Constants/MissingClassConstantTypehintRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ private function processSingleConstant(ClassReflection $classReflection, string
6161
$constantReflection->getDeclaringClass()->getDisplayName(),
6262
$constantName,
6363
$iterableTypeDescription,
64-
))->tip(MissingTypehintCheck::TURN_OFF_MISSING_ITERABLE_VALUE_TYPE_TIP)->build();
64+
))->tip(MissingTypehintCheck::MISSING_ITERABLE_VALUE_TYPE_TIP)->build();
6565
}
6666

6767
foreach ($this->missingTypehintCheck->getNonGenericObjectTypesWithGenericClass($constantType) as [$name, $genericTypeNames]) {

src/Rules/Functions/MissingFunctionParameterTypehintRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ private function checkFunctionParameter(FunctionReflection $functionReflection,
7878
$functionReflection->getName(),
7979
$parameterReflection->getName(),
8080
$iterableTypeDescription,
81-
))->tip(MissingTypehintCheck::TURN_OFF_MISSING_ITERABLE_VALUE_TYPE_TIP)->build();
81+
))->tip(MissingTypehintCheck::MISSING_ITERABLE_VALUE_TYPE_TIP)->build();
8282
}
8383

8484
foreach ($this->missingTypehintCheck->getNonGenericObjectTypesWithGenericClass($parameterType) as [$name, $genericTypeNames]) {

src/Rules/Functions/MissingFunctionReturnTypehintRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function processNode(Node $node, Scope $scope): array
5353
$messages = [];
5454
foreach ($this->missingTypehintCheck->getIterableTypesWithMissingValueTypehint($returnType) as $iterableType) {
5555
$iterableTypeDescription = $iterableType->describe(VerbosityLevel::typeOnly());
56-
$messages[] = RuleErrorBuilder::message(sprintf('Function %s() return type has no value type specified in iterable type %s.', $functionReflection->getName(), $iterableTypeDescription))->tip(MissingTypehintCheck::TURN_OFF_MISSING_ITERABLE_VALUE_TYPE_TIP)->build();
56+
$messages[] = RuleErrorBuilder::message(sprintf('Function %s() return type has no value type specified in iterable type %s.', $functionReflection->getName(), $iterableTypeDescription))->tip(MissingTypehintCheck::MISSING_ITERABLE_VALUE_TYPE_TIP)->build();
5757
}
5858

5959
foreach ($this->missingTypehintCheck->getNonGenericObjectTypesWithGenericClass($returnType) as [$name, $genericTypeNames]) {

src/Rules/Methods/MissingMethodParameterTypehintRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ private function checkMethodParameter(MethodReflection $methodReflection, Parame
7777
$methodReflection->getName(),
7878
$parameterReflection->getName(),
7979
$iterableTypeDescription,
80-
))->tip(MissingTypehintCheck::TURN_OFF_MISSING_ITERABLE_VALUE_TYPE_TIP)->build();
80+
))->tip(MissingTypehintCheck::MISSING_ITERABLE_VALUE_TYPE_TIP)->build();
8181
}
8282

8383
foreach ($this->missingTypehintCheck->getNonGenericObjectTypesWithGenericClass($parameterType) as [$name, $genericTypeNames]) {

src/Rules/Methods/MissingMethodReturnTypehintRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function processNode(Node $node, Scope $scope): array
5757
$methodReflection->getDeclaringClass()->getDisplayName(),
5858
$methodReflection->getName(),
5959
$iterableTypeDescription,
60-
))->tip(MissingTypehintCheck::TURN_OFF_MISSING_ITERABLE_VALUE_TYPE_TIP)->build();
60+
))->tip(MissingTypehintCheck::MISSING_ITERABLE_VALUE_TYPE_TIP)->build();
6161
}
6262

6363
foreach ($this->missingTypehintCheck->getNonGenericObjectTypesWithGenericClass($returnType) as [$name, $genericTypeNames]) {

src/Rules/MissingTypehintCheck.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
class MissingTypehintCheck
2828
{
2929

30-
public const TURN_OFF_MISSING_ITERABLE_VALUE_TYPE_TIP = 'See: https://phpstan.org/blog/solving-phpstan-no-value-type-specified-in-iterable-type';
30+
public const MISSING_ITERABLE_VALUE_TYPE_TIP = 'See: https://phpstan.org/blog/solving-phpstan-no-value-type-specified-in-iterable-type';
3131

3232
public const TURN_OFF_NON_GENERIC_CHECK_TIP = 'You can turn this off by setting <fg=cyan>checkGenericClassInNonGenericObjectType: false</> in your <fg=cyan>%configurationFile%</>.';
3333

@@ -43,6 +43,7 @@ class MissingTypehintCheck
4343
*/
4444
public function __construct(
4545
private ReflectionProvider $reflectionProvider,
46+
private bool $disableCheckMissingIterableValueType,
4647
private bool $checkMissingIterableValueType,
4748
private bool $checkGenericClassInNonGenericObjectType,
4849
private bool $checkMissingCallableSignature,
@@ -57,7 +58,9 @@ public function __construct(
5758
public function getIterableTypesWithMissingValueTypehint(Type $type): array
5859
{
5960
if (!$this->checkMissingIterableValueType) {
60-
return [];
61+
if (!$this->disableCheckMissingIterableValueType) {
62+
return [];
63+
}
6164
}
6265

6366
$iterablesWithMissingValueTypehint = [];

src/Rules/PhpDoc/InvalidPhpDocVarTagTypeRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function processNode(Node $node, Scope $scope): array
9090
'%s has no value type specified in iterable type %s.',
9191
$identifier,
9292
$iterableTypeDescription,
93-
))->tip(MissingTypehintCheck::TURN_OFF_MISSING_ITERABLE_VALUE_TYPE_TIP)->build();
93+
))->tip(MissingTypehintCheck::MISSING_ITERABLE_VALUE_TYPE_TIP)->build();
9494
}
9595
}
9696

src/Rules/Properties/MissingPropertyTypehintRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function processNode(Node $node, Scope $scope): array
5555
$propertyReflection->getDeclaringClass()->getDisplayName(),
5656
$node->getName(),
5757
$iterableTypeDescription,
58-
))->tip(MissingTypehintCheck::TURN_OFF_MISSING_ITERABLE_VALUE_TYPE_TIP)->build();
58+
))->tip(MissingTypehintCheck::MISSING_ITERABLE_VALUE_TYPE_TIP)->build();
5959
}
6060

6161
foreach ($this->missingTypehintCheck->getNonGenericObjectTypesWithGenericClass($propertyType) as [$name, $genericTypeNames]) {

0 commit comments

Comments
 (0)