No flags found
Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.
e.g., #unittest #integration
#production #enterprise
#frontend #backend
2967d6e
... +244 ...
37da047
Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.
e.g., #unittest #integration
#production #enterprise
#frontend #backend
13 | 13 | ||
14 | 14 | namespace Sonata\Doctrine\Entity; |
|
15 | 15 | ||
16 | + | use Doctrine\DBAL\Connection; |
|
16 | 17 | use Doctrine\ORM\EntityManagerInterface; |
|
17 | 18 | use Doctrine\ORM\EntityRepository; |
|
19 | + | use Doctrine\Persistence\ObjectManager; |
|
20 | + | use Doctrine\Persistence\ObjectRepository; |
|
18 | 21 | use Sonata\Doctrine\Model\BaseManager; |
|
19 | 22 | ||
20 | 23 | /** |
55 | 58 | * |
|
56 | 59 | * @deprecated since sonata-project/sonata-doctrine-extensions 1.15 |
|
57 | 60 | */ |
|
58 | - | public function getConnection() |
|
61 | + | public function getConnection(): Connection |
|
59 | 62 | { |
|
60 | 63 | @trigger_error(sprintf( |
|
61 | 64 | 'The "%s()" method is deprecated since sonata-project/sonata-doctrine-extensions 1.15' |
70 | 73 | /** |
|
71 | 74 | * @return EntityManagerInterface |
|
72 | 75 | */ |
|
73 | - | public function getEntityManager() |
|
76 | + | public function getEntityManager(): ObjectManager |
|
74 | 77 | { |
|
75 | 78 | $objectManager = $this->getObjectManager(); |
|
76 | 79 | \assert($objectManager instanceof EntityManagerInterface); |
81 | 84 | /** |
|
82 | 85 | * @phpstan-return EntityRepository<T> |
|
83 | 86 | */ |
|
84 | - | protected function getRepository(): EntityRepository |
|
87 | + | protected function getRepository(): ObjectRepository |
|
85 | 88 | { |
|
86 | 89 | return $this->getEntityManager()->getRepository($this->class); |
|
87 | 90 | } |
39 | 39 | protected $class; |
|
40 | 40 | ||
41 | 41 | /** |
|
42 | - | * @param string $class |
|
43 | - | * |
|
44 | 42 | * @phpstan-param class-string<T> $class |
|
45 | 43 | */ |
|
46 | - | public function __construct($class, ManagerRegistry $registry) |
|
44 | + | public function __construct(string $class, ManagerRegistry $registry) |
|
47 | 45 | { |
|
48 | 46 | $this->registry = $registry; |
|
49 | 47 | $this->class = $class; |
|
50 | 48 | } |
|
51 | 49 | ||
52 | 50 | /** |
|
53 | 51 | * @throws \RuntimeException |
|
54 | - | * |
|
55 | - | * @return ObjectManager |
|
56 | 52 | */ |
|
57 | - | public function getObjectManager() |
|
53 | + | public function getObjectManager(): ObjectManager |
|
58 | 54 | { |
|
59 | 55 | $manager = $this->registry->getManagerForClass($this->class); |
|
60 | 56 |
71 | 67 | return $manager; |
|
72 | 68 | } |
|
73 | 69 | ||
74 | - | public function getClass() |
|
70 | + | public function getClass(): string |
|
75 | 71 | { |
|
76 | 72 | return $this->class; |
|
77 | 73 | } |
|
78 | 74 | ||
79 | - | public function findAll() |
|
75 | + | public function findAll(): array |
|
80 | 76 | { |
|
81 | 77 | return $this->getRepository()->findAll(); |
|
82 | 78 | } |
|
83 | 79 | ||
84 | - | public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null) |
|
80 | + | public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array |
|
85 | 81 | { |
|
86 | 82 | return $this->getRepository()->findBy($criteria, $orderBy, $limit, $offset); |
|
87 | 83 | } |
|
88 | 84 | ||
89 | - | public function findOneBy(array $criteria, ?array $orderBy = null) |
|
85 | + | public function findOneBy(array $criteria, ?array $orderBy = null): ?object |
|
90 | 86 | { |
|
91 | 87 | if (null !== $orderBy) { |
|
92 | 88 | @trigger_error( |
98 | 94 | return $this->getRepository()->findOneBy($criteria); |
|
99 | 95 | } |
|
100 | 96 | ||
101 | - | public function find($id) |
|
97 | + | public function find($id): ?object |
|
102 | 98 | { |
|
103 | 99 | return $this->getRepository()->find($id); |
|
104 | 100 | } |
|
105 | 101 | ||
106 | - | public function create() |
|
102 | + | public function create(): object |
|
107 | 103 | { |
|
108 | 104 | return new $this->class(); |
|
109 | 105 | } |
|
110 | 106 | ||
111 | - | public function save($entity, $andFlush = true) |
|
107 | + | public function save(object $entity, bool $andFlush = true): void |
|
112 | 108 | { |
|
113 | 109 | $this->checkObject($entity); |
|
114 | 110 |
119 | 115 | } |
|
120 | 116 | } |
|
121 | 117 | ||
122 | - | public function delete($entity, $andFlush = true) |
|
118 | + | public function delete(object $entity, bool $andFlush = true): void |
|
123 | 119 | { |
|
124 | 120 | $this->checkObject($entity); |
|
125 | 121 |
135 | 131 | * |
|
136 | 132 | * @deprecated since sonata-project/sonata-doctrine-extensions 1.15 |
|
137 | 133 | */ |
|
138 | - | public function getTableName() |
|
134 | + | public function getTableName(): string |
|
139 | 135 | { |
|
140 | 136 | @trigger_error(sprintf( |
|
141 | 137 | 'The "%s()" method is deprecated since sonata-project/sonata-doctrine-extensions 1.15' |
161 | 157 | * |
|
162 | 158 | * @phpstan-return ObjectRepository<T> |
|
163 | 159 | */ |
|
164 | - | protected function getRepository() |
|
160 | + | protected function getRepository(): ObjectRepository |
|
165 | 161 | { |
|
166 | 162 | return $this->getObjectManager()->getRepository($this->class); |
|
167 | 163 | } |
171 | 167 | * |
|
172 | 168 | * @throws \InvalidArgumentException |
|
173 | 169 | * |
|
174 | - | * @return void |
|
175 | - | * |
|
176 | 170 | * @phpstan-param T $object |
|
177 | 171 | */ |
|
178 | - | protected function checkObject($object) |
|
172 | + | protected function checkObject($object): void |
|
179 | 173 | { |
|
180 | 174 | if (!$object instanceof $this->class) { |
|
181 | 175 | throw new \InvalidArgumentException(sprintf( |
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 | /** |
54 | 56 | * |
|
55 | 57 | * @deprecated since sonata-project/sonata-doctrine-extensions 1.15 |
|
56 | 58 | */ |
|
57 | - | public function getConnection() |
|
59 | + | public function getConnection(): Connection |
|
58 | 60 | { |
|
59 | 61 | throw new \LogicException('MongoDB does not use a database connection.'); |
|
60 | 62 | } |
|
61 | 63 | ||
62 | 64 | /** |
|
63 | 65 | * @return DocumentManager |
|
64 | 66 | */ |
|
65 | - | public function getDocumentManager() |
|
67 | + | public function getDocumentManager(): ObjectManager |
|
66 | 68 | { |
|
67 | 69 | $dm = $this->getObjectManager(); |
|
68 | 70 |
25 | 25 | /** |
|
26 | 26 | * Return the Entity class name. |
|
27 | 27 | * |
|
28 | - | * @return string |
|
29 | - | * |
|
30 | 28 | * @phpstan-return class-string<T> |
|
31 | 29 | */ |
|
32 | - | public function getClass(); |
|
30 | + | public function getClass(): string; |
|
33 | 31 | ||
34 | 32 | /** |
|
35 | 33 | * Find all entities in the repository. |
38 | 36 | * |
|
39 | 37 | * @phpstan-return T[] |
|
40 | 38 | */ |
|
41 | - | public function findAll(); |
|
39 | + | public function findAll(): array; |
|
42 | 40 | ||
43 | 41 | /** |
|
44 | 42 | * Find entities by a set of criteria. |
|
45 | 43 | * |
|
46 | 44 | * @param array<string, mixed> $criteria |
|
47 | 45 | * @param array<string, 'asc'|'ASC'|'desc'|'DESC'>|null $orderBy |
|
48 | - | * @param int|null $limit |
|
49 | - | * @param int|null $offset |
|
50 | 46 | * |
|
51 | 47 | * @return object[] |
|
52 | 48 | * |
|
53 | 49 | * @phpstan-return T[] |
|
54 | 50 | */ |
|
55 | - | public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null); |
|
51 | + | public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array; |
|
56 | 52 | ||
57 | 53 | /** |
|
58 | 54 | * Find a single entity by a set of criteria. |
|
59 | 55 | * |
|
60 | 56 | * @param array<string, mixed> $criteria |
|
61 | 57 | * @param array<string, string>|null $orderBy |
|
62 | 58 | * |
|
63 | - | * @return object|null |
|
64 | - | * |
|
65 | 59 | * @phpstan-return T|null |
|
66 | 60 | */ |
|
67 | - | public function findOneBy(array $criteria, ?array $orderBy = null); |
|
61 | + | public function findOneBy(array $criteria, ?array $orderBy = null): ?object; |
|
68 | 62 | ||
69 | 63 | /** |
|
70 | 64 | * Finds an entity by its primary key / identifier. |
|
71 | 65 | * |
|
72 | 66 | * @param mixed $id The identifier |
|
73 | 67 | * |
|
74 | - | * @return object|null |
|
75 | - | * |
|
76 | 68 | * @phpstan-return T|null |
|
77 | 69 | */ |
|
78 | - | public function find($id); |
|
70 | + | public function find($id): ?object; |
|
79 | 71 | ||
80 | 72 | /** |
|
81 | 73 | * Create an empty Entity instance. |
|
82 | 74 | * |
|
83 | - | * @return object |
|
84 | - | * |
|
85 | 75 | * @phpstan-return T |
|
86 | 76 | */ |
|
87 | - | public function create(); |
|
77 | + | public function create(): object; |
|
88 | 78 | ||
89 | 79 | /** |
|
90 | 80 | * Save an Entity. |
|
91 | 81 | * |
|
92 | 82 | * @param object $entity The Entity to save |
|
93 | 83 | * @param bool $andFlush Flush the EntityManager after saving the object? |
|
94 | 84 | * |
|
95 | - | * @return void |
|
96 | - | * |
|
97 | 85 | * @phpstan-param T $entity |
|
98 | 86 | */ |
|
99 | - | public function save($entity, $andFlush = true); |
|
87 | + | public function save(object $entity, bool $andFlush = true): void; |
|
100 | 88 | ||
101 | 89 | /** |
|
102 | 90 | * Delete an Entity. |
|
103 | 91 | * |
|
104 | 92 | * @param object $entity The Entity to delete |
|
105 | 93 | * @param bool $andFlush Flush the EntityManager after deleting the object? |
|
106 | 94 | * |
|
107 | - | * @return void |
|
108 | - | * |
|
109 | 95 | * @phpstan-param T $entity |
|
110 | 96 | */ |
|
111 | - | public function delete($entity, $andFlush = true); |
|
97 | + | public function delete(object $entity, bool $andFlush = true): void; |
|
112 | 98 | ||
113 | 99 | /** |
|
114 | 100 | * Get the related table name. |
|
115 | 101 | * |
|
116 | 102 | * NEXT_MAJOR: Remove this ORM-related method from the interface. |
|
117 | - | * |
|
118 | - | * @return string |
|
119 | 103 | */ |
|
120 | - | public function getTableName(); |
|
104 | + | public function getTableName(): string; |
|
121 | 105 | ||
122 | 106 | /** |
|
123 | 107 | * Get the DB driver connection. |
|
124 | 108 | * |
|
125 | 109 | * NEXT_MAJOR: Remove this ORM-related method from the interface. |
|
126 | - | * |
|
127 | - | * @return Connection |
|
128 | 110 | */ |
|
129 | - | public function getConnection(); |
|
111 | + | public function getConnection(): Connection; |
|
130 | 112 | } |
|
131 | 113 | ||
132 | 114 | interface_exists(\Sonata\CoreBundle\Model\ManagerInterface::class); |
Files | Complexity | Coverage |
---|---|---|
src | ø | 63.48% |
Project Totals (27 files) | 211 | 63.48% |
37da047
f5ab526
57cf21c
e494e07
3c253fe
8799474
87b01c4
a067a28
1ede6cf
48b887d
cc505ae
37fe36f
794b125
807b897
c4169aa
7d3b562
82d28dd
c417908
d1287db
a4d21a3
a6ef5c2
035cc4c
61542db
f11dfe2
972d524
db73db9
fd2384e
94a7454
b206abd
98d03cf
5cdceb1
5ef36bc
eea261f
04d9084
065c3b2
9aede77
8b9e4df
01c9c3e
5b3a7c0
397b0f2
599ee11
ba01e65
8cdb6ef
a551a92
252ca4f
c3e8b63
d2276bc
d1c3108
6fde51f
e124ad9
552a5fd
0d8e383
2c02ae5
5691dc3
2c704d2
5e4117f
9a99231
b8755f9
e5e8642
7a08f19
994144a
7c67ae3
6038b98
8af8042
24afbc2
45a947b
f5f6a5a
928e07d
93c2a96
5d0e55d
fdda277
0507d7f
7e67e88
8c86cb7
07b967b
9910281
9cd264a
da8addd
3e84aac
b49a5cd
9bb7df0
97663f6
62db047
a43e447
9511530
de89b3a
56c2abc
f814111
598a2f3
9048f7c
e58f441
36d74b5
58cf135
4497fe5
54895c5
80ff8c4
bad91c5
c35751c
49bdf0f
e88d5a3
588dea7
3290872
62bb7ba
fdedbb0
2411e5f
579dff7
b109dd1
76a0a17
1cfd790
f4a4dcb
2ea43fa
39f228c
faaf36b
d099c40
7c2f39a
9720a51
e654a12
629e239
2579b46
a452673
2897618
a71d514
c23839e
28117b0
890ad42
38914e3
5d631b8
d1e6808
6d922c0
ba6979d
2d237aa
b075dee
ec24c92
9f38358
00c1266
8d8bb8b
458bf61
b26a521
7c1d2e4
10ab1d5
617f9ef
14b7516
c2108df
90d8046
ab8f2a7
f54ace0
8fdcd48
c4cd23e
4fc99af
e4c5d11
7860e62
bbe23e4
8dc00be
726c72c
630cd8e
bf63c4c
8f05005
c015c56
09181ad
c583a5f
5851998
2337987
eaded43
ca28048
8795061
9e75009
01d2fd2
9e4db82
c55a5fc
874bacb
3772283
c37b913
1f0c182
41ff231
08534ed
47f6d2a
50a6e28
8815965
733d7ad
8ec844a
e54f715
14d3046
68d20d9
9b82c39
96f6cd0
363dd1f
23d35cc
0496abf
fabeec2
b394f05
8969d2b
0fdbe6d
491533c
c194584
0d487f2
6a9bacf
87b8a0b
a723d0e
bd74c33
2fa7f3f
ef2a06d
b969484
a2f4720
b67a0f2
78c1344
b2ed365
bd1c4b0
2dffc3c
b9b19b1
a5decda
deaf033
f6cc38b
878b65d
8ef9330
52a0f29
59be29e
31892d0
aec01f1
b41e06c
f7a9131
fbaff00
1cf6197
10eae48
79f67f6
c7de6b9
c1fa54c
7bb373b
5772150
536fe62
8c59582
a964beb
5c9d746
ae0a5f4
ade1908
7f666aa
732d9b5
e91c7ff
79fd498
24cfa8f
8d8813e
a1da8a2
469dd76
d84c5ca
eff4f97
2b947ce
2967d6e