Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Fix ORMInvalidArgumentException factory methods with return instead of throw #427

Merged
merged 1 commit into from over 1 year ago

3 participants

Kirill chEbba Chebunin Don't Add Me To Your Organization a.k.a The Travis Bot Benjamin Eberlei
Kirill chEbba Chebunin

Exception factories should not throw exceptions but just return them

Don't Add Me To Your Organization a.k.a The Travis Bot

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

Benjamin Eberlei beberlei merged commit 48e9434 into from August 29, 2012
Benjamin Eberlei beberlei closed this August 29, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Aug 19, 2012
Kirill chEbba Chebunin Fix ORMInvalidArgumentException factory methods with return instead o…
…f throw
3aaa90e
This page is out of date. Refresh to see the latest.
12  lib/Doctrine/ORM/ORMInvalidArgumentException.php
@@ -43,7 +43,7 @@ static public function scheduleInsertTwice($entity)
43 43
 
44 44
     static public function entityWithoutIdentity($className, $entity)
45 45
     {
46  
-        throw new self(
  46
+        return new self(
47 47
             "The given entity of type '" . $className . "' (".self::objToStr($entity).") has no identity/no " . 
48 48
             "id values set. It cannot be added to the identity map."
49 49
         );
@@ -70,30 +70,30 @@ static public function newEntityFoundThroughRelationship(array $assoc, $entry)
70 70
 
71 71
     static public function detachedEntityFoundThroughRelationship(array $assoc, $entry)
72 72
     {
73  
-        throw new self("A detached entity of type " . $assoc['targetEntity'] . " (" . self::objToStr($entry) . ") "
  73
+        return new self("A detached entity of type " . $assoc['targetEntity'] . " (" . self::objToStr($entry) . ") "
74 74
                         . " was found through the relationship '" . $assoc['sourceEntity'] . "#" . $assoc['fieldName'] . "' "
75 75
                         . "during cascading a persist operation.");
76 76
     }
77 77
 
78 78
     static public function entityNotManaged($entity)
79 79
     {
80  
-        throw new self("Entity " . self::objToStr($entity) . " is not managed. An entity is managed if its fetched " .
  80
+        return new self("Entity " . self::objToStr($entity) . " is not managed. An entity is managed if its fetched " .
81 81
                 "from the database or registered as new through EntityManager#persist");
82 82
     }
83 83
 
84 84
     static public function entityHasNoIdentity($entity, $operation)
85 85
     {
86  
-        throw new self("Entity has no identity, therefore " . $operation ." cannot be performed. " . self::objToStr($entity));
  86
+        return new self("Entity has no identity, therefore " . $operation ." cannot be performed. " . self::objToStr($entity));
87 87
     }
88 88
 
89 89
     static public function entityIsRemoved($entity, $operation)
90 90
     {
91  
-        throw new self("Entity is removed, therefore " . $operation ." cannot be performed. " . self::objToStr($entity));
  91
+        return new self("Entity is removed, therefore " . $operation ." cannot be performed. " . self::objToStr($entity));
92 92
     }
93 93
 
94 94
     static public function detachedEntityCannot($entity, $operation)
95 95
     {
96  
-        throw new self("A detached entity was found during " . $operation . " " . self::objToStr($entity));
  96
+        return new self("A detached entity was found during " . $operation . " " . self::objToStr($entity));
97 97
     }
98 98
 
99 99
     public static function invalidObject($context, $given, $parameterIndex = 1)
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.