sonata-project / sonata-doctrine-extensions

Compare 969f6f1 ... +242 ... 57cf21c


@@ -13,7 +13,9 @@
Loading
13 13
14 14
namespace Sonata\Doctrine\Document;
15 15
16 +
use Doctrine\DBAL\Connection;
16 17
use Doctrine\ODM\MongoDB\DocumentManager;
18 +
use Doctrine\Persistence\ObjectManager;
17 19
use Sonata\Doctrine\Model\BaseManager;
18 20
19 21
/**
@@ -38,15 +40,15 @@
Loading
38 40
        throw new \RuntimeException(sprintf('The property %s does not exists', $name));
39 41
    }
40 42
41 -
    public function getConnection()
43 +
    public function getConnection(): Connection
42 44
    {
43 45
        return $this->getObjectManager()->getConnection();
44 46
    }
45 47
46 48
    /**
47 49
     * @return DocumentManager
48 50
     */
49 -
    public function getDocumentManager()
51 +
    public function getDocumentManager(): ObjectManager
50 52
    {
51 53
        $dm = $this->getObjectManager();
52 54

@@ -13,6 +13,7 @@
Loading
13 13
14 14
namespace Sonata\Doctrine\Document;
15 15
16 +
use Doctrine\DBAL\Connection;
16 17
use Doctrine\Persistence\ObjectManager;
17 18
use Sonata\Doctrine\Model\BaseManager;
18 19
@@ -41,7 +42,7 @@
Loading
41 42
     *
42 43
     * @throws \LogicException Each call
43 44
     */
44 -
    public function getConnection()
45 +
    public function getConnection(): Connection
45 46
    {
46 47
        throw new \LogicException('PHPCR does not use a database connection.');
47 48
    }
@@ -51,15 +52,12 @@
Loading
51 52
     *
52 53
     * @throws \LogicException Each call
53 54
     */
54 -
    public function getTableName()
55 +
    public function getTableName(): string
55 56
    {
56 57
        throw new \LogicException('PHPCR does not use a reference name for a list of data.');
57 58
    }
58 59
59 -
    /**
60 -
     * @return ObjectManager
61 -
     */
62 -
    public function getDocumentManager()
60 +
    public function getDocumentManager(): ObjectManager
63 61
    {
64 62
        return $this->getObjectManager();
65 63
    }

@@ -25,7 +25,7 @@
Loading
25 25
 */
26 26
class SonataDoctrineExtension extends Extension
27 27
{
28 -
    public function load(array $configs, ContainerBuilder $container)
28 +
    public function load(array $configs, ContainerBuilder $container): void
29 29
    {
30 30
        $loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
31 31
        $loader->load('services.php');

@@ -38,22 +38,18 @@
Loading
38 38
    protected $class;
39 39
40 40
    /**
41 -
     * @param string $class
42 -
     *
43 41
     * @phpstan-param class-string<T> $class
44 42
     */
45 -
    public function __construct($class, ManagerRegistry $registry)
43 +
    public function __construct(string $class, ManagerRegistry $registry)
46 44
    {
47 45
        $this->registry = $registry;
48 46
        $this->class = $class;
49 47
    }
50 48
51 49
    /**
52 50
     * @throws \RuntimeException
53 -
     *
54 -
     * @return ObjectManager
55 51
     */
56 -
    public function getObjectManager()
52 +
    public function getObjectManager(): ObjectManager
57 53
    {
58 54
        $manager = $this->registry->getManagerForClass($this->class);
59 55
@@ -70,22 +66,22 @@
Loading
70 66
        return $manager;
71 67
    }
72 68
73 -
    public function getClass()
69 +
    public function getClass(): string
74 70
    {
75 71
        return $this->class;
76 72
    }
77 73
78 -
    public function findAll()
74 +
    public function findAll(): array
79 75
    {
80 76
        return $this->getRepository()->findAll();
81 77
    }
82 78
83 -
    public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null)
79 +
    public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array
84 80
    {
85 81
        return $this->getRepository()->findBy($criteria, $orderBy, $limit, $offset);
86 82
    }
87 83
88 -
    public function findOneBy(array $criteria, ?array $orderBy = null)
84 +
    public function findOneBy(array $criteria, ?array $orderBy = null): ?object
89 85
    {
90 86
        if (null !== $orderBy) {
91 87
            @trigger_error(
@@ -97,17 +93,17 @@
Loading
97 93
        return $this->getRepository()->findOneBy($criteria);
98 94
    }
99 95
100 -
    public function find($id)
96 +
    public function find($id): ?object
101 97
    {
102 98
        return $this->getRepository()->find($id);
103 99
    }
104 100
105 -
    public function create()
101 +
    public function create(): object
106 102
    {
107 103
        return new $this->class();
108 104
    }
109 105
110 -
    public function save($entity, $andFlush = true)
106 +
    public function save(object $entity, bool $andFlush = true): void
111 107
    {
112 108
        $this->checkObject($entity);
113 109
@@ -118,7 +114,7 @@
Loading
118 114
        }
119 115
    }
120 116
121 -
    public function delete($entity, $andFlush = true)
117 +
    public function delete(object $entity, bool $andFlush = true): void
122 118
    {
123 119
        $this->checkObject($entity);
124 120
@@ -129,7 +125,7 @@
Loading
129 125
        }
130 126
    }
131 127
132 -
    public function getTableName()
128 +
    public function getTableName(): string
133 129
    {
134 130
        return $this->getObjectManager()->getClassMetadata($this->class)->table['name'];
135 131
    }
@@ -141,20 +137,16 @@
Loading
141 137
142 138
    /**
143 139
     * Returns the related Object Repository.
144 -
     *
145 -
     * @return ObjectRepository
146 140
     */
147 -
    protected function getRepository()
141 +
    protected function getRepository(): ObjectRepository
148 142
    {
149 143
        return $this->getObjectManager()->getRepository($this->class);
150 144
    }
151 145
152 146
    /**
153 147
     * @throws \InvalidArgumentException
154 -
     *
155 -
     * @return void
156 148
     */
157 -
    protected function checkObject($object)
149 +
    protected function checkObject($object): void
158 150
    {
159 151
        if (!$object instanceof $this->class) {
160 152
            throw new \InvalidArgumentException(sprintf(

@@ -20,7 +20,7 @@
Loading
20 20
     */
21 21
    protected $adapters = [];
22 22
23 -
    public function addAdapter(AdapterInterface $adapter)
23 +
    public function addAdapter(AdapterInterface $adapter): void
24 24
    {
25 25
        $this->adapters[] = $adapter;
26 26
    }

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Everything is accounted for!

No changes detected that need to be reviewed.
What changes does Codecov check for?
Lines, not adjusted in diff, that have changed coverage data.
Files that introduced coverage data that had none before.
Files that have missing coverage data that once were tracked.

244 Commits

+40
+32
+8
+16
+16
+2
+2
+3
+3
-13
-13
+4
+4
+4 Files
+20
+20
Hiding 144 contexual commits
-4 Files
-72
-61
-11
Files Complexity Coverage
src ø 64.09%
Project Totals (27 files) 211 64.09%
Loading