Skip to content

Commit 98de49b

Browse files
committed
Don't report "no value type specified in iterable type array&callable"
1 parent c8106c3 commit 98de49b

3 files changed

Lines changed: 28 additions & 0 deletions

File tree

src/Rules/MissingTypehintCheck.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ public function getIterableTypesWithMissingValueTypehint(Type $type): array
7373
if ($type instanceof AccessoryType) {
7474
return $type;
7575
}
76+
if ($type->isCallable()->yes() && $type->isArray()->yes()) {
77+
return $type;
78+
}
7679
if ($type instanceof ConditionalType || $type instanceof ConditionalTypeForParameter) {
7780
$iterablesWithMissingValueTypehint = array_merge(
7881
$iterablesWithMissingValueTypehint,

tests/PHPStan/Rules/Methods/MissingMethodParameterTypehintRuleTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,4 +148,14 @@ public function testBug7662(): void
148148
]);
149149
}
150150

151+
public function testBug14549(): void
152+
{
153+
$this->analyse([__DIR__ . '/data/bug-14549.php'], [
154+
[
155+
'Method Bug14549\MondayMorning::call() has parameter $task with no signature specified for callable.',
156+
10
157+
]
158+
]);
159+
}
160+
151161
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace Bug14549;
4+
5+
class MondayMorning
6+
{
7+
/**
8+
* @param callable-array $task
9+
*/
10+
public function call(array $task): void
11+
{
12+
}
13+
}
14+
15+

0 commit comments

Comments
 (0)