Skip to content

Commit bdaffb0

Browse files
tigitznicolas-grekas
authored andcommitted
Leverage arrow function syntax for closure
1 parent b355ad8 commit bdaffb0

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
@@ -108,9 +108,7 @@ abstract protected function doSend(SentMessage $message): void;
108108
*/
109109
protected function stringifyAddresses(array $addresses): array
110110
{
111-
return array_map(function (Address $a) {
112-
return $a->toString();
113-
}, $addresses);
111+
return array_map(fn (Address $a) => $a->toString(), $addresses);
114112
}
115113

116114
protected function getLogger(): LoggerInterface

0 commit comments

Comments
 (0)