Completed
Push — master ( dba66b...b8eb92 )
by Fabien
03:50
created

ServiceEntityRepository   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 13
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
1
<?php
2
3
/*
4
 * This file is part of the Doctrine Bundle
5
 *
6
 * The code was originally distributed inside the Symfony framework.
7
 *
8
 * (c) Fabien Potencier <[email protected]>
9
 * (c) Doctrine Project, Benjamin Eberlei <[email protected]>
10
 *
11
 * For the full copyright and license information, please view the LICENSE
12
 * file that was distributed with this source code.
13
 */
14
15
namespace Doctrine\Bundle\DoctrineBundle\Repository;
16
17
use Doctrine\Common\Persistence\ManagerRegistry;
18
use Doctrine\ORM\EntityRepository;
19
20
/**
21
 * Optional EntityRepository base class with a simplified constructor (for autowiring).
22
 *
23
 * To use in your class, inject the "registry" service and call
24
 * the parent constructor. For example:
25
 *
26
 * class YourEntityRepository extends ServiceEntityRepository
27
 * {
28
 *     public function __construct(RegistryInterface $registry)
29
 *     {
30
 *         parent::__construct($registry, YourEntity::class);
31
 *     }
32
 * }
33
 *
34
 * @author Ryan Weaver <[email protected]>
35
 */
36
class ServiceEntityRepository extends EntityRepository implements ServiceEntityRepositoryInterface
37
{
38
    /**
39
     * @param ManagerRegistry $registry
40
     * @param string          $entityClass The class name of the entity this repository manages
41
     */
42
    public function __construct(ManagerRegistry $registry, $entityClass)
43
    {
44
        $manager = $registry->getManagerForClass($entityClass);
45
46
        parent::__construct($manager, $manager->getClassMetadata($entityClass));
0 ignored issues
show
Documentation introduced by
$manager is of type object<Doctrine\Common\P...nce\ObjectManager>|null, but the function expects a object<Doctrine\ORM\EntityManager>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
47
    }
48
}
49