1 | <?php |
||
10 | class Driver implements DriverInterface |
||
11 | { |
||
12 | /** |
||
13 | * @var RequestParser |
||
14 | */ |
||
15 | protected $requestParser; |
||
16 | |||
17 | /** |
||
18 | * @var ResponseParser |
||
19 | */ |
||
20 | protected $responseParser; |
||
21 | |||
22 | /** |
||
23 | * @var RecursiveSerializer |
||
24 | */ |
||
25 | protected $serializer; |
||
26 | |||
27 | /** |
||
28 | * |
||
29 | */ |
||
30 | public function __construct() |
||
36 | |||
37 | /** |
||
38 | * @inheritDoc |
||
39 | */ |
||
40 | 1 | public function commands(Request $request) |
|
47 | |||
48 | /** |
||
49 | * @return RecursiveSerializer |
||
50 | */ |
||
51 | public function getSerializer() |
||
55 | |||
56 | /** |
||
57 | * @return RequestParser |
||
58 | */ |
||
59 | public function getRequestParser() |
||
63 | |||
64 | /** |
||
65 | * @return ResponseParser |
||
66 | */ |
||
67 | public function getResponseParser() |
||
71 | |||
72 | /** |
||
73 | * @param $data |
||
74 | * @return ModelInterface[] |
||
75 | */ |
||
76 | 1 | public function parseResponse($data) |
|
80 | |||
81 | /** |
||
82 | * @param $data |
||
83 | * @return string |
||
84 | */ |
||
85 | public function buildResponse($data) |
||
89 | |||
90 | } |
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: