Skip to content

Commit 7dfd9e0

Browse files
committed
assert errors on optional but wrong value types
1 parent 9b5349b commit 7dfd9e0

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2488,4 +2488,16 @@ public function testBug13862b(): void
24882488
$this->analyse([__DIR__ . '/data/bug-13862b.php'], []);
24892489
}
24902490

2491+
#[RequiresPhp('>= 8.1')]
2492+
public function testBug13862c(): void
2493+
{
2494+
$this->analyse([__DIR__ . '/data/bug-13862c.php'], [
2495+
[
2496+
'Parameter #2 $options of function curl_setopt_array expects array{10022?: non-empty-string}, array{}|array{10022: 123} given.',
2497+
12,
2498+
'Offset 10022 (non-empty-string) does not accept type 123.',
2499+
],
2500+
]);
2501+
}
2502+
24912503
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace Bug13862c;
4+
5+
$options = [];
6+
7+
if (rand()) {
8+
$options[CURLOPT_COOKIE] = 123;
9+
}
10+
11+
$ch = curl_init();
12+
curl_setopt_array($ch, $options);

0 commit comments

Comments
 (0)