Skip to content

Commit aa697c8

Browse files
phpstan-botclaude
andcommitted
Test that a repeated missing iterable value type is reported once regardless of Type instance sharing
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent a4139ac commit aa697c8

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

‎tests/PHPStan/Rules/Methods/MissingMethodParameterTypehintRuleTest.php‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,22 @@ public function testBug14549(): void
163163
]);
164164
}
165165

166+
public function testRepeatedIterableTypeReportedOnce(): void
167+
{
168+
// the same missing value type is reported once per parameter,
169+
// regardless of whether the occurrences share a Type instance (type alias) or not
170+
$this->analyse([__DIR__ . '/data/missing-iterable-value-type-repeated.php'], [
171+
[
172+
'Method MissingIterableValueTypeRepeated\\Foo::inline() has parameter $a with no value type specified in iterable type array.',
173+
14,
174+
MissingTypehintCheck::MISSING_ITERABLE_VALUE_TYPE_TIP,
175+
],
176+
[
177+
'Method MissingIterableValueTypeRepeated\\Foo::alias() has parameter $a with no value type specified in iterable type array.',
178+
21,
179+
MissingTypehintCheck::MISSING_ITERABLE_VALUE_TYPE_TIP,
180+
],
181+
]);
182+
}
183+
166184
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace MissingIterableValueTypeRepeated;
4+
5+
/**
6+
* @phpstan-type BareArr array
7+
*/
8+
class Foo
9+
{
10+
11+
/**
12+
* @param callable(array): array $a
13+
*/
14+
public function inline($a): void
15+
{
16+
}
17+
18+
/**
19+
* @param callable(BareArr): BareArr $a
20+
*/
21+
public function alias($a): void
22+
{
23+
}
24+
25+
}

0 commit comments

Comments
 (0)