public static function mergeObj($objA, $objB){
      if(get_class($objA) != get_class($objB)) throw new \Exception("Can't assign object value to a different type.");
      $property_fields = get_object_vars($objA);
      foreach ($property_fields as $propertyName => $val){
          $BsValue = $objB->$propertyName;
          if(isset($BsValue)){
               $objA->$propertyName = $BsValue;
          }
      }
      return $objA;
  }
public static function mergeObj($objA, $objB){
      if(get_class($objA) != get_class($objB)) throw new \Exception("Can't assign object value to a different type.");
      $property_fields = get_object_vars($objA);
      foreach ($property_fields as $propertyName => $val){
          $BsValue = $objB->$propertyName;
          if(isset($BsValue)){
               $objA->$propertyName = $BsValue;
          }
      }
      return $objA;
  }
public static function mergeObj ( $ objA , $ objB ) { if ( get_class ( $ objA ) != get_class ( $ objB ) ) throw new \ Exception ( "Can't assign object value to a different type." ) ; $ property_fields = get_object_vars ( $ objA ) ; foreach ( $ property_fields as $ propertyName => $ val ) { $ BsValue = $ objB -> $ propertyName ; if ( isset ( $ BsValue ) ) { $ objA -> $ propertyName = $ BsValue ; } } return $ objA ; }
Override the content from Object B to Object A
Don't use array_merge here. As the NUll Value will be overriden as well
Remove the !empty check. For integer or string that is 0, it needs to be passed and set.
Override the content from Object B to Object A Don t use array_merge here . As the NUll Value will be overriden as well Remove the !empty check . For integer or string that is 0 it needs to be passed and set .