Completed
Pull Request — master (#48)
by Claudio
07:27
created

TestKernel   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 6
eloc 17
c 2
b 0
f 0
dl 0
loc 36
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getProjectDir() 0 3 1
A registerBundles() 0 8 3
A getRootDir() 0 3 1
A build() 0 12 1
1
<?php
2
3
namespace Flagbit\Bundle\TableAttributeBundle\Test\Kernel;
4
5
require_once __DIR__.'/../../vendor/akeneo/pim-community-dev/src/Kernel.php';
6
7
use Symfony\Component\DependencyInjection\ContainerBuilder;
8
9
class TestKernel extends \Kernel
10
{
11
    public function registerBundles(): iterable
12
    {
13
        $bundles = require __DIR__ . '/../../vendor/akeneo/pim-community-dev/config/bundles.php';
14
        $bundles += require __DIR__ . '/config/bundles.php';
15
16
        foreach ($bundles as $class => $envs) {
17
            if ($envs[$this->environment] ?? $envs['all'] ?? false) {
18
                yield new $class();
0 ignored issues
show
Bug Best Practice introduced by
The expression yield new $class() 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...
19
            }
20
        }
21
    }
22
23
    public function getRootDir(): string
24
    {
25
        return __DIR__;
26
    }
27
28
    public function getProjectDir(): string
29
    {
30
        return __DIR__;
31
    }
32
33
    protected function build(ContainerBuilder $container)
34
    {
35
        $serviceIds = [
36
            'pim_catalog.validator.constraint_guesser.chained_attribute',
37
            'akeneo.pim.enrichment.factory.value',
38
            'pim_catalog.repository.attribute',
39
            'pim_catalog.repository.cached_attribute',
40
            'form.extension',
41
        ];
42
        $container->addCompilerPass(new PublicServiceCompilerPass($serviceIds));
43
        $container->addCompilerPass(new EnterpriseFilterStubPass('product_proposal'));
44
        $container->addCompilerPass(new EnterpriseFilterStubPass('published_product'));
45
    }
46
}
47