Skip to content

Commit ea97ea4

Browse files
authored
Add types to entity manager (#9292)
1 parent 081f3e4 commit ea97ea4

File tree

8 files changed

+293
-651
lines changed

8 files changed

+293
-651
lines changed

lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php

Lines changed: 56 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,23 @@
44

55
namespace Doctrine\ORM\Decorator;
66

7+
use Doctrine\Common\EventManager;
8+
use Doctrine\DBAL\Connection;
9+
use Doctrine\ORM\Cache;
10+
use Doctrine\ORM\Configuration;
711
use Doctrine\ORM\EntityManagerInterface;
12+
use Doctrine\ORM\EntityRepository;
13+
use Doctrine\ORM\Internal\Hydration\AbstractHydrator;
14+
use Doctrine\ORM\Mapping\ClassMetadata;
15+
use Doctrine\ORM\Mapping\ClassMetadataFactory;
16+
use Doctrine\ORM\NativeQuery;
17+
use Doctrine\ORM\Proxy\ProxyFactory;
18+
use Doctrine\ORM\Query;
19+
use Doctrine\ORM\Query\Expr;
20+
use Doctrine\ORM\Query\FilterCollection;
821
use Doctrine\ORM\Query\ResultSetMapping;
22+
use Doctrine\ORM\QueryBuilder;
23+
use Doctrine\ORM\UnitOfWork;
924
use Doctrine\Persistence\ObjectManagerDecorator;
1025

1126
/**
@@ -21,26 +36,35 @@ public function __construct(EntityManagerInterface $wrapped)
2136
$this->wrapped = $wrapped;
2237
}
2338

39+
public function getRepository($className): EntityRepository
40+
{
41+
return parent::getRepository($className);
42+
}
43+
44+
public function getMetadataFactory(): ClassMetadataFactory
45+
{
46+
return parent::getMetadataFactory();
47+
}
48+
2449
/**
2550
* {@inheritdoc}
2651
*/
27-
public function getConnection()
52+
public function getClassMetadata($className): ClassMetadata
53+
{
54+
return parent::getClassMetadata($className);
55+
}
56+
57+
public function getConnection(): Connection
2858
{
2959
return $this->wrapped->getConnection();
3060
}
3161

32-
/**
33-
* {@inheritdoc}
34-
*/
35-
public function getExpressionBuilder()
62+
public function getExpressionBuilder(): Expr
3663
{
3764
return $this->wrapped->getExpressionBuilder();
3865
}
3966

40-
/**
41-
* {@inheritdoc}
42-
*/
43-
public function beginTransaction()
67+
public function beginTransaction(): void
4468
{
4569
$this->wrapped->beginTransaction();
4670
}
@@ -53,194 +77,135 @@ public function wrapInTransaction(callable $func)
5377
return $this->wrapped->wrapInTransaction($func);
5478
}
5579

56-
/**
57-
* {@inheritdoc}
58-
*/
59-
public function commit()
80+
public function commit(): void
6081
{
6182
$this->wrapped->commit();
6283
}
6384

64-
/**
65-
* {@inheritdoc}
66-
*/
67-
public function rollback()
85+
public function rollback(): void
6886
{
6987
$this->wrapped->rollback();
7088
}
7189

72-
/**
73-
* {@inheritdoc}
74-
*/
75-
public function createQuery($dql = '')
90+
public function createQuery(string $dql = ''): Query
7691
{
7792
return $this->wrapped->createQuery($dql);
7893
}
7994

80-
/**
81-
* {@inheritdoc}
82-
*/
83-
public function createNamedQuery($name)
95+
public function createNamedQuery(string $name): Query
8496
{
8597
return $this->wrapped->createNamedQuery($name);
8698
}
8799

88-
/**
89-
* {@inheritdoc}
90-
*/
91-
public function createNativeQuery($sql, ResultSetMapping $rsm)
100+
public function createNativeQuery(string $sql, ResultSetMapping $rsm): NativeQuery
92101
{
93102
return $this->wrapped->createNativeQuery($sql, $rsm);
94103
}
95104

96-
/**
97-
* {@inheritdoc}
98-
*/
99-
public function createNamedNativeQuery($name)
105+
public function createNamedNativeQuery(string $name): NativeQuery
100106
{
101107
return $this->wrapped->createNamedNativeQuery($name);
102108
}
103109

104-
/**
105-
* {@inheritdoc}
106-
*/
107-
public function createQueryBuilder()
110+
public function createQueryBuilder(): QueryBuilder
108111
{
109112
return $this->wrapped->createQueryBuilder();
110113
}
111114

112115
/**
113116
* {@inheritdoc}
114117
*/
115-
public function getReference($entityName, $id)
118+
public function getReference(string $entityName, $id): ?object
116119
{
117120
return $this->wrapped->getReference($entityName, $id);
118121
}
119122

120123
/**
121124
* {@inheritdoc}
122125
*/
123-
public function getPartialReference($entityName, $identifier)
126+
public function getPartialReference(string $entityName, $identifier): ?object
124127
{
125128
return $this->wrapped->getPartialReference($entityName, $identifier);
126129
}
127130

128-
/**
129-
* {@inheritdoc}
130-
*/
131-
public function close()
131+
public function close(): void
132132
{
133133
$this->wrapped->close();
134134
}
135135

136136
/**
137137
* {@inheritdoc}
138138
*/
139-
public function lock($entity, $lockMode, $lockVersion = null)
139+
public function lock(object $entity, int $lockMode, $lockVersion = null): void
140140
{
141141
$this->wrapped->lock($entity, $lockMode, $lockVersion);
142142
}
143143

144144
/**
145145
* {@inheritdoc}
146146
*/
147-
public function find($className, $id, $lockMode = null, $lockVersion = null)
147+
public function find($className, mixed $id, ?int $lockMode = null, ?int $lockVersion = null): ?object
148148
{
149149
return $this->wrapped->find($className, $id, $lockMode, $lockVersion);
150150
}
151151

152152
/**
153153
* {@inheritdoc}
154154
*/
155-
public function flush($entity = null)
155+
public function flush($entity = null): void
156156
{
157157
$this->wrapped->flush($entity);
158158
}
159159

160-
/**
161-
* {@inheritdoc}
162-
*/
163-
public function getEventManager()
160+
public function getEventManager(): EventManager
164161
{
165162
return $this->wrapped->getEventManager();
166163
}
167164

168-
/**
169-
* {@inheritdoc}
170-
*/
171-
public function getConfiguration()
165+
public function getConfiguration(): Configuration
172166
{
173167
return $this->wrapped->getConfiguration();
174168
}
175169

176-
/**
177-
* {@inheritdoc}
178-
*/
179-
public function isOpen()
170+
public function isOpen(): bool
180171
{
181172
return $this->wrapped->isOpen();
182173
}
183174

184-
/**
185-
* {@inheritdoc}
186-
*/
187-
public function getUnitOfWork()
175+
public function getUnitOfWork(): UnitOfWork
188176
{
189177
return $this->wrapped->getUnitOfWork();
190178
}
191179

192180
/**
193181
* {@inheritdoc}
194182
*/
195-
public function getHydrator($hydrationMode)
196-
{
197-
return $this->wrapped->getHydrator($hydrationMode);
198-
}
199-
200-
/**
201-
* {@inheritdoc}
202-
*/
203-
public function newHydrator($hydrationMode)
183+
public function newHydrator($hydrationMode): AbstractHydrator
204184
{
205185
return $this->wrapped->newHydrator($hydrationMode);
206186
}
207187

208-
/**
209-
* {@inheritdoc}
210-
*/
211-
public function getProxyFactory()
188+
public function getProxyFactory(): ProxyFactory
212189
{
213190
return $this->wrapped->getProxyFactory();
214191
}
215192

216-
/**
217-
* {@inheritdoc}
218-
*/
219-
public function getFilters()
193+
public function getFilters(): FilterCollection
220194
{
221195
return $this->wrapped->getFilters();
222196
}
223197

224-
/**
225-
* {@inheritdoc}
226-
*/
227-
public function isFiltersStateClean()
198+
public function isFiltersStateClean(): bool
228199
{
229200
return $this->wrapped->isFiltersStateClean();
230201
}
231202

232-
/**
233-
* {@inheritdoc}
234-
*/
235-
public function hasFilters()
203+
public function hasFilters(): bool
236204
{
237205
return $this->wrapped->hasFilters();
238206
}
239207

240-
/**
241-
* {@inheritdoc}
242-
*/
243-
public function getCache()
208+
public function getCache(): ?Cache
244209
{
245210
return $this->wrapped->getCache();
246211
}

0 commit comments

Comments
 (0)