diff --git a/lib/Doctrine/ORM/Proxy/ProxyFactory.php b/lib/Doctrine/ORM/Proxy/ProxyFactory.php index c3f9b5fd42e..eeff253eb7e 100644 --- a/lib/Doctrine/ORM/Proxy/ProxyFactory.php +++ b/lib/Doctrine/ORM/Proxy/ProxyFactory.php @@ -24,21 +24,13 @@ */ class ProxyFactory extends AbstractProxyFactory { - /** @var EntityManagerInterface The EntityManager this factory is bound to. */ - private $em; - /** @var UnitOfWork The UnitOfWork this factory uses to retrieve persisters */ - private $uow; - - /** @var string */ - private $proxyNs; + private UnitOfWork $uow; /** * The IdentifierFlattener used for manipulating identifiers - * - * @var IdentifierFlattener */ - private $identifierFlattener; + private IdentifierFlattener $identifierFlattener; /** * Initializes a new instance of the ProxyFactory class that is @@ -51,23 +43,23 @@ class ProxyFactory extends AbstractProxyFactory * values are constants of {@see AbstractProxyFactory}. * @psalm-param bool|AutogenerateMode $autoGenerate */ - public function __construct(EntityManagerInterface $em, $proxyDir, $proxyNs, $autoGenerate = AbstractProxyFactory::AUTOGENERATE_NEVER) - { + public function __construct( + /** @var EntityManagerInterface The EntityManager this factory is bound to. */ + private EntityManagerInterface $em, + string $proxyDir, + private string $proxyNs, + $autoGenerate = AbstractProxyFactory::AUTOGENERATE_NEVER + ) { $proxyGenerator = new ProxyGenerator($proxyDir, $proxyNs); $proxyGenerator->setPlaceholder('baseProxyInterface', Proxy::class); parent::__construct($proxyGenerator, $em->getMetadataFactory(), $autoGenerate); - $this->em = $em; $this->uow = $em->getUnitOfWork(); - $this->proxyNs = $proxyNs; $this->identifierFlattener = new IdentifierFlattener($this->uow, $em->getMetadataFactory()); } - /** - * {@inheritDoc} - */ - protected function skipClass(ClassMetadata $metadata) + protected function skipClass(ClassMetadata $metadata): bool { return $metadata->isMappedSuperclass || $metadata->isEmbeddedClass @@ -77,7 +69,7 @@ protected function skipClass(ClassMetadata $metadata) /** * {@inheritDoc} */ - protected function createProxyDefinition($className) + protected function createProxyDefinition($className): ProxyDefinition { $classMetadata = $this->em->getClassMetadata($className); $entityPersister = $this->uow->getEntityPersister($className); diff --git a/lib/Doctrine/ORM/Tools/AttachEntityListenersListener.php b/lib/Doctrine/ORM/Tools/AttachEntityListenersListener.php index d1657367eef..72908a86636 100644 --- a/lib/Doctrine/ORM/Tools/AttachEntityListenersListener.php +++ b/lib/Doctrine/ORM/Tools/AttachEntityListenersListener.php @@ -14,7 +14,7 @@ class AttachEntityListenersListener { /** @var mixed[][] */ - private $entityListeners = []; + private array $entityListeners = []; /** * Adds a entity listener for a specific entity. @@ -23,11 +23,13 @@ class AttachEntityListenersListener * @param string $listenerClass The listener class. * @param string $eventName The entity lifecycle event. * @param string|null $listenerCallback The listener callback method or NULL to use $eventName. - * - * @return void */ - public function addEntityListener($entityClass, $listenerClass, $eventName, $listenerCallback = null) - { + public function addEntityListener( + string $entityClass, + string $listenerClass, + string $eventName, + $listenerCallback = null + ): void { $this->entityListeners[ltrim($entityClass, '\\')][] = [ 'event' => $eventName, 'class' => $listenerClass, @@ -37,10 +39,8 @@ public function addEntityListener($entityClass, $listenerClass, $eventName, $lis /** * Processes event and attach the entity listener. - * - * @return void */ - public function loadClassMetadata(LoadClassMetadataEventArgs $event) + public function loadClassMetadata(LoadClassMetadataEventArgs $event): void { $metadata = $event->getClassMetadata(); diff --git a/lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php b/lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php index ab8b301c20f..42d25aa9c68 100644 --- a/lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php +++ b/lib/Doctrine/ORM/Tools/DebugUnitOfWorkListener.php @@ -26,12 +26,6 @@ */ class DebugUnitOfWorkListener { - /** @var string */ - private $file; - - /** @var string */ - private $context; - /** * Pass a stream and context information for the debugging session. * @@ -40,26 +34,19 @@ class DebugUnitOfWorkListener * @param string $file * @param string $context */ - public function __construct($file = 'php://output', $context = '') + public function __construct(private $file = 'php://output', private $context = '') { - $this->file = $file; - $this->context = $context; } - /** - * @return void - */ - public function onFlush(OnFlushEventArgs $args) + public function onFlush(OnFlushEventArgs $args): void { $this->dumpIdentityMap($args->getEntityManager()); } /** * Dumps the contents of the identity map into a stream. - * - * @return void */ - public function dumpIdentityMap(EntityManagerInterface $em) + public function dumpIdentityMap(EntityManagerInterface $em): void { $uow = $em->getUnitOfWork(); $identityMap = $uow->getIdentityMap(); @@ -119,10 +106,7 @@ public function dumpIdentityMap(EntityManagerInterface $em) fclose($fh); } - /** - * @param mixed $var - */ - private function getType($var): string + private function getType(mixed $var): string { if (is_object($var)) { $refl = new ReflectionObject($var); @@ -133,10 +117,7 @@ private function getType($var): string return gettype($var); } - /** - * @param object $entity - */ - private function getIdString($entity, UnitOfWork $uow): string + private function getIdString(object $entity, UnitOfWork $uow): string { if ($uow->isInIdentityMap($entity)) { $ids = $uow->getEntityIdentifier($entity); diff --git a/lib/Doctrine/ORM/Tools/ResolveTargetEntityListener.php b/lib/Doctrine/ORM/Tools/ResolveTargetEntityListener.php index e7f2fb3e469..663c4b681dc 100644 --- a/lib/Doctrine/ORM/Tools/ResolveTargetEntityListener.php +++ b/lib/Doctrine/ORM/Tools/ResolveTargetEntityListener.php @@ -23,12 +23,12 @@ class ResolveTargetEntityListener implements EventSubscriber { /** @var mixed[][] indexed by original entity name */ - private $resolveTargetEntities = []; + private array $resolveTargetEntities = []; /** * {@inheritDoc} */ - public function getSubscribedEvents() + public function getSubscribedEvents(): array { return [ Events::loadClassMetadata, @@ -39,13 +39,9 @@ public function getSubscribedEvents() /** * Adds a target-entity class name to resolve to a new class name. * - * @param string $originalEntity - * @param string $newEntity * @psalm-param array $mapping - * - * @return void */ - public function addResolveTargetEntity($originalEntity, $newEntity, array $mapping) + public function addResolveTargetEntity(string $originalEntity, string $newEntity, array $mapping): void { $mapping['targetEntity'] = ltrim($newEntity, '\\'); $this->resolveTargetEntities[ltrim($originalEntity, '\\')] = $mapping; @@ -53,10 +49,8 @@ public function addResolveTargetEntity($originalEntity, $newEntity, array $mappi /** * @internal this is an event callback, and should not be called directly - * - * @return void */ - public function onClassMetadataNotFound(OnClassMetadataNotFoundEventArgs $args) + public function onClassMetadataNotFound(OnClassMetadataNotFoundEventArgs $args): void { if (array_key_exists($args->getClassName(), $this->resolveTargetEntities)) { $args->setFoundMetadata( @@ -71,10 +65,8 @@ public function onClassMetadataNotFound(OnClassMetadataNotFoundEventArgs $args) * Processes event and resolves new target entity names. * * @internal this is an event callback, and should not be called directly - * - * @return void */ - public function loadClassMetadata(LoadClassMetadataEventArgs $args) + public function loadClassMetadata(LoadClassMetadataEventArgs $args): void { $cm = $args->getClassMetadata(); diff --git a/lib/Doctrine/ORM/Utility/IdentifierFlattener.php b/lib/Doctrine/ORM/Utility/IdentifierFlattener.php index 837f2dc1d57..f8291c92396 100644 --- a/lib/Doctrine/ORM/Utility/IdentifierFlattener.php +++ b/lib/Doctrine/ORM/Utility/IdentifierFlattener.php @@ -19,27 +19,19 @@ */ final class IdentifierFlattener { - /** - * The UnitOfWork used to coordinate object-level transactions. - * - * @var UnitOfWork - */ - private $unitOfWork; - - /** - * The metadata factory, used to retrieve the ORM metadata of entity classes. - * - * @var ClassMetadataFactory - */ - private $metadataFactory; - /** * Initializes a new IdentifierFlattener instance, bound to the given EntityManager. */ - public function __construct(UnitOfWork $unitOfWork, ClassMetadataFactory $metadataFactory) - { - $this->unitOfWork = $unitOfWork; - $this->metadataFactory = $metadataFactory; + public function __construct( + /** + * The UnitOfWork used to coordinate object-level transactions. + */ + private UnitOfWork $unitOfWork, + /** + * The metadata factory, used to retrieve the ORM metadata of entity classes. + */ + private ClassMetadataFactory $metadataFactory + ) { } /**