From 723da945b539df2b01ba42fbfe802e318c3b0ca4 Mon Sep 17 00:00:00 2001 From: Alex Kalineskou Date: Thu, 9 Jun 2022 14:18:43 +0300 Subject: [PATCH] Add test --- .../CallToFunctionParametersRuleTest.php | 22 ++++++++++++ .../Rules/Functions/data/array_udiff.php | 34 +++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 tests/PHPStan/Rules/Functions/data/array_udiff.php diff --git a/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php b/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php index c7d2e698e7e..cc0c0cff510 100644 --- a/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php +++ b/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php @@ -618,6 +618,28 @@ public function testArrayWalkArrowFunctionCallback(): void ]); } + public function testArrayUdiffCallback(): void + { + $this->analyse([__DIR__ . '/data/array_udiff.php'], [ + [ + 'Parameter #3 $data_comp_func of function array_udiff expects callable(mixed, mixed): int, Closure(string, string): string given.', + 6, + ], + [ + 'Parameter #3 $data_comp_func of function array_udiff expects callable(mixed, mixed): int, Closure(int, int): non-empty-string given.', + 14, + ], + [ + 'Parameter #1 $array of function array_reduce expects array, null given.', + 20, + ], + [ + 'Parameter #2 $callback of function array_reduce expects callable(Closure(string, int): string, TIn): Closure(string, int): string, null given.', + 21, + ], + ]); + } + public function testPregReplaceCallback(): void { $this->analyse([__DIR__ . '/data/preg_replace_callback.php'], [ diff --git a/tests/PHPStan/Rules/Functions/data/array_udiff.php b/tests/PHPStan/Rules/Functions/data/array_udiff.php new file mode 100644 index 00000000000..2e44050e7a4 --- /dev/null +++ b/tests/PHPStan/Rules/Functions/data/array_udiff.php @@ -0,0 +1,34 @@ + $b; + }, +); +