Skip to content

Commit

Permalink
Rewrite tests with long closures
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Jun 13, 2021
1 parent 9a7f39b commit de33a9d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
4 changes: 3 additions & 1 deletion tests/PHPStan/Rules/Functions/data/array_map.php
@@ -1,6 +1,8 @@
<?php declare(strict_types = 1);

array_map(
fn(stdClass $in): string => '',
function(stdClass $in): string {
return '';
},
[1, 2, 3]
);
12 changes: 9 additions & 3 deletions tests/PHPStan/Rules/Functions/data/array_reduce.php
Expand Up @@ -2,18 +2,24 @@

array_reduce(
[1,2,3],
fn(string $foo, string $current): string => $foo . $current,
function(string $foo, string $current): string {
return $foo . $current;
},
''
);

array_reduce(
[1,2,3],
fn(string $foo, int $current): string => $foo . $current,
function(string $foo, int $current): string {
return $foo . $current;
},
null
);


array_reduce(
[1,2,3],
fn(string $foo, int $current): string => $foo . $current,
function(string $foo, int $current): string {
return $foo . $current;
},
);
8 changes: 6 additions & 2 deletions tests/PHPStan/Rules/Functions/data/array_walk.php
Expand Up @@ -3,12 +3,16 @@
$array = ['foo' => 1, 'bar' => 2];
array_walk(
$array,
fn(stdClass $in, float $key) => ''
function(stdClass $in, float $key): string {
return '';
}
);

$array = ['foo' => 1, 'bar' => 2];
array_walk(
$array,
fn(int $in, string $key, int $extra) => '',
function(int $in, string $key, int $extra): string {
return '';
},
'extra'
);

0 comments on commit de33a9d

Please sign in to comment.