Skip to content

Commit a805b84

Browse files
authored
Added regression tests (#5050)
1 parent 5b79cca commit a805b84

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2711,4 +2711,23 @@ public function testBug14012(): void
27112711
$this->analyse([__DIR__ . '/../Properties/data/bug-14012.php'], []);
27122712
}
27132713

2714+
public function testBug11534(): void
2715+
{
2716+
$this->checkExplicitMixed = true;
2717+
$this->checkImplicitMixed = true;
2718+
$this->analyse([__DIR__ . '/data/bug-11534.php'], [
2719+
[
2720+
'Parameter #2 $param2 of function Bug11534\hello expects int, mixed given.',
2721+
14,
2722+
],
2723+
]);
2724+
}
2725+
2726+
public function testBug10559(): void
2727+
{
2728+
$this->checkExplicitMixed = true;
2729+
$this->checkImplicitMixed = true;
2730+
$this->analyse([__DIR__ . '/data/bug-10559.php'], []);
2731+
}
2732+
27142733
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace Bug10559;
4+
5+
/** @var mixed[] $arr1 */
6+
$arr1 = [
7+
'a1' => 1,
8+
'b1' => '2',
9+
'c1' => 3.3,
10+
];
11+
// There is no error
12+
echo (string)$arr1['c1'];
13+
14+
15+
/** @var mixed[] $arr2 */
16+
$arr2 = [
17+
'a1' => 1,
18+
'b1' => '2',
19+
'c1' => 3.3,
20+
];
21+
if ($arr2['a1'] > 1) {}
22+
echo (string)$arr2['c1'];
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace Bug11534;
4+
5+
function hello(int $param1, int $param2): void
6+
{
7+
}
8+
/** @param mixed[] $params */
9+
function world(array $params): void
10+
{
11+
if (!is_int($params['param1'])) {
12+
throw new \Exception();
13+
}
14+
hello($params['param1'], $params['param2']);
15+
}

0 commit comments

Comments
 (0)