1 | <?php |
||
40 | class EntityRepository implements ObjectRepository, Selectable |
||
41 | { |
||
42 | /** |
||
43 | * @var string |
||
44 | */ |
||
45 | protected $_entityName; |
||
46 | |||
47 | /** |
||
48 | * @var EntityManager |
||
49 | */ |
||
50 | protected $_em; |
||
51 | |||
52 | /** |
||
53 | * @var \Doctrine\ORM\Mapping\ClassMetadata |
||
54 | */ |
||
55 | protected $_class; |
||
56 | |||
57 | /** |
||
58 | * Initializes a new <tt>EntityRepository</tt>. |
||
59 | * |
||
60 | * @param EntityManager $em The EntityManager to use. |
||
61 | * @param Mapping\ClassMetadata $class The class descriptor. |
||
62 | */ |
||
63 | 146 | public function __construct(EntityManagerInterface $em, Mapping\ClassMetadata $class) |
|
69 | |||
70 | /** |
||
71 | * Creates a new QueryBuilder instance that is prepopulated for this entity name. |
||
72 | * |
||
73 | * @param string $alias |
||
74 | * @param string $indexBy The index for the from. |
||
75 | * |
||
76 | * @return QueryBuilder |
||
77 | */ |
||
78 | 6 | public function createQueryBuilder($alias, $indexBy = null) |
|
84 | |||
85 | /** |
||
86 | * Creates a new result set mapping builder for this entity. |
||
87 | * |
||
88 | * The column naming strategy is "INCREMENT". |
||
89 | * |
||
90 | * @param string $alias |
||
91 | * |
||
92 | * @return ResultSetMappingBuilder |
||
93 | */ |
||
94 | 1 | public function createResultSetMappingBuilder($alias) |
|
101 | |||
102 | /** |
||
103 | * Creates a new Query instance based on a predefined metadata named query. |
||
104 | * |
||
105 | * @param string $queryName |
||
106 | * |
||
107 | * @return Query |
||
108 | */ |
||
109 | 3 | public function createNamedQuery($queryName) |
|
113 | |||
114 | /** |
||
115 | * Creates a native SQL query. |
||
116 | * |
||
117 | * @param string $queryName |
||
118 | * |
||
119 | * @return NativeQuery |
||
120 | */ |
||
121 | 7 | public function createNativeNamedQuery($queryName) |
|
129 | |||
130 | /** |
||
131 | * Clears the repository, causing all managed entities to become detached. |
||
132 | * |
||
133 | * @return void |
||
134 | */ |
||
135 | public function clear() |
||
139 | |||
140 | /** |
||
141 | * Finds an entity by its primary key / identifier. |
||
142 | * |
||
143 | * @param mixed $id The identifier. |
||
144 | * @param int|null $lockMode One of the \Doctrine\DBAL\LockMode::* constants |
||
145 | * or NULL if no specific lock mode should be used |
||
146 | * during the search. |
||
147 | * @param int|null $lockVersion The lock version. |
||
148 | * |
||
149 | * @return object|null The entity instance or NULL if the entity can not be found. |
||
150 | */ |
||
151 | 14 | public function find($id, $lockMode = null, $lockVersion = null) |
|
155 | |||
156 | /** |
||
157 | * Finds all entities in the repository. |
||
158 | * |
||
159 | * @return array The entities. |
||
160 | */ |
||
161 | 30 | public function findAll() |
|
165 | |||
166 | /** |
||
167 | * Finds entities by a set of criteria. |
||
168 | * |
||
169 | * @param array $criteria |
||
170 | * @param array|null $orderBy |
||
171 | * @param int|null $limit |
||
172 | * @param int|null $offset |
||
173 | * |
||
174 | * @return array The objects. |
||
175 | */ |
||
176 | 60 | public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) |
|
182 | |||
183 | /** |
||
184 | * Finds a single entity by a set of criteria. |
||
185 | * |
||
186 | * @param array $criteria |
||
187 | * @param array|null $orderBy |
||
188 | * |
||
189 | * @return object|null The entity instance or NULL if the entity can not be found. |
||
190 | */ |
||
191 | 21 | public function findOneBy(array $criteria, array $orderBy = null) |
|
197 | |||
198 | /** |
||
199 | * Counts entities by a set of criteria. |
||
200 | * |
||
201 | * @param array $criteria |
||
202 | * |
||
203 | * @return int The quantity of objects that matches the criteria. |
||
204 | */ |
||
205 | 2 | public function count(array $criteria) |
|
211 | |||
212 | /** |
||
213 | * Adds support for magic finders/counters. |
||
214 | * |
||
215 | * @param string $method |
||
216 | * @param array $arguments |
||
217 | * |
||
218 | * @return array|object|int The found entity/entities or its resulting count. |
||
219 | * |
||
220 | * @throws ORMException |
||
221 | * @throws \BadMethodCallException If the method called is an invalid find* or countBy method |
||
222 | * or no find* or countBy method at all and therefore an invalid |
||
223 | * method call. |
||
224 | */ |
||
225 | 13 | public function __call($method, $arguments) |
|
279 | |||
280 | /** |
||
281 | * @return string |
||
282 | */ |
||
283 | protected function getEntityName() |
||
287 | |||
288 | /** |
||
289 | * @return string |
||
290 | */ |
||
291 | public function getClassName() |
||
295 | |||
296 | /** |
||
297 | * @return EntityManager |
||
298 | */ |
||
299 | protected function getEntityManager() |
||
303 | |||
304 | /** |
||
305 | * @return Mapping\ClassMetadata |
||
306 | */ |
||
307 | protected function getClassMetadata() |
||
311 | |||
312 | /** |
||
313 | * Select all elements from a selectable that match the expression and |
||
314 | * return a new collection containing these elements. |
||
315 | * |
||
316 | * @param \Doctrine\Common\Collections\Criteria $criteria |
||
317 | * |
||
318 | * @return \Doctrine\Common\Collections\Collection |
||
319 | */ |
||
320 | 24 | public function matching(Criteria $criteria) |
|
326 | } |
||
327 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.
Either this assignment is in error or an instanceof check should be added for that assignment.