code: private function mergeRecursive($existingValue, $newValue, string $path)
      {
          $existingType = gettype($existingValue);
          $newType = gettype($newValue);
  
          if ($existingType !== $newType) {
              throw new \LogicException(
                  sprintf('Type conversion from "%s" to "%s" at path "%s"', $existingType, $newType, $path)
              );
          }
  
          if ('array' !== $newType) {
              return $newValue;
          }
  
          foreach ($newValue as $key => $newSubValue) {
              if (!is_string($key)) {
                  $existingValue[] = $newSubValue;
  
                  continue;
              }
  
              if (isset($existingValue[$key])) {
                  $subPath = $path.'.'.$key;
  
                  $existingValue[$key] = $this->mergeRecursive($existingValue[$key], $newSubValue, $subPath);
              } else {
                  $existingValue[$key] = $newSubValue;
              }
          }
  
          return $existingValue;
      }
docs: @param array|string|float|int|bool $existingValue
  @param array|string|float|int|bool $newValue
  @param string                      $path
  
  @return array|string|float|int|bool