open-orchestra/open-orchestra-cms-bundle

View on GitHub
Backoffice/Form/Type/Extension/CollectionExtension.php

Summary

Maintainability
A
0 mins
Test Coverage

The method buildView uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                $view->vars['attr'] = array_merge_recursive($view->vars['attr'], array('class' => 'collection-sortable'));
            }

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

Avoid unused parameters such as '$form'.
Open

    public function buildView(FormView $view, FormInterface $form, array $options)

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

Parameter $resolver has undeclared type \Symfony\Component\OptionsResolver\OptionsResolver
Open

    public function configureOptions(OptionsResolver $resolver)

Parameter $form has undeclared type \Symfony\Component\Form\FormInterface
Open

    public function buildView(FormView $view, FormInterface $form, array $options)

Parameter $builder has undeclared type \Symfony\Component\Form\FormBuilderInterface
Open

    public function buildForm(FormBuilderInterface $builder, array $options)

Parameter $view has undeclared type \Symfony\Component\Form\FormView
Open

    public function buildView(FormView $view, FormInterface $form, array $options)

Reference to instance property vars from undeclared class \Symfony\Component\Form\FormView
Open

            if (array_key_exists('class', $view->vars['attr'])) {

Reference to instance property vars from undeclared class \Symfony\Component\Form\FormView
Open

            $view->vars['sortable'] = true;

Class extends undeclared class \Symfony\Component\Form\AbstractTypeExtension
Open

class CollectionExtension extends AbstractTypeExtension

Call to method addEventSubscriber from undeclared class \Symfony\Component\Form\FormBuilderInterface
Open

            $builder->addEventSubscriber(new SortableCollectionSubscriber());

Call to method setDefaults from undeclared class \Symfony\Component\OptionsResolver\OptionsResolver
Open

        $resolver->setDefaults(array(

Reference to instance property vars from undeclared class \Symfony\Component\Form\FormView
Open

                $view->vars['attr']['class'] = $view->vars['attr']['class'] . ' collection-sortable';

Reference to instance property vars from undeclared class \Symfony\Component\Form\FormView
Open

                $view->vars['attr'] = array_merge_recursive($view->vars['attr'], array('class' => 'collection-sortable'));

Line exceeds 120 characters; contains 122 characters
Open

                $view->vars['attr'] = array_merge_recursive($view->vars['attr'], array('class' => 'collection-sortable'));

There are no issues that match your filters.

Category
Status