-
Notifications
You must be signed in to change notification settings - Fork 470
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
skip param castable to X on non-arrays
Fixes bug 12146
- Loading branch information
1 parent
7070346
commit bd44528
Showing
6 changed files
with
106 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Bug12146; | ||
|
||
/** | ||
* @param mixed $mixed invalid, but don't report because it's reported by CallToFunctionParametersRule | ||
* @param array<int>|array<float> $validArrayUnion valid | ||
* @param array<int>|array<\stdClass> $invalidArrayUnion invalid, report | ||
* @param ?array<\stdClass> $nullableInvalidArray invalid, but don't report because it's reported by CallToFunctionParametersRule | ||
* @param array<\stdClass>|\SplFixedArray<int> $arrayOrSplArray invalid, but don't report because it's reported by CallToFunctionParametersRule | ||
* @return void | ||
*/ | ||
function foo($mixed, $validArrayUnion, $invalidArrayUnion, $nullableInvalidArray, $arrayOrSplArray) { | ||
var_dump(array_sum($mixed)); | ||
var_dump(array_sum($validArrayUnion)); | ||
var_dump(array_sum($invalidArrayUnion)); | ||
var_dump(array_sum($nullableInvalidArray)); | ||
var_dump(array_sum($arrayOrSplArray)); | ||
|
||
var_dump(array_product($mixed)); | ||
var_dump(array_product($validArrayUnion)); | ||
var_dump(array_product($invalidArrayUnion)); | ||
var_dump(array_product($nullableInvalidArray)); | ||
var_dump(array_product($arrayOrSplArray)); | ||
|
||
var_dump(implode(',', $mixed)); | ||
var_dump(implode(',', $validArrayUnion)); | ||
var_dump(implode(',', $invalidArrayUnion)); | ||
var_dump(implode(',', $nullableInvalidArray)); | ||
var_dump(implode(',', $arrayOrSplArray)); | ||
|
||
var_dump(array_intersect($mixed, [5])); | ||
var_dump(array_intersect($validArrayUnion, [5])); | ||
var_dump(array_intersect($invalidArrayUnion, [5])); | ||
var_dump(array_intersect($nullableInvalidArray, [5])); | ||
var_dump(array_intersect($arrayOrSplArray, [5])); | ||
|
||
var_dump(array_fill_keys($mixed, 1)); | ||
var_dump(array_fill_keys($validArrayUnion, 1)); | ||
var_dump(array_fill_keys($invalidArrayUnion, 1)); | ||
var_dump(array_fill_keys($nullableInvalidArray, 1)); | ||
var_dump(array_fill_keys($arrayOrSplArray, 1)); | ||
|
||
var_dump(array_unique($mixed)); | ||
var_dump(array_unique($validArrayUnion)); | ||
var_dump(array_unique($invalidArrayUnion)); | ||
var_dump(array_unique($nullableInvalidArray)); | ||
var_dump(array_unique($arrayOrSplArray)); | ||
} |