Go\Proxy\AbstractProxy::getParameterCode PHP Method

getParameterCode() protected method

Return string representation of parameter
protected getParameterCode ( ReflectionParameter $parameter ) : string
$parameter ReflectionParameter Reflection parameter
return string
    protected function getParameterCode(ReflectionParameter $parameter)
    {
        $type = '';
        if (PHP_VERSION_ID >= 50700) {
            $reflectionType = $parameter->getType();
            if ($reflectionType) {
                $nsPrefix = $reflectionType->isBuiltin() ? '' : '\\';
                $type = $nsPrefix . (string) $reflectionType;
            }
        } else {
            if ($parameter->isArray()) {
                $type = 'array';
            } elseif ($parameter->isCallable()) {
                $type = 'callable';
            } elseif ($parameter->getClass()) {
                $type = '\\' . $parameter->getClass()->name;
            }
        }
        $defaultValue = null;
        $isDefaultValueAvailable = $parameter->isDefaultValueAvailable();
        if ($isDefaultValueAvailable) {
            $defaultValue = var_export($parameter->getDefaultValue(), true);
        } elseif ($parameter->isOptional() && !$parameter->isVariadic()) {
            $defaultValue = 'null';
        }
        $code = ($type ? "{$type} " : '') . ($parameter->isPassedByReference() ? '&' : '') . ($parameter->isVariadic() ? '...' : '') . '$' . $parameter->name . ($defaultValue !== null ? " = " . $defaultValue : '');
        return $code;
    }