Skip to content

Commit

Permalink
Ignore some PHP MD errors
Browse files Browse the repository at this point in the history
  • Loading branch information
maximehuran committed Jun 18, 2024
1 parent 95fe933 commit 8dbad33
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/Controller/FormController.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public function __construct(RegistryInterface $uiElementRegistry)

/**
* Generate the form for an element.
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function viewAction(Request $request, string $code): Response
{
Expand Down Expand Up @@ -83,6 +85,9 @@ public function viewAction(Request $request, string $code): Response

/**
* Render all UI elements in HTML.
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.ElseExpression)
*/
public function renderElementsAction(Request $request, SwitchAdminLocaleInterface $switchAdminLocale): Response
{
Expand Down Expand Up @@ -218,6 +223,8 @@ private function processFormData(FormInterface $form, FileUploaderInterface $fil
* @param array|string $requestData
*
* @return array|mixed|string
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
private function processFormDataWithoutChild(FormInterface $form, FileUploaderInterface $fileUploader, $requestData)
{
Expand All @@ -240,6 +247,8 @@ private function processFormDataWithoutChild(FormInterface $form, FileUploaderIn
* Recursively convert multidimensional array to one dimension
* The key is the full input name (ex : `image_collection[images][0][image]`)
* It is used in form with file inputs when the form is not valid to avoid to loose uploaded files.
*
* @SuppressWarnings(PHPMD.ElseExpression)
*/
private function convertFormDataForRequest(array $formData, string $prefix = ''): array
{
Expand Down
4 changes: 4 additions & 0 deletions src/Form/Constraints/RichEditorConstraints.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ final class RichEditorConstraints
* Return constraint depending on data
* If user created the element, the field is required
* If it's an edition and it contains a filename, we don't flag it as required.
*
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
*/
public static function getImageConstraints(array $data, string $fieldName, bool $required = true, array $defaultConstraints = []): array
{
Expand All @@ -42,6 +44,8 @@ public static function getImageConstraints(array $data, string $fieldName, bool
* Return constraint depending on data
* If user created the element, the field is required
* If it's an edition and it contains a filename, we don't flag it as required.
*
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
*/
public static function getVideoConstraints(array $data, string $fieldName, bool $required = true, array $defaultConstraints = []): array
{
Expand Down
2 changes: 1 addition & 1 deletion src/Form/Type/UiElement/ButtonLinkType.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
class ButtonLinkType extends AbstractType
{
/**
* @inheritdoc
* @SuppressWarnings(PHPMD.ElseExpression)
*/
public function buildForm(FormBuilderInterface $builder, array $options): void
{
Expand Down
3 changes: 3 additions & 0 deletions src/Form/Type/UiElement/ImageType.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
$this->addEvents($builder, $options);
}

/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function addFields(FormBuilderInterface $builder, array $options): void
{
$builder
Expand Down
3 changes: 3 additions & 0 deletions src/Form/Type/UiElement/VideoType.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
$this->addEvents($builder, $options);
}

/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function addFields(FormBuilderInterface $builder, array $options): void
{
$builder
Expand Down
2 changes: 2 additions & 0 deletions src/Form/Type/WysiwygType.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public function __construct(

/**
* @inheritdoc
*
* @SuppressWarnings(PHPMD.ElseExpression)
*/
public function buildView(FormView $view, FormInterface $form, array $options): void
{
Expand Down
5 changes: 5 additions & 0 deletions src/Twig/RichEditorExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ public function renderElements(array $context, array $elements): string
* @throws LoaderError [twig.render] When the template cannot be found
* @throws SyntaxError [twig.render] When an error occurred during compilation
* @throws RuntimeError [twig.render] When an error occurred during rendering
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function renderElement(array $context, array $element): string
{
Expand Down Expand Up @@ -231,6 +233,9 @@ public function getDefaultElementDataField(): string
return $this->defaultElementDataField;
}

/**
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function getCurrentFilePath(array $context, string $varName = 'full_name'): ?string
{
$form = $context['form'];
Expand Down

0 comments on commit 8dbad33

Please sign in to comment.