1 | <?php |
||
7 | abstract class Form extends \hemio\html\Form |
||
8 | { |
||
9 | /** |
||
10 | * |
||
11 | * @var string |
||
12 | */ |
||
13 | protected $name; |
||
14 | |||
15 | /** |
||
16 | * |
||
17 | * @var array |
||
18 | */ |
||
19 | private $get = []; |
||
20 | |||
21 | /** |
||
22 | * |
||
23 | * @var array |
||
24 | */ |
||
25 | private $post = []; |
||
26 | |||
27 | /** |
||
28 | * |
||
29 | * @var array |
||
30 | */ |
||
31 | protected $storedValues = []; |
||
32 | |||
33 | public function __construct($name, array $post = null, array $get = null, |
||
55 | |||
56 | public function addLogicalChild(FormElement $element) |
||
60 | |||
61 | /** |
||
62 | * |
||
63 | * @param array $storedValues |
||
64 | */ |
||
65 | public function setStoredValues(array $storedValues) |
||
69 | |||
70 | /** |
||
71 | * @return TemplateFormField |
||
72 | */ |
||
73 | public function getSingleControlTemplate() |
||
77 | const FORM_FIELD_TEMPLATE = '_INPUT_SINGLE_TEMPLATE'; |
||
78 | |||
79 | /** |
||
80 | * Check for occured errors |
||
81 | * |
||
82 | * @return boolean |
||
83 | */ |
||
84 | public function dataValid() |
||
95 | |||
96 | /** |
||
97 | * |
||
98 | * @return string |
||
99 | */ |
||
100 | public function getHtmlName() |
||
104 | |||
105 | /** |
||
106 | * |
||
107 | * @return string |
||
108 | */ |
||
109 | public function getName() |
||
113 | |||
114 | /** |
||
115 | * |
||
116 | * @param string $key |
||
117 | * @return null|string |
||
118 | */ |
||
119 | public function getPost($key) |
||
127 | |||
128 | /** |
||
129 | * |
||
130 | * @param string $key |
||
131 | * @return null|string |
||
132 | */ |
||
133 | public function getGet($key) |
||
141 | |||
142 | /** |
||
143 | * Stored values like from database |
||
144 | * |
||
145 | * @param string $key |
||
146 | * @return mixed |
||
147 | */ |
||
148 | public function getValueStored($key) |
||
156 | |||
157 | /** |
||
158 | * Get value from GET or POST |
||
159 | * |
||
160 | * @since 1.0 |
||
161 | */ |
||
162 | abstract public function getValueUser($key); |
||
163 | |||
164 | public function __toString() |
||
169 | } |
||
170 |
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: