Passed
Push — releases ( 51c2cc...e1d10c )
by steve
39:06 queued 13:38
created
neon/core/form/fields/Wysiwyg.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -61,17 +61,17 @@
 block discarded – undo
61 61
 				'toolbar' =>  [
62 62
 					[
63 63
 						'name' => 'paragraph',
64
-						'items' => [ 'Bold', 'Italic', 'Underline', 'Link', 'Unlink', 'EmojiPanel', 'Source' ]
64
+						'items' => ['Bold', 'Italic', 'Underline', 'Link', 'Unlink', 'EmojiPanel', 'Source']
65 65
 					]
66 66
 				]
67 67
 			],
68 68
 			'default' => [
69 69
 				'toolbar' =>  [
70
-					[ 'name' => 'paragraph', 'items' => [ 'Format', 'Bold', 'Italic', 'Underline', '-', 'Superscript', 'Subscript', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock','-', 'NumberedList', 'BulletedList', 'Outdent', 'Indent', 'Blockquote'] ],
71
-					[ 'name' => 'links', 'items' => [ 'Link', 'Unlink', 'Anchor', '-', 'EmojiPanel' ] ],
72
-					[ 'name' => 'insert', 'items' => [ 'Image', 'SimpleImageUpload', 'Table', 'SpecialChar' ] ],
73
-					[ 'name' => 'document', 'items' => ['Maximize' ] ],
74
-					[ 'name' => 'source', 'items' => [ 'RemoveFormat', '-', 'Source' ] ]
70
+					['name' => 'paragraph', 'items' => ['Format', 'Bold', 'Italic', 'Underline', '-', 'Superscript', 'Subscript', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'NumberedList', 'BulletedList', 'Outdent', 'Indent', 'Blockquote']],
71
+					['name' => 'links', 'items' => ['Link', 'Unlink', 'Anchor', '-', 'EmojiPanel']],
72
+					['name' => 'insert', 'items' => ['Image', 'SimpleImageUpload', 'Table', 'SpecialChar']],
73
+					['name' => 'document', 'items' => ['Maximize']],
74
+					['name' => 'source', 'items' => ['RemoveFormat', '-', 'Source']]
75 75
 				],
76 76
 				'extraPlugins' => ['simpleImageUpload'],
77 77
 			]
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -81,8 +81,9 @@
 block discarded – undo
81 81
 		$fullConfig = array_merge_recursive($defaultConfigSets, $additionalConfigSets);
82 82
 		// convert the extraPlugins into a comma separated list as required by ckeditor
83 83
 		foreach ($fullConfig as $set=>$config) {
84
-			if (isset($config['extraPlugins']))
85
-				$fullConfig[$set]['extraPlugins'] = implode(',', $config['extraPlugins']);
84
+			if (isset($config['extraPlugins'])) {
85
+							$fullConfig[$set]['extraPlugins'] = implode(',', $config['extraPlugins']);
86
+			}
86 87
 		}
87 88
 		return json_encode($fullConfig);
88 89
 	}
Please login to merge, or discard this patch.
neon/core/form/fields/filters/File.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
 	/**
23 23
 	 * @inheritdoc
24 24
 	 */
25
-	public function processAsFilter(IQuery $query, $searchData=null)
25
+	public function processAsFilter(IQuery $query, $searchData = null)
26 26
 	{
27 27
 		// do a query
28 28
 		$ids = neon()->db->query()->from('firefly_file_manager')->select('uuid')->where(['like', 'name', $searchData])->column();
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,7 +26,8 @@
 block discarded – undo
26 26
 	{
27 27
 		// do a query
28 28
 		$ids = neon()->db->query()->from('firefly_file_manager')->select('uuid')->where(['like', 'name', $searchData])->column();
29
-		if (!empty($ids))
30
-			$query->where($this->getDataKey(), '=', $ids);
29
+		if (!empty($ids)) {
30
+					$query->where($this->getDataKey(), '=', $ids);
31
+		}
31 32
 	}
32 33
 }
33 34
\ No newline at end of file
Please login to merge, or discard this patch.
neon/core/form/fields/Date.php 2 patches
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -129,8 +129,9 @@
 block discarded – undo
129 129
 	public function getValueDisplay()
130 130
 	{
131 131
 		// the asDate function sets all empty values to 0 meaning it returns a formatted version of 1970-01-01
132
-		if (empty($this->getData()))
133
-			return neon()->formatter->nullDisplay;
132
+		if (empty($this->getData())) {
133
+					return neon()->formatter->nullDisplay;
134
+		}
134 135
 		return neon()->formatter->asDate($this->getData());
135 136
 	}
136 137
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@
 block discarded – undo
60 60
 	/**
61 61
 	 * @inheritdoc
62 62
 	 */
63
-	public function processAsFilter(IQuery $query, $searchData=null)
63
+	public function processAsFilter(IQuery $query, $searchData = null)
64 64
 	{
65 65
 		$searchData = ($searchData === null) ? $this->getValue() : $searchData;
66 66
 		if ($searchData !== '') {
Please login to merge, or discard this patch.
neon/core/form/fields/Real.php 1 patch
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -36,8 +36,9 @@  discard block
 block discarded – undo
36 36
 	 */
37 37
 	public function setValue($value)
38 38
 	{
39
-		if (is_numeric($value))
40
-			return parent::setValue(round($value, $this->decimal));
39
+		if (is_numeric($value)) {
40
+					return parent::setValue(round($value, $this->decimal));
41
+		}
41 42
 		parent::setvalue(null);
42 43
 	}
43 44
 
@@ -47,8 +48,9 @@  discard block
 block discarded – undo
47 48
 	public function getValue()
48 49
 	{
49 50
 		// prevent returning 0 when casting a null value to a (real) number
50
-		if (!is_numeric($this->_value))
51
-			return null;
51
+		if (!is_numeric($this->_value)) {
52
+					return null;
53
+		}
52 54
 		return (real) $this->_value;
53 55
 	}
54 56
 
@@ -58,8 +60,9 @@  discard block
 block discarded – undo
58 60
 	public function getValueDisplay()
59 61
 	{
60 62
 		$value = $this->getValue();
61
-		if ($this->decimal === 0)
62
-			return neon()->formatter->asInteger($value);
63
+		if ($this->decimal === 0) {
64
+					return neon()->formatter->asInteger($value);
65
+		}
63 66
 		return neon()->formatter->asDecimal($value, $this->decimal);
64 67
 	}
65 68
 
Please login to merge, or discard this patch.
neon/core/form/traits/BuilderTrait.php 2 patches
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 	 * @param boolean $overwrite (optional) - whether to overwrite an existing field of the same name defaults to false
85 85
 	 * @return fields\Field|Form|FormRepeater
86 86
 	 */
87
-	abstract public function add($field, $defaults=[], $overwrite=false);
87
+	abstract public function add($field, $defaults = [], $overwrite = false);
88 88
 
89 89
 	/**
90 90
 	 * Adds a sub form box to the form
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 * @param array $options
94 94
 	 * @return IField|Form
95 95
 	 */
96
-	public function addSubForm($name, $options=[])
96
+	public function addSubForm($name, $options = [])
97 97
 	{
98 98
 		if (is_object($name)) {
99 99
 			return $this->add($name);
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 	 * @param array $options
110 110
 	 * @return IField|fields\Text
111 111
 	 */
112
-	public function addFieldText($name, $options=[])
112
+	public function addFieldText($name, $options = [])
113 113
 	{
114 114
 		return $this->add($options, ['name' => $name, 'class' => 'text']);
115 115
 	}
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	 * @param array $options
122 122
 	 * @return IField|fields\Password
123 123
 	 */
124
-	public function addFieldPassword($name, $options=[])
124
+	public function addFieldPassword($name, $options = [])
125 125
 	{
126 126
 		return $this->add($options, ['name' => $name, 'class' => 'password']);
127 127
 	}
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 	 * @param string $name
133 133
 	 * @return IField|fields\Text
134 134
 	 */
135
-	public function addFieldFile($name, $options=[])
135
+	public function addFieldFile($name, $options = [])
136 136
 	{
137 137
 		return $this->add($options, ['class' => 'file', 'name' => $name]);
138 138
 	}
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	 * @param string $name
146 146
 	 * @return IField|fields\Text
147 147
 	 */
148
-	public function addFieldImage($name, $options=[])
148
+	public function addFieldImage($name, $options = [])
149 149
 	{
150 150
 		return $this->add($options, ['class' => 'image', 'name' => $name]);
151 151
 	}
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 	 * @param string $name
157 157
 	 * @return IField|fields\Email
158 158
 	 */
159
-	public function addFieldEmail($name, $options=[])
159
+	public function addFieldEmail($name, $options = [])
160 160
 	{
161 161
 		return $this->add($options, ['class' => 'email', 'name' => $name]);
162 162
 	}
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 	 * @param array $options
169 169
 	 * @return IField|fields\Submit
170 170
 	 */
171
-	public function addFieldSubmit($name, $options=[])
171
+	public function addFieldSubmit($name, $options = [])
172 172
 	{
173 173
 		return $this->add($options, ['class' => 'submit', 'name' => $name]);
174 174
 	}
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 	 * @param array $options
181 181
 	 * @return IField|fields\Text
182 182
 	 */
183
-	public function addFieldHidden($name, $options=[])
183
+	public function addFieldHidden($name, $options = [])
184 184
 	{
185 185
 		return $this->add($options, ['class' => 'hidden', 'name' => $name]);
186 186
 	}
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	 * @param array  $options
193 193
 	 * @return IField|fields\Checkbox
194 194
 	 */
195
-	public function addFieldCheckbox($name, $options=[])
195
+	public function addFieldCheckbox($name, $options = [])
196 196
 	{
197 197
 		return $this->add($options, ['class' => 'checkbox', 'name' => $name]);
198 198
 	}
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 	 * @param array  $options
205 205
 	 * @return IField|fields\Checkbox
206 206
 	 */
207
-	public function addFieldCheckList($name, $options=[])
207
+	public function addFieldCheckList($name, $options = [])
208 208
 	{
209 209
 		return $this->add($options, ['class' => 'checklist', 'name' => $name]);
210 210
 	}
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 	 * @param array  $options
217 217
 	 * @return IField|fields\Date
218 218
 	 */
219
-	public function addFieldDate($name, $options=[])
219
+	public function addFieldDate($name, $options = [])
220 220
 	{
221 221
 		return $this->add($options, ['name' => $name, 'class' => 'date']);
222 222
 	}
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 	 * @param array  $options
229 229
 	 * @return IField|fields\DateTime
230 230
 	 */
231
-	public function addFieldDateTime($name, $options=[])
231
+	public function addFieldDateTime($name, $options = [])
232 232
 	{
233 233
 		return $this->add($options, ['name' => $name, 'class' => 'datetime']);
234 234
 	}
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 	 * @param array  $options
241 241
 	 * @return IField|fields\Integer
242 242
 	 */
243
-	public function addFieldInteger($name, $options=[])
243
+	public function addFieldInteger($name, $options = [])
244 244
 	{
245 245
 		return $this->add($options, ['name' => $name, 'class' => 'integer']);
246 246
 	}
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 	 * @param array  $options
253 253
 	 * @return IField|fields\Select
254 254
 	 */
255
-	public function addFieldSelect($name, $options=[])
255
+	public function addFieldSelect($name, $options = [])
256 256
 	{
257 257
 		return $this->add($options, ['class' => 'select', 'name' => $name]);
258 258
 	}
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 	 * @param array  $options
265 265
 	 * @return IField|fields\Section
266 266
 	 */
267
-	public function addFieldSection($name, $options=[])
267
+	public function addFieldSection($name, $options = [])
268 268
 	{
269 269
 		return $this->add($options, ['class' => 'section', 'name' => $name]);
270 270
 	}
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 	 * @param array  $options
277 277
 	 * @return IField|fields\SwitchButton
278 278
 	 */
279
-	public function addFieldSwitch($name, $options=[])
279
+	public function addFieldSwitch($name, $options = [])
280 280
 	{
281 281
 		return $this->add($options, ['class' => 'switch', 'name' => $name]);
282 282
 	}
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 	 * @param array  $options
289 289
 	 * @return IField|fields\Textarea
290 290
 	 */
291
-	public function addFieldTextArea($name, $options=[])
291
+	public function addFieldTextArea($name, $options = [])
292 292
 	{
293 293
 		return $this->add($options, ['class' => 'textarea', 'name' => $name]);
294 294
 	}
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 	 * @param array  $options
301 301
 	 * @return IField|fields\Time
302 302
 	 */
303
-	public function addFieldTime($name, $options=[])
303
+	public function addFieldTime($name, $options = [])
304 304
 	{
305 305
 		return $this->add($options, ['name' => $name, 'class' => 'time']);
306 306
 	}
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 	 * @param array  $options
313 313
 	 * @return IField|fields\Wysiwyg
314 314
 	 */
315
-	public function addFieldWysiwyg($name, $options=[])
315
+	public function addFieldWysiwyg($name, $options = [])
316 316
 	{
317 317
 		return $this->add($options, ['class' => 'wysiwyg', 'name' => $name]);
318 318
 	}
@@ -350,14 +350,14 @@  discard block
 block discarded – undo
350 350
 	 * @throws UnknownFieldClass if the class is not found
351 351
 	 * @return IField
352 352
 	 */
353
-	public function makeField($field, $defaults=[])
353
+	public function makeField($field, $defaults = [])
354 354
 	{
355 355
 		if (is_array($field))
356 356
 			$field = $this->createFieldObjectFromConfig($field, $defaults);
357 357
 
358 358
 		if (!($field instanceof IField || $field instanceof Form)) {
359 359
 			// add this form as the parent form reference
360
-			throw new \InvalidArgumentException('The $field parameter was not a valid \neon\core\form\fields\Field or \neon\core\form\Form object "' . print_r($field, true) . '" given');
360
+			throw new \InvalidArgumentException('The $field parameter was not a valid \neon\core\form\fields\Field or \neon\core\form\Form object "'.print_r($field, true).'" given');
361 361
 		}
362 362
 		return $field;
363 363
 	}
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
 	 * @throws UnknownFieldClass
382 382
 	 * @return IField
383 383
 	 */
384
-	public function createFieldObjectFromConfig($config, $defaults=[])
384
+	public function createFieldObjectFromConfig($config, $defaults = [])
385 385
 	{
386 386
 		$config = Arr::merge($defaults, $config);
387 387
 		// allows class config property to be specified by an alias "switch"
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -352,8 +352,9 @@  discard block
 block discarded – undo
352 352
 	 */
353 353
 	public function makeField($field, $defaults=[])
354 354
 	{
355
-		if (is_array($field))
356
-			$field = $this->createFieldObjectFromConfig($field, $defaults);
355
+		if (is_array($field)) {
356
+					$field = $this->createFieldObjectFromConfig($field, $defaults);
357
+		}
357 358
 
358 359
 		if (!($field instanceof IField || $field instanceof Form)) {
359 360
 			// add this form as the parent form reference
@@ -422,8 +423,9 @@  discard block
 block discarded – undo
422 423
 	 */
423 424
 	public function getFieldClassByAlias($alias)
424 425
 	{
425
-		if (!$this->fieldAliasExists($alias))
426
-			throw new \InvalidArgumentException("There is no alias with the key '$alias' in the Forms fieldAliases array");
426
+		if (!$this->fieldAliasExists($alias)) {
427
+					throw new \InvalidArgumentException("There is no alias with the key '$alias' in the Forms fieldAliases array");
428
+		}
427 429
 		return $this->fieldAliases[strtolower($alias)];
428 430
 	}
429 431
 
Please login to merge, or discard this patch.
neon/core/form/Deprecated.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	 * @return \neon\core\form\Form
37 37
 	 * @deprecated should be using phoebe this should be replaced with using the loadFromDefinition via phoebe
38 38
 	 */
39
-	public static function ddsLoadFrom($form, $classType, $includeDeleted=false)
39
+	public static function ddsLoadFrom($form, $classType, $includeDeleted = false)
40 40
 	{
41 41
 		\Neon::warning('neon\core\form\Form::ddsLoadFrom is a deprecated function - phoebe is responsible for loading form definitions');
42 42
 		$class = neon()->getDds()->getIDdsClassManagement()->getClass($classType);
@@ -58,11 +58,11 @@  discard block
 block discarded – undo
58 58
 		$formDefinition = Arr::merge($formDefinition, $immutable);
59 59
 		// remove the class option
60 60
 		Arr::remove($formDefinition, 'class');
61
-		foreach($formDefinition as $key => $value) {
61
+		foreach ($formDefinition as $key => $value) {
62 62
 			$form->$key = $value;
63 63
 		}
64 64
 		// Add fields to the form from the individual members
65
-		if (! empty($members) ) {
65
+		if (!empty($members)) {
66 66
 			foreach ($members as $member) {
67 67
 				$form->ddsAddField($member);
68 68
 			}
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 * @return void
79 79
 	 * @deprecated
80 80
 	 */
81
-	public static function ddsSaveDefinition($form, $classType=null, $ddsMembers=null)
81
+	public static function ddsSaveDefinition($form, $classType = null, $ddsMembers = null)
82 82
 	{
83 83
 		\Neon::warning('neon\core\form\Form::ddsSaveDefinition is a deprecated function - phoebe is now responsible for saving form definitions');
84 84
 		// \neon\phoebe\builders\database\builder\Dds::saveDefinition($form);
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 			]);
98 98
 		}
99 99
 		$members = $ddsClassManager->listMembers($classType, true);
100
-		foreach($form->getFields() as $key => $field) {
100
+		foreach ($form->getFields() as $key => $field) {
101 101
 			// set the order value to be the same as how we received them
102 102
 			$field->ddsSaveDefinition($classType, $members, $key);
103 103
 		}
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 		]);
144 144
 		// the definition might supply more information
145 145
 		$widgetDefinition = [];
146
-		if (!empty($member['definition'])){
146
+		if (!empty($member['definition'])) {
147 147
 			// if the definition is already array then assume it is decoded - if it is not then assume it is a json string
148 148
 			$widgetDefinition = is_array($member['definition'])
149 149
 				? $member['definition']
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 		}
152 152
 		// remove the value from the widget definition as this should be populated by the actual data
153 153
 		Arr::remove($widgetDefinition, 'value');
154
-		$config = Arr::merge($defaults, $widgetDefinition , $immutable);
154
+		$config = Arr::merge($defaults, $widgetDefinition, $immutable);
155 155
 
156 156
 		$form->add($config);
157 157
 	}
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 	 * @param array|null $ddsMembers if not specified it will look up the members of the classType
167 167
 	 * @deprecated
168 168
 	 */
169
-	public static function ddsSaveDefinitionField($field, $classType=null, $ddsMembers=null)
169
+	public static function ddsSaveDefinitionField($field, $classType = null, $ddsMembers = null)
170 170
 	{
171 171
 		\Neon::warning('neon\core\form\field::ddsSaveDefinition is a deprecated function - you should be using phoebe');
172 172
 		$iDdsClassManagement = neon()->getDds()->getIDdsClassManagement();
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -180,8 +180,9 @@
 block discarded – undo
180 180
 		}
181 181
 
182 182
 		// ignore if this is a deleted field
183
-		if ($field->deleted == 1)
184
-			return;
183
+		if ($field->deleted == 1) {
184
+					return;
185
+		}
185 186
 
186 187
 		// check if member exists
187 188
 		$memberRef = $field->getDdsName();
Please login to merge, or discard this patch.
neon/core/form/interfaces/IField.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	 * @param mixed $searchData - The request data if null should populate from the form fields internal $this->getValue()
234 234
 	 * @return void
235 235
 	 */
236
-	public function processAsFilter(IQuery $query, $searchData=null);
236
+	public function processAsFilter(IQuery $query, $searchData = null);
237 237
 
238 238
 // endregion
239 239
 
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 	 * @param string $delimiter - the string delimiter to separate concatenated field names by
244 244
 	 * @return mixed
245 245
 	 */
246
-	public function getIdPath($delimiter='.');
246
+	public function getIdPath($delimiter = '.');
247 247
 
248 248
 	/**
249 249
 	 * Generate fake data for the field
Please login to merge, or discard this patch.
neon/core/form/interfaces/IValidate.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 	 * @param bool $required
17 17
 	 * @return $this method can be chained
18 18
 	 */
19
-	public function setRequired($required=true);
19
+	public function setRequired($required = true);
20 20
 
21 21
 	/**
22 22
 	 * Add a validator to a form field
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	 *
53 53
 	 * @return $this Is a chainable function
54 54
 	 */
55
-	public function addValidator($validator, $options=[]);
55
+	public function addValidator($validator, $options = []);
56 56
 
57 57
 	/**
58 58
 	 * @param array $validators
Please login to merge, or discard this patch.
neon/core/form/Form.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -661,7 +661,7 @@
 block discarded – undo
661 661
 	/**
662 662
 	 * render the form header html
663 663
 	 * @return string
664
-    */
664
+	 */
665 665
 	public function renderHeader()
666 666
 	{
667 667
 		// TODO: 27/06/2018 - toArray does a fair bit of work if form has multiple fields set, we want to serialize all properties EXCEPT for fields
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -95,13 +95,13 @@  discard block
 block discarded – undo
95 95
 	 * @param bool $replace - will replace any existing attributes
96 96
 	 * @return $this - chainable interface
97 97
 	 */
98
-	public function setAttributes($attrs, $replace=false)
98
+	public function setAttributes($attrs, $replace = false)
99 99
 	{
100 100
 		if ($replace) {
101 101
 			$this->_attributes = $attrs;
102 102
 		} else {
103 103
 			if (isset($attrs['class'])) {
104
-				$this->_attributes['class'] = ' ' . $attrs['class'];
104
+				$this->_attributes['class'] = ' '.$attrs['class'];
105 105
 				unset($attrs['class']);
106 106
 			}
107 107
 			$this->_attributes = array_merge($this->_attributes, $attrs);
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	 * if a string is provided then it is used as the name property
146 146
 	 * @param array $config additional configuration
147 147
 	 */
148
-	public function __construct($name=[], array $config=[])
148
+	public function __construct($name = [], array $config = [])
149 149
 	{
150 150
 		// The $name field can also be a configuration array
151 151
 		if (is_array($name)) {
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 	/**
197 197
 	 * @inheritdoc
198 198
 	 */
199
-	public function registerScripts($view=null, $mount=true)
199
+	public function registerScripts($view = null, $mount = true)
200 200
 	{
201 201
 		$view = ($view === null) ? $this->getView() : $view;
202 202
 		FormAsset::register($view);
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 			$field->registerScripts($view);
205 205
 		if ($this->isRootForm()) {
206 206
 			if ($mount)
207
-				$view->registerJs('(new Vue()).$mount("#' . $this->id . '");', $view::POS_END, $this->id . 'vue');
207
+				$view->registerJs('(new Vue()).$mount("#'.$this->id.'");', $view::POS_END, $this->id.'vue');
208 208
 		}
209 209
 	}
210 210
 
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 	public function validate($names = null, $clearErrors = true)
255 255
 	{
256 256
 		$valid = true;
257
-		foreach($this->getFields($names) as $key => $field) {
257
+		foreach ($this->getFields($names) as $key => $field) {
258 258
 			$valid = $field->validate() && $valid;
259 259
 		}
260 260
 		return $valid;
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 	 * @param array $errors
301 301
 	 * @return array
302 302
 	 */
303
-	protected function _getFormErrors($form, &$errors=[])
303
+	protected function _getFormErrors($form, &$errors = [])
304 304
 	{
305 305
 		foreach ($form->getFields() as $field) {
306 306
 			if ($field->isForm()) {
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 	public function getErrors()
326 326
 	{
327 327
 		$errors = [];
328
-		foreach($this->getFields() as $name => $field) {
328
+		foreach ($this->getFields() as $name => $field) {
329 329
 			if ($field->hasError())
330 330
 				$errors[$name] = $field->getErrors();
331 331
 		}
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
 	 * @param string $error  if this is not null then it is the error
355 355
 	 * @return void
356 356
 	 */
357
-	public function addError($fieldNameOrError='', $error=null)
357
+	public function addError($fieldNameOrError = '', $error = null)
358 358
 	{
359 359
 		if ($error === null)
360 360
 			$this->_errors[] = $fieldNameOrError;
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
 	 */
395 395
 	public function getViewPath()
396 396
 	{
397
-		return __DIR__ . DIRECTORY_SEPARATOR . 'views';
397
+		return __DIR__.DIRECTORY_SEPARATOR.'views';
398 398
 	}
399 399
 
400 400
 	/**
@@ -410,9 +410,9 @@  discard block
 block discarded – undo
410 410
 		$i = 1;
411 411
 		while ($this->hasField($name)) {
412 412
 			if (preg_match('/.*(_[0-9]+)/', $name, $matches)) {
413
-				$name = str_replace($matches[1], '_' . $i++, $name);
413
+				$name = str_replace($matches[1], '_'.$i++, $name);
414 414
 			} else {
415
-				$name .= '_' . $i++;
415
+				$name .= '_'.$i++;
416 416
 			}
417 417
 		}
418 418
 		return $name;
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
 	 * @throws InvalidCallException if a name key specified in the $names array does not exist as a field
484 484
 	 * @return \neon\core\form\fields\Field[] [name => field object]
485 485
 	 */
486
-	public function getFields($names=null)
486
+	public function getFields($names = null)
487 487
 	{
488 488
 		$this->orderFields();
489 489
 		if ($names === null)
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
 	 */
517 517
 	public function getSubForm($name)
518 518
 	{
519
-		if (! $this->hasField($name)) {
519
+		if (!$this->hasField($name)) {
520 520
 			throw new \Exception("No sub form exists with the name '$name'");
521 521
 		}
522 522
 		return $this->getField($name);
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
 	 * @throws exceptions\UnknownFieldClass - if the field class can not be created
620 620
 	 * @return fields\Field
621 621
 	 */
622
-	public function add($field, $defaults=[], $overwrite=false)
622
+	public function add($field, $defaults = [], $overwrite = false)
623 623
 	{
624 624
 		$object = $this->makeField($field, $defaults);
625 625
 		return $this->_addField($object, $overwrite);
@@ -632,12 +632,12 @@  discard block
 block discarded – undo
632 632
 	 *
633 633
 	 * @return \neon\core\form\fields\Field
634 634
 	 */
635
-	protected function _addField(IField $object, $overwrite=false)
635
+	protected function _addField(IField $object, $overwrite = false)
636 636
 	{
637 637
 		// pass the field a reference to its parent form
638 638
 		$object->setForm($this);
639 639
 		if ($object->getName() == '') {
640
-			throw new \InvalidArgumentException('A field object must have a name set before adding it to the form. You tried to add ' . print_r($object->toArray(), true));
640
+			throw new \InvalidArgumentException('A field object must have a name set before adding it to the form. You tried to add '.print_r($object->toArray(), true));
641 641
 		}
642 642
 		if ($object instanceof Field || $object instanceof Form) {
643 643
 			// the field object seems to be valid so before we add it we just check this is not a conflict with an existing field
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
 			// add this form as the parent form reference
649 649
 			$this->_fields[$object->getName()] = $object;
650 650
 		} else {
651
-			throw new \InvalidArgumentException('The $object parameter was not a valid \neon\core\form\Field or \neon\core\form\Form object "' . print_r($object, true) . '" given');
651
+			throw new \InvalidArgumentException('The $object parameter was not a valid \neon\core\form\Field or \neon\core\form\Form object "'.print_r($object, true).'" given');
652 652
 		}
653 653
 		return $object;
654 654
 	}
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
 	 */
677 677
 	public function renderCsrfField()
678 678
 	{
679
-		return '<input type="hidden" name="'.$this->getRequest()->csrfParam.'" value="' . $this->getRequest()->getCsrfToken() . '" />';
679
+		return '<input type="hidden" name="'.$this->getRequest()->csrfParam.'" value="'.$this->getRequest()->getCsrfToken().'" />';
680 680
 	}
681 681
 
682 682
 	/**
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
 	 * @throws \yii\base\InvalidConfigException getBodyParams may throw this error if a registered parser does not implement the [[RequestParserInterface]].
749 749
 	 * @return array  the request data
750 750
 	 */
751
-	public function getRawRequestData($key=null)
751
+	public function getRawRequestData($key = null)
752 752
 	{
753 753
 		$params = $this->getRequest()->getBodyParams();
754 754
 		$data = isset($params[$this->getName()]) ? $params[$this->getName()] : [];
@@ -779,7 +779,7 @@  discard block
 block discarded – undo
779 779
 	 * @throws \Exception - if request object is configured incorrectly
780 780
 	 * @return $this
781 781
 	 */
782
-	public function load($data=[])
782
+	public function load($data = [])
783 783
 	{
784 784
 		if (empty($data) && $this->hasRequestData()) {
785 785
 			$data = $this->getRawRequestData();
@@ -871,7 +871,7 @@  discard block
 block discarded – undo
871 871
 	 * Root forms always require an id
872 872
 	 * @return String
873 873
 	 */
874
-	public function getId($autoGenerate=false)
874
+	public function getId($autoGenerate = false)
875 875
 	{
876 876
 		if ($this->_id)
877 877
 			return $this->_id;
@@ -992,7 +992,7 @@  discard block
 block discarded – undo
992 992
 	 * @inheritdoc - IField implementation,
993 993
 	 * Possibly applicable to the form - perhaps if set the form will complain unless all its children are set??
994 994
 	 */
995
-	public function setRequired($required=true)
995
+	public function setRequired($required = true)
996 996
 	{}
997 997
 // endregion
998 998
 
@@ -1065,7 +1065,7 @@  discard block
 block discarded – undo
1065 1065
 	public function getProperties()
1066 1066
 	{
1067 1067
 		$props = [
1068
-			'class', 'id', 'name', 'enableAjaxValidation','enableAjaxSubmission',
1068
+			'class', 'id', 'name', 'enableAjaxValidation', 'enableAjaxSubmission',
1069 1069
 			'label', 'hint', 'inline', 'visible', 'order', 'action', 'readOnly', 'printOnly', 'validationUrl',
1070 1070
 			'attributes', 'fields', 'objectToken'
1071 1071
 		];
@@ -1201,10 +1201,10 @@  discard block
 block discarded – undo
1201 1201
 	 *
1202 1202
 	 * @return Form
1203 1203
 	 */
1204
-	public function getFilterForm($config=[])
1204
+	public function getFilterForm($config = [])
1205 1205
 	{
1206 1206
 		$searchForm = new Form($config);
1207
-		foreach($this->getFields() as $field) {
1207
+		foreach ($this->getFields() as $field) {
1208 1208
 			$filterField = $field->getFilterField();
1209 1209
 
1210 1210
 			if ($filterField !== false) {
@@ -1228,7 +1228,7 @@  discard block
 block discarded – undo
1228 1228
 	public function processAsFilter(IQuery $query, $searchData = null)
1229 1229
 	{
1230 1230
 		$searchData = ($searchData === null) ? $this->getValue() : $searchData;
1231
-		foreach($this->getFields() as $key => $field) {
1231
+		foreach ($this->getFields() as $key => $field) {
1232 1232
 			if (isset($searchData[$key])) {
1233 1233
 				$field->processAsFilter($query, $searchData[$key]);
1234 1234
 			}
@@ -1268,7 +1268,7 @@  discard block
 block discarded – undo
1268 1268
 	 */
1269 1269
 	public function reset()
1270 1270
 	{
1271
-		foreach($this->getFields() as $field)
1271
+		foreach ($this->getFields() as $field)
1272 1272
 			$field->reset();
1273 1273
 	}
1274 1274
 
@@ -1287,7 +1287,7 @@  discard block
 block discarded – undo
1287 1287
 	public function fake()
1288 1288
 	{
1289 1289
 		$fake = [];
1290
-		foreach($this->getFields() as $key => $field) {
1290
+		foreach ($this->getFields() as $key => $field) {
1291 1291
 			$val = $field->fake();
1292 1292
 			if (empty($val)) continue;
1293 1293
 			$fake[$key] = $val;
@@ -1299,7 +1299,7 @@  discard block
 block discarded – undo
1299 1299
 	 * @deprecated should be using phoebe this should be replaced with using the loadFromDefinition via phoebe
1300 1300
 	 * @see Deprecated::ddsLoadFrom
1301 1301
 	 */
1302
-	public function ddsLoadFrom($classType, $includeDeleted=false)
1302
+	public function ddsLoadFrom($classType, $includeDeleted = false)
1303 1303
 	{
1304 1304
 		return Deprecated::ddsLoadFrom($this, $classType, $includeDeleted);
1305 1305
 	}
@@ -1308,7 +1308,7 @@  discard block
 block discarded – undo
1308 1308
 	 * @deprecated - should be using phoebe
1309 1309
 	 * @see Deprecated::ddsSaveDefinition
1310 1310
 	 */
1311
-	public function ddsSaveDefinition($classType=null, $ddsMembers=null)
1311
+	public function ddsSaveDefinition($classType = null, $ddsMembers = null)
1312 1312
 	{
1313 1313
 		Deprecated::ddsSaveDefinition($this, $classType, $ddsMembers);
1314 1314
 	}
Please login to merge, or discard this patch.
Braces   +47 added lines, -31 removed lines patch added patch discarded remove patch
@@ -200,11 +200,13 @@  discard block
 block discarded – undo
200 200
 	{
201 201
 		$view = ($view === null) ? $this->getView() : $view;
202 202
 		FormAsset::register($view);
203
-		foreach ($this->getFields() as $field)
204
-			$field->registerScripts($view);
203
+		foreach ($this->getFields() as $field) {
204
+					$field->registerScripts($view);
205
+		}
205 206
 		if ($this->isRootForm()) {
206
-			if ($mount)
207
-				$view->registerJs('(new Vue()).$mount("#' . $this->id . '");', $view::POS_END, $this->id . 'vue');
207
+			if ($mount) {
208
+							$view->registerJs('(new Vue()).$mount("#' . $this->id . '");', $view::POS_END, $this->id . 'vue');
209
+			}
208 210
 		}
209 211
 	}
210 212
 
@@ -326,8 +328,9 @@  discard block
 block discarded – undo
326 328
 	{
327 329
 		$errors = [];
328 330
 		foreach($this->getFields() as $name => $field) {
329
-			if ($field->hasError())
330
-				$errors[$name] = $field->getErrors();
331
+			if ($field->hasError()) {
332
+							$errors[$name] = $field->getErrors();
333
+			}
331 334
 		}
332 335
 		return array_merge($this->_errors, $errors);
333 336
 	}
@@ -356,10 +359,11 @@  discard block
 block discarded – undo
356 359
 	 */
357 360
 	public function addError($fieldNameOrError='', $error=null)
358 361
 	{
359
-		if ($error === null)
360
-			$this->_errors[] = $fieldNameOrError;
361
-		else
362
-			$this->getField($fieldNameOrError)->addError($error);
362
+		if ($error === null) {
363
+					$this->_errors[] = $fieldNameOrError;
364
+		} else {
365
+					$this->getField($fieldNameOrError)->addError($error);
366
+		}
363 367
 	}
364 368
 
365 369
 // ============================================================================
@@ -451,8 +455,9 @@  discard block
 block discarded – undo
451 455
 		// the root path bit can be the the name or the id of the form
452 456
 		// all children of the root will use the name property
453 457
 		$bits = explode('.', $path);
454
-		if (!($bits[0] === $this->name || ($this->isRootForm() && $bits[0] === $this->id)))
455
-			throw new \Exception("The first part of the path should be the form name or the id if this is a root form. Form name={$this->name}, id={$this->id}, path=$path.");
458
+		if (!($bits[0] === $this->name || ($this->isRootForm() && $bits[0] === $this->id))) {
459
+					throw new \Exception("The first part of the path should be the form name or the id if this is a root form. Form name={$this->name}, id={$this->id}, path=$path.");
460
+		}
456 461
 		// remove first item and reindex array : note unset does not update array indexes
457 462
 		array_splice($bits, 0, 1);
458 463
 		$field = $this->getField($bits[0]);
@@ -486,8 +491,9 @@  discard block
 block discarded – undo
486 491
 	public function getFields($names=null)
487 492
 	{
488 493
 		$this->orderFields();
489
-		if ($names === null)
490
-			return $this->_fields;
494
+		if ($names === null) {
495
+					return $this->_fields;
496
+		}
491 497
 
492 498
 		return Arr::only($this->_fields, $names);
493 499
 	}
@@ -811,8 +817,9 @@  discard block
 block discarded – undo
811 817
 		$data = [];
812 818
 		foreach ($this->getFields() as $field) {
813 819
 			if (!$field->deleted) {
814
-				if ($field->getIsInput())
815
-					$data[$field->getDataKey()] = $field->getData();
820
+				if ($field->getIsInput()) {
821
+									$data[$field->getDataKey()] = $field->getData();
822
+				}
816 823
 			}
817 824
 		}
818 825
 		return $data;
@@ -827,8 +834,9 @@  discard block
 block discarded – undo
827 834
 	{
828 835
 		$data = [];
829 836
 		foreach ($this->getFields() as $field) {
830
-			if ($field->getIsInput())
831
-				$data[$field->getName()] = $field->getValueDisplay();
837
+			if ($field->getIsInput()) {
838
+							$data[$field->getName()] = $field->getValueDisplay();
839
+			}
832 840
 		}
833 841
 		return $data;
834 842
 	}
@@ -841,8 +849,9 @@  discard block
 block discarded – undo
841 849
 	 */
842 850
 	public function getDataKey()
843 851
 	{
844
-		if ($this->_dataKey !== null)
845
-			return $this->_dataKey;
852
+		if ($this->_dataKey !== null) {
853
+					return $this->_dataKey;
854
+		}
846 855
 		return $this->getName();
847 856
 	}
848 857
 
@@ -873,8 +882,9 @@  discard block
 block discarded – undo
873 882
 	 */
874 883
 	public function getId($autoGenerate=false)
875 884
 	{
876
-		if ($this->_id)
877
-			return $this->_id;
885
+		if ($this->_id) {
886
+					return $this->_id;
887
+		}
878 888
 		return $this->getName();
879 889
 	}
880 890
 
@@ -908,8 +918,9 @@  discard block
 block discarded – undo
908 918
 		$value = [];
909 919
 		foreach ($this->getFields() as $field) {
910 920
 			if (!$field->deleted) {
911
-				if ($field->getIsInput())
912
-					$value[$field->getDataKey()] = $field->getValue();
921
+				if ($field->getIsInput()) {
922
+									$value[$field->getDataKey()] = $field->getValue();
923
+				}
913 924
 			}
914 925
 		}
915 926
 		return $value;
@@ -1136,8 +1147,9 @@  discard block
 block discarded – undo
1136 1147
 		$fields = [];
1137 1148
 		foreach ($this->getFields() as $key => $field) {
1138 1149
 			$fieldDefinition = $field->exportDefinition();
1139
-			if (!is_null($fieldDefinition))
1140
-				$fields[$key] = $fieldDefinition;
1150
+			if (!is_null($fieldDefinition)) {
1151
+							$fields[$key] = $fieldDefinition;
1152
+			}
1141 1153
 		}
1142 1154
 		$formDefinition['definition']['fields'] = $fields;
1143 1155
 		return $formDefinition;
@@ -1248,8 +1260,9 @@  discard block
 block discarded – undo
1248 1260
 	 */
1249 1261
 	public function getRequest()
1250 1262
 	{
1251
-		if ($this->_request === null)
1252
-			$this->_request = neon()->request;
1263
+		if ($this->_request === null) {
1264
+					$this->_request = neon()->request;
1265
+		}
1253 1266
 		return $this->_request;
1254 1267
 	}
1255 1268
 
@@ -1268,8 +1281,9 @@  discard block
 block discarded – undo
1268 1281
 	 */
1269 1282
 	public function reset()
1270 1283
 	{
1271
-		foreach($this->getFields() as $field)
1272
-			$field->reset();
1284
+		foreach($this->getFields() as $field) {
1285
+					$field->reset();
1286
+		}
1273 1287
 	}
1274 1288
 
1275 1289
 	/**
@@ -1289,7 +1303,9 @@  discard block
 block discarded – undo
1289 1303
 		$fake = [];
1290 1304
 		foreach($this->getFields() as $key => $field) {
1291 1305
 			$val = $field->fake();
1292
-			if (empty($val)) continue;
1306
+			if (empty($val)) {
1307
+				continue;
1308
+			}
1293 1309
 			$fake[$key] = $val;
1294 1310
 		}
1295 1311
 		return $fake;
Please login to merge, or discard this patch.