1 | <?php namespace Mascame\Artificer\Fields; |
||
9 | class FieldFactory extends \Mascame\Formality\Factory\Factory |
||
10 | { |
||
11 | |||
12 | public $fieldClass; |
||
13 | public $fields; |
||
14 | public $relatedFields = null; |
||
15 | public $custom_fields = null; |
||
16 | |||
17 | /** |
||
18 | * @var Model |
||
19 | */ |
||
20 | public $modelObject; |
||
21 | public $data; |
||
22 | |||
23 | public $namespace = '\Mascame\Artificer\Fields\Types\\'; |
||
24 | |||
25 | /** |
||
26 | * @param $data |
||
27 | * @return mixed |
||
28 | */ |
||
29 | public function makeFields() |
||
48 | |||
49 | /** |
||
50 | * @param $name |
||
51 | * @return bool|mixed |
||
52 | */ |
||
53 | protected function getTypeFromConfig($name) { |
||
62 | |||
63 | /** |
||
64 | * @param $name |
||
65 | * @return bool |
||
66 | */ |
||
67 | protected function isRelation($name) |
||
71 | |||
72 | /** |
||
73 | * @return array|null |
||
74 | */ |
||
75 | public function getRelated() |
||
90 | |||
91 | /** |
||
92 | * @return array |
||
93 | */ |
||
94 | protected function withRelated() |
||
106 | |||
107 | /** |
||
108 | * @return array |
||
109 | */ |
||
110 | protected function withCustomFields() |
||
124 | |||
125 | /** |
||
126 | * @param $field |
||
127 | * @return null |
||
128 | */ |
||
129 | public function fieldValue($field) |
||
133 | |||
134 | } |
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: