Skip to content

Commit 82b135f

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

File tree

10 files changed

+169
-86
lines changed

10 files changed

+169
-86
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Doctrine\ODM\PHPCR\Decorator;
44

5-
use Doctrine\Common\Collections\Collection;
65
use Doctrine\Common\EventManager;
76
use Doctrine\ODM\PHPCR\ChildrenCollection;
87
use Doctrine\ODM\PHPCR\Configuration;
@@ -15,6 +14,7 @@
1514
use Doctrine\ODM\PHPCR\Translation\LocaleChooser\LocaleChooserInterface;
1615
use Doctrine\ODM\PHPCR\Translation\TranslationStrategy\TranslationStrategyInterface;
1716
use Doctrine\ODM\PHPCR\UnitOfWork;
17+
use Doctrine\Persistence\ObjectManager;
1818
use Doctrine\Persistence\ObjectManagerDecorator;
1919
use PHPCR\NodeInterface;
2020
use PHPCR\PropertyType;
@@ -26,13 +26,15 @@
2626
* Base class for DocumentManager decorators.
2727
*
2828
* @since 1.3
29+
*
30+
* @extends ObjectManagerDecorator<DocumentManagerInterface>
2931
*/
3032
abstract class DocumentManagerDecorator extends ObjectManagerDecorator implements DocumentManagerInterface
3133
{
3234
/**
3335
* @var DocumentManagerInterface
3436
*/
35-
protected $wrapped;
37+
protected ObjectManager $wrapped;
3638

3739
public function __construct(DocumentManagerInterface $wrapped)
3840
{
@@ -100,7 +102,7 @@ public function find(?string $className, $id): ?object
100102
return $this->wrapped->find($className, $id);
101103
}
102104

103-
public function findMany(?string $className, array $ids): Collection
105+
public function findMany(?string $className, array $ids): array
104106
{
105107
return $this->wrapped->findMany($className, $ids);
106108
}
@@ -140,7 +142,7 @@ public function createPhpcrQueryBuilder(): PhpcrQueryBuilder
140142
return $this->wrapped->createPhpcrQueryBuilder();
141143
}
142144

143-
public function getDocumentsByPhpcrQuery(QueryInterface $query, ?string $className = null, ?string $primarySelector = null): Collection
145+
public function getDocumentsByPhpcrQuery(QueryInterface $query, ?string $className = null, ?string $primarySelector = null): array
144146
{
145147
return $this->wrapped->getDocumentsByPhpcrQuery($query, $className, $primarySelector);
146148
}

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)