1 | <?php |
||
19 | class Builder implements BuilderContract |
||
20 | { |
||
21 | use HasAttributes; |
||
22 | |||
23 | /** |
||
24 | * @var Container |
||
25 | */ |
||
26 | protected $container; |
||
27 | |||
28 | /** |
||
29 | * @var array |
||
30 | */ |
||
31 | protected $items; |
||
32 | |||
33 | /** |
||
34 | * @var string |
||
35 | */ |
||
36 | protected $name; |
||
37 | |||
38 | /** |
||
39 | * @var string |
||
40 | */ |
||
41 | protected $type; |
||
42 | |||
43 | /** |
||
44 | * @var AttributesContract |
||
45 | */ |
||
46 | protected $activeAttributes; |
||
47 | |||
48 | /** |
||
49 | * @param Container $container |
||
50 | * @param string $name |
||
51 | * @param string $type |
||
52 | * @param array $attributes |
||
53 | * @param array $activeAttributes |
||
54 | */ |
||
55 | 14 | public function __construct(Container $container, $name, $type = self::UL, $attributes = [], $activeAttributes = []) |
|
64 | |||
65 | /** |
||
66 | * @param string $name |
||
67 | * @param \Closure $itemCallable |
||
68 | * @param \Closure $menuCallable |
||
69 | * @return Group |
||
70 | */ |
||
71 | 2 | public function group($name, \Closure $itemCallable, \Closure $menuCallable) |
|
99 | |||
100 | /** |
||
101 | * @param string $name |
||
102 | * @param string $title |
||
103 | * @param string $url |
||
104 | * @param array $attributes |
||
105 | * @param array $linkAttributes |
||
106 | * @param \Closure|null $callback |
||
107 | * @return Item |
||
108 | */ |
||
109 | 6 | public function add($name, $title, $url, $attributes = [], $linkAttributes = [], $callback = null) |
|
132 | |||
133 | /** |
||
134 | * @param string $name |
||
135 | * @return bool |
||
136 | */ |
||
137 | 4 | public function has($name) |
|
141 | |||
142 | /** |
||
143 | * @param string $name |
||
144 | * @param mixed|null $default |
||
145 | * @return Item|Group|null |
||
146 | */ |
||
147 | 2 | public function get($name, $default = null) |
|
154 | |||
155 | /** |
||
156 | * @return array |
||
157 | */ |
||
158 | 3 | public function all() |
|
162 | |||
163 | /** |
||
164 | * @param string $name |
||
165 | */ |
||
166 | 2 | public function forget($name) |
|
172 | |||
173 | /** |
||
174 | * @return string |
||
175 | */ |
||
176 | 3 | public function getType() |
|
180 | |||
181 | /** |
||
182 | * @param string $type |
||
183 | */ |
||
184 | 1 | public function setType($type) |
|
188 | |||
189 | /** |
||
190 | * @param string|null $view |
||
191 | * @return string |
||
192 | */ |
||
193 | 2 | public function render($view = null) |
|
215 | |||
216 | /** |
||
217 | * @param \Closure|null $callback |
||
218 | * @return Attributes|mixed |
||
219 | */ |
||
220 | 6 | public function activeAttributes($callback = null) |
|
228 | |||
229 | /** |
||
230 | * @param $html |
||
231 | * @return mixed |
||
232 | */ |
||
233 | 2 | protected function minifyHtmlOutput($html) |
|
249 | } |
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: