Skip to content

Commit

Permalink
Replace comment with real method signature
Browse files Browse the repository at this point in the history
  • Loading branch information
greg0ire committed May 22, 2024
1 parent 27441f8 commit 4ca86df
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
5 changes: 5 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ awareness about deprecated code.

# Upgrade to 4.0

## BC Break: Added `ObjectManager::isUninitializedObject()`

Classes implementing `Doctrine\Persistence\ObjectManager` must implement this
new method.

## BC Break: Dropped support for Common proxies

Proxy objects implementing the `Doctrine\Common\Proxy\Proxy` interface are not
Expand Down
9 changes: 4 additions & 5 deletions src/Persistence/ObjectManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@
use Doctrine\Persistence\Mapping\ClassMetadata;
use Doctrine\Persistence\Mapping\ClassMetadataFactory;

/**
* Contract for a Doctrine persistence layer ObjectManager class to implement.
*
* @method bool isUninitializedObject(mixed $value) Implementing this method will be mandatory in version 4.
*/
/** Contract for a Doctrine persistence layer ObjectManager class to implement. */
interface ObjectManager
{
/**
Expand Down Expand Up @@ -136,6 +132,9 @@ public function getMetadataFactory();
*/
public function initializeObject(object $obj);

/** Helper method to check whether a lazy loading proxy or persistent collection has been initialized. */
public function isUninitializedObject(mixed $value): bool;

/**
* Checks if the object is part of the current UnitOfWork and therefore managed.
*
Expand Down
5 changes: 5 additions & 0 deletions src/Persistence/ObjectManagerDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ public function initializeObject(object $obj)
$this->wrapped->initializeObject($obj);
}

public function isUninitializedObject(mixed $value): bool
{
return $this->wrapped->isUninitializedObject($value);
}

/**
* {@inheritDoc}
*/
Expand Down
13 changes: 13 additions & 0 deletions tests/Persistence/ObjectManagerDecoratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,19 @@ public function testContains(): void

self::assertTrue($this->decorated->contains($object));
}

/** @requires PHP 8.0 */
public function testIsUninitializedObject(): void
{
$object = new TestObject();

$this->wrapped->expects(self::once())
->method('isUninitializedObject')
->with($object)
->willReturn(false);

self::assertFalse($this->decorated->isUninitializedObject($object));
}
}

/** @extends ObjectManagerDecorator<ObjectManager&MockObject> */
Expand Down

0 comments on commit 4ca86df

Please sign in to comment.