Test Failed
Push — master ( 677611...7e4286 )
by Jean-Bernard
02:30
created

Identity::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
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
use Knp\Rad\ResourceResolver\Bundle\ResourceResolverBundle;
13
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
14
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
15
use Symfony\Bundle\TwigBundle\TwigBundle;
16
use Symfony\Component\Config\Loader\LoaderInterface;
17
use Symfony\Component\DependencyInjection\ContainerBuilder;
18
use Symfony\Component\HttpKernel\Kernel;
19
use Symfony\Component\Routing\Route;
20
use Symfony\Component\Routing\RouteCollectionBuilder;
21
use SymfonyUtil\Controller\EngineAsArgumentController;
22
use SymfonyUtil\Controller\TemplatingController;
23
use SymfonyUtil\Controller\VariadicController;
24
25
class Identity
26
{
27
    public function __invoke($a)
28
    {
29
        dump($a);
30
31
        return $a;
32
    }
33
}
34
35
class AppKernel extends Kernel
0 ignored issues
show
Comprehensibility Best Practice introduced by
The type AppKernel has been defined more than once; this definition is ignored, only the first definition in tests/Framework/src/AppKernel.php (L29-92) is considered.

This check looks for classes that have been defined more than once.

If you can, we would recommend to use standard object-oriented programming techniques. For example, to avoid multiple types, it might make sense to create a common interface, and then multiple, different implementations for that interface.

This also has the side-effect of providing you with better IDE auto-completion, static analysis and also better OPCode caching from PHP.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
36
{
37
    use MicroKernelTrait;
38
39
    public function registerBundles()
40
    {
41
        return [
42
            new FrameworkBundle(),
43
            new ResourceResolverBundle(),
44
            new TwigBundle(),
45
        ];
46
    }
47
48
    protected function configureRoutes(RouteCollectionBuilder $routes)
49
    {
50
        $routes->add('/', EngineAsArgumentController::class, 'index');
51
        $routes->add('/argument', EngineAsArgumentController::class, 'argument');
52
        $routes->add('/constructor', TemplatingController::class, 'constructor');
53
        $routes->addRoute(new Route('/variadic/request', [
54
                '_controller' => VariadicController::class,
55
                '_resources' => [ Identity::class, ['request']],
56
            ]),
57
            'variadic_request'
58
        );
59
    }
60
61
    protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader)
0 ignored issues
show
Unused Code introduced by
The parameter $loader is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
62
    {
63
        //Controllers
64
        $c->autowire(EngineAsArgumentController::class)
65
            ->setAutoconfigured(true)
66
            ->addTag('controller.service_arguments')
67
            ->setPublic(true);
68
69
        $c->autowire(TemplatingController::class)
70
            ->setAutoconfigured(true)
71
            // ->addTag('controller.service_arguments')
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% 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...
72
            ->setPublic(true);
73
74
        $c->autowire(VariadicController::class)
75
            ->setAutoconfigured(true)
76
            ->setPublic(true);
77
78
        // Extensions
79
        $c->loadFromExtension('framework', [
80
            'secret' => 'NotSecret', // What about use $ uuid -v4  or $ uuidgen
81
            'test' => in_array($this->getEnvironment(), ['test'], true), // test.client service for eg. PHPUnit
82
            'templating' => ['engines' => 'twig'],
83
        ]);
84
        $c->loadFromExtension('twig', [
85
            'debug' => true,
86
            'paths' => ['%kernel.project_dir%/tests/templates'],
87
        ]);
88
    }
89
}
90