Skip to content

Commit f8f438e

Browse files
committed
adjust to persistence 4
1 parent 3a82723 commit f8f438e

File tree

8 files changed

+166
-82
lines changed

8 files changed

+166
-82
lines changed

lib/Doctrine/ODM/PHPCR/Decorator/DocumentManagerDecorator.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Doctrine\ODM\PHPCR\Translation\LocaleChooser\LocaleChooserInterface;
1616
use Doctrine\ODM\PHPCR\Translation\TranslationStrategy\TranslationStrategyInterface;
1717
use Doctrine\ODM\PHPCR\UnitOfWork;
18+
use Doctrine\Persistence\ObjectManager;
1819
use Doctrine\Persistence\ObjectManagerDecorator;
1920
use PHPCR\NodeInterface;
2021
use PHPCR\PropertyType;
@@ -26,13 +27,15 @@
2627
* Base class for DocumentManager decorators.
2728
*
2829
* @since 1.3
30+
*
31+
* @extends ObjectManagerDecorator<DocumentManagerInterface>
2932
*/
3033
abstract class DocumentManagerDecorator extends ObjectManagerDecorator implements DocumentManagerInterface
3134
{
3235
/**
3336
* @var DocumentManagerInterface
3437
*/
35-
protected $wrapped;
38+
protected ObjectManager $wrapped;
3639

3740
public function __construct(DocumentManagerInterface $wrapped)
3841
{
@@ -100,7 +103,7 @@ public function find(?string $className, $id): ?object
100103
return $this->wrapped->find($className, $id);
101104
}
102105

103-
public function findMany(?string $className, array $ids): Collection
106+
public function findMany(?string $className, array $ids): array
104107
{
105108
return $this->wrapped->findMany($className, $ids);
106109
}
@@ -140,7 +143,7 @@ public function createPhpcrQueryBuilder(): PhpcrQueryBuilder
140143
return $this->wrapped->createPhpcrQueryBuilder();
141144
}
142145

143-
public function getDocumentsByPhpcrQuery(QueryInterface $query, ?string $className = null, ?string $primarySelector = null): Collection
146+
public function getDocumentsByPhpcrQuery(QueryInterface $query, ?string $className = null, ?string $primarySelector = null): array
144147
{
145148
return $this->wrapped->getDocumentsByPhpcrQuery($query, $className, $primarySelector);
146149
}

lib/Doctrine/ODM/PHPCR/DocumentManager.php

Lines changed: 8 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ public function find(?string $className, $id): ?object
211211
}
212212
}
213213

214-
public function findMany(?string $className, array $ids): Collection
214+
public function findMany(?string $className, array $ids): array
215215
{
216216
// when loading duplicate ID's the resulting response would be a collection of unique ids,
217217
// but having duplicates would also cause a lot of overhead as well as break translation loading,
@@ -343,7 +343,7 @@ public function createPhpcrQueryBuilder(): PhpcrQueryBuilder
343343
return new PhpcrQueryBuilder($qm->getQOMFactory());
344344
}
345345

346-
public function getDocumentsByPhpcrQuery(QueryInterface $query, ?string $className = null, ?string $primarySelector = null): Collection
346+
public function getDocumentsByPhpcrQuery(QueryInterface $query, ?string $className = null, ?string $primarySelector = null): array
347347
{
348348
$this->errorIfClosed();
349349

@@ -372,11 +372,9 @@ public function getDocumentsByPhpcrQuery(QueryInterface $query, ?string $classNa
372372
* for the default language and that is used to store. The field is
373373
* updated with the locale.
374374
*
375-
* @param object $document the document to persist
376-
*
377375
* @throws InvalidArgumentException if $document is not an object
378376
*/
379-
public function persist($document): void
377+
public function persist(object $document): void
380378
{
381379
if (!is_object($document)) {
382380
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
447445
* Be aware of the PHPCR tree structure: this removes all nodes with a path under
448446
* the path of this object, even if there are no Parent / Child mappings
449447
* that make the relationship explicit.
450-
*
451-
* @param object $document
452-
*
453-
* @throws InvalidArgumentException if $document is not an object
454448
*/
455-
public function remove($document): void
449+
public function remove(object $document): void
456450
{
457-
if (!is_object($document)) {
458-
throw new InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
459-
}
460-
461451
$this->errorIfClosed();
462452
$this->unitOfWork->scheduleRemove($document);
463453
}
@@ -471,17 +461,9 @@ public function remove($document): void
471461
* removal of the object) will not be synchronized to the database.
472462
* Objects which previously referenced the detached object will continue to
473463
* reference it.
474-
*
475-
* @param object $document the object to detach
476-
*
477-
* @throws InvalidArgumentException if $document is not an object
478464
*/
479-
public function detach($document): void
465+
public function detach(object $document): void
480466
{
481-
if (!is_object($document)) {
482-
throw new InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
483-
}
484-
485467
$this->errorIfClosed();
486468
$this->unitOfWork->detach($document);
487469
}
@@ -490,17 +472,9 @@ public function detach($document): void
490472
* {@inheritdoc}
491473
*
492474
* Refresh the given document by querying the PHPCR to get the current state.
493-
*
494-
* @param object $document
495-
*
496-
* @throws InvalidArgumentException if $document is not an object
497475
*/
498-
public function refresh($document): void
476+
public function refresh(object $document): void
499477
{
500-
if (!is_object($document)) {
501-
throw new InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
502-
}
503-
504478
$this->errorIfClosed();
505479
$this->unitOfWork->refresh($document);
506480
}
@@ -594,19 +568,9 @@ public function findVersionByName(?string $className, string $id, string $versio
594568
* {@inheritdoc}
595569
*
596570
* Check if this repository contains the object
597-
*
598-
* @param object $document
599-
*
600-
* @return bool true if the repository contains the object, false otherwise
601-
*
602-
* @throws InvalidArgumentException if $document is not an object
603571
*/
604-
public function contains($document): bool
572+
public function contains(object $document): bool
605573
{
606-
if (!is_object($document)) {
607-
throw new InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
608-
}
609-
610574
return $this->unitOfWork->contains($document);
611575
}
612576

@@ -637,12 +601,8 @@ public function close(): void
637601
$this->closed = true;
638602
}
639603

640-
public function initializeObject($document): void
604+
public function initializeObject(object $document): void
641605
{
642-
if (!is_object($document)) {
643-
throw new InvalidArgumentException('Parameter $document needs to be an object, '.gettype($document).' given');
644-
}
645-
646606
$this->unitOfWork->initializeObject($document);
647607
}
648608

0 commit comments

Comments
 (0)