@@ -189,8 +189,9 @@ public function find($params = [], $one = false)
189189 $ params = $ this ->normalize ($ params );
190190
191191 if (array_key_exists ('id ' , $ params )) {
192- if (array_key_exists ($ params ['id ' ], $ this ->persisted )) {
193- $ instance = $ this ->persisted [$ params ['id ' ]];
192+ $ key = (string ) $ params ['id ' ];
193+ if (array_key_exists ($ key , $ this ->persisted )) {
194+ $ instance = $ this ->persisted [$ key ];
194195 return $ one ? $ instance : [$ instance ];
195196 }
196197 }
@@ -229,8 +230,14 @@ public function find($params = [], $one = false)
229230 return $ this ->results [$ cacheKey ] = $ result ;
230231 }
231232
232- public function forget (int $ id ): self
233+ public function forget ($ id ): self
233234 {
235+ if ($ id instanceof Entity) {
236+ $ id = $ this ->space ->getInstanceKey ($ id );
237+ }
238+
239+ $ id = (string ) $ id ;
240+
234241 if (array_key_exists ($ id , $ this ->persisted )) {
235242 $ instance = $ this ->persisted [$ id ];
236243 unset($ this ->keys [$ instance ]);
@@ -244,7 +251,7 @@ public function forget(int $id): self
244251
245252 public function getInstance (array $ tuple ): Entity
246253 {
247- $ key = $ this ->space ->getTupleKey ($ tuple );
254+ $ key = ( string ) $ this ->space ->getTupleKey ($ tuple );
248255
249256 if (array_key_exists ($ key , $ this ->persisted )) {
250257 return $ this ->persisted [$ key ];
@@ -326,7 +333,7 @@ public function remove($params = []): self
326333
327334 public function removeEntity (Entity $ instance ): self
328335 {
329- $ key = $ this ->space ->getInstanceKey ($ instance );
336+ $ key = ( string ) $ this ->space ->getInstanceKey ($ instance );
330337
331338 if (!array_key_exists ($ key , $ this ->original )) {
332339 return $ this ;
@@ -372,7 +379,7 @@ public function removeEntity(Entity $instance): self
372379
373380 public function save (Entity $ instance ): Entity
374381 {
375- $ key = $ this ->space ->getInstanceKey ($ instance );
382+ $ key = ( string ) $ this ->space ->getInstanceKey ($ instance );
376383 $ client = $ this ->getMapper ()->getClient ();
377384
378385 if (array_key_exists ($ key , $ this ->persisted )) {
@@ -478,7 +485,7 @@ private function addDefaultValues(Entity $instance): Entity
478485
479486 public function getOriginal (Entity $ instance ): ?array
480487 {
481- $ key = $ this ->space ->getInstanceKey ($ instance );
488+ $ key = ( string ) $ this ->space ->getInstanceKey ($ instance );
482489
483490 if (array_key_exists ($ key , $ this ->original )) {
484491 return $ this ->original [$ key ];
0 commit comments