Skip to content

Commit 4778221

Browse files
committed
added test
1 parent c6704ad commit 4778221

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2718,9 +2718,16 @@ public function testBug11534(): void
27182718
$this->analyse([__DIR__ . '/data/bug-11534.php'], [
27192719
[
27202720
'Parameter #2 $param2 of function Bug11534\hello expects int, mixed given.',
2721-
14
2722-
]
2721+
14,
2722+
],
27232723
]);
27242724
}
27252725

2726+
public function testBug10559(): void
2727+
{
2728+
$this->checkExplicitMixed = true;
2729+
$this->checkImplicitMixed = true;
2730+
$this->analyse([__DIR__ . '/data/bug-10559.php'], []);
2731+
}
2732+
27262733
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
// !!! There is error "Cannot cast mixed to string." on next line if "checkImplicitMixed: true"
23+
echo (string)$arr2['c1'];

0 commit comments

Comments
 (0)