Skip to content

Commit 87c6971

Browse files
SanderMullerclaude
andcommitted
Assert the native types of array_map() callback parameters
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent 6b00283 commit 87c6971

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎tests/PHPStan/Analyser/nsrt/bug-13217.php‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Bug13217;
44

5+
use function PHPStan\Testing\assertNativeType;
56
use function PHPStan\Testing\assertType;
67

78
class Foo
@@ -12,6 +13,8 @@ public function shorterSecondArray(): void
1213
array_map(function ($a, $b) {
1314
assertType('1|2', $a);
1415
assertType('3|null', $b);
16+
assertNativeType('1|2', $a);
17+
assertNativeType('3|null', $b);
1518
}, [1, 2], [3]);
1619

1720
array_map(fn ($a, $b) => assertType('3|null', $b), [1, 2], [3]);
@@ -24,6 +27,8 @@ public function shorterFirstArray(): void
2427
array_map(function ($a, $b) {
2528
assertType('1|null', $a);
2629
assertType('3|4', $b);
30+
assertNativeType('1|null', $a);
31+
assertNativeType('3|4', $b);
2732
}, [1], [3, 4]);
2833
}
2934

@@ -43,6 +48,8 @@ public function sizeRange(array $maybe): void
4348
array_map(function ($a, $b) {
4449
assertType('1|2|null', $a);
4550
assertType('3|4|5', $b);
51+
assertNativeType('mixed', $a);
52+
assertNativeType('3|4|5', $b);
4653
}, $maybe, [3, 4, 5]);
4754

4855
array_map(function ($a, $b) {

0 commit comments

Comments
 (0)