Passed
Pull Request — master (#139)
by Kevin
03:11
created

Kernel   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 6
eloc 38
c 2
b 0
f 1
dl 0
loc 68
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A registerBundles() 0 12 3
A configureRoutes() 0 2 1
A configureContainer() 0 43 2
1
<?php
2
3
namespace Zenstruck\Foundry\Tests\Fixtures;
4
5
use DAMA\DoctrineTestBundle\DAMADoctrineTestBundle;
6
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
7
use Psr\Log\NullLogger;
8
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
9
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
10
use Symfony\Bundle\MakerBundle\MakerBundle;
11
use Symfony\Component\Config\Loader\LoaderInterface;
12
use Symfony\Component\DependencyInjection\ContainerBuilder;
13
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
14
use Symfony\Component\Routing\RouteCollectionBuilder;
15
use Zenstruck\Foundry\Tests\Fixtures\Factories\CategoryFactory;
16
use Zenstruck\Foundry\Tests\Fixtures\Factories\CategoryServiceFactory;
17
use Zenstruck\Foundry\Tests\Fixtures\Stories\ServiceStory;
18
use Zenstruck\Foundry\ZenstruckFoundryBundle;
19
20
/**
21
 * @author Kevin Bond <[email protected]>
22
 */
23
class Kernel extends BaseKernel
24
{
25
    use MicroKernelTrait;
0 ignored issues
show
Bug introduced by
The trait Symfony\Bundle\Framework...Kernel\MicroKernelTrait requires the property $instanceof which is not provided by Zenstruck\Foundry\Tests\Fixtures\Kernel.
Loading history...
26
27
    public function registerBundles(): iterable
28
    {
29
        yield new FrameworkBundle();
0 ignored issues
show
Bug Best Practice introduced by
The expression yield new Symfony\Bundle...undle\FrameworkBundle() returns the type Generator which is incompatible with the return type mandated by Symfony\Component\HttpKe...face::registerBundles() of Symfony\Component\HttpKe...dleInterface[]|iterable.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
30
        yield new DoctrineBundle();
31
        yield new MakerBundle();
32
33
        if (\getenv('USE_FOUNDRY_BUNDLE')) {
34
            yield new ZenstruckFoundryBundle();
35
        }
36
37
        if (\getenv('USE_DAMA_DOCTRINE_TEST_BUNDLE')) {
38
            yield new DAMADoctrineTestBundle();
39
        }
40
    }
41
42
    protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader): void
0 ignored issues
show
Unused Code introduced by
The parameter $loader is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

42
    protected function configureContainer(ContainerBuilder $c, /** @scrutinizer ignore-unused */ LoaderInterface $loader): void

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

Loading history...
43
    {
44
        $c->register('logger', NullLogger::class);
45
46
        $c->register(Service::class);
47
        $c->register(ServiceStory::class)
48
            ->setAutoconfigured(true)
49
            ->setAutowired(true)
50
        ;
51
        $c->register(CategoryFactory::class)
52
            ->setAutoconfigured(true)
53
            ->setAutowired(true)
54
        ;
55
        $c->register(CategoryServiceFactory::class)
56
            ->setAutoconfigured(true)
57
            ->setAutowired(true)
58
        ;
59
60
        $c->loadFromExtension('framework', [
61
            'secret' => 'S3CRET',
62
            'test' => true,
63
        ]);
64
65
        $c->loadFromExtension('doctrine', [
66
            'dbal' => ['url' => '%env(resolve:DATABASE_URL)%'],
67
            'orm' => [
68
                'auto_generate_proxy_classes' => true,
69
                'auto_mapping' => true,
70
                'mappings' => [
71
                    'Test' => [
72
                        'is_bundle' => false,
73
                        'type' => 'annotation',
74
                        'dir' => '%kernel.project_dir%/tests/Fixtures/Entity',
75
                        'prefix' => 'Zenstruck\Foundry\Tests\Fixtures\Entity',
76
                        'alias' => 'Test',
77
                    ],
78
                ],
79
            ],
80
        ]);
81
82
        if (\getenv('USE_FOUNDRY_BUNDLE')) {
83
            $c->loadFromExtension('zenstruck_foundry', [
84
                'auto_refresh_proxies' => false,
85
            ]);
86
        }
87
    }
88
89
    protected function configureRoutes(RouteCollectionBuilder $routes): void
0 ignored issues
show
Unused Code introduced by
The parameter $routes is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

89
    protected function configureRoutes(/** @scrutinizer ignore-unused */ RouteCollectionBuilder $routes): void

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

Loading history...
90
    {
91
        // noop
92
    }
93
}
94