getSubscribedEvents()   A
last analyzed

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 0
1
<?php
2
/*
3
 * WellCommerce Open-Source E-Commerce Platform
4
 * 
5
 * This file is part of the WellCommerce package.
6
 *
7
 * (c) Adam Piotrowski <[email protected]>
8
 * 
9
 * For the full copyright and license information,
10
 * please view the LICENSE file that was distributed with this source code.
11
 */
12
13
namespace WellCommerce\Bundle\CoreBundle\Doctrine\EventSubscriber;
14
15
use Doctrine\Common\EventSubscriber;
16
use Doctrine\ORM\Event\LoadClassMetadataEventArgs;
17
use Doctrine\ORM\Events;
18
use WellCommerce\Component\DoctrineEnhancer\ClassMetadata\ClassMetadataEnhancerTraverserInterface;
19
20
/**
21
 * Class ClassMetadataEventSubscriber
22
 *
23
 * @author  Adam Piotrowski <[email protected]>
24
 */
25
class ClassMetadataEventSubscriber implements EventSubscriber
26
{
27
    /**
28
     * @var ClassMetadataEnhancerTraverserInterface
29
     */
30
    protected $traverser;
31
32
    /**
33
     * ClassMetadataEventSubscriber constructor.
34
     *
35
     * @param ClassMetadataEnhancerTraverserInterface $traverser
36
     */
37
    public function __construct(ClassMetadataEnhancerTraverserInterface $traverser)
38
    {
39
        $this->traverser = $traverser;
40
    }
41
42
    public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
43
    {
44
        /** @var $metadata \Doctrine\Common\Persistence\Mapping\ClassMetadata */
45
        $metadata        = $eventArgs->getClassMetadata();
46
        $this->traverser->traverse($metadata);
0 ignored issues
show
Compatibility introduced by
$metadata of type object<Doctrine\Common\P...\Mapping\ClassMetadata> is not a sub-type of object<Doctrine\ORM\Mapping\ClassMetadataInfo>. It seems like you assume a concrete implementation of the interface Doctrine\Common\Persistence\Mapping\ClassMetadata 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...
47
    }
48
49
    public function getSubscribedEvents()
50
    {
51
        return [
52
            Events::loadClassMetadata
53
        ];
54
    }
55
}
56