/** * Determine the fully-qualified name of a type-hint for the given param without actually loading typehinted classes. * * @param \ReflectionParameter $param * @return string Hinted typename or NULL when no type-hint is present. */ protected function getParamType(\ReflectionParameter $param) { if ($param->isArray()) { return 'array'; } if ($param->isCallable()) { return 'callable'; } $m = NULL; if (defined('HHVM_VERSION')) { // @codeCoverageIgnoreStart $type = $param->getTypehintText(); if ('' === trim($type)) { $type = NULL; } // @codeCoverageIgnoreEnd } elseif (preg_match("'\\[\\s*<[^>]+>\\s+([a-z_][a-z_0-9]*(?:\\s*\\\\\\s*[a-z_][a-z_0-9]*)*)'i", (string) $param, $m)) { $type = preg_replace("'\\s+'", '', $m[1]); } else { $type = NULL; } if ($type !== NULL) { switch (strtolower($type)) { case 'self': $ref = $param->getDeclaringFunction(); if ($ref instanceof \ReflectionMethod) { return $ref->getDeclaringClass()->name; } throw new \RuntimeException(sprintf('Unable to resolve "self" in parameter "%s" of function %s', $param->name, $ref->name)); case 'boolean': return 'bool'; case 'integer': return 'int'; } return $type; } return NULL; }