1 | <?php |
||
2 | |||
3 | namespace Honeybadger\HoneybadgerLaravel\Breadcrumbs; |
||
4 | |||
5 | use Illuminate\Mail\Events\MessageSending; |
||
6 | use Illuminate\Mail\Events\MessageSent; |
||
7 | |||
8 | abstract class MailBreadcrumb extends Breadcrumb |
||
9 | { |
||
10 | /** |
||
11 | * @param MessageSending|MessageSent $event |
||
12 | * @return array |
||
13 | */ |
||
14 | protected function getMetadata($event): array |
||
15 | { |
||
16 | return [ |
||
17 | 'queue' => $event->data['queue'] ?? null, |
||
18 | 'replyTo' => $this->extractAddresses($event->message->getReplyTo()), |
||
0 ignored issues
–
show
|
|||
19 | 'to' => $this->extractAddresses($event->message->getTo()), |
||
0 ignored issues
–
show
Are you sure the usage of
$this->extractAddresses($event->message->getTo()) targeting Honeybadger\HoneybadgerL...umb::extractAddresses() seems to always return null.
This check looks for function or method calls that always return null and whose return value is used. class A
{
function getObject()
{
return null;
}
}
$a = new A();
if ($a->getObject()) {
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||
20 | 'cc' => $this->extractAddresses(($event->message->getCc() ?? [])), |
||
0 ignored issues
–
show
Are you sure the usage of
$this->extractAddresses(...ge->getCc() ?? array()) targeting Honeybadger\HoneybadgerL...umb::extractAddresses() seems to always return null.
This check looks for function or method calls that always return null and whose return value is used. class A
{
function getObject()
{
return null;
}
}
$a = new A();
if ($a->getObject()) {
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||
21 | 'bcc' => $this->extractAddresses(($event->message->getBcc() ?? [])), |
||
0 ignored issues
–
show
Are you sure the usage of
$this->extractAddresses(...e->getBcc() ?? array()) targeting Honeybadger\HoneybadgerL...umb::extractAddresses() seems to always return null.
This check looks for function or method calls that always return null and whose return value is used. class A
{
function getObject()
{
return null;
}
}
$a = new A();
if ($a->getObject()) {
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||
22 | 'subject' => $event->message->getSubject(), |
||
23 | ]; |
||
24 | } |
||
25 | |||
26 | protected function extractAddresses($addresses): ?string |
||
27 | { |
||
28 | if ($addresses == null) { |
||
29 | return null; |
||
30 | } |
||
31 | |||
32 | $keys = array_keys($addresses); |
||
33 | if (($keys[0] ?? null) === 0) { |
||
34 | // Symfony < v6 (SwiftMailer) uses an array keyed by email, |
||
35 | // but v6 (Symfony Mailer) uses a list of Address objects |
||
36 | $addresses = collect($addresses)->map->getAddress()->toArray(); |
||
37 | } else { |
||
38 | $addresses = $keys; |
||
39 | } |
||
40 | |||
41 | return implode(',', $addresses) ?: null; |
||
42 | } |
||
43 | } |
||
44 |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.