These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | /* |
||
6 | * The MIT License (MIT) |
||
7 | * |
||
8 | * Copyright (c) 2014-2019 Spomky-Labs |
||
9 | * |
||
10 | * This software may be modified and distributed under the terms |
||
11 | * of the MIT license. See the LICENSE file for details. |
||
12 | */ |
||
13 | |||
14 | namespace Jose\Bundle\JoseFramework\Services; |
||
15 | |||
16 | use Jose\Bundle\JoseFramework\Event\NestedTokenIssuedEvent; |
||
17 | use Jose\Component\Encryption\JWEBuilder; |
||
0 ignored issues
–
show
|
|||
18 | use Jose\Component\Encryption\Serializer\JWESerializerManager; |
||
19 | use Jose\Component\NestedToken\NestedTokenBuilder as BaseNestedTokenBuilder; |
||
20 | use Jose\Component\Signature\JWSBuilder; |
||
0 ignored issues
–
show
This use statement conflicts with another class in this namespace,
Jose\Bundle\JoseFramework\Services\JWSBuilder .
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...
|
|||
21 | use Jose\Component\Signature\Serializer\JWSSerializerManager; |
||
22 | use Psr\EventDispatcher\EventDispatcherInterface; |
||
23 | |||
24 | final class NestedTokenBuilder extends BaseNestedTokenBuilder |
||
25 | { |
||
26 | /** |
||
27 | * @var EventDispatcherInterface |
||
28 | */ |
||
29 | private $eventDispatcher; |
||
30 | |||
31 | public function __construct(JWEBuilder $jweBuilder, JWESerializerManager $jweSerializerManager, JWSBuilder $jwsBuilder, JWSSerializerManager $jwsSerializerManager, EventDispatcherInterface $eventDispatcher) |
||
32 | { |
||
33 | parent::__construct($jweBuilder, $jweSerializerManager, $jwsBuilder, $jwsSerializerManager); |
||
34 | $this->eventDispatcher = $eventDispatcher; |
||
35 | } |
||
36 | |||
37 | public function create(string $payload, array $signatures, string $jws_serialization_mode, array $jweSharedProtectedHeader, array $jweSharedHeader, array $recipients, string $jwe_serialization_mode, ?string $aad = null): string |
||
38 | { |
||
39 | $nestedToken = parent::create($payload, $signatures, $jws_serialization_mode, $jweSharedProtectedHeader, $jweSharedHeader, $recipients, $jwe_serialization_mode, $aad); |
||
40 | $this->eventDispatcher->dispatch(new NestedTokenIssuedEvent($nestedToken)); |
||
41 | |||
42 | return $nestedToken; |
||
43 | } |
||
44 | } |
||
45 |
Let’s assume that you have a directory layout like this:
and let’s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are 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.php
However, as
OtherDir/Foo.php
does 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: