-
-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement isUninitializedObject() in ObjectManagerDecorator #369
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,14 @@ | |
|
||
namespace Doctrine\Persistence; | ||
|
||
use BadMethodCallException; | ||
use Doctrine\Persistence\Mapping\ClassMetadata; | ||
use Doctrine\Persistence\Mapping\ClassMetadataFactory; | ||
|
||
use function get_class; | ||
use function method_exists; | ||
use function sprintf; | ||
|
||
/** | ||
* Base class to simplify ObjectManager decorators | ||
* | ||
|
@@ -82,6 +87,29 @@ public function initializeObject(object $obj) | |
$this->wrapped->initializeObject($obj); | ||
} | ||
|
||
/** @param mixed $value */ | ||
public function isUninitializedObject($value): bool | ||
{ | ||
if (! method_exists($this->wrapped, 'isUninitializedObject')) { | ||
$wrappedClass = get_class($this->wrapped); | ||
|
||
throw new BadMethodCallException(sprintf( | ||
<<<'EXCEPTION' | ||
Context: Trying to call %s | ||
Problem: The wrapped ObjectManager, an instance of %s does not implement this method. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not really, since the FQCN at hand is not the same as the one referred to in the "Problem" part. In the context part, I say we are calling the decorator, in the problem part, I talk about the decorated class. |
||
Solution: Implement %s::isUninitializedObject() with a signature compatible with this one: | ||
public function isUninitializedObject(mixed $value): bool | ||
EXCEPTION | ||
, | ||
__METHOD__, | ||
$wrappedClass, | ||
$wrappedClass | ||
)); | ||
} | ||
|
||
return $this->wrapped->isUninitializedObject($value); | ||
derrabus marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
old versions of PHPUnit seem to struggle with
@requires
annotation that are included in a single-line comment.