Skip to content

Commit 923521a

Browse files
tigitznicolas-grekas
authored andcommitted
Leverage arrow function syntax for closure
1 parent 9b37627 commit 923521a

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

Tests/AbstractCrawlerTest.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,7 @@ public function testNormalizeWhiteSpace()
262262

263263
public function testEach()
264264
{
265-
$data = $this->createTestCrawler()->filterXPath('//ul[1]/li')->each(function ($node, $i) {
266-
return $i.'-'.$node->text();
267-
});
265+
$data = $this->createTestCrawler()->filterXPath('//ul[1]/li')->each(fn ($node, $i) => $i.'-'.$node->text());
268266

269267
$this->assertEquals(['0-One', '1-Two', '2-Three'], $data, '->each() executes an anonymous function on each node of the list');
270268
}
@@ -290,9 +288,7 @@ public function testSlice()
290288
public function testReduce()
291289
{
292290
$crawler = $this->createTestCrawler()->filterXPath('//ul[1]/li');
293-
$nodes = $crawler->reduce(function ($node, $i) {
294-
return 1 !== $i;
295-
});
291+
$nodes = $crawler->reduce(fn ($node, $i) => 1 !== $i);
296292
$this->assertNotSame($nodes, $crawler, '->reduce() returns a new instance of a crawler');
297293
$this->assertInstanceOf(Crawler::class, $nodes, '->reduce() returns a new instance of a crawler');
298294

0 commit comments

Comments
 (0)