Skip to content

Commit

Permalink
PSR-12 code style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
annda committed Jul 5, 2024
1 parent 04e4026 commit ebd59d0
Show file tree
Hide file tree
Showing 22 changed files with 22 additions and 24 deletions.
1 change: 1 addition & 0 deletions src/Actions/AbstractAction.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace CosmoCode\Formserver\Actions;
Expand Down
1 change: 1 addition & 0 deletions src/Actions/FormAction.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace CosmoCode\Formserver\Actions;
Expand Down
1 change: 0 additions & 1 deletion src/Exceptions/FormException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@
*/
class FormException extends \RuntimeException
{

}
1 change: 0 additions & 1 deletion src/Exceptions/LanguageException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@
*/
class LanguageException extends \RuntimeException
{

}
1 change: 0 additions & 1 deletion src/Exceptions/MailException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@
*/
class MailException extends \RuntimeException
{

}
1 change: 0 additions & 1 deletion src/Exceptions/TwigException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@
*/
class TwigException extends \RuntimeException
{

}
1 change: 0 additions & 1 deletion src/Exceptions/YamlException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@
*/
class YamlException extends \RuntimeException
{

}
9 changes: 6 additions & 3 deletions src/FormGenerator/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,8 @@ protected function setDefaultValues(AbstractFormElement $formElement): void
foreach ($formElement->getChildren() as $fieldsetChild) {
$this->setDefaultValues($fieldsetChild);
}
} elseif ($formElement instanceof ChecklistFormElement
} elseif (
$formElement instanceof ChecklistFormElement
|| $formElement instanceof DropdownFormElement
) {
if (! $formElement->hasValue()) {
Expand All @@ -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();
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/FormGenerator/FormElements/AbstractFormElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/FormGenerator/FormElements/ChecklistFormElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <p>...</p>
// https://github.com/michelf/php-markdown/issues/230
Expand Down
1 change: 0 additions & 1 deletion src/FormGenerator/FormElements/DownloadFormElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@
*/
class DownloadFormElement extends AbstractStaticFormElement
{

}
1 change: 0 additions & 1 deletion src/FormGenerator/FormElements/FieldsetFormElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
*/
class FieldsetFormElement extends AbstractFormElement
{

/**
* @var AbstractFormElement[]
*/
Expand Down
1 change: 0 additions & 1 deletion src/FormGenerator/FormElements/HiddenFormElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@
*/
class HiddenFormElement extends AbstractStaticFormElement
{

}
1 change: 0 additions & 1 deletion src/FormGenerator/FormElements/HrFormElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@
*/
class HrFormElement extends AbstractStaticFormElement
{

}
1 change: 0 additions & 1 deletion src/FormGenerator/FormElements/ImageFormElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@
*/
class ImageFormElement extends AbstractStaticFormElement
{

}
1 change: 0 additions & 1 deletion src/FormGenerator/FormElements/RadiosetFormElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@
*/
class RadiosetFormElement extends AbstractDynamicFormElement
{

}
1 change: 0 additions & 1 deletion src/FormGenerator/FormElements/TextAreaFormElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@
*/
class TextAreaFormElement extends AbstractDynamicFormElement
{

}
1 change: 1 addition & 0 deletions src/FormGenerator/FormElements/UploadFormElement.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace CosmoCode\Formserver\FormGenerator\FormElements;
Expand Down
9 changes: 6 additions & 3 deletions src/FormGenerator/FormValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,15 @@ public function validate()
*/
protected function validateFormElement(AbstractFormElement $formElement)
{
if ($formElement instanceof FieldsetFormElement
if (
$formElement instanceof FieldsetFormElement
&& ! $formElement->isDisabled()
) {
foreach ($formElement->getChildren() as $fieldsetChild) {
$this->validateFormElement($fieldsetChild);
}
} elseif ($formElement instanceof AbstractDynamicFormElement
} elseif (
$formElement instanceof AbstractDynamicFormElement
&& ($formElement->hasValue() || $formElement->isRequired())
) {
$value = $formElement->getValue();
Expand Down Expand Up @@ -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));
}
Expand Down
5 changes: 2 additions & 3 deletions src/Helper/FileHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*/
class FileHelper
{

/**
* Get file extension from file path
*
Expand Down Expand Up @@ -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';
Expand Down
1 change: 1 addition & 0 deletions src/ResponseEmitter/ResponseEmitter.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace CosmoCode\Formserver\ResponseEmitter;
Expand Down
3 changes: 2 additions & 1 deletion src/Service/Mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ protected function formToMessage(
* @var AbstractDynamicFormElement $element
*/
foreach ($formElements as $element) {
if ($element instanceof FieldsetFormElement
if (
$element instanceof FieldsetFormElement
&& ! $element->isDisabled()
) {
$this->htmlBody
Expand Down

0 comments on commit ebd59d0

Please sign in to comment.