protected function renderReturnType(Method $method) { $type = $method->getReturnType(); return $type ? sprintf(': %s', $type) : ''; }
/** * Gets the declaration code, as a string, for the passed method. * * @param Method $method * @param array $namedParameters * @return string */ private function getMethodDeclaration(Method $method, array $namedParameters) { $declaration = 'public'; $declaration .= $method->isStatic() ? ' static' : ''; $declaration .= ' function ' . $method->getName() . '('; foreach ($method->getParameters() as $index => $parameter) { $declaration .= $parameter->getTypeHintAsString() . ' '; $name = isset($namedParameters[$index]) ? $namedParameters[$index] : $parameter->getName(); $declaration .= '$' . $name; $declaration .= ','; } $declaration = rtrim($declaration, ','); $declaration .= ') '; $returnType = $method->getReturnType(); if (!empty($returnType)) { $declaration .= ': ' . $returnType; } return $declaration; }