code: public static function type($arg)
      {
          $type = gettype($arg);
          if (isset(self::$typeMap[$type])) {
              return self::$typeMap[$type];
          } elseif ($type === 'array') {
              if (empty($arg)) {
                  return 'array';
              }
              reset($arg);
              return key($arg) === 0 ? 'array' : 'object';
          } elseif ($arg instanceof \stdClass) {
              return 'object';
          } elseif ($arg instanceof JmesPathableObjectInterface) {
              return 'object';
          } elseif ($arg instanceof \Closure) {
              return 'expression';
          } elseif ($arg instanceof \ArrayAccess
              && $arg instanceof \Countable
          ) {
              return count($arg) == 0 || $arg->offsetExists(0)
                  ? 'array'
                  : 'object';
          } elseif (method_exists($arg, '__toString')) {
              return 'string';
          }
  
          throw new \InvalidArgumentException(
              'Unable to determine JMESPath type from ' . get_class($arg)
          );
      }
docs: Gets the JMESPath type equivalent of a PHP variable.
  
  @param mixed $arg PHP variable
  @return string Returns the JSON data type
  @throws \InvalidArgumentException when an unknown type is given.