Skip to content

Commit

Permalink
Implement isUninitializedObject() in ObjectManagerDecorator
Browse files Browse the repository at this point in the history
That method will be part of the ObjectManager interface in 4.0.x.
  • Loading branch information
greg0ire committed May 22, 2024
1 parent bea01f5 commit 9c9c61a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"phpstan/phpstan-strict-rules": "^1.1",
"doctrine/coding-standard": "^12",
"doctrine/common": "^3.0",
"phpunit/phpunit": "^8.5 || ^9.5",
"phpunit/phpunit": "^8.5.38 || ^9.5",
"symfony/cache": "^4.4 || ^5.4 || ^6.0",
"vimeo/psalm": "4.30.0 || 5.24.0"
},
Expand Down
6 changes: 6 additions & 0 deletions src/Persistence/ObjectManagerDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ public function initializeObject(object $obj)
$this->wrapped->initializeObject($obj);
}

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

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

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

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

$wrapped = $this->createMock(ObjectManagerV4::class);
$decorated = new NullObjectManagerDecorator($wrapped);
$wrapped->expects(self::once())
->method('isUninitializedObject')
->with($object)
->willReturn(false);

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

interface ObjectManagerV4 extends ObjectManager
{
public function isUninitializedObject(mixed $object): bool;
}

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

0 comments on commit 9c9c61a

Please sign in to comment.