Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
akalineskou committed Jun 9, 2022
1 parent ca4a8d9 commit 723da94
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php
Expand Up @@ -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<TIn>, 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'], [
Expand Down
34 changes: 34 additions & 0 deletions tests/PHPStan/Rules/Functions/data/array_udiff.php
@@ -0,0 +1,34 @@
<?php declare(strict_types = 1);

array_udiff(
[1,2,3],
[4,5,6],
function(string $a, string $b): string {
return $a . $b;
},
);

array_udiff(
[1,2,3],
[4,5,6],
function(int $a, int $b): string {
return $a . $b;
},
);

array_reduce(
null,
null,
function(string $a, int $b): string {
return $a . $b;
},
);

array_udiff(
[25,26],
[26,27],
static function(int $a, int $b): int {
return $a <=> $b;
},
);

0 comments on commit 723da94

Please sign in to comment.