Passed
Push — master ( e88490...575397 )
by Alexandre
04:15
created

StorageManager::getAuthorizationCodeStorage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Alexandre
5
 * Date: 18/03/2018
6
 * Time: 16:21
7
 */
8
9
namespace OAuth2\Extensions\OpenID\Storages;
10
11
12
use OAuth2\Storages\AccessTokenStorageInterface;
13
use OAuth2\Storages\AuthorizationCodeStorageInterface;
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, OAuth2\Extensions\OpenID...ionCodeStorageInterface. 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:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/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 before OtherDir/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:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
14
use OAuth2\Storages\ClientStorageInterface;
15
use OAuth2\Storages\RefreshTokenStorageInterface;
16
use OAuth2\Storages\ResourceOwnerStorageInterface;
17
18
class StorageManager extends \OAuth2\Storages\StorageManager
19
{
20
    public function __construct(ClientStorageInterface $clientStorage,
21
                                ResourceOwnerStorageInterface $resourceOwnerStorage,
22
                                AuthorizationCodeStorageInterface $authorizationCodeStorage,
23
                                AccessTokenStorageInterface $accessTokenStorage,
24
                                RefreshTokenStorageInterface $refreshTokenStorage)
25
    {
26
        parent::__construct($clientStorage,
27
            $resourceOwnerStorage,
28
            $authorizationCodeStorage,
29
            $accessTokenStorage,
30
            $refreshTokenStorage);
31
    }
32
33
    /**
34
     * @return \OAuth2\Extensions\OpenID\Storages\AuthorizationCodeStorageInterface
35
     */
36
    public function getAuthorizationCodeStorage(): AuthorizationCodeStorageInterface
37
    {
38
        return parent::getAuthorizationCodeStorage();
39
    }
40
41
}