Skip to content
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

Closed
wants to merge 5 commits into from

Conversation

westinpigott
Copy link

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.

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))
Copy link
Member

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

@stof
Copy link
Member

stof commented Sep 13, 2013

Please also add a test for it

@westinpigott
Copy link
Author

Still need to add a test. Will take care of tomorrow.

@westinpigott
Copy link
Author

@stof The test was added.

@westinpigott
Copy link
Author

@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");
Copy link
Member

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

@lavoiesl
Copy link
Member

Fixed by #179

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants