1 | <?php |
||
21 | class Auth implements AdapterAwareInterface |
||
22 | { |
||
23 | /** |
||
24 | * Adapter |
||
25 | * |
||
26 | * @var array |
||
27 | */ |
||
28 | protected $adapter = []; |
||
29 | |||
30 | |||
31 | /** |
||
32 | * Identity |
||
33 | * |
||
34 | * @var Identity |
||
35 | */ |
||
36 | protected $identity; |
||
37 | |||
38 | |||
39 | /** |
||
40 | * Logger |
||
41 | * |
||
42 | * @var Logger |
||
43 | */ |
||
44 | protected $logger; |
||
45 | |||
46 | |||
47 | /** |
||
48 | * Identity class |
||
49 | * |
||
50 | * @var string |
||
51 | */ |
||
52 | protected $identity_class = Identity::class; |
||
53 | |||
54 | |||
55 | /** |
||
56 | * Attribute map class |
||
57 | * |
||
58 | * @var string |
||
59 | */ |
||
60 | protected $attribute_map_class = AttributeMap::class; |
||
61 | |||
62 | |||
63 | /** |
||
64 | * Initialize |
||
65 | * |
||
66 | * @param Logger $logger |
||
67 | * @param Iterable $config |
||
68 | * @return void |
||
69 | */ |
||
70 | public function __construct(Logger $logger, ? Iterable $config = null) |
||
75 | |||
76 | |||
77 | /** |
||
78 | * Set options |
||
79 | * |
||
80 | * @param Iterable $config |
||
81 | * @return Auth |
||
82 | */ |
||
83 | public function setOptions(? Iterable $config = null) : Auth |
||
107 | |||
108 | |||
109 | /** |
||
110 | * Has adapter |
||
111 | * |
||
112 | * @param string $name |
||
113 | * @return bool |
||
114 | */ |
||
115 | public function hasAdapter(string $name): bool |
||
119 | |||
120 | |||
121 | /** |
||
122 | * Get default adapter |
||
123 | * |
||
124 | * @return array |
||
125 | */ |
||
126 | public function getDefaultAdapter(): array |
||
130 | |||
131 | |||
132 | /** |
||
133 | * Inject adapter |
||
134 | * |
||
135 | * @param string $name |
||
136 | * @param AdapterInterface $adapter |
||
137 | * @return AdapterInterface |
||
138 | */ |
||
139 | public function injectAdapter(string $name, AdapterInterface $adapter) : AdapterInterface |
||
148 | |||
149 | |||
150 | /** |
||
151 | * Get adapter |
||
152 | * |
||
153 | * @param string $name |
||
154 | * @return AdapterInterface |
||
155 | */ |
||
156 | public function getAdapter(string $name): AdapterInterface |
||
164 | |||
165 | |||
166 | /** |
||
167 | * Get adapters |
||
168 | * |
||
169 | * @param array $adapters |
||
170 | * @return array |
||
171 | */ |
||
172 | public function getAdapters(array $adapters = []): array |
||
188 | |||
189 | |||
190 | /** |
||
191 | * Create identity |
||
192 | * |
||
193 | * @param AdapterInterface $adapter |
||
194 | * @return Identity |
||
195 | */ |
||
196 | protected function createIdentity(AdapterInterface $adapter): Identity |
||
202 | |||
203 | |||
204 | /** |
||
205 | * Authenticate |
||
206 | * |
||
207 | * @return bool |
||
208 | */ |
||
209 | public function requireOne(): bool |
||
243 | |||
244 | |||
245 | /** |
||
246 | * Get identity |
||
247 | * |
||
248 | * @return Identity |
||
249 | */ |
||
250 | public function getIdentity(): Identity |
||
258 | |||
259 | |||
260 | /** |
||
261 | * Check if valid identity exists |
||
262 | * |
||
263 | * @return bool |
||
264 | */ |
||
265 | public function isAuthenticated(): bool |
||
269 | } |
||
270 |
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: