Skip to content

Commit

Permalink
Leverage arrow function syntax for closure
Browse files Browse the repository at this point in the history
  • Loading branch information
tigitz authored and nicolas-grekas committed Jan 13, 2023
1 parent 91c342f commit 952d70d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
4 changes: 1 addition & 3 deletions Node/FunctionNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ public function getSpecificity(): Specificity

public function __toString(): string
{
$arguments = implode(', ', array_map(function (Token $token) {
return "'".$token->getValue()."'";
}, $this->arguments));
$arguments = implode(', ', array_map(fn (Token $token) => "'".$token->getValue()."'", $this->arguments));

return sprintf('%s[%s:%s(%s)]', $this->getNodeName(), $this->selector, $this->name, $arguments ? '['.$arguments.']' : '');
}
Expand Down
4 changes: 1 addition & 3 deletions Parser/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ public static function parseSeries(array $tokens): array
}
}

$joined = trim(implode('', array_map(function (Token $token) {
return $token->getValue();
}, $tokens)));
$joined = trim(implode('', array_map(fn (Token $token) => $token->getValue(), $tokens)));

$int = function ($string) {
if (!is_numeric($string)) {
Expand Down
4 changes: 1 addition & 3 deletions Tests/Parser/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ public function testParser($source, $representation)
{
$parser = new Parser();

$this->assertEquals($representation, array_map(function (SelectorNode $node) {
return (string) $node->getTree();
}, $parser->parse($source)));
$this->assertEquals($representation, array_map(fn (SelectorNode $node) => (string) $node->getTree(), $parser->parse($source)));
}

/** @dataProvider getParserExceptionTestData */
Expand Down

0 comments on commit 952d70d

Please sign in to comment.