Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix ORMInvalidArgumentException factory methods with return instead of throw #427

Merged
merged 1 commit into from

3 participants

@chEbba

Exception factories should not throw exceptions but just return them

@travisbot

This pull request passes (merged 3aaa90e into 971865f).

@beberlei beberlei merged commit 48e9434 into doctrine:2.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 6 deletions.
  1. +6 −6 lib/Doctrine/ORM/ORMInvalidArgumentException.php
View
12 lib/Doctrine/ORM/ORMInvalidArgumentException.php
@@ -43,7 +43,7 @@ static public function scheduleInsertTwice($entity)
static public function entityWithoutIdentity($className, $entity)
{
- throw new self(
+ return new self(
"The given entity of type '" . $className . "' (".self::objToStr($entity).") has no identity/no " .
"id values set. It cannot be added to the identity map."
);
@@ -70,30 +70,30 @@ static public function newEntityFoundThroughRelationship(array $assoc, $entry)
static public function detachedEntityFoundThroughRelationship(array $assoc, $entry)
{
- throw new self("A detached entity of type " . $assoc['targetEntity'] . " (" . self::objToStr($entry) . ") "
+ return new self("A detached entity of type " . $assoc['targetEntity'] . " (" . self::objToStr($entry) . ") "
. " was found through the relationship '" . $assoc['sourceEntity'] . "#" . $assoc['fieldName'] . "' "
. "during cascading a persist operation.");
}
static public function entityNotManaged($entity)
{
- throw new self("Entity " . self::objToStr($entity) . " is not managed. An entity is managed if its fetched " .
+ return new self("Entity " . self::objToStr($entity) . " is not managed. An entity is managed if its fetched " .
"from the database or registered as new through EntityManager#persist");
}
static public function entityHasNoIdentity($entity, $operation)
{
- throw new self("Entity has no identity, therefore " . $operation ." cannot be performed. " . self::objToStr($entity));
+ return new self("Entity has no identity, therefore " . $operation ." cannot be performed. " . self::objToStr($entity));
}
static public function entityIsRemoved($entity, $operation)
{
- throw new self("Entity is removed, therefore " . $operation ." cannot be performed. " . self::objToStr($entity));
+ return new self("Entity is removed, therefore " . $operation ." cannot be performed. " . self::objToStr($entity));
}
static public function detachedEntityCannot($entity, $operation)
{
- throw new self("A detached entity was found during " . $operation . " " . self::objToStr($entity));
+ return new self("A detached entity was found during " . $operation . " " . self::objToStr($entity));
}
public static function invalidObject($context, $given, $parameterIndex = 1)
Something went wrong with that request. Please try again.