Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 6 additions & 4 deletions lib/Doctrine/ODM/PHPCR/Decorator/DocumentManagerDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -26,13 +26,15 @@
* Base class for DocumentManager decorators.
*
* @since 1.3
*
* @extends ObjectManagerDecorator<DocumentManagerInterface>
*/
abstract class DocumentManagerDecorator extends ObjectManagerDecorator implements DocumentManagerInterface
{
/**
* @var DocumentManagerInterface
*/
protected $wrapped;
protected ObjectManager $wrapped;

public function __construct(DocumentManagerInterface $wrapped)
{
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down
56 changes: 8 additions & 48 deletions lib/Doctrine/ODM/PHPCR/DocumentManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand Down
Loading
Loading