Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like EntityManager often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use EntityManager, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
63 | /* final */class EntityManager implements EntityManagerInterface |
||
64 | { |
||
65 | /** |
||
66 | * The used Configuration. |
||
67 | * |
||
68 | * @var \Doctrine\ORM\Configuration |
||
69 | */ |
||
70 | private $config; |
||
71 | |||
72 | /** |
||
73 | * The database connection used by the EntityManager. |
||
74 | * |
||
75 | * @var \Doctrine\DBAL\Connection |
||
76 | */ |
||
77 | private $conn; |
||
78 | |||
79 | /** |
||
80 | * The metadata factory, used to retrieve the ORM metadata of entity classes. |
||
81 | * |
||
82 | * @var \Doctrine\ORM\Mapping\ClassMetadataFactory |
||
83 | */ |
||
84 | private $metadataFactory; |
||
85 | |||
86 | /** |
||
87 | * The UnitOfWork used to coordinate object-level transactions. |
||
88 | * |
||
89 | * @var \Doctrine\ORM\UnitOfWork |
||
90 | */ |
||
91 | private $unitOfWork; |
||
92 | |||
93 | /** |
||
94 | * The event manager that is the central point of the event system. |
||
95 | * |
||
96 | * @var \Doctrine\Common\EventManager |
||
97 | */ |
||
98 | private $eventManager; |
||
99 | |||
100 | /** |
||
101 | * The proxy factory used to create dynamic proxies. |
||
102 | * |
||
103 | * @var \Doctrine\ORM\Proxy\ProxyFactory |
||
104 | */ |
||
105 | private $proxyFactory; |
||
106 | |||
107 | /** |
||
108 | * The repository factory used to create dynamic repositories. |
||
109 | * |
||
110 | * @var \Doctrine\ORM\Repository\RepositoryFactory |
||
111 | */ |
||
112 | private $repositoryFactory; |
||
113 | |||
114 | /** |
||
115 | * The expression builder instance used to generate query expressions. |
||
116 | * |
||
117 | * @var \Doctrine\ORM\Query\Expr |
||
118 | */ |
||
119 | private $expressionBuilder; |
||
120 | |||
121 | /** |
||
122 | * Whether the EntityManager is closed or not. |
||
123 | * |
||
124 | * @var bool |
||
125 | */ |
||
126 | private $closed = false; |
||
127 | |||
128 | /** |
||
129 | * Collection of query filters. |
||
130 | * |
||
131 | * @var \Doctrine\ORM\Query\FilterCollection |
||
132 | */ |
||
133 | private $filterCollection; |
||
134 | |||
135 | /** |
||
136 | * @var \Doctrine\ORM\Cache The second level cache regions API. |
||
137 | */ |
||
138 | private $cache; |
||
139 | |||
140 | /** |
||
141 | * Creates a new EntityManager that operates on the given database connection |
||
142 | * and uses the given Configuration and EventManager implementations. |
||
143 | * |
||
144 | * @param \Doctrine\DBAL\Connection $conn |
||
145 | * @param \Doctrine\ORM\Configuration $config |
||
146 | * @param \Doctrine\Common\EventManager $eventManager |
||
147 | */ |
||
148 | 2393 | protected function __construct(Connection $conn, Configuration $config, EventManager $eventManager) |
|
149 | { |
||
150 | 2393 | $this->conn = $conn; |
|
151 | 2393 | $this->config = $config; |
|
152 | 2393 | $this->eventManager = $eventManager; |
|
153 | |||
154 | 2393 | $metadataFactoryClassName = $config->getClassMetadataFactoryName(); |
|
155 | |||
156 | 2393 | $this->metadataFactory = new $metadataFactoryClassName; |
|
157 | 2393 | $this->metadataFactory->setEntityManager($this); |
|
158 | 2393 | $this->metadataFactory->setCacheDriver($this->config->getMetadataCacheImpl()); |
|
159 | |||
160 | 2393 | $this->repositoryFactory = $config->getRepositoryFactory(); |
|
161 | 2393 | $this->unitOfWork = new UnitOfWork($this); |
|
162 | 2393 | $this->proxyFactory = new ProxyFactory( |
|
163 | 2393 | $this, |
|
164 | 2393 | $config->getProxyDir(), |
|
165 | 2393 | $config->getProxyNamespace(), |
|
166 | 2393 | $config->getAutoGenerateProxyClasses() |
|
167 | ); |
||
168 | |||
169 | 2393 | if ($config->isSecondLevelCacheEnabled()) { |
|
170 | 283 | $cacheConfig = $config->getSecondLevelCacheConfiguration(); |
|
171 | 283 | $cacheFactory = $cacheConfig->getCacheFactory(); |
|
172 | 283 | $this->cache = $cacheFactory->createCache($this); |
|
173 | } |
||
174 | 2393 | } |
|
175 | |||
176 | /** |
||
177 | * {@inheritDoc} |
||
178 | */ |
||
179 | 1878 | public function getConnection() |
|
183 | |||
184 | /** |
||
185 | * Gets the metadata factory used to gather the metadata of classes. |
||
186 | * |
||
187 | * @return \Doctrine\ORM\Mapping\ClassMetadataFactory |
||
188 | */ |
||
189 | 2393 | public function getMetadataFactory() |
|
193 | |||
194 | /** |
||
195 | * {@inheritDoc} |
||
196 | */ |
||
197 | 17 | public function getExpressionBuilder() |
|
205 | |||
206 | /** |
||
207 | * {@inheritDoc} |
||
208 | */ |
||
209 | 1 | public function beginTransaction() |
|
213 | |||
214 | /** |
||
215 | * {@inheritDoc} |
||
216 | */ |
||
217 | 216 | public function getCache() |
|
221 | |||
222 | /** |
||
223 | * {@inheritDoc} |
||
224 | */ |
||
225 | 4 | public function transactional($func) |
|
247 | |||
248 | /** |
||
249 | * {@inheritDoc} |
||
250 | */ |
||
251 | 1 | public function commit() |
|
255 | |||
256 | /** |
||
257 | * {@inheritDoc} |
||
258 | */ |
||
259 | public function rollback() |
||
260 | { |
||
261 | $this->conn->rollBack(); |
||
262 | } |
||
263 | |||
264 | /** |
||
265 | * Returns the ORM metadata descriptor for a class. |
||
266 | * |
||
267 | * The class name must be the fully-qualified class name without a leading backslash |
||
268 | * (as it is returned by get_class($obj)) or an aliased class name. |
||
269 | * |
||
270 | * Examples: |
||
271 | * MyProject\Domain\User |
||
272 | * sales:PriceRequest |
||
273 | * |
||
274 | * Internal note: Performance-sensitive method. |
||
275 | * |
||
276 | * @param string $className |
||
277 | * |
||
278 | * @return \Doctrine\ORM\Mapping\ClassMetadata |
||
279 | */ |
||
280 | 1938 | public function getClassMetadata($className) |
|
284 | |||
285 | /** |
||
286 | * {@inheritDoc} |
||
287 | */ |
||
288 | 941 | public function createQuery($dql = '') |
|
298 | |||
299 | /** |
||
300 | * {@inheritDoc} |
||
301 | */ |
||
302 | 1 | public function createNamedQuery($name) |
|
306 | |||
307 | /** |
||
308 | * {@inheritDoc} |
||
309 | */ |
||
310 | 21 | public function createNativeQuery($sql, ResultSetMapping $rsm) |
|
319 | |||
320 | /** |
||
321 | * {@inheritDoc} |
||
322 | */ |
||
323 | 1 | public function createNamedNativeQuery($name) |
|
329 | |||
330 | /** |
||
331 | * {@inheritDoc} |
||
332 | */ |
||
333 | 117 | public function createQueryBuilder() |
|
337 | |||
338 | /** |
||
339 | * Flushes all changes to objects that have been queued up to now to the database. |
||
340 | * This effectively synchronizes the in-memory state of managed objects with the |
||
341 | * database. |
||
342 | * |
||
343 | * If an entity is explicitly passed to this method only this entity and |
||
344 | * the cascade-persist semantics + scheduled inserts/removals are synchronized. |
||
345 | * |
||
346 | * @param null|object|array $entity |
||
347 | * |
||
348 | * @return void |
||
349 | * |
||
350 | * @throws \Doctrine\ORM\OptimisticLockException If a version check on an entity that |
||
351 | * makes use of optimistic locking fails. |
||
352 | * @throws ORMException |
||
353 | */ |
||
354 | 1036 | public function flush($entity = null) |
|
360 | |||
361 | /** |
||
362 | * Finds an Entity by its identifier. |
||
363 | * |
||
364 | * @param string $entityName The class name of the entity to find. |
||
365 | * @param mixed $id The identity of the entity to find. |
||
366 | * @param integer|null $lockMode One of the \Doctrine\DBAL\LockMode::* constants |
||
367 | * or NULL if no specific lock mode should be used |
||
368 | * during the search. |
||
369 | * @param integer|null $lockVersion The version of the entity to find when using |
||
370 | * optimistic locking. |
||
371 | * |
||
372 | * @return object|null The entity instance or NULL if the entity can not be found. |
||
373 | * |
||
374 | * @throws OptimisticLockException |
||
375 | * @throws ORMInvalidArgumentException |
||
376 | * @throws TransactionRequiredException |
||
377 | * @throws ORMException |
||
378 | */ |
||
379 | 429 | public function find($entityName, $id, $lockMode = null, $lockVersion = null) |
|
380 | { |
||
381 | 429 | $class = $this->metadataFactory->getMetadataFor(ltrim($entityName, '\\')); |
|
382 | |||
383 | 429 | if ( ! is_array($id)) { |
|
384 | 383 | if ($class->isIdentifierComposite) { |
|
|
|||
385 | throw ORMInvalidArgumentException::invalidCompositeIdentifier(); |
||
386 | } |
||
387 | |||
388 | 383 | $id = [$class->identifier[0] => $id]; |
|
389 | } |
||
390 | |||
391 | 429 | foreach ($id as $i => $value) { |
|
392 | 429 | View Code Duplication | if (is_object($value) && $this->metadataFactory->hasMetadataFor(ClassUtils::getClass($value))) { |
393 | 7 | $id[$i] = $this->unitOfWork->getSingleIdentifierValue($value); |
|
394 | |||
395 | 7 | if ($id[$i] === null) { |
|
396 | 1 | throw ORMInvalidArgumentException::invalidIdentifierBindingEntity(); |
|
397 | } |
||
398 | } |
||
399 | } |
||
400 | |||
401 | 428 | $sortedId = []; |
|
402 | |||
403 | 428 | View Code Duplication | foreach ($class->identifier as $identifier) { |
404 | 428 | if ( ! isset($id[$identifier])) { |
|
405 | 1 | throw ORMException::missingIdentifierField($class->name, $identifier); |
|
406 | } |
||
407 | |||
408 | 427 | $sortedId[$identifier] = $id[$identifier]; |
|
409 | 427 | unset($id[$identifier]); |
|
410 | } |
||
411 | |||
412 | 427 | if ($id) { |
|
413 | 1 | throw ORMException::unrecognizedIdentifierFields($class->name, array_keys($id)); |
|
414 | } |
||
415 | |||
416 | 426 | $unitOfWork = $this->getUnitOfWork(); |
|
417 | |||
418 | // Check identity map first |
||
419 | 426 | if (($entity = $unitOfWork->tryGetById($sortedId, $class->rootEntityName)) !== false) { |
|
420 | 46 | if ( ! ($entity instanceof $class->name)) { |
|
421 | 1 | return null; |
|
422 | } |
||
423 | |||
424 | switch (true) { |
||
425 | 45 | case LockMode::OPTIMISTIC === $lockMode: |
|
426 | 1 | $this->lock($entity, $lockMode, $lockVersion); |
|
427 | break; |
||
428 | |||
429 | 45 | case LockMode::NONE === $lockMode: |
|
430 | 45 | case LockMode::PESSIMISTIC_READ === $lockMode: |
|
431 | 45 | case LockMode::PESSIMISTIC_WRITE === $lockMode: |
|
432 | $persister = $unitOfWork->getEntityPersister($class->name); |
||
433 | $persister->refresh($sortedId, $entity, $lockMode); |
||
434 | break; |
||
435 | } |
||
436 | |||
437 | 45 | return $entity; // Hit! |
|
438 | } |
||
439 | |||
440 | 407 | $persister = $unitOfWork->getEntityPersister($class->name); |
|
441 | |||
442 | switch (true) { |
||
443 | 407 | case LockMode::OPTIMISTIC === $lockMode: |
|
444 | 1 | if ( ! $class->isVersioned) { |
|
445 | 1 | throw OptimisticLockException::notVersioned($class->name); |
|
446 | } |
||
447 | |||
448 | $entity = $persister->load($sortedId); |
||
449 | |||
450 | $unitOfWork->lock($entity, $lockMode, $lockVersion); |
||
451 | |||
452 | return $entity; |
||
453 | |||
454 | 406 | case LockMode::PESSIMISTIC_READ === $lockMode: |
|
455 | 405 | case LockMode::PESSIMISTIC_WRITE === $lockMode: |
|
456 | 2 | if ( ! $this->getConnection()->isTransactionActive()) { |
|
457 | 2 | throw TransactionRequiredException::transactionRequired(); |
|
458 | } |
||
459 | |||
460 | return $persister->load($sortedId, null, null, [], $lockMode); |
||
461 | |||
462 | default: |
||
463 | 404 | return $persister->loadById($sortedId); |
|
464 | } |
||
465 | } |
||
466 | |||
467 | /** |
||
468 | * {@inheritDoc} |
||
469 | */ |
||
470 | 92 | public function getReference($entityName, $id) |
|
471 | { |
||
472 | 92 | $class = $this->metadataFactory->getMetadataFor(ltrim($entityName, '\\')); |
|
473 | |||
474 | 92 | if ( ! is_array($id)) { |
|
475 | 49 | $id = [$class->identifier[0] => $id]; |
|
476 | } |
||
477 | |||
478 | 92 | $sortedId = []; |
|
479 | |||
480 | 92 | View Code Duplication | foreach ($class->identifier as $identifier) { |
481 | 92 | if ( ! isset($id[$identifier])) { |
|
482 | throw ORMException::missingIdentifierField($class->name, $identifier); |
||
483 | } |
||
484 | |||
485 | 92 | $sortedId[$identifier] = $id[$identifier]; |
|
486 | 92 | unset($id[$identifier]); |
|
487 | } |
||
488 | |||
489 | 92 | if ($id) { |
|
490 | 1 | throw ORMException::unrecognizedIdentifierFields($class->name, array_keys($id)); |
|
491 | } |
||
492 | |||
493 | // Check identity map first, if its already in there just return it. |
||
494 | 91 | View Code Duplication | if (($entity = $this->unitOfWork->tryGetById($sortedId, $class->rootEntityName)) !== false) { |
495 | 27 | return ($entity instanceof $class->name) ? $entity : null; |
|
496 | } |
||
497 | |||
498 | 87 | if ($class->subClasses) { |
|
499 | 2 | return $this->find($entityName, $sortedId); |
|
500 | } |
||
501 | |||
502 | 87 | $entity = $this->proxyFactory->getProxy($class->name, $sortedId); |
|
503 | |||
504 | 87 | $this->unitOfWork->registerManaged($entity, $sortedId, []); |
|
505 | |||
506 | 87 | return $entity; |
|
507 | } |
||
508 | |||
509 | /** |
||
510 | * {@inheritDoc} |
||
511 | */ |
||
512 | 4 | public function getPartialReference($entityName, $identifier) |
|
513 | { |
||
514 | 4 | $class = $this->metadataFactory->getMetadataFor(ltrim($entityName, '\\')); |
|
515 | |||
516 | // Check identity map first, if its already in there just return it. |
||
517 | 4 | View Code Duplication | if (($entity = $this->unitOfWork->tryGetById($identifier, $class->rootEntityName)) !== false) { |
518 | 1 | return ($entity instanceof $class->name) ? $entity : null; |
|
519 | } |
||
520 | |||
521 | 3 | if ( ! is_array($identifier)) { |
|
522 | 3 | $identifier = [$class->identifier[0] => $identifier]; |
|
523 | } |
||
524 | |||
525 | 3 | $entity = $class->newInstance(); |
|
526 | |||
527 | 3 | $class->setIdentifierValues($entity, $identifier); |
|
528 | |||
529 | 3 | $this->unitOfWork->registerManaged($entity, $identifier, []); |
|
530 | 3 | $this->unitOfWork->markReadOnly($entity); |
|
531 | |||
532 | 3 | return $entity; |
|
533 | } |
||
534 | |||
535 | /** |
||
536 | * Clears the EntityManager. All entities that are currently managed |
||
537 | * by this EntityManager become detached. |
||
538 | * |
||
539 | * @param string|null $entityName if given, only entities of this type will get detached |
||
540 | * |
||
541 | * @return void |
||
542 | * |
||
543 | * @throws ORMInvalidArgumentException if a non-null non-string value is given |
||
544 | * @throws \Doctrine\Common\Persistence\Mapping\MappingException if a $entityName is given, but that entity is not |
||
545 | * found in the mappings |
||
546 | */ |
||
547 | 1255 | public function clear($entityName = null) |
|
548 | { |
||
549 | 1255 | if (null !== $entityName && ! is_string($entityName)) { |
|
550 | 1 | throw ORMInvalidArgumentException::invalidEntityName($entityName); |
|
551 | } |
||
552 | |||
553 | 1254 | $this->unitOfWork->clear( |
|
554 | 1254 | null === $entityName |
|
555 | 1252 | ? null |
|
556 | 1254 | : $this->metadataFactory->getMetadataFor($entityName)->getName() |
|
557 | ); |
||
558 | 1253 | } |
|
559 | |||
560 | /** |
||
561 | * {@inheritDoc} |
||
562 | */ |
||
563 | 19 | public function close() |
|
569 | |||
570 | /** |
||
571 | * Tells the EntityManager to make an instance managed and persistent. |
||
572 | * |
||
573 | * The entity will be entered into the database at or before transaction |
||
574 | * commit or as a result of the flush operation. |
||
575 | * |
||
576 | * NOTE: The persist operation always considers entities that are not yet known to |
||
577 | * this EntityManager as NEW. Do not pass detached entities to the persist operation. |
||
578 | * |
||
579 | * @param object $entity The instance to make managed and persistent. |
||
580 | * |
||
581 | * @return void |
||
582 | * |
||
583 | * @throws ORMInvalidArgumentException |
||
584 | * @throws ORMException |
||
585 | */ |
||
586 | 1032 | View Code Duplication | public function persist($entity) |
587 | { |
||
588 | 1032 | if ( ! is_object($entity)) { |
|
589 | 1 | throw ORMInvalidArgumentException::invalidObject('EntityManager#persist()', $entity); |
|
590 | } |
||
591 | |||
592 | 1031 | $this->errorIfClosed(); |
|
593 | |||
594 | 1030 | $this->unitOfWork->persist($entity); |
|
595 | 1029 | } |
|
596 | |||
597 | /** |
||
598 | * Removes an entity instance. |
||
599 | * |
||
600 | * A removed entity will be removed from the database at or before transaction commit |
||
601 | * or as a result of the flush operation. |
||
602 | * |
||
603 | * @param object $entity The entity instance to remove. |
||
604 | * |
||
605 | * @return void |
||
606 | * |
||
607 | * @throws ORMInvalidArgumentException |
||
608 | * @throws ORMException |
||
609 | */ |
||
610 | 51 | View Code Duplication | public function remove($entity) |
611 | { |
||
612 | 51 | if ( ! is_object($entity)) { |
|
613 | 1 | throw ORMInvalidArgumentException::invalidObject('EntityManager#remove()', $entity); |
|
614 | } |
||
615 | |||
616 | 50 | $this->errorIfClosed(); |
|
617 | |||
618 | 49 | $this->unitOfWork->remove($entity); |
|
619 | 49 | } |
|
620 | |||
621 | /** |
||
622 | * Refreshes the persistent state of an entity from the database, |
||
623 | * overriding any local changes that have not yet been persisted. |
||
624 | * |
||
625 | * @param object $entity The entity to refresh. |
||
626 | * |
||
627 | * @return void |
||
628 | * |
||
629 | * @throws ORMInvalidArgumentException |
||
630 | * @throws ORMException |
||
631 | */ |
||
632 | 19 | View Code Duplication | public function refresh($entity) |
633 | { |
||
634 | 19 | if ( ! is_object($entity)) { |
|
635 | 1 | throw ORMInvalidArgumentException::invalidObject('EntityManager#refresh()', $entity); |
|
636 | } |
||
637 | |||
638 | 18 | $this->errorIfClosed(); |
|
639 | |||
640 | 17 | $this->unitOfWork->refresh($entity); |
|
641 | 17 | } |
|
642 | |||
643 | /** |
||
644 | * Detaches an entity from the EntityManager, causing a managed entity to |
||
645 | * become detached. Unflushed changes made to the entity if any |
||
646 | * (including removal of the entity), will not be synchronized to the database. |
||
647 | * Entities which previously referenced the detached entity will continue to |
||
648 | * reference it. |
||
649 | * |
||
650 | * @param object $entity The entity to detach. |
||
651 | * |
||
652 | * @return void |
||
653 | * |
||
654 | * @throws ORMInvalidArgumentException |
||
655 | */ |
||
656 | 13 | public function detach($entity) |
|
664 | |||
665 | /** |
||
666 | * Merges the state of a detached entity into the persistence context |
||
667 | * of this EntityManager and returns the managed copy of the entity. |
||
668 | * The entity passed to merge will not become associated/managed with this EntityManager. |
||
669 | * |
||
670 | * @param object $entity The detached entity to merge into the persistence context. |
||
671 | * |
||
672 | * @return object The managed copy of the entity. |
||
673 | * |
||
674 | * @throws ORMInvalidArgumentException |
||
675 | * @throws ORMException |
||
676 | */ |
||
677 | 42 | View Code Duplication | public function merge($entity) |
678 | { |
||
679 | 42 | if ( ! is_object($entity)) { |
|
680 | 1 | throw ORMInvalidArgumentException::invalidObject('EntityManager#merge()', $entity); |
|
681 | } |
||
682 | |||
683 | 41 | $this->errorIfClosed(); |
|
684 | |||
685 | 40 | return $this->unitOfWork->merge($entity); |
|
686 | } |
||
687 | |||
688 | /** |
||
689 | * {@inheritDoc} |
||
690 | * |
||
691 | * @todo Implementation need. This is necessary since $e2 = clone $e1; throws an E_FATAL when access anything on $e: |
||
692 | * Fatal error: Maximum function nesting level of '100' reached, aborting! |
||
693 | */ |
||
694 | public function copy($entity, $deep = false) |
||
698 | |||
699 | /** |
||
700 | * {@inheritDoc} |
||
701 | */ |
||
702 | 9 | public function lock($entity, $lockMode, $lockVersion = null) |
|
703 | { |
||
704 | 9 | $this->unitOfWork->lock($entity, $lockMode, $lockVersion); |
|
705 | 2 | } |
|
706 | |||
707 | /** |
||
708 | * Gets the repository for an entity class. |
||
709 | * |
||
710 | * @param string $entityName The name of the entity. |
||
711 | * |
||
712 | * @return \Doctrine\ORM\EntityRepository The repository class. |
||
713 | */ |
||
714 | 155 | public function getRepository($entityName) |
|
718 | |||
719 | /** |
||
720 | * Determines whether an entity instance is managed in this EntityManager. |
||
721 | * |
||
722 | * @param object $entity |
||
723 | * |
||
724 | * @return boolean TRUE if this EntityManager currently manages the given entity, FALSE otherwise. |
||
725 | */ |
||
726 | 24 | public function contains($entity) |
|
732 | |||
733 | /** |
||
734 | * {@inheritDoc} |
||
735 | */ |
||
736 | 2393 | public function getEventManager() |
|
740 | |||
741 | /** |
||
742 | * {@inheritDoc} |
||
743 | */ |
||
744 | 2393 | public function getConfiguration() |
|
748 | |||
749 | /** |
||
750 | * Throws an exception if the EntityManager is closed or currently not active. |
||
751 | * |
||
752 | * @return void |
||
753 | * |
||
754 | * @throws ORMException If the EntityManager is closed. |
||
755 | */ |
||
756 | 1051 | private function errorIfClosed() |
|
762 | |||
763 | /** |
||
764 | * {@inheritDoc} |
||
765 | */ |
||
766 | 1 | public function isOpen() |
|
770 | |||
771 | /** |
||
772 | * {@inheritDoc} |
||
773 | */ |
||
774 | 2393 | public function getUnitOfWork() |
|
778 | |||
779 | /** |
||
780 | * {@inheritDoc} |
||
781 | */ |
||
782 | public function getHydrator($hydrationMode) |
||
786 | |||
787 | /** |
||
788 | * {@inheritDoc} |
||
789 | */ |
||
790 | 917 | public function newHydrator($hydrationMode) |
|
816 | |||
817 | /** |
||
818 | * {@inheritDoc} |
||
819 | */ |
||
820 | 174 | public function getProxyFactory() |
|
824 | |||
825 | /** |
||
826 | * {@inheritDoc} |
||
827 | */ |
||
828 | public function initializeObject($obj) |
||
832 | |||
833 | /** |
||
834 | * Factory method to create EntityManager instances. |
||
835 | * |
||
836 | * @param array|Connection $connection An array with the connection parameters or an existing Connection instance. |
||
837 | * @param Configuration $config The Configuration instance to use. |
||
838 | * @param EventManager $eventManager The EventManager instance to use. |
||
839 | * |
||
840 | * @return EntityManager The created EntityManager. |
||
841 | * |
||
842 | * @throws \InvalidArgumentException |
||
843 | * @throws ORMException |
||
844 | */ |
||
845 | 1258 | public static function create($connection, Configuration $config, EventManager $eventManager = null) |
|
855 | |||
856 | /** |
||
857 | * Factory method to create Connection instances. |
||
858 | * |
||
859 | * @param array|Connection $connection An array with the connection parameters or an existing Connection instance. |
||
860 | * @param Configuration $config The Configuration instance to use. |
||
861 | * @param EventManager $eventManager The EventManager instance to use. |
||
862 | * |
||
863 | * @return Connection |
||
864 | * |
||
865 | * @throws \InvalidArgumentException |
||
866 | * @throws ORMException |
||
867 | */ |
||
868 | 1258 | protected static function createConnection($connection, Configuration $config, EventManager $eventManager = null) |
|
890 | |||
891 | /** |
||
892 | * {@inheritDoc} |
||
893 | */ |
||
894 | 631 | public function getFilters() |
|
902 | |||
903 | /** |
||
904 | * {@inheritDoc} |
||
905 | */ |
||
906 | 40 | public function isFiltersStateClean() |
|
910 | |||
911 | /** |
||
912 | * {@inheritDoc} |
||
913 | */ |
||
914 | 752 | public function hasFilters() |
|
918 | } |
||
919 |
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: