Skip to content

Commit d80d711

Browse files
committed
align unit tests for new generic Iterable checks
1 parent e262f13 commit d80d711

File tree

6 files changed

+20
-5
lines changed

6 files changed

+20
-5
lines changed

stubs/runtime/ReflectionAttribute.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,16 @@ public function isRepeated(): bool
2222
{
2323
}
2424

25+
/**
26+
* @return array<array-key, mixed>;
27+
*/
2528
public function getArguments(): array
2629
{
2730
}
2831

32+
/**
33+
* @return self
34+
*/
2935
public function newInstance(): object
3036
{
3137
}

tests/PHPStan/Analyser/nsrt/bug-8886.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ function testPDOStatementGetIterator(): void {
99
$pdo = new PDO('sqlite::memory:');
1010
$stmt = $pdo->query('SELECT 1');
1111

12-
assertType('Iterator', $stmt->getIterator());
12+
assertType('Iterator<mixed, array<int|string, mixed>>', $stmt->getIterator());
1313
}

tests/PHPStan/Rules/Classes/MixinRuleTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ public function testRule(): void
6868
'PHPDoc tag @mixin contains generic class ReflectionClass but does not specify its types: T',
6969
50,
7070
],
71+
[
72+
'PHPDoc tag @mixin contains generic interface Iterator but does not specify its types: TKey, TValue',
73+
50,
74+
],
7175
[
7276
'PHPDoc tag @mixin contains unknown class MixinRule\UnknownestClass.',
7377
50,

tests/PHPStan/Rules/Functions/MissingFunctionParameterTypehintRuleTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ public function testRule(): void
7171
148,
7272
MissingTypehintCheck::MISSING_ITERABLE_VALUE_TYPE_TIP,
7373
],
74+
[
75+
'Function MissingFunctionParameterTypehint\missingTraversableTypehint() has parameter $traversable with generic interface Traversable but does not specify its types: TKey, TValu',
76+
148,
77+
MissingTypehintCheck::MISSING_ITERABLE_VALUE_TYPE_TIP,
78+
],
7479
[
7580
'Function MissingFunctionParameterTypehint\missingTraversableTypehintPhpDoc() has parameter $traversable with no value type specified in iterable type Traversable.',
7681
156,

tests/PHPStan/Rules/Functions/data/missing-function-parameter-typehint.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ function unionTypeWithUnknownArrayValueTypehint($a)
6363
}
6464

6565
/**
66-
* @param iterable<int>&\Traversable $a
66+
* @param iterable<int>&\Traversable<array-key,int> $a
6767
*/
6868
function iterableIntersectionTypehint($a)
6969
{
7070

7171
}
7272

7373
/**
74-
* @param iterable<mixed>&\Traversable $a
74+
* @param iterable<mixed>&\Traversable<array-key,mixed> $a
7575
*/
7676
function iterableIntersectionTypehint2($a)
7777
{
@@ -151,7 +151,7 @@ function missingTraversableTypehint(\Traversable $traversable)
151151
}
152152

153153
/**
154-
* @param \Traversable $traversable
154+
* @param \Traversable<array-key, mixed> $traversable
155155
*/
156156
function missingTraversableTypehintPhpDoc($traversable)
157157
{

tests/PHPStan/Rules/Methods/data/missing-method-return-typehint.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public function doFoo(): callable
106106
class IterableIntersection
107107
{
108108

109-
/** @return FooInterface[]|\Traversable */
109+
/** @return FooInterface[]|\Traversable<array-key, FooInterface> */
110110
public function doFoo(): \Traversable
111111
{
112112

0 commit comments

Comments
 (0)