1 | <?php |
||
18 | abstract class NavigationAbstract implements NavigationInterface |
||
19 | { |
||
20 | /** |
||
21 | * instance of the registry class |
||
22 | * |
||
23 | * @var Registry |
||
24 | */ |
||
25 | |||
26 | protected $_registry; |
||
27 | |||
28 | /** |
||
29 | * instance of the language class |
||
30 | * |
||
31 | * @var Language |
||
32 | */ |
||
33 | |||
34 | protected $_language; |
||
35 | |||
36 | /** |
||
37 | * options of the navigation |
||
38 | * |
||
39 | * @var array |
||
40 | */ |
||
41 | |||
42 | protected $_optionArray = |
||
43 | [ |
||
44 | 'className' => |
||
45 | [ |
||
46 | 'list' => 'rs-list-navigation', |
||
47 | 'active' => 'rs-item-active' |
||
48 | ] |
||
49 | ]; |
||
50 | |||
51 | /** |
||
52 | * constructor of the class |
||
53 | * |
||
54 | * @since 3.3.0 |
||
55 | * |
||
56 | * @param Registry $registry instance of the registry class |
||
57 | * @param Language $language instance of the language class |
||
58 | */ |
||
59 | |||
60 | public function __construct(Registry $registry, Language $language) |
||
65 | |||
66 | /** |
||
67 | * init the class |
||
68 | * |
||
69 | * @since 3.3.0 |
||
70 | * |
||
71 | * @param array $optionArray options of the navigation |
||
72 | * |
||
73 | * @return self |
||
74 | */ |
||
75 | |||
76 | public function init(array $optionArray = []) : self |
||
81 | |||
82 | /** |
||
83 | * stringify the navigation |
||
84 | * |
||
85 | * @since 3.3.0 |
||
86 | * |
||
87 | * @return string |
||
88 | */ |
||
89 | |||
90 | public function __toString() : string |
||
94 | } |
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: