Passed
Push — master ( 174956...a0b45a )
by Jean-Bernard
07:30
created

ReRouteControllerModel.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
/*
4
 * This file is part of the Symfony-Util package.
5
 *
6
 * (c) Jean-Bernard Addor
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace SymfonyUtil\Component\HttpFoundation;
13
14
// Similar namespace in Symfony
15
// https://github.com/symfony/symfony/tree/v3.3.8/src/Symfony/Component/Routing/Generator
16
17
use Symfony\Component\HttpFoundation\Request;
18
19
// Used from same namespace
20
// ReRouteControllerModelInterface
21
// ReRouteInterface
22
// ResponseParameters
23
24
class ReRouteControllerModel implements ReRouteControllerModelInterface
25
{
26
    protected $reRoute;
27
28
    public function __construct(ReRouteInterface $reRoute)
29
    {
30
        $this->reRoute = $reRoute;
31
    }
32
33
    /**
34
     * Returns ResponseParameters to the given route with the given parameters.
35
     *
36
     * @param string $routeName  The name of the route
37
     * @param mixed  $parameters An array of parameters
38
     *
39
     * @return ResponseParametersInterface
40
     *
41
     * @see Interface ReRouteControllerModelInterface
42
     */
43
    public function __invoke($routeName, $parameters = [], Request $request = null)
44
    {
45
        // return new ResponseParameters([], ($this->reRoute)($routeName, $parameters)); // PHP 7+
0 ignored issues
show
Unused Code Comprehensibility introduced by
68% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
46
        return new ResponseParameters([], call_user_func($this->reRoute, $routeName, $parameters)); // PHP 4+ (5+)
0 ignored issues
show
Unused Code Comprehensibility introduced by
40% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
47
    }
48
}
49
50
// Inspired from https://github.com/symfony/symfony/blob/v3.3.8/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php
51