honeybadger-io /
honeybadger-laravel
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Honeybadger\HoneybadgerLaravel\Breadcrumbs; |
||
| 4 | |||
| 5 | use Illuminate\Notifications\Events\NotificationFailed; |
||
|
0 ignored issues
–
show
|
|||
| 6 | use Illuminate\Notifications\Events\NotificationSending; |
||
|
0 ignored issues
–
show
This use statement conflicts with another class in this namespace,
Honeybadger\HoneybadgerL...mbs\NotificationSending. Consider defining an alias.
Let?s assume that you have a directory layout like this: .
|-- OtherDir
| |-- Bar.php
| `-- Foo.php
`-- SomeDir
`-- Foo.php
and let?s assume the following content of // Bar.php
namespace OtherDir;
use SomeDir\Foo; // This now conflicts the class OtherDir\Foo
If both files PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as // Bar.php
namespace OtherDir;
use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
|
|||
| 7 | use Illuminate\Notifications\Events\NotificationSent; |
||
|
0 ignored issues
–
show
This use statement conflicts with another class in this namespace,
Honeybadger\HoneybadgerL...crumbs\NotificationSent. Consider defining an alias.
Let?s assume that you have a directory layout like this: .
|-- OtherDir
| |-- Bar.php
| `-- Foo.php
`-- SomeDir
`-- Foo.php
and let?s assume the following content of // Bar.php
namespace OtherDir;
use SomeDir\Foo; // This now conflicts the class OtherDir\Foo
If both files PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as // Bar.php
namespace OtherDir;
use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
|
|||
| 8 | |||
| 9 | abstract class NotificationBreadcrumb extends Breadcrumb |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @param NotificationSending|NotificationFailed|NotificationSent $event |
||
| 13 | * @return array |
||
| 14 | */ |
||
| 15 | protected function getMetadata($event): array |
||
| 16 | { |
||
| 17 | return [ |
||
| 18 | 'notification' => get_class($event->notification), |
||
| 19 | 'channel' => $event->channel, |
||
| 20 | 'queue' => $event->queue, |
||
| 21 | 'notifiable' => get_class($event->notifiable), |
||
| 22 | ]; |
||
| 23 | } |
||
| 24 | } |
||
| 25 |
Let?s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let?s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: