@@ -4,6 +4,10 @@ discard block |
||
4 | 4 | class DataContainer extends \ArrayObject |
5 | 5 | { |
6 | 6 | |
7 | + /** |
|
8 | + * @param string $nameOrArray |
|
9 | + * @param string $value |
|
10 | + */ |
|
7 | 11 | function set($nameOrArray, $value = null) |
8 | 12 | { |
9 | 13 | if (is_array($nameOrArray)) { |
@@ -23,6 +27,9 @@ discard block |
||
23 | 27 | } |
24 | 28 | } |
25 | 29 | |
30 | + /** |
|
31 | + * @param string $name |
|
32 | + */ |
|
26 | 33 | function get($name) |
27 | 34 | { |
28 | 35 | return isset($this[$name]) |
@@ -13,7 +13,7 @@ |
||
13 | 13 | |
14 | 14 | return; |
15 | 15 | } |
16 | - if ( ! is_string($nameOrArray)) { |
|
16 | + if (!is_string($nameOrArray)) { |
|
17 | 17 | throw new \InvalidArgumentException('Only strings or arrays are accepted as first argument of the set() method of the DataContainer class'); |
18 | 18 | } |
19 | 19 | if ($value !== null) { |
@@ -3,7 +3,6 @@ |
||
3 | 3 | |
4 | 4 | use Sirius\Input\Element\Input; |
5 | 5 | use Sirius\Input\Element; |
6 | -use Sirius\Input\Specs; |
|
7 | 6 | |
8 | 7 | class Factory |
9 | 8 | { |
@@ -30,13 +30,13 @@ discard block |
||
30 | 30 | |
31 | 31 | return $this; |
32 | 32 | } |
33 | - if ( ! is_string($classOrClosure)) { |
|
33 | + if (!is_string($classOrClosure)) { |
|
34 | 34 | throw new \RuntimeException('Input type must be a class or a closure'); |
35 | 35 | } |
36 | - if ( ! class_exists($classOrClosure)) { |
|
36 | + if (!class_exists($classOrClosure)) { |
|
37 | 37 | throw new \RuntimeException(sprintf('Class %s does not exist', $classOrClosure)); |
38 | 38 | } |
39 | - if ( ! is_subclass_of($classOrClosure, '\Sirius\Input\Element')) { |
|
39 | + if (!is_subclass_of($classOrClosure, '\Sirius\Input\Element')) { |
|
40 | 40 | throw new \RuntimeException( |
41 | 41 | sprintf('Class %s must extend the \Sirius\Input\Element class', $classOrClosure) |
42 | 42 | ); |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | $element = new $class($name, $options); |
71 | 71 | } |
72 | 72 | |
73 | - if ( ! $element instanceof Element) { |
|
73 | + if (!$element instanceof Element) { |
|
74 | 74 | throw new \RuntimeException('Cannot create a valid element based on the data provided'); |
75 | 75 | } |
76 | 76 |
@@ -2,7 +2,6 @@ |
||
2 | 2 | namespace Sirius\Input\Element\Input; |
3 | 3 | |
4 | 4 | use Sirius\Input\Specs; |
5 | -use Sirius\Filtration\Filter\Callback; |
|
6 | 5 | |
7 | 6 | class MultiSelect extends Select |
8 | 7 | { |
@@ -27,10 +27,10 @@ |
||
27 | 27 | */ |
28 | 28 | function filterValue($value, $valueIdentifier = null) |
29 | 29 | { |
30 | - if ( ! $value) { |
|
30 | + if (!$value) { |
|
31 | 31 | return null; |
32 | 32 | } |
33 | - if ( ! is_array($value)) { |
|
33 | + if (!is_array($value)) { |
|
34 | 34 | $value = (array) $value; |
35 | 35 | } |
36 | 36 | $allowedValues = array_keys($this->getOptions()); |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * Initialize the form |
99 | 99 | * This is the place to put your definition (properties, elements) |
100 | 100 | * |
101 | - * @return \Sirius\Input\Form |
|
101 | + * @return InputFilter |
|
102 | 102 | */ |
103 | 103 | function init() |
104 | 104 | { |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | * @param bool $force force the execution of the preparation code even if already prepared |
147 | 147 | * |
148 | 148 | * @throws \LogicException |
149 | - * @return \Sirius\Input\Form |
|
149 | + * @return InputFilter |
|
150 | 150 | */ |
151 | 151 | function prepare($force = false) |
152 | 152 | { |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | * $form->setUploadHandler('resume', $resumeHandler); |
261 | 261 | * $form->setUploadHandler('pictures[*]', $pictureHandler); |
262 | 262 | * |
263 | - * @param $selector |
|
263 | + * @param string $selector |
|
264 | 264 | * @param UploadHandler $handler |
265 | 265 | * |
266 | 266 | * @return $this |
@@ -3,7 +3,6 @@ |
||
3 | 3 | |
4 | 4 | use Sirius\Filtration\Filtrator; |
5 | 5 | use Sirius\Filtration\FiltratorInterface; |
6 | -use Sirius\Input\Element\AbstractElement; |
|
7 | 6 | use Sirius\Input\Element\Factory as ElementFactory; |
8 | 7 | use Sirius\Input\Traits\HasChildrenTrait; |
9 | 8 | use Sirius\Input\Traits\HasAttributesTrait; |
@@ -77,17 +77,17 @@ discard block |
||
77 | 77 | ValidatorInterface $validator = null, |
78 | 78 | FiltratorInterface $filtrator = null |
79 | 79 | ) { |
80 | - if ( ! $elementFactory) { |
|
80 | + if (!$elementFactory) { |
|
81 | 81 | $elementFactory = new ElementFactory(); |
82 | 82 | } |
83 | 83 | $this->elementFactory = $elementFactory; |
84 | 84 | |
85 | - if ( ! $validator) { |
|
85 | + if (!$validator) { |
|
86 | 86 | $validator = new Validator(); |
87 | 87 | } |
88 | 88 | $this->validator = $validator; |
89 | 89 | |
90 | - if ( ! $filtrator) { |
|
90 | + if (!$filtrator) { |
|
91 | 91 | $filtrator = new Filtrator(); |
92 | 92 | } |
93 | 93 | $this->filtrator = $filtrator; |
@@ -150,11 +150,11 @@ discard block |
||
150 | 150 | */ |
151 | 151 | function prepare($force = false) |
152 | 152 | { |
153 | - if ($this->isPrepared && ! $force) { |
|
153 | + if ($this->isPrepared && !$force) { |
|
154 | 154 | return $this; |
155 | 155 | } |
156 | 156 | $this->init(); |
157 | - if ( ! $this->isInitialized()) { |
|
157 | + if (!$this->isInitialized()) { |
|
158 | 158 | throw new \LogicException('Input was not properly initialized'); |
159 | 159 | } |
160 | 160 | |
@@ -197,12 +197,12 @@ discard block |
||
197 | 197 | protected function prepareFiltration() |
198 | 198 | { |
199 | 199 | $filters = $this->getFilters(); |
200 | - if ( ! $filters || ! is_array($filters)) { |
|
200 | + if (!$filters || !is_array($filters)) { |
|
201 | 201 | return; |
202 | 202 | } |
203 | 203 | $filtrator = $this->getFiltrator(); |
204 | 204 | foreach ($filters as $filter) { |
205 | - $params = is_array($filter) ? $filter : array( $filter ); |
|
205 | + $params = is_array($filter) ? $filter : array($filter); |
|
206 | 206 | if (isset($params[0])) { |
207 | 207 | $filtrator->add(Filtrator::SELECTOR_ROOT, $params[0], @$params[1], @$params[2], @$params[3]); |
208 | 208 | } |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | */ |
248 | 248 | function getUploadHandlers() |
249 | 249 | { |
250 | - if ( ! $this->uploadHandlers) { |
|
250 | + if (!$this->uploadHandlers) { |
|
251 | 251 | $this->uploadHandlers = new UploadHandlerAggregate; |
252 | 252 | } |
253 | 253 | |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | function populate($values = array()) |
283 | 283 | { |
284 | 284 | $this->prepare(); |
285 | - if ( ! $this->isPrepared()) { |
|
285 | + if (!$this->isPrepared()) { |
|
286 | 286 | throw new \LogicException('Input was not prepared and cannot receive data'); |
287 | 287 | } |
288 | 288 | |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | */ |
332 | 332 | function isValid($skipDataProcessing = false) |
333 | 333 | { |
334 | - if ( ! $skipDataProcessing) { |
|
334 | + if (!$skipDataProcessing) { |
|
335 | 335 | $this->values = $this->getFiltrator()->filter($this->rawValues); |
336 | 336 | } |
337 | 337 | |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | $validator = $this->getValidator(); |
340 | 340 | $validator->validate($this->values); |
341 | 341 | |
342 | - if ( ! $skipDataProcessing) { |
|
342 | + if (!$skipDataProcessing) { |
|
343 | 343 | $this->processUploads(); |
344 | 344 | } |
345 | 345 |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * |
32 | 32 | * @param array $attrs |
33 | 33 | * |
34 | - * @return mixed |
|
34 | + * @return HasAttributesTrait |
|
35 | 35 | */ |
36 | 36 | function setAttributes($attrs) |
37 | 37 | { |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * Set/Unset a label attribute |
60 | 60 | * |
61 | 61 | * @param string $attr |
62 | - * @param mixed|null $value |
|
62 | + * @param string $value |
|
63 | 63 | * |
64 | 64 | * @return self |
65 | 65 | */ |
@@ -9,7 +9,7 @@ |
||
9 | 9 | |
10 | 10 | protected function ensureAttributes() |
11 | 11 | { |
12 | - if ( ! isset($this[Specs::ATTRIBUTES])) { |
|
12 | + if (!isset($this[Specs::ATTRIBUTES])) { |
|
13 | 13 | $this[Specs::ATTRIBUTES] = new AttributesContainer(); |
14 | 14 | } |
15 | 15 | } |
@@ -130,7 +130,7 @@ |
||
130 | 130 | * @param \ArrayObject $childA |
131 | 131 | * @param \ArrayObject $childB |
132 | 132 | * |
133 | - * @return number |
|
133 | + * @return integer |
|
134 | 134 | */ |
135 | 135 | protected function childComparator($childA, $childB) |
136 | 136 | { |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | throw new \RuntimeException(sprintf('Variable $nameorElement must be a string or an instance of the Element class')); |
62 | 62 | } |
63 | 63 | // add the index for sorting |
64 | - if ( ! isset($element['__index'])) { |
|
65 | - $element['__index'] = ($this->elementsIndex --); |
|
64 | + if (!isset($element['__index'])) { |
|
65 | + $element['__index'] = ($this->elementsIndex--); |
|
66 | 66 | } |
67 | 67 | $this->elements[$name] = $element; |
68 | 68 | |
@@ -135,20 +135,20 @@ discard block |
||
135 | 135 | protected function childComparator($childA, $childB) |
136 | 136 | { |
137 | 137 | if ($childA->getPosition() < $childB->getPosition()) { |
138 | - return - 1; |
|
138 | + return -1; |
|
139 | 139 | } |
140 | 140 | if ($childA->getPosition() > $childB->getPosition()) { |
141 | 141 | return 1; |
142 | 142 | } |
143 | 143 | if ($childA->get('__index') > $childB->get('__index')) { |
144 | - return - 1; |
|
144 | + return -1; |
|
145 | 145 | } |
146 | 146 | if ($childA->get('__index') < $childB->get('__index')) { |
147 | 147 | return 1; |
148 | 148 | } |
149 | 149 | |
150 | 150 | // if the priority is the same, childB is first |
151 | - return - 1; |
|
151 | + return -1; |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | function getElements() |
160 | 160 | { |
161 | 161 | // first sort the children so they are retrieved by priority |
162 | - uasort($this->elements, array( $this, 'childComparator' )); |
|
162 | + uasort($this->elements, array($this, 'childComparator')); |
|
163 | 163 | |
164 | 164 | return $this->elements; |
165 | 165 | } |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | { |
173 | 173 | foreach ($this->elements as $element) { |
174 | 174 | $group = $element->getGroup(); |
175 | - if ($group && ! isset($this->elements[$group])) { |
|
175 | + if ($group && !isset($this->elements[$group])) { |
|
176 | 176 | $element->setGroup(null); |
177 | 177 | } |
178 | 178 | } |
@@ -55,7 +55,7 @@ |
||
55 | 55 | * |
56 | 56 | * @param array $attrs |
57 | 57 | * |
58 | - * @return mixed |
|
58 | + * @return HasHintTrait |
|
59 | 59 | */ |
60 | 60 | function setHintAttributes($attrs) |
61 | 61 | { |
@@ -9,7 +9,7 @@ |
||
9 | 9 | |
10 | 10 | protected function ensureHintAttributes() |
11 | 11 | { |
12 | - if ( ! isset($this[Specs::HINT_ATTRIBUTES])) { |
|
12 | + if (!isset($this[Specs::HINT_ATTRIBUTES])) { |
|
13 | 13 | $this[Specs::HINT_ATTRIBUTES] = new AttributesContainer(); |
14 | 14 | } |
15 | 15 | } |
@@ -55,7 +55,7 @@ |
||
55 | 55 | * |
56 | 56 | * @param array $attrs |
57 | 57 | * |
58 | - * @return mixed |
|
58 | + * @return HasLabelTrait |
|
59 | 59 | */ |
60 | 60 | function setLabelAttributes($attrs) |
61 | 61 | { |
@@ -9,7 +9,7 @@ |
||
9 | 9 | |
10 | 10 | protected function ensureLabelAttributes() |
11 | 11 | { |
12 | - if ( ! isset($this[Specs::LABEL_ATTRIBUTES])) { |
|
12 | + if (!isset($this[Specs::LABEL_ATTRIBUTES])) { |
|
13 | 13 | $this[Specs::LABEL_ATTRIBUTES] = new AttributesContainer(); |
14 | 14 | } |
15 | 15 | } |
@@ -19,7 +19,7 @@ |
||
19 | 19 | |
20 | 20 | function removeClass($className) |
21 | 21 | { |
22 | - if ( ! $this->hasClass($className)) { |
|
22 | + if (!$this->hasClass($className)) { |
|
23 | 23 | return; |
24 | 24 | } |
25 | 25 | $classes = preg_replace('/\b' . $className . '\b/i', '', $this->get('class')); |