Skip to content

Commit 2e2ac75

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 38b6106 + bdaffb0 commit 2e2ac75

File tree

3 files changed

+7
-17
lines changed

3 files changed

+7
-17
lines changed

Tests/Command/MailerTestCommandTest.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,10 @@ public function testSendsEmail()
3030
$mailer
3131
->expects($this->once())
3232
->method('send')
33-
->with(self::callback(static function (Email $message) use ($from, $to, $subject, $body): bool {
34-
return
35-
$message->getFrom()[0]->getAddress() === $from &&
36-
$message->getTo()[0]->getAddress() === $to &&
37-
$message->getSubject() === $subject &&
38-
$message->getTextBody() === $body
39-
;
40-
}))
33+
->with(self::callback(static fn (Email $message): bool => $message->getFrom()[0]->getAddress() === $from &&
34+
$message->getTo()[0]->getAddress() === $to &&
35+
$message->getSubject() === $subject &&
36+
$message->getTextBody() === $body))
4137
;
4238

4339
$tester = new CommandTester(new MailerTestCommand($mailer));
@@ -57,9 +53,7 @@ public function testUsesCustomTransport()
5753
$mailer
5854
->expects($this->once())
5955
->method('send')
60-
->with(self::callback(static function (Email $message) use ($transport): bool {
61-
return $message->getHeaders()->getHeaderBody('X-Transport') === $transport;
62-
}))
56+
->with(self::callback(static fn (Email $message): bool => $message->getHeaders()->getHeaderBody('X-Transport') === $transport))
6357
;
6458

6559
$tester = new CommandTester(new MailerTestCommand($mailer));

Transport/AbstractApiTransport.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ protected function doSendHttp(SentMessage $message): ResponseInterface
3939

4040
protected function getRecipients(Email $email, Envelope $envelope): array
4141
{
42-
return array_filter($envelope->getRecipients(), function (Address $address) use ($email) {
43-
return false === \in_array($address, array_merge($email->getCc(), $email->getBcc()), true);
44-
});
42+
return array_filter($envelope->getRecipients(), fn (Address $address) => false === \in_array($address, array_merge($email->getCc(), $email->getBcc()), true));
4543
}
4644
}

Transport/AbstractTransport.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,7 @@ abstract protected function doSend(SentMessage $message): void;
112112
*/
113113
protected function stringifyAddresses(array $addresses): array
114114
{
115-
return array_map(function (Address $a) {
116-
return $a->toString();
117-
}, $addresses);
115+
return array_map(fn (Address $a) => $a->toString(), $addresses);
118116
}
119117

120118
protected function getLogger(): LoggerInterface

0 commit comments

Comments
 (0)