1 | <?php |
||
17 | class Ldap |
||
18 | { |
||
19 | /** |
||
20 | * Connection resource |
||
21 | * |
||
22 | * @var resource |
||
23 | */ |
||
24 | protected $connection; |
||
25 | |||
26 | |||
27 | /** |
||
28 | * Logger |
||
29 | * |
||
30 | * @var Logger |
||
31 | */ |
||
32 | protected $logger; |
||
33 | |||
34 | |||
35 | /** |
||
36 | * URI |
||
37 | * |
||
38 | * @var string |
||
39 | */ |
||
40 | protected $uri = 'ldap://127.0.0.1:389'; |
||
41 | |||
42 | |||
43 | /** |
||
44 | * Binddn |
||
45 | * |
||
46 | * @var string |
||
47 | */ |
||
48 | protected $binddn; |
||
49 | |||
50 | |||
51 | /** |
||
52 | * Bindpw |
||
53 | * |
||
54 | * @var string |
||
55 | */ |
||
56 | protected $bindpw; |
||
57 | |||
58 | |||
59 | /** |
||
60 | * Basedn |
||
61 | * |
||
62 | * @var string |
||
63 | */ |
||
64 | protected $basedn = ''; |
||
65 | |||
66 | |||
67 | /** |
||
68 | * tls |
||
69 | * |
||
70 | * @var bool |
||
71 | */ |
||
72 | protected $tls = false; |
||
73 | |||
74 | |||
75 | /** |
||
76 | * Options |
||
77 | * |
||
78 | * @var array |
||
79 | */ |
||
80 | protected $options = []; |
||
81 | |||
82 | |||
83 | /** |
||
84 | * construct |
||
85 | * |
||
86 | * @param Iterable $config |
||
87 | * @param Logger $logger |
||
88 | * @return resource |
||
89 | */ |
||
90 | public function __construct(LoggerInterface $logger, ?Iterable $config=null) |
||
95 | |||
96 | |||
97 | /** |
||
98 | * Connect |
||
99 | * |
||
100 | * @return Ldap |
||
101 | */ |
||
102 | public function connect(): Ldap |
||
150 | |||
151 | |||
152 | /** |
||
153 | * Close socket |
||
154 | * |
||
155 | * @return bool |
||
156 | */ |
||
157 | public function close(): bool |
||
165 | |||
166 | |||
167 | /** |
||
168 | * Set options |
||
169 | * |
||
170 | * @param Iterable $config |
||
171 | * @return Ldap |
||
172 | */ |
||
173 | public function setOptions(? Iterable $config = null) : Ldap |
||
206 | |||
207 | |||
208 | /** |
||
209 | * Get base |
||
210 | * |
||
211 | * @return string |
||
212 | */ |
||
213 | public function getBase(): string |
||
217 | |||
218 | |||
219 | /** |
||
220 | * Get connection |
||
221 | * |
||
222 | * @return resource |
||
223 | */ |
||
224 | public function getResource() |
||
232 | } |
||
233 |
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: