Skip to content

Commit

Permalink
Arrow functions
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMorel committed Sep 1, 2023
1 parent 0592664 commit deea5f0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/Internal/ObjectExporter/ClosureExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ private function getClosure(
int $line,
array $path
) : Node\Expr\Closure {
$finder = new FindingVisitor(function(Node $node) use ($line) : bool {
return ($node instanceof Node\Expr\Closure || $node instanceof Node\Expr\ArrowFunction)
&& $node->getStartLine() === $line;
});
$finder = new FindingVisitor(
fn(Node $node): bool => ($node instanceof Node\Expr\Closure || $node instanceof Node\Expr\ArrowFunction)
&& $node->getStartLine() === $line
);

$traverser = new NodeTraverser();
$traverser->addVisitor($finder);
Expand Down
7 changes: 4 additions & 3 deletions src/VarExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,10 @@ public static function export($var, int $options = 0, int $indentLevel = 0) : st
$export = implode(PHP_EOL, $lines);
} else {
$firstLine = array_shift($lines);
$lines = array_map(function ($line) use ($indentLevel) {
return str_repeat(' ', $indentLevel) . $line;
}, $lines);
$lines = array_map(
fn($line) => str_repeat(' ', $indentLevel) . $line,
$lines,
);

$export = $firstLine . PHP_EOL . implode(PHP_EOL, $lines);
}
Expand Down
4 changes: 1 addition & 3 deletions tests/AbstractTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ public function assertExportEquals(string $expected, $var, int $options = 0) : v
*/
public function assertExportThrows(string $expectedMessage, $var, int $options = 0) : void
{
$expectedMessageRegExp = '/' . implode('.*', array_map(function(string $str) {
return preg_quote($str, '/');
}, explode('*', $expectedMessage))) . '/';
$expectedMessageRegExp = '/' . implode('.*', array_map(fn(string $str) => preg_quote($str, '/'), explode('*', $expectedMessage))) . '/';

$this->expectException(ExportException::class);
$this->expectExceptionMessageMatches($expectedMessageRegExp);
Expand Down

0 comments on commit deea5f0

Please sign in to comment.