From ebd59d0abce859457e6092b5cd30feb07963acce Mon Sep 17 00:00:00 2001 From: Anna Dabrowska Date: Fri, 5 Jul 2024 13:31:30 +0200 Subject: [PATCH] PSR-12 code style fixes --- src/Actions/AbstractAction.php | 1 + src/Actions/FormAction.php | 1 + src/Exceptions/FormException.php | 1 - src/Exceptions/LanguageException.php | 1 - src/Exceptions/MailException.php | 1 - src/Exceptions/TwigException.php | 1 - src/Exceptions/YamlException.php | 1 - src/FormGenerator/Form.php | 9 ++++++--- src/FormGenerator/FormElements/AbstractFormElement.php | 2 +- src/FormGenerator/FormElements/ChecklistFormElement.php | 2 +- src/FormGenerator/FormElements/DownloadFormElement.php | 1 - src/FormGenerator/FormElements/FieldsetFormElement.php | 1 - src/FormGenerator/FormElements/HiddenFormElement.php | 1 - src/FormGenerator/FormElements/HrFormElement.php | 1 - src/FormGenerator/FormElements/ImageFormElement.php | 1 - src/FormGenerator/FormElements/RadiosetFormElement.php | 1 - src/FormGenerator/FormElements/TextAreaFormElement.php | 1 - src/FormGenerator/FormElements/UploadFormElement.php | 1 + src/FormGenerator/FormValidator.php | 9 ++++++--- src/Helper/FileHelper.php | 5 ++--- src/ResponseEmitter/ResponseEmitter.php | 1 + src/Service/Mailer.php | 3 ++- 22 files changed, 22 insertions(+), 24 deletions(-) diff --git a/src/Actions/AbstractAction.php b/src/Actions/AbstractAction.php index 9acb70b..8987cdf 100644 --- a/src/Actions/AbstractAction.php +++ b/src/Actions/AbstractAction.php @@ -1,4 +1,5 @@ getChildren() as $fieldsetChild) { $this->setDefaultValues($fieldsetChild); } - } elseif ($formElement instanceof ChecklistFormElement + } elseif ( + $formElement instanceof ChecklistFormElement || $formElement instanceof DropdownFormElement ) { if (! $formElement->hasValue()) { @@ -413,7 +414,8 @@ protected function injectValueToArray( $this->injectValueToArray($tempValues, $fieldsetChild); } $values[$formElement->getId()] = $tempValues; - } elseif ($formElement instanceof AbstractDynamicFormElement + } elseif ( + $formElement instanceof AbstractDynamicFormElement && $formElement->hasValue() ) { $values[$formElement->getId()] = $formElement->getValue(); @@ -428,7 +430,8 @@ protected function injectValueToArray( */ protected function isFormElementValid(AbstractFormElement $formElement): bool { - if ($formElement instanceof FieldsetFormElement + if ( + $formElement instanceof FieldsetFormElement && ! $formElement->isDisabled() ) { foreach ($formElement->getChildren() as $fieldsetChild) { diff --git a/src/FormGenerator/FormElements/AbstractFormElement.php b/src/FormGenerator/FormElements/AbstractFormElement.php index 3bb4735..c7df538 100644 --- a/src/FormGenerator/FormElements/AbstractFormElement.php +++ b/src/FormGenerator/FormElements/AbstractFormElement.php @@ -206,7 +206,7 @@ protected function dottedIdToFormId(string $id): string $toggleViewId = $toggleIdPath[0]; for ($i = 1; $i < $togglePathCount; $i++) { - $toggleViewId .= '[' .$toggleIdPath[$i] . ']'; + $toggleViewId .= '[' . $toggleIdPath[$i] . ']'; } return $toggleViewId; diff --git a/src/FormGenerator/FormElements/ChecklistFormElement.php b/src/FormGenerator/FormElements/ChecklistFormElement.php index c6fb860..501f3fe 100644 --- a/src/FormGenerator/FormElements/ChecklistFormElement.php +++ b/src/FormGenerator/FormElements/ChecklistFormElement.php @@ -36,7 +36,7 @@ public function getViewVariables(): array $transformedChoices = []; foreach ($choices as $choice) { - $transformedChoice= MarkdownExtra::defaultTransform($choice); + $transformedChoice = MarkdownExtra::defaultTransform($choice); // Markdown lib always wraps the content in a

...

// https://github.com/michelf/php-markdown/issues/230 diff --git a/src/FormGenerator/FormElements/DownloadFormElement.php b/src/FormGenerator/FormElements/DownloadFormElement.php index 03042e4..84c348c 100644 --- a/src/FormGenerator/FormElements/DownloadFormElement.php +++ b/src/FormGenerator/FormElements/DownloadFormElement.php @@ -7,5 +7,4 @@ */ class DownloadFormElement extends AbstractStaticFormElement { - } diff --git a/src/FormGenerator/FormElements/FieldsetFormElement.php b/src/FormGenerator/FormElements/FieldsetFormElement.php index 50e34d1..f48acee 100644 --- a/src/FormGenerator/FormElements/FieldsetFormElement.php +++ b/src/FormGenerator/FormElements/FieldsetFormElement.php @@ -12,7 +12,6 @@ */ class FieldsetFormElement extends AbstractFormElement { - /** * @var AbstractFormElement[] */ diff --git a/src/FormGenerator/FormElements/HiddenFormElement.php b/src/FormGenerator/FormElements/HiddenFormElement.php index a11953c..bce2f7d 100644 --- a/src/FormGenerator/FormElements/HiddenFormElement.php +++ b/src/FormGenerator/FormElements/HiddenFormElement.php @@ -7,5 +7,4 @@ */ class HiddenFormElement extends AbstractStaticFormElement { - } diff --git a/src/FormGenerator/FormElements/HrFormElement.php b/src/FormGenerator/FormElements/HrFormElement.php index c3d3e78..300d50f 100644 --- a/src/FormGenerator/FormElements/HrFormElement.php +++ b/src/FormGenerator/FormElements/HrFormElement.php @@ -7,5 +7,4 @@ */ class HrFormElement extends AbstractStaticFormElement { - } diff --git a/src/FormGenerator/FormElements/ImageFormElement.php b/src/FormGenerator/FormElements/ImageFormElement.php index 21c9374..29beb63 100644 --- a/src/FormGenerator/FormElements/ImageFormElement.php +++ b/src/FormGenerator/FormElements/ImageFormElement.php @@ -7,5 +7,4 @@ */ class ImageFormElement extends AbstractStaticFormElement { - } diff --git a/src/FormGenerator/FormElements/RadiosetFormElement.php b/src/FormGenerator/FormElements/RadiosetFormElement.php index c034878..1b9a3c9 100644 --- a/src/FormGenerator/FormElements/RadiosetFormElement.php +++ b/src/FormGenerator/FormElements/RadiosetFormElement.php @@ -7,5 +7,4 @@ */ class RadiosetFormElement extends AbstractDynamicFormElement { - } diff --git a/src/FormGenerator/FormElements/TextAreaFormElement.php b/src/FormGenerator/FormElements/TextAreaFormElement.php index 1381d28..44711a5 100644 --- a/src/FormGenerator/FormElements/TextAreaFormElement.php +++ b/src/FormGenerator/FormElements/TextAreaFormElement.php @@ -7,5 +7,4 @@ */ class TextAreaFormElement extends AbstractDynamicFormElement { - } diff --git a/src/FormGenerator/FormElements/UploadFormElement.php b/src/FormGenerator/FormElements/UploadFormElement.php index 1f4c494..6c53673 100644 --- a/src/FormGenerator/FormElements/UploadFormElement.php +++ b/src/FormGenerator/FormElements/UploadFormElement.php @@ -1,4 +1,5 @@ isDisabled() ) { foreach ($formElement->getChildren() as $fieldsetChild) { $this->validateFormElement($fieldsetChild); } - } elseif ($formElement instanceof AbstractDynamicFormElement + } elseif ( + $formElement instanceof AbstractDynamicFormElement && ($formElement->hasValue() || $formElement->isRequired()) ) { $value = $formElement->getValue(); @@ -134,7 +136,8 @@ protected function validateFormElement(AbstractFormElement $formElement) * @var UploadFormElement $formElement */ $validators = []; - foreach ($formElement->getAllowedExtensionsAsArray() as $ext + foreach ( + $formElement->getAllowedExtensionsAsArray() as $ext ) { $validators[] = Validator::extension(trim($ext)); } diff --git a/src/Helper/FileHelper.php b/src/Helper/FileHelper.php index f203171..4000f9b 100644 --- a/src/Helper/FileHelper.php +++ b/src/Helper/FileHelper.php @@ -9,7 +9,6 @@ */ class FileHelper { - /** * Get file extension from file path * @@ -111,9 +110,9 @@ public static function humanToBytes($size) */ public static function getMaxSizeHuman(int $size) { - if ($size >= 1024**3) { + if ($size >= 1024 ** 3) { $fileSize = round($size / 1024 / 1024 / 1024, 1) . 'GB'; - } elseif ($size >= 1024**2) { + } elseif ($size >= 1024 ** 2) { $fileSize = round($size / 1024 / 1024, 1) . 'MB'; } elseif ($size >= 1024) { $fileSize = round($size / 1024, 1) . 'KB'; diff --git a/src/ResponseEmitter/ResponseEmitter.php b/src/ResponseEmitter/ResponseEmitter.php index 438fdc9..381d38a 100644 --- a/src/ResponseEmitter/ResponseEmitter.php +++ b/src/ResponseEmitter/ResponseEmitter.php @@ -1,4 +1,5 @@ isDisabled() ) { $this->htmlBody