-
-
Notifications
You must be signed in to change notification settings - Fork 225
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
Allowing getReference to detect when the reference does not exist. #110
Conversation
If the reference requested does not exist, the $reference variable is NULL which cause the "$this->manager->getClassMetadata(get_class($reference));" line to attempt to get the metadata for Doctrine\Common\DataFixtures\ReferenceRepository (default because $referenceis NULL) rather than the class of the reference object.
*/ | ||
public function getReference($name) | ||
{ | ||
$reference = $this->references[$name]; | ||
if (is_null($reference)) |
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.
CS issues: please use null ===
to check for null and please add the curly braces for the conditional structure
Please also add a test for it |
Still need to add a test. Will take care of tomorrow. |
@stof The test was added. |
@stof, DId you get a chance to review this? |
*/ | ||
public function getReference($name) | ||
{ | ||
$reference = $this->references[$name]; | ||
if (null === $reference) | ||
throw new \InvalidArgumentException("Reference to: ({$name}) does not exist, use method hasReference in order to check for existance"); |
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.
This check should be done before reading the reference, using isset($this->references[$name])
instead, to avoid a NOTICE when the reference does not exist
Fixed by #179 |
If the reference requested does not exist, the $reference variable is NULL which cause the "$this->manager->getClassMetadata(get_class($reference));" line to attempt to get the metadata for Doctrine\Common\DataFixtures\ReferenceRepository (default because $referenceis NULL) rather than the class of the reference object.