diff --git a/composer.json b/composer.json index cfee54dcc..913a9b2f9 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "doctrine/collections": "^2.0", "doctrine/common": "^2.4 || ^3.0", "doctrine/event-manager": "^1.0 || ^2.0", - "doctrine/persistence": "^3.0", + "doctrine/persistence": "^3.0 || ^4.0", "phpcr/phpcr": "^2.1.1", "phpcr/phpcr-implementation": "^2.1", "phpcr/phpcr-utils": "^1.3.0 || ^2.0", diff --git a/lib/Doctrine/ODM/PHPCR/Decorator/DocumentManagerDecorator.php b/lib/Doctrine/ODM/PHPCR/Decorator/DocumentManagerDecorator.php index ace7e8628..2f4aa24a8 100644 --- a/lib/Doctrine/ODM/PHPCR/Decorator/DocumentManagerDecorator.php +++ b/lib/Doctrine/ODM/PHPCR/Decorator/DocumentManagerDecorator.php @@ -2,7 +2,6 @@ namespace Doctrine\ODM\PHPCR\Decorator; -use Doctrine\Common\Collections\Collection; use Doctrine\Common\EventManager; use Doctrine\ODM\PHPCR\ChildrenCollection; use Doctrine\ODM\PHPCR\Configuration; @@ -15,6 +14,7 @@ use Doctrine\ODM\PHPCR\Translation\LocaleChooser\LocaleChooserInterface; use Doctrine\ODM\PHPCR\Translation\TranslationStrategy\TranslationStrategyInterface; use Doctrine\ODM\PHPCR\UnitOfWork; +use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectManagerDecorator; use PHPCR\NodeInterface; use PHPCR\PropertyType; @@ -26,13 +26,15 @@ * Base class for DocumentManager decorators. * * @since 1.3 + * + * @extends ObjectManagerDecorator */ abstract class DocumentManagerDecorator extends ObjectManagerDecorator implements DocumentManagerInterface { /** * @var DocumentManagerInterface */ - protected $wrapped; + protected ObjectManager $wrapped; public function __construct(DocumentManagerInterface $wrapped) { @@ -100,7 +102,7 @@ public function find(?string $className, $id): ?object return $this->wrapped->find($className, $id); } - public function findMany(?string $className, array $ids): Collection + public function findMany(?string $className, array $ids): array { return $this->wrapped->findMany($className, $ids); } @@ -140,7 +142,7 @@ public function createPhpcrQueryBuilder(): PhpcrQueryBuilder return $this->wrapped->createPhpcrQueryBuilder(); } - public function getDocumentsByPhpcrQuery(QueryInterface $query, ?string $className = null, ?string $primarySelector = null): Collection + public function getDocumentsByPhpcrQuery(QueryInterface $query, ?string $className = null, ?string $primarySelector = null): array { return $this->wrapped->getDocumentsByPhpcrQuery($query, $className, $primarySelector); } diff --git a/lib/Doctrine/ODM/PHPCR/DocumentManager.php b/lib/Doctrine/ODM/PHPCR/DocumentManager.php index 215b0ba59..f892b133d 100644 --- a/lib/Doctrine/ODM/PHPCR/DocumentManager.php +++ b/lib/Doctrine/ODM/PHPCR/DocumentManager.php @@ -211,7 +211,7 @@ public function find(?string $className, $id): ?object } } - public function findMany(?string $className, array $ids): Collection + public function findMany(?string $className, array $ids): array { // when loading duplicate ID's the resulting response would be a collection of unique ids, // but having duplicates would also cause a lot of overhead as well as break translation loading, @@ -343,7 +343,7 @@ public function createPhpcrQueryBuilder(): PhpcrQueryBuilder return new PhpcrQueryBuilder($qm->getQOMFactory()); } - public function getDocumentsByPhpcrQuery(QueryInterface $query, ?string $className = null, ?string $primarySelector = null): Collection + public function getDocumentsByPhpcrQuery(QueryInterface $query, ?string $className = null, ?string $primarySelector = null): array { $this->errorIfClosed(); @@ -372,11 +372,9 @@ public function getDocumentsByPhpcrQuery(QueryInterface $query, ?string $classNa * for the default language and that is used to store. The field is * updated with the locale. * - * @param object $document the document to persist - * * @throws InvalidArgumentException if $document is not an object */ - public function persist($document): void + public function persist(object $document): void { if (!is_object($document)) { throw new InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given'); @@ -447,17 +445,9 @@ public function reorder(object $document, string $srcName, string $targetName, b * Be aware of the PHPCR tree structure: this removes all nodes with a path under * the path of this object, even if there are no Parent / Child mappings * that make the relationship explicit. - * - * @param object $document - * - * @throws InvalidArgumentException if $document is not an object */ - public function remove($document): void + public function remove(object $document): void { - if (!is_object($document)) { - throw new InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given'); - } - $this->errorIfClosed(); $this->unitOfWork->scheduleRemove($document); } @@ -471,17 +461,9 @@ public function remove($document): void * removal of the object) will not be synchronized to the database. * Objects which previously referenced the detached object will continue to * reference it. - * - * @param object $document the object to detach - * - * @throws InvalidArgumentException if $document is not an object */ - public function detach($document): void + public function detach(object $document): void { - if (!is_object($document)) { - throw new InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given'); - } - $this->errorIfClosed(); $this->unitOfWork->detach($document); } @@ -490,17 +472,9 @@ public function detach($document): void * {@inheritdoc} * * Refresh the given document by querying the PHPCR to get the current state. - * - * @param object $document - * - * @throws InvalidArgumentException if $document is not an object */ - public function refresh($document): void + public function refresh(object $document): void { - if (!is_object($document)) { - throw new InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given'); - } - $this->errorIfClosed(); $this->unitOfWork->refresh($document); } @@ -594,19 +568,9 @@ public function findVersionByName(?string $className, string $id, string $versio * {@inheritdoc} * * Check if this repository contains the object - * - * @param object $document - * - * @return bool true if the repository contains the object, false otherwise - * - * @throws InvalidArgumentException if $document is not an object */ - public function contains($document): bool + public function contains(object $document): bool { - if (!is_object($document)) { - throw new InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given'); - } - return $this->unitOfWork->contains($document); } @@ -637,12 +601,8 @@ public function close(): void $this->closed = true; } - public function initializeObject($document): void + public function initializeObject(object $document): void { - if (!is_object($document)) { - throw new InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given'); - } - $this->unitOfWork->initializeObject($document); } diff --git a/lib/Doctrine/ODM/PHPCR/DocumentManagerInterface.php b/lib/Doctrine/ODM/PHPCR/DocumentManagerInterface.php index b158a6761..25449b4a6 100644 --- a/lib/Doctrine/ODM/PHPCR/DocumentManagerInterface.php +++ b/lib/Doctrine/ODM/PHPCR/DocumentManagerInterface.php @@ -20,7 +20,6 @@ namespace Doctrine\ODM\PHPCR; -use Doctrine\Common\Collections\Collection; use Doctrine\Common\EventManager; use Doctrine\ODM\PHPCR\Exception\InvalidArgumentException; use Doctrine\ODM\PHPCR\Mapping\ClassMetadata as PhpcrClassMetadata; @@ -125,7 +124,13 @@ public function isOpen(): bool; * @param string|null $className optional object class name to use * @param string $id the path or uuid of the document to find * + * @phpstan-param class-string|null $className + * * @return object|null the document if found, otherwise null + * + * @phpstan-return T|null + * + * @template T of object */ public function find(?string $className, $id): ?object; @@ -137,10 +142,16 @@ public function find(?string $className, $id): ?object; * @param string[] $ids List of repository paths and/or uuids to * find documents. Non-existing ids are ignored. * - * @return Collection list of documents that where found with the $ids and - * if specified the $className + * @phpstan-param class-string|null $className + * + * @return array list of documents that where found with the $ids and + * if specified the $className + * + * @phpstan-return array + * + * @template T of object */ - public function findMany(?string $className, array $ids): Collection; + public function findMany(?string $className, array $ids): array; /** * Load the document from the content repository in the given language. @@ -161,12 +172,18 @@ public function findMany(?string $className, array $ids): Collection; * @param string $locale The language to try to load * @param bool $fallback Set to true if the language fallback mechanism should be used * + * @phpstan-param class-string|null $className + * * @return object|null the translated document or null if not found * + * @phpstan-return T|null + * * @throws MissingTranslationException if $fallback is false and the * translation was not found * @throws PHPCRException if $className is specified and does not match * the class of the document that was found at $id + * + * @template T of object */ public function findTranslation(?string $className, string $id, string $locale, bool $fallback = true): ?object; @@ -234,8 +251,16 @@ public function createPhpcrQueryBuilder(): PhpcrQueryBuilder; * @param QueryInterface $query the query instance as acquired through createPhpcrQuery() * @param string|null $className document class * @param string|null $primarySelector name of the selector for the document to return in case of a join query + * + * @phpstan-param class-string|null $className + * + * @return array + * + * @phpstan-return array + * + * @template T of object */ - public function getDocumentsByPhpcrQuery(QueryInterface $query, ?string $className = null, ?string $primarySelector = null): Collection; + public function getDocumentsByPhpcrQuery(QueryInterface $query, ?string $className = null, ?string $primarySelector = null): array; /** * Bind the translatable fields of the document in the specified locale. @@ -245,8 +270,12 @@ public function getDocumentsByPhpcrQuery(QueryInterface $query, ?string $classNa * @param object $document the document to persist a translation of * @param string $locale the locale this document currently has * + * @phpstan-param T $document + * * @throws InvalidArgumentException if $document is not an object or not managed * @throws PHPCRException if the document is not translatable + * + * @template T of object */ public function bindTranslation(object $document, string $locale): void; @@ -256,7 +285,11 @@ public function bindTranslation(object $document, string $locale): void; * @param object $document the document to persist a translation of * @param string $locale the locale this document currently has * + * @phpstan-param T $document + * * @throws InvalidArgumentException if $document is not an object + * + * @template T of object */ public function removeTranslation(object $document, string $locale): void; @@ -267,10 +300,14 @@ public function removeTranslation(object $document, string $locale): void; * @param object $document The document to get the locales for * @param bool $includeFallbacks Whether to include the available language fallbacks * + * @phpstan-param T $document + * * @return string[] All locales existing for this particular document * * @throws MissingTranslationException if the document is not translatable * @throws InvalidArgumentException if $document is not an object + * + * @template T of object */ public function getLocalesFor(object $document, bool $includeFallbacks): array; @@ -279,6 +316,10 @@ public function getLocalesFor(object $document, bool $includeFallbacks): array; * * To be translatable, it needs a translation strategy and have at least * one translated field. + * + * @phpstan-param T $document + * + * @template T of object */ public function isDocumentTranslatable(object $document): bool; @@ -293,7 +334,11 @@ public function isDocumentTranslatable(object $document): bool; * @param object $document An already registered document * @param string $targetPath The target path including the nodename * + * @phpstan-param T $document + * * @throws InvalidArgumentException if $document is not an object + * + * @template T of object */ public function move(object $document, string $targetPath): void; @@ -309,7 +354,11 @@ public function move(object $document, string $targetPath): void; * @param string $targetName The nodename of the target of the reordering * @param bool $before Whether to move before or after the target * + * @phpstan-param T $document + * * @throws InvalidArgumentException if $document is not an object + * + * @template T of object */ public function reorder(object $document, string $srcName, string $targetName, bool $before): void; @@ -326,9 +375,13 @@ public function reorder(object $document, string $srcName, string $targetName, b * @param int $fetchDepth Optional fetch depth * @param string|null $locale The locale to use during the loading of this collection * + * @phpstan-param T $document + * * @return ChildrenCollection collection of child documents * * @throws InvalidArgumentException if $document is not an object + * + * @template T of object */ public function getChildren(object $document, array|string|null $filter = null, int $fetchDepth = -1, ?string $locale = null): ChildrenCollection; @@ -350,7 +403,11 @@ public function getChildren(object $document, array|string|null $filter = null, * @param string|null $locale The locale to use during the loading of this collection * @param string|null $refClass Class the referrer document must be instanceof * + * @phpstan-param T $document + * * @throws InvalidArgumentException if $document is not an object + * + * @template T of object */ public function getReferrers(object $document, ?string $type = null, ?string $name = null, ?string $locale = null, ?string $refClass = null): ReferrersCollection; @@ -362,7 +419,11 @@ public function getReferrers(object $document, ?string $type = null, ?string $na * has its identifier populated. Otherwise a proxy is returned that automatically * loads itself on first access. * + * @phpstan-param T|string $id + * * @return mixed|object the document reference + * + * @template T of object */ public function getReference(string $documentName, object|string $id): mixed; @@ -375,16 +436,24 @@ public function getReference(string $documentName, object|string $id): mixed; * * The document is made read only until you call checkout again. * + * @phpstan-param T $document + * * @throws InvalidArgumentException if $document is not managed * * @see checkpoint + * + * @template T of object */ public function checkin(object $document): void; /** * Make a checked in document writable again. * + * @phpstan-param T $document + * * @throws InvalidArgumentException if $document is not managed + * + * @template T of object */ public function checkout(object $document): void; @@ -393,7 +462,11 @@ public function checkout(object $document): void; * * A new version is created and the writable document stays in checked out state * + * @phpstan-param T $document + * * @throws InvalidArgumentException if $document is not managed + * + * @template T of object */ public function checkpoint(object $document): void; @@ -410,7 +483,11 @@ public function checkpoint(object $document): void; * identifiers. If true, existing documents with the identical * identifier will be replaced, otherwise an exception is thrown. * - *@see findVersionByName + * @phpstan-param T $documentVersion + * + * @see findVersionByName + * + * @template T of object */ public function restoreVersion(object $documentVersion, bool $removeExisting = true): void; @@ -422,7 +499,11 @@ public function restoreVersion(object $documentVersion, bool $removeExisting = t * * @param object $documentVersion The version document as returned by findVersionByName * + * @phpstan-param T $documentVersion + * * @throws RepositoryException when trying to remove the root version or the last version + * + * @template T of object */ public function removeVersion(object $documentVersion): void; @@ -434,10 +515,13 @@ public function removeVersion(object $documentVersion): void; * @param object $document the document of which to get the version history * @param int $limit an optional limit to only get the latest $limit information * - * @return array of => array("name" => , "labels" => , "created" => ) - * oldest version first + * @phpstan-param T $document + * + * @return array, created: \DateTimeInterface}> Array keys are the version name * * @throws InvalidArgumentException if $document is not an object + * + * @template T of object */ public function getAllLinearVersions(object $document, int $limit = -1): array; @@ -451,10 +535,16 @@ public function getAllLinearVersions(object $document, int $limit = -1): array; * @param string $id Id of the document * @param string $versionName The version name as given by getLinearPredecessors * + * @phpstan-param class-string|null $className + * * @return object|null The detached document or null if the document is not found * + * @phpstan-return T|null + * * @throws UnsupportedRepositoryOperationException if the implementation does not support versioning * @throws InvalidArgumentException if there is a document with $id but no version with $name + * + * @template T of object */ public function findVersionByName(?string $className, string $id, string $versionName): ?object; @@ -476,8 +566,12 @@ public function getUnitOfWork(): UnitOfWork; * @param object|array|null $document Optionally limit to a specific * document or an array of documents * + * @phpstan-param T|array|null $document + * * @throws InvalidArgumentException if $document is neither null nor a * document or an array of documents + * + * @template T of object */ public function flush(object|array|null $document = null): void; @@ -491,8 +585,12 @@ public function close(): void; /** * Return the node of the given object. * + * @phpstan-param T $document + * * @throws PHPCRException if $document is not managed * @throws InvalidArgumentException if $document is not an object + * + * @template T of object */ public function getNodeForDocument(object $document): NodeInterface; @@ -501,7 +599,11 @@ public function getNodeForDocument(object $document): NodeInterface; * * @param object $document A managed document * + * @phpstan-param T $document + * * @throws PHPCRException if $document is not managed + * + * @template T of object */ public function getDocumentId(object $document): ?string; } diff --git a/lib/Doctrine/ODM/PHPCR/DocumentRepository.php b/lib/Doctrine/ODM/PHPCR/DocumentRepository.php index c70cf76a0..b85000391 100644 --- a/lib/Doctrine/ODM/PHPCR/DocumentRepository.php +++ b/lib/Doctrine/ODM/PHPCR/DocumentRepository.php @@ -2,13 +2,13 @@ namespace Doctrine\ODM\PHPCR; -use Doctrine\Common\Collections\Collection; use Doctrine\Common\Proxy\Proxy; use Doctrine\ODM\PHPCR\Exception\InvalidArgumentException; use Doctrine\ODM\PHPCR\Mapping\ClassMetadata; use Doctrine\ODM\PHPCR\Query\Builder\ConstraintFactory; use Doctrine\ODM\PHPCR\Query\Builder\QueryBuilder; use Doctrine\ODM\PHPCR\Query\Query; +use Doctrine\ODM\PHPCR\Query\QueryException; use Doctrine\Persistence\ObjectRepository; use PHPCR\Query\QOM\QueryObjectModelConstantsInterface as Constants; @@ -21,6 +21,10 @@ * * @author Jordi Boggiano * @author Pascal Helfenstein + * + * @template T of object + * + * @template-implements ObjectRepository */ class DocumentRepository implements ObjectRepository { @@ -43,6 +47,8 @@ public function __construct( * The id may either be a PHPCR path or UUID * * @param string $id document id + * + * @phpstan-return T */ public function find($id): ?object { @@ -55,16 +61,20 @@ public function find($id): ?object * The ids may either be PHPCR paths or UUID's, but all must be of the same type * * @param string[] $ids document ids + * + * @phpstan-return list */ - public function findMany(array $ids): Collection + public function findMany(array $ids): array { return $this->dm->findMany($this->className, $ids); } /** * Finds all documents in the repository. + * + * @phpstan-return list */ - public function findAll(): Collection + public function findAll(): array { return $this->findBy([]); } @@ -76,9 +86,13 @@ public function findAll(): Collection * an InvalidArgumentException if certain values of the sorting or limiting details are * not supported. * - * @return Collection the objects matching the criteria + * @return array the documents matching the criteria + * + * @phpstan-return list + * + * @throws QueryException */ - public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): Collection + public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array { $qb = $this->createQueryBuilder('a'); @@ -126,7 +140,7 @@ public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = nu } } - return $qb->getQuery()->execute(); + return $qb->getQuery()->execute()->toArray(); } /** @@ -150,16 +164,22 @@ protected function constraintField(ConstraintFactory $where, string $field, mixe * * @return object|null The first document matching the criteria or null if * none found + * + * @phpstan-return T + * + * @throws QueryException */ public function findOneBy(array $criteria): ?object { $documents = $this->findBy($criteria, null, 1); - return $documents->isEmpty() ? null : $documents->first(); + return \count($documents) ? null : reset($documents); } /** * Refresh a document with the data from PHPCR. + * + * @phpstan-param T $document */ public function refresh(object $document): void { @@ -173,6 +193,8 @@ public function refreshDocumentForProxy(Proxy $document): void /** * Get the document class name this repository is for. + * + * @phpstan-return class-string */ public function getClassName(): string { diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/ClassMetadata.php b/lib/Doctrine/ODM/PHPCR/Mapping/ClassMetadata.php index 2312aebd2..c8722d19d 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/ClassMetadata.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/ClassMetadata.php @@ -102,7 +102,7 @@ class ClassMetadata implements ClassMetadataInterface /** * READ-ONLY: The name of the document class that is stored in the phpcr:class property. */ - public ?string $name; + public string $name; /** * READ-ONLY: The namespace the document class is contained in. @@ -1160,7 +1160,7 @@ public function isIdGeneratorNone(): bool return self::GENERATOR_TYPE_NONE === $this->idGenerator; } - public function getName(): ?string + public function getName(): string { return $this->name; } @@ -1294,25 +1294,24 @@ public function getAssociationNames(): array /** * PHPCR-ODM uses integer codes for relation types. - * - * @return int|string|null */ - public function getTypeOfField($fieldName) + public function getTypeOfField($fieldName): ?string { + // TODO: need to make sure our types are strings not int return $this->mappings[$fieldName]['type'] ?? null; } - public function getAssociationTargetClass($fieldName): ?string + public function getAssociationTargetClass($assocName): ?string { - if (empty($this->mappings[$fieldName]['targetDocument'])) { + if (empty($this->mappings[$assocName]['targetDocument'])) { throw new MappingException(sprintf( 'Association name expected, "%s" is not an association in "%s".', - $fieldName, + $assocName, $this->name )); } - return $this->mappings[$fieldName]['targetDocument']; + return $this->mappings[$assocName]['targetDocument']; } public function getAssociationMappedByTargetField($assocName): string @@ -1338,7 +1337,7 @@ public function isAssociationInverseSide($assocName): bool * * @return string|bool class name if the field is inherited, FALSE otherwise */ - public function isInheritedField(string $fieldName) + public function isInheritedField(string $fieldName): bool|string { return $this->inheritedFields[$fieldName] ?? false; } @@ -1571,10 +1570,8 @@ public function getIdentifierValue(object $document): string * * If there is no identifier mapped, returns an empty array as per the * specification. - * - * @param object $document */ - public function getIdentifierValues($document): array + public function getIdentifierValues(object $document): array { try { return [$this->identifier => $this->getIdentifierValue($document)]; diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ODM/PHPCR/Mapping/ClassMetadataFactory.php index b174f613f..37851e535 100644 --- a/lib/Doctrine/ODM/PHPCR/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ODM/PHPCR/Mapping/ClassMetadataFactory.php @@ -21,7 +21,7 @@ */ class ClassMetadataFactory extends AbstractClassMetadataFactory { - protected $cacheSalt = '__PHPCRODMCLASSMETADATA'; + protected string $cacheSalt = '__PHPCRODMCLASSMETADATA'; private DocumentManagerInterface $dm; private ?MappingDriver $driver; diff --git a/lib/Doctrine/ODM/PHPCR/Query/Query.php b/lib/Doctrine/ODM/PHPCR/Query/Query.php index d29bad155..49c5fcca7 100644 --- a/lib/Doctrine/ODM/PHPCR/Query/Query.php +++ b/lib/Doctrine/ODM/PHPCR/Query/Query.php @@ -124,7 +124,7 @@ public function setDocumentClass(string $documentClass): self * * @throws QueryException if $hydrationMode is not known */ - public function execute(?array $parameters = null, ?int $hydrationMode = null) + public function execute(?array $parameters = null, ?int $hydrationMode = null): Collection|QueryResultInterface { if (!empty($parameters)) { $this->setParameters($parameters); diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/DocumentRepositoryTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/DocumentRepositoryTest.php index 4a90b8c0c..d2fa084c6 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/DocumentRepositoryTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/DocumentRepositoryTest.php @@ -93,7 +93,7 @@ public function testLoadMany(): void // read second document into memory $usersRepository->find($user2->id); $users = $usersRepository->findMany([$user1->id, $user2->id]); - $this->assertEquals('/functional/beberlei', $users->key(), 'Documents are not returned in the order they were requested'); + $this->assertEquals('/functional/beberlei', array_keys($users)[0], 'Documents are not returned in the order they were requested'); } public function testFindBy(): void diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/ReferenceTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/ReferenceTest.php index f564a0f46..52763181e 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/ReferenceTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/ReferenceTest.php @@ -108,7 +108,7 @@ public function testFindByUUID(): void $this->assertInstanceOf($this->referencedType, $document); $documents = $this->dm->findMany($this->referencedType, [$node->getIdentifier()]); - $this->assertInstanceOf($this->referencedType, $documents->first()); + $this->assertInstanceOf($this->referencedType, reset($documents)); } public function testCreateByPath(): void diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/UnitOfWorkTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/UnitOfWorkTest.php index 39aefe861..9ff3a38bf 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/UnitOfWorkTest.php @@ -241,8 +241,8 @@ public function testFetchingMultipleHierarchicalObjectsWithChildIdFirst(): void /* @var $child ParentTestObj */ /* @var $parent ParentTestObj */ - $child = $documents->first(); - $parent = $documents->last(); + $child = reset($documents); + $parent = end($documents); $this->assertSame($child->parent, $parent); $this->assertSame('parent', $parent->nodename);