Eloquent\Phony\Reflection\HhvmFunctionSignatureInspector::signature PHP Метод

signature() публичный Метод

Get the function signature of the supplied function.
public signature ( ReflectionFunctionAbstract $function ) : array>\array
$function ReflectionFunctionAbstract The function.
Результат array>\array
    public function signature(ReflectionFunctionAbstract $function)
    {
        $signature = array();
        foreach ($function->getParameters() as $parameter) {
            $name = $parameter->getName();
            if ($typehint = $parameter->getTypehintText()) {
                switch ($typehint) {
                    case 'array':
                    case 'callable':
                        $typehint .= ' ';
                        break;
                    case 'iterable':
                        if ($this->isIterableTypeHintSupported) {
                            $typehint .= ' ';
                            break;
                        }
                        // fall through to default behavior
                    // fall through to default behavior
                    default:
                        $typehint = '\\' . $typehint . ' ';
                }
            }
            $byReference = $parameter->isPassedByReference() ? '&' : '';
            if ($this->isVariadicParameterSupported && $parameter->isVariadic()) {
                $variadic = '...';
            } else {
                $variadic = '';
            }
            $defaultValue = $parameter->getDefaultValueText();
            if ('' !== $defaultValue) {
                if ('NULL' === $defaultValue) {
                    $defaultValue = ' = null';
                } elseif ('PHP_INT_MAX' === $defaultValue || 'PHP_INT_MIN' === $defaultValue) {
                    $typehint = '';
                    $defaultValue = ' = ' . $defaultValue;
                } else {
                    $defaultValue = eval('return ' . $defaultValue . ';');
                    if ('\\HH\\float ' === $typehint) {
                        $defaultValue = sprintf(' = %f', $defaultValue);
                    } else {
                        $defaultValue = ' = ' . var_export($defaultValue, true);
                    }
                }
            }
            $signature[$name] = array($typehint, $byReference, $variadic, $defaultValue);
        }
        return $signature;
    }
HhvmFunctionSignatureInspector