Skip to content

Commit 24bbb81

Browse files
committed
do not skip generic iterables for MissingTypehintCheck on bleeding edge
1 parent 94e36ac commit 24bbb81

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

conf/bleedingEdge.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ parameters:
99
internalTag: true
1010
newStaticInAbstractClassStaticMethod: true
1111
checkExtensionsForComparisonOperators: true
12+
checkGenericIterableClasses: true

conf/config.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ parameters:
3333
internalTag: false
3434
newStaticInAbstractClassStaticMethod: false
3535
checkExtensionsForComparisonOperators: false
36+
checkGenericIterableClasses: false
3637
fileExtensions:
3738
- php
3839
checkAdvancedIsset: false

conf/parametersSchema.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ parametersSchema:
3636
internalTag: bool()
3737
newStaticInAbstractClassStaticMethod: bool()
3838
checkExtensionsForComparisonOperators: bool()
39+
checkGenericIterableClasses: bool()
3940
])
4041
fileExtensions: listOf(string())
4142
checkAdvancedIsset: bool()

src/Rules/MissingTypehintCheck.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ final class MissingTypehintCheck
4343
Traversable::class,
4444
Iterator::class,
4545
IteratorAggregate::class,
46-
//Generator::class,
46+
Generator::class,
4747
];
4848

4949
/**
@@ -54,6 +54,8 @@ public function __construct(
5454
private bool $checkMissingCallableSignature,
5555
#[AutowiredParameter(ref: '%featureToggles.skipCheckGenericClasses%')]
5656
private array $skipCheckGenericClasses,
57+
#[AutowiredParameter(ref: '%featureToggles.checkGenericIterableClasses%')]
58+
private bool $checkGenericIterableClasses,
5759
)
5860
{
5961
}
@@ -118,7 +120,10 @@ public function getNonGenericObjectTypesWithGenericClass(Type $type): array
118120
if ($classReflection === null) {
119121
return $type;
120122
}
121-
if (in_array($classReflection->getName(), self::ITERABLE_GENERIC_CLASS_NAMES, true)) {
123+
if (
124+
$this->checkGenericIterableClasses !== true &&
125+
in_array($classReflection->getName(), self::ITERABLE_GENERIC_CLASS_NAMES, true)
126+
) {
122127
// checked by getIterableTypesWithMissingValueTypehint() already
123128
return $type;
124129
}

0 commit comments

Comments
 (0)