1 | <?php |
||
21 | class AccessToken implements AccessTokenInterface, ArrayAccess, JsonSerializable |
||
22 | { |
||
23 | use HasAttributes; |
||
24 | |||
25 | /** |
||
26 | * AccessToken constructor. |
||
27 | * |
||
28 | * @param array $attributes |
||
29 | */ |
||
30 | public function __construct(array $attributes) |
||
38 | |||
39 | /** |
||
40 | * Return the access token string. |
||
41 | * |
||
42 | * @return string |
||
43 | */ |
||
44 | public function getToken() |
||
48 | |||
49 | /** |
||
50 | * Return the refresh token string. |
||
51 | * |
||
52 | * @return string |
||
53 | */ |
||
54 | public function getRefreshToken() |
||
58 | |||
59 | /** |
||
60 | * Set refresh token into this object. |
||
61 | * |
||
62 | * @param string $token |
||
63 | */ |
||
64 | public function setRefreshToken($token) |
||
68 | |||
69 | /** |
||
70 | * {@inheritdoc} |
||
71 | */ |
||
72 | public function __toString() |
||
76 | |||
77 | /** |
||
78 | * {@inheritdoc} |
||
79 | */ |
||
80 | public function jsonSerialize() |
||
84 | } |
||
85 |
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: