diff --git a/composer.json b/composer.json index cf7b249ae57..56e544310d8 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "composer-runtime-api": "^2", "ext-ctype": "*", "doctrine/cache": "^1.12.1 || ^2.1.1", - "doctrine/collections": "^1.5", + "doctrine/collections": "^1.5 || 2.0.x@dev", "doctrine/common": "^3.0.3", "doctrine/dbal": "^2.13.1 || ^3.2", "doctrine/deprecations": "^0.5.3 || ^1", diff --git a/lib/Doctrine/ORM/EntityRepository.php b/lib/Doctrine/ORM/EntityRepository.php index 9e633050b40..b55f7799d53 100644 --- a/lib/Doctrine/ORM/EntityRepository.php +++ b/lib/Doctrine/ORM/EntityRepository.php @@ -7,6 +7,7 @@ use BadMethodCallException; use Doctrine\Common\Collections\AbstractLazyCollection; use Doctrine\Common\Collections\Criteria; +use Doctrine\Common\Collections\ReadableCollection; use Doctrine\Common\Collections\Selectable; use Doctrine\Common\Persistence\PersistentObject; use Doctrine\DBAL\LockMode; @@ -326,7 +327,7 @@ protected function getClassMetadata() * @return AbstractLazyCollection * @psalm-return AbstractLazyCollection&Selectable */ - public function matching(Criteria $criteria) + public function matching(Criteria $criteria): ReadableCollection { $persister = $this->_em->getUnitOfWork()->getEntityPersister($this->_entityName); diff --git a/lib/Doctrine/ORM/LazyCriteriaCollection.php b/lib/Doctrine/ORM/LazyCriteriaCollection.php index 21261308401..61c67a0c856 100644 --- a/lib/Doctrine/ORM/LazyCriteriaCollection.php +++ b/lib/Doctrine/ORM/LazyCriteriaCollection.php @@ -7,6 +7,7 @@ use Doctrine\Common\Collections\AbstractLazyCollection; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Criteria; +use Doctrine\Common\Collections\ReadableCollection; use Doctrine\Common\Collections\Selectable; use Doctrine\ORM\Persisters\Entity\EntityPersister; use ReturnTypeWillChange; @@ -43,11 +44,8 @@ public function __construct(EntityPersister $entityPersister, Criteria $criteria /** * Do an efficient count on the collection - * - * @return int */ - #[ReturnTypeWillChange] - public function count() + public function count(): int { if ($this->isInitialized()) { return $this->collection->count(); @@ -66,7 +64,7 @@ public function count() * * @return bool TRUE if the collection is empty, FALSE otherwise. */ - public function isEmpty() + public function isEmpty(): bool { if ($this->isInitialized()) { return $this->collection->isEmpty(); @@ -80,10 +78,8 @@ public function isEmpty() * * @param object $element * @psalm-param TValue $element - * - * @return bool */ - public function contains($element) + public function contains($element): bool { if ($this->isInitialized()) { return $this->collection->contains($element); @@ -95,7 +91,7 @@ public function contains($element) /** * {@inheritDoc} */ - public function matching(Criteria $criteria) + public function matching(Criteria $criteria): ReadableCollection { $this->initialize(); assert($this->collection instanceof Selectable); @@ -106,7 +102,7 @@ public function matching(Criteria $criteria) /** * {@inheritDoc} */ - protected function doInitialize() + protected function doInitialize(): void { $elements = $this->entityPersister->loadCriteria($this->criteria); $this->collection = new ArrayCollection($elements); diff --git a/lib/Doctrine/ORM/PersistentCollection.php b/lib/Doctrine/ORM/PersistentCollection.php index 8dac7210fbc..0f97515c40f 100644 --- a/lib/Doctrine/ORM/PersistentCollection.php +++ b/lib/Doctrine/ORM/PersistentCollection.php @@ -323,7 +323,7 @@ public function setInitialized($bool): void /** * {@inheritdoc} */ - public function remove($key) + public function remove($key): mixed { // TODO: If the keys are persistent as well (not yet implemented) // and the collection is not initialized and orphanRemoval is @@ -408,7 +408,7 @@ public function contains($element): bool /** * {@inheritdoc} */ - public function get($key) + public function get($key): mixed { if ( ! $this->initialized @@ -479,8 +479,7 @@ public function offsetExists($offset): bool /** * {@inheritdoc} */ - #[ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet($offset): mixed { return $this->get($offset); } @@ -501,13 +500,10 @@ public function offsetSet($offset, $value): void /** * {@inheritdoc} - * - * @return object|null */ - #[ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset($offset): void { - return $this->remove($offset); + $this->remove($offset); } public function isEmpty(): bool diff --git a/lib/Doctrine/ORM/Persisters/SqlExpressionVisitor.php b/lib/Doctrine/ORM/Persisters/SqlExpressionVisitor.php index 967d4b4f65c..5f793bb070d 100644 --- a/lib/Doctrine/ORM/Persisters/SqlExpressionVisitor.php +++ b/lib/Doctrine/ORM/Persisters/SqlExpressionVisitor.php @@ -35,10 +35,8 @@ public function __construct(BasicEntityPersister $persister, ClassMetadata $clas /** * Converts a comparison expression into the target query language output. - * - * @return mixed */ - public function walkComparison(Comparison $comparison) + public function walkComparison(Comparison $comparison): mixed { $field = $comparison->getField(); $value = $comparison->getValue()->getValue(); // shortcut for walkValue() @@ -65,7 +63,7 @@ public function walkComparison(Comparison $comparison) * * @throws RuntimeException */ - public function walkCompositeExpression(CompositeExpression $expr) + public function walkCompositeExpression(CompositeExpression $expr): mixed { $expressionList = []; @@ -90,7 +88,7 @@ public function walkCompositeExpression(CompositeExpression $expr) * * @return string */ - public function walkValue(Value $value) + public function walkValue(Value $value): mixed { return '?'; } diff --git a/lib/Doctrine/ORM/Persisters/SqlValueVisitor.php b/lib/Doctrine/ORM/Persisters/SqlValueVisitor.php index a61d0a25f86..795cb7b856e 100644 --- a/lib/Doctrine/ORM/Persisters/SqlValueVisitor.php +++ b/lib/Doctrine/ORM/Persisters/SqlValueVisitor.php @@ -25,7 +25,7 @@ class SqlValueVisitor extends ExpressionVisitor * * {@inheritDoc} */ - public function walkComparison(Comparison $comparison) + public function walkComparison(Comparison $comparison): mixed { $value = $this->getValueFromComparison($comparison); $field = $comparison->getField(); @@ -48,7 +48,7 @@ public function walkComparison(Comparison $comparison) * * {@inheritDoc} */ - public function walkCompositeExpression(CompositeExpression $expr) + public function walkCompositeExpression(CompositeExpression $expr): mixed { foreach ($expr->getExpressionList() as $child) { $this->dispatch($child); @@ -62,7 +62,7 @@ public function walkCompositeExpression(CompositeExpression $expr) * * {@inheritDoc} */ - public function walkValue(Value $value) + public function walkValue(Value $value): mixed { return null; } diff --git a/lib/Doctrine/ORM/Query/QueryExpressionVisitor.php b/lib/Doctrine/ORM/Query/QueryExpressionVisitor.php index a17323c0002..4de269ce704 100644 --- a/lib/Doctrine/ORM/Query/QueryExpressionVisitor.php +++ b/lib/Doctrine/ORM/Query/QueryExpressionVisitor.php @@ -77,10 +77,7 @@ private static function convertComparisonOperator($criteriaOperator) return self::$operatorMap[$criteriaOperator] ?? null; } - /** - * {@inheritDoc} - */ - public function walkCompositeExpression(CompositeExpression $expr) + public function walkCompositeExpression(CompositeExpression $expr): mixed { $expressionList = []; @@ -103,7 +100,7 @@ public function walkCompositeExpression(CompositeExpression $expr) /** * {@inheritDoc} */ - public function walkComparison(Comparison $comparison) + public function walkComparison(Comparison $comparison): mixed { if (! isset($this->queryAliases[0])) { throw new QueryException('No aliases are set before invoking walkComparison().'); @@ -197,10 +194,7 @@ public function walkComparison(Comparison $comparison) } } - /** - * {@inheritDoc} - */ - public function walkValue(Value $value) + public function walkValue(Value $value): mixed { return $value->getValue(); }