Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2711,4 +2711,23 @@ public function testBug14012(): void
$this->analyse([__DIR__ . '/../Properties/data/bug-14012.php'], []);
}

public function testBug11534(): void
{
$this->checkExplicitMixed = true;
$this->checkImplicitMixed = true;
$this->analyse([__DIR__ . '/data/bug-11534.php'], [
[
'Parameter #2 $param2 of function Bug11534\hello expects int, mixed given.',
14,
],
]);
}

public function testBug10559(): void
{
$this->checkExplicitMixed = true;
$this->checkImplicitMixed = true;
$this->analyse([__DIR__ . '/data/bug-10559.php'], []);
}

}
22 changes: 22 additions & 0 deletions tests/PHPStan/Rules/Functions/data/bug-10559.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace Bug10559;

/** @var mixed[] $arr1 */
$arr1 = [
'a1' => 1,
'b1' => '2',
'c1' => 3.3,
];
// There is no error
echo (string)$arr1['c1'];


/** @var mixed[] $arr2 */
$arr2 = [
'a1' => 1,
'b1' => '2',
'c1' => 3.3,
];
if ($arr2['a1'] > 1) {}
echo (string)$arr2['c1'];
15 changes: 15 additions & 0 deletions tests/PHPStan/Rules/Functions/data/bug-11534.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Bug11534;

function hello(int $param1, int $param2): void
{
}
/** @param mixed[] $params */
function world(array $params): void
{
if (!is_int($params['param1'])) {
throw new \Exception();
}
hello($params['param1'], $params['param2']);
}
Loading