Completed
Push — master ( 91fdab...75a7b9 )
by
unknown
13:37
created

Controller/RedirectAdminListController.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Kunstmaan\RedirectBundle\Controller;
4
5
use Kunstmaan\AdminListBundle\AdminList\Configurator\AdminListConfiguratorInterface;
6
use Kunstmaan\AdminListBundle\Controller\AdminListController;
7
use Kunstmaan\RedirectBundle\AdminList\RedirectAdminListConfigurator;
8
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
9
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
10
use Symfony\Component\HttpFoundation\Request;
11
use Symfony\Component\HttpFoundation\Response;
12
13
class RedirectAdminListController extends AdminListController
14
{
15
    /**
16
     * @var AdminListConfiguratorInterface
17
     */
18
    private $configurator;
19
20
    /**
21
     * @return AdminListConfiguratorInterface
22
     */
23
    public function getAdminListConfigurator()
24
    {
25
        if (!isset($this->configurator)) {
26
            $this->configurator = new RedirectAdminListConfigurator($this->getEntityManager(), null, $this->container->get('kunstmaan_admin.domain_configuration'));
27
        }
28
29
        return $this->configurator;
30
    }
31
32
    /**
33
     * The index action
34
     *
35
     * @Route("/", name="kunstmaanredirectbundle_admin_redirect")
36
     */
37
    public function indexAction(Request $request)
38
    {
39
        return parent::doIndexAction($this->getAdminListConfigurator(), $request);
40
    }
41
42
    /**
43
     * The add action
44
     *
45
     * @Route("/add", name="kunstmaanredirectbundle_admin_redirect_add")
46
     * @Method({"GET", "POST"})
47
     * @return Response
48
     */
49
    public function addAction(Request $request)
50
    {
51
        return parent::doAddAction($this->getAdminListConfigurator(), null, $request);
0 ignored issues
show
$this->getAdminListConfigurator() of type object<Kunstmaan\AdminLi...tConfiguratorInterface> is not a sub-type of object<Kunstmaan\AdminLi...tAdminListConfigurator>. It seems like you assume a concrete implementation of the interface Kunstmaan\AdminListBundl...stConfiguratorInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
Comprehensibility Bug introduced by
It seems like you call parent on a different method (doAddAction() instead of addAction()). Are you sure this is correct? If so, you might want to change this to $this->doAddAction().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
52
    }
53
54
    /**
55
     * The edit action
56
     *
57
     * @param int $id
58
     *
59
     * @Route("/{id}", requirements={"id" = "\d+"}, name="kunstmaanredirectbundle_admin_redirect_edit")
60
     * @Method({"GET", "POST"})
61
     *
62
     * @return Response
63
     */
64
    public function editAction(Request $request, $id)
65
    {
66
        return parent::doEditAction($this->getAdminListConfigurator(), $id, $request);
67
    }
68
69
    /**
70
     * The delete action
71
     *
72
     * @param int $id
73
     *
74
     * @Route("/{id}/delete", requirements={"id" = "\d+"}, name="kunstmaanredirectbundle_admin_redirect_delete")
75
     * @Method({"GET", "POST"})
76
     *
77
     * @return Response
78
     */
79
    public function deleteAction(Request $request, $id)
80
    {
81
        return parent::doDeleteAction($this->getAdminListConfigurator(), $id, $request);
82
    }
83
84
    /**
85
     * The export action
86
     *
87
     * @param string $_format
88
     *
89
     * @Route("/export.{_format}", requirements={"_format" = "csv|xlsx|ods"}, name="kunstmaanredirectbundle_admin_redirect_export")
90
     * @Method({"GET", "POST"})
91
     * @return Response
92
     */
93
    public function exportAction(Request $request, $_format)
94
    {
95
        return parent::doExportAction($this->getAdminListConfigurator(), $_format, $request);
96
    }
97
}
98