original_string: protected static function throwOnInvalidArgument($arg, $type)
      {
          $args     = func_get_args();
          $arg      = array_shift($args);
          $arg_type = gettype($arg);
          
          $found = false;
          foreach($args as $type) {
              if ((in_array($type, self::$native_php_types) && $arg_type == $type) || $arg instanceof $type) {
                  $found = true;
                  break;
              }
          }
          
          if (!$found) {
              throw new Exceptions\InvalidArgumentException(
                  sprintf(
                      "Argument must be of type %s.",
                      Arrays::conjunct($args, "or")
                  )
              );
          }
          
          return true;
      }
code: protected static function throwOnInvalidArgument($arg, $type)
      {
          $args     = func_get_args();
          $arg      = array_shift($args);
          $arg_type = gettype($arg);
          
          $found = false;
          foreach($args as $type) {
              if ((in_array($type, self::$native_php_types) && $arg_type == $type) || $arg instanceof $type) {
                  $found = true;
                  break;
              }
          }
          
          if (!$found) {
              throw new Exceptions\InvalidArgumentException(
                  sprintf(
                      "Argument must be of type %s.",
                      Arrays::conjunct($args, "or")
                  )
              );
          }
          
          return true;
      }
code_tokens: protected static function throwOnInvalidArgument ( $ arg , $ type ) { $ args = func_get_args ( ) ; $ arg = array_shift ( $ args ) ; $ arg_type = gettype ( $ arg ) ; $ found = false ; foreach ( $ args as $ type ) { if ( ( in_array ( $ type , self :: $ native_php_types ) && $ arg_type == $ type ) || $ arg instanceof $ type ) { $ found = true ; break ; } } if ( ! $ found ) { throw new Exceptions \ InvalidArgumentException ( sprintf ( "Argument must be of type %s." , Arrays :: conjunct ( $ args , "or" ) ) ) ; } return true ; }
docstring: Throws an InvalidArgumentException when the argument is not one of the given types
  
  The $type argument should be one of the native PHP types returned by gettype() or the name of
  a class, in which case the argument must be an instance of that class.
  
  This method always returns true.
  
  Example:
  public function fetch($values)
  {
  $this->throwOnInvalidArgument($values, "array", ArrayableInterface::class);
  
  ... other stuff ...
  }
  ```
  
  @param string $arg  The argument
  @param string $type The first type to check
  
  @throws Exceptions\InvalidArgumentException
  @internal param $string ...   Additional types to check
  
  @return bool
docstring_tokens: Throws an InvalidArgumentException when the argument is not one of the given types