@@ -567,7 +567,7 @@ public function find($id = null)
567567 'singleton ' => $ singleton ,
568568 ]);
569569
570- if (! empty ($ eventData ['returnData ' ])) {
570+ if (isset ($ eventData ['returnData ' ]) && $ eventData [ ' returnData ' ] === true ) {
571571 return $ eventData ['data ' ];
572572 }
573573 }
@@ -629,7 +629,7 @@ public function findAll(int $limit = 0, int $offset = 0)
629629 'singleton ' => false ,
630630 ]);
631631
632- if (! empty ($ eventData ['returnData ' ])) {
632+ if (isset ($ eventData ['returnData ' ]) && $ eventData [ ' returnData ' ] === true ) {
633633 return $ eventData ['data ' ];
634634 }
635635 }
@@ -667,7 +667,7 @@ public function first()
667667 'singleton ' => true ,
668668 ]);
669669
670- if (! empty ($ eventData ['returnData ' ])) {
670+ if (isset ($ eventData ['returnData ' ]) && $ eventData [ ' returnData ' ] === true ) {
671671 return $ eventData ['data ' ];
672672 }
673673 }
@@ -703,7 +703,7 @@ public function first()
703703 */
704704 public function save ($ row ): bool
705705 {
706- if (empty ( $ row) ) {
706+ if (( array ) $ row === [] ) {
707707 return true ;
708708 }
709709
@@ -729,7 +729,9 @@ public function save($row): bool
729729 */
730730 protected function shouldUpdate ($ row ): bool
731731 {
732- return ! empty ($ this ->getIdValue ($ row ));
732+ $ id = $ this ->getIdValue ($ row );
733+
734+ return ! ($ id === null || $ id === []);
733735 }
734736
735737 /**
@@ -1510,15 +1512,15 @@ public function validate($row): bool
15101512 {
15111513 $ rules = $ this ->getValidationRules ();
15121514
1513- if ($ this ->skipValidation || $ rules === [] || empty ($ row )) {
1514- return true ;
1515- }
1516-
15171515 // Validation requires array, so cast away.
15181516 if (is_object ($ row )) {
15191517 $ row = (array ) $ row ;
15201518 }
15211519
1520+ if ($ this ->skipValidation || $ rules === [] || $ row === []) {
1521+ return true ;
1522+ }
1523+
15221524 $ rules = $ this ->cleanValidationRules ? $ this ->cleanValidationRules ($ rules , $ row ) : $ rules ;
15231525
15241526 // If no data existed that needs validation
@@ -1632,7 +1634,7 @@ public function allowCallbacks(bool $val = true)
16321634 protected function trigger (string $ event , array $ eventData )
16331635 {
16341636 // Ensure it's a valid event
1635- if (! isset ($ this ->{$ event }) || empty ( $ this ->{$ event }) ) {
1637+ if (! isset ($ this ->{$ event }) || $ this ->{$ event } === [] ) {
16361638 return $ eventData ;
16371639 }
16381640
@@ -1772,7 +1774,7 @@ protected function transformDataToArray($row, string $type): array
17721774 throw new InvalidArgumentException (sprintf ('Invalid type "%s" used upon transforming data to array. ' , $ type ));
17731775 }
17741776
1775- if (! $ this ->allowEmptyInserts && empty ($ row )) {
1777+ if (! $ this ->allowEmptyInserts && ($ row === null || ( array ) $ row === [] )) {
17761778 throw DataException::forEmptyDataset ($ type );
17771779 }
17781780
0 commit comments