Skip to content

Commit 5eb8c0d

Browse files
minor #48793 Leverage arrow function syntax for closure (tigitz)
This PR was merged into the 6.3 branch. Discussion ---------- Leverage arrow function syntax for closure | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | Fix #47658 <!-- prefix each issue number with "Fix #", no need to create an issue if none exists, explain below instead --> | License | MIT | Doc PR | <!-- required for new features --> Rationale in the RFC [here](https://wiki.php.net/rfc/arrow_functions_v2#introduction) It's also notable that using arrow function syntax rather than the classic one has been enforced in the past by symfony core member: symfony/symfony#48069 (comment) So this PR would be consistent. Commits ------- f5802d3a2a Leverage arrow function syntax for closure
2 parents 0c005b9 + 923521a commit 5eb8c0d

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)