Passed
Push — develop ( 7bdbd7...e398eb )
by Neill
33:33 queued 15s
created
neon/core/form/fields/Wysiwyg.php 1 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 1 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 1 patch
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.
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 1 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 1 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/Form.php 1 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.
neon/core/form/FormField.php 1 patch
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -279,8 +279,9 @@  discard block
 block discarded – undo
279 279
 	 */
280 280
 	public function setValidators($validators, $overwrite=true)
281 281
 	{
282
-		if ($overwrite)
283
-			$this->_validators = [];
282
+		if ($overwrite) {
283
+					$this->_validators = [];
284
+		}
284 285
 		if (is_array($validators)) {
285 286
 			foreach ($validators as $key => $validator) {
286 287
 				if (is_numeric($key)) {
@@ -407,10 +408,12 @@  discard block
 block discarded – undo
407 408
 	 */
408 409
 	protected function _getValidatorClass($class)
409 410
 	{
410
-		if (is_array($class) && isset($class['class']))
411
-			$class = $class['class'];
412
-		if (is_object($class))
413
-			$class = get_class($class);
411
+		if (is_array($class) && isset($class['class'])) {
412
+					$class = $class['class'];
413
+		}
414
+		if (is_object($class)) {
415
+					$class = get_class($class);
416
+		}
414 417
 
415 418
 		if (isset(Validator::$builtInValidators[$class])) {
416 419
 			$class = Validator::$builtInValidators[$class]['class'];
@@ -460,8 +463,9 @@  discard block
 block discarded – undo
460 463
 	public function getIdPath($delimiter='.')
461 464
 	{
462 465
 		// set the form id if not already set to something else
463
-		if ($this->isRootForm())
464
-			return $this->getId() ?: $this->getName();
466
+		if ($this->isRootForm()) {
467
+					return $this->getId() ?: $this->getName();
468
+		}
465 469
 		return $this->hasForm()
466 470
 			? $this->getForm()->getIdPath($delimiter) . $delimiter . $this->getName()
467 471
 			: $this->getName();
Please login to merge, or discard this patch.
neon/core/form/FormRepeater.php 1 patch
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -60,8 +60,9 @@  discard block
 block discarded – undo
60 60
 	public function loadFromDb($data)
61 61
 	{
62 62
 		foreach ($data as $name => $value) {
63
-			if (!$this->hasField($name))
64
-				$this->addInstance($name);
63
+			if (!$this->hasField($name)) {
64
+							$this->addInstance($name);
65
+			}
65 66
 			$this->getField($name)->setValueFromDb($value);
66 67
 		}
67 68
 	}
@@ -102,8 +103,9 @@  discard block
 block discarded – undo
102 103
 	{
103 104
 		// throw an exception - should probably cope with this scenario but set
104 105
 		// a validation to fail rather than throwing toys out of the pram
105
-		if (!is_array($value))
106
-			throw new \InvalidArgumentException('The value should be an array');
106
+		if (!is_array($value)) {
107
+					throw new \InvalidArgumentException('The value should be an array');
108
+		}
107 109
 
108 110
 		foreach($value as $position => $values) {
109 111
 			if (!$this->hasField($position)) {
@@ -134,8 +136,9 @@  discard block
 block discarded – undo
134 136
 	public function registerScripts($view=null, $mount=true)
135 137
 	{
136 138
 		$view = ($view === null) ? $this->getView() : $view;
137
-		foreach ($this->getTemplate()->getFields() as $field)
138
-			$field->registerScripts($view, $mount);
139
+		foreach ($this->getTemplate()->getFields() as $field) {
140
+					$field->registerScripts($view, $mount);
141
+		}
139 142
 	}
140 143
 
141 144
 	/**
@@ -240,16 +243,18 @@  discard block
 block discarded – undo
240 243
 	{
241 244
 		// the root path bit can be the the name or the id.
242 245
 		$bits = explode('.', $path);
243
-		if (!($bits[0] === $this->name))
244
-			throw new \Exception("The first part of the path should be the current repeater name. Repeater form name=$this->name, id=$this->id, path=$path.");
246
+		if (!($bits[0] === $this->name)) {
247
+					throw new \Exception("The first part of the path should be the current repeater name. Repeater form name=$this->name, id=$this->id, path=$path.");
248
+		}
245 249
 
246 250
 		// if the repeater has an existing instance - then lets return that
247 251
 		if ($this->hasField($bits[1])) {
248 252
 			$field = $this->getField($bits[1]);
249 253
 			// fields within repeaters should always be forms - so this should never happen
250 254
 			// but just to ensure we trap the error - lets throw an exception
251
-			if (!$field->isForm())
252
-				throw new \InvalidArgumentException('FormRepeaters should only contain form instances.');
255
+			if (!$field->isForm()) {
256
+							throw new \InvalidArgumentException('FormRepeaters should only contain form instances.');
257
+			}
253 258
 			array_splice($bits, 0, 1);
254 259
 			return $field->getFieldByPath(implode('.', $bits));
255 260
 		}
Please login to merge, or discard this patch.