open-orchestra/open-orchestra-cms-bundle

View on GitHub
Backoffice/EventSubscriber/RedirectionTypeSubscriber.php

Summary

Maintainability
A
0 mins
Test Coverage

Avoid assigning values to variables in if clauses and the like (line '25', column '28').
Open

    public function postSubmit(FormEvent $event)
    {
        $form = $event->getForm();
        /** @var RedirectionInterface $data */
        $data = $event->getData();

IfStatementAssignment

Since: 2.7.0

Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

Example

class Foo
{
    public function bar($flag)
    {
        if ($foo = 'bar') { // possible typo
            // ...
        }
        if ($baz = 0) { // always false
            // ...
        }
    }
}

Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

Parameter $event has undeclared type \Symfony\Component\Form\FormEvent
Open

    public function postSubmit(FormEvent $event)

Class implements undeclared interface \Symfony\Component\EventDispatcher\EventSubscriberInterface
Open

class RedirectionTypeSubscriber implements EventSubscriberInterface

Checking instanceof against undeclared class \OpenOrchestra\ModelInterface\Model\RedirectionInterface
Open

        if ($data instanceof RedirectionInterface) {

Reference to constant POST_SUBMIT from undeclared class \Symfony\Component\Form\FormEvents
Open

            FormEvents::POST_SUBMIT => 'postSubmit',

Call to method setSiteName from undeclared class \OpenOrchestra\ModelInterface\Model\RedirectionInterface
Open

                $data->setSiteName($siteName);

Call to method getData from undeclared class \Symfony\Component\Form\FormEvent
Open

        $data = $event->getData();

Call to method getSiteId from undeclared class \OpenOrchestra\ModelInterface\Model\RedirectionInterface
Open

            if (false !== ($siteName = array_search($data->getSiteId(), $form->get('siteId')->getConfig()->getOption('choices')))) {

Call to method getForm from undeclared class \Symfony\Component\Form\FormEvent
Open

        $form = $event->getForm();

Line exceeds 120 characters; contains 132 characters
Open

            if (false !== ($siteName = array_search($data->getSiteId(), $form->get('siteId')->getConfig()->getOption('choices')))) {

There are no issues that match your filters.

Category
Status