File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ public function repository(): ?string;
3434 *
3535 * @phpstan-param array<string, mixed>|EntityType $data
3636 *
37- * @return int|string
37+ * @return int|string|null
3838 */
39- public function identity (array |object $ data ): int |string ;
39+ public function identity (array |object $ data ): int |string | null ;
4040}
Original file line number Diff line number Diff line change @@ -52,13 +52,13 @@ public function repository(): ?string
5252 *
5353 * @phpstan-param array<string, mixed>|EntityType $data
5454 *
55- * @return int|string
55+ * @return int|string|null
5656 */
57- public function identity (object |array $ data ): int |string
57+ public function identity (object |array $ data ): int |string | null
5858 {
5959 if (is_object ($ data )) {
6060 if (method_exists ($ data , 'hasId ' ) && ! $ data ->hasId ()) {
61- throw new RuntimeException ( ' Cannot get identity from an entity without an ID ' ) ;
61+ return null ;
6262 }
6363
6464 if (property_exists ($ data , 'id ' )) {
@@ -77,7 +77,7 @@ public function identity(object|array $data): int|string
7777 }
7878
7979 if (! isset ($ data ['id ' ])) {
80- throw new RuntimeException ( ' Cannot get identity from an entity without an ID ' ) ;
80+ return null ;
8181 }
8282
8383 assert (is_string ($ data ['id ' ]) || is_int ($ data ['id ' ]), 'The ID must be an int or string ' );
You can’t perform that action at this time.
0 commit comments