1 | <?php |
||
19 | class Format extends FormatConstraint |
||
20 | { |
||
21 | |||
22 | /** |
||
23 | * @var EventDispatcherInterface |
||
24 | */ |
||
25 | private $dispatcher; |
||
26 | |||
27 | /** |
||
28 | * @var Factory |
||
29 | */ |
||
30 | private $factory; |
||
31 | |||
32 | /** |
||
33 | * Format constructor. |
||
34 | * |
||
35 | * @param int $checkMode check mode |
||
36 | * @param UriRetriever|null $uriRetriever uri retriever |
||
37 | * @param Factory|null $factory factory |
||
38 | */ |
||
39 | public function __construct( |
||
47 | |||
48 | /** |
||
49 | * sets the event dispatcher |
||
50 | * |
||
51 | * @param EventDispatcherInterface $dispatcher dispatcher |
||
52 | * |
||
53 | * @return void |
||
54 | */ |
||
55 | public function setEventDispatcher(EventDispatcherInterface $dispatcher) |
||
59 | |||
60 | /** |
||
61 | * checks the input |
||
62 | * |
||
63 | * @param mixed $element element |
||
64 | * @param null $schema schema |
||
65 | * @param null $path path |
||
66 | * @param null $i iterator value |
||
67 | * |
||
68 | * @return void |
||
69 | */ |
||
70 | public function check($element, $schema = null, $path = null, $i = null) |
||
79 | } |
||
80 |
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: