From 6394e2d548891d29e9bbb7b6678af4a5106047b9 Mon Sep 17 00:00:00 2001 From: Andrew Nagy Date: Mon, 14 Feb 2022 22:18:01 +0000 Subject: [PATCH] fix new lines in funcs with no params --- src/Psalm/Storage/FunctionLikeStorage.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Psalm/Storage/FunctionLikeStorage.php b/src/Psalm/Storage/FunctionLikeStorage.php index 4ca0cdada..5f6acd2ca 100644 --- a/src/Psalm/Storage/FunctionLikeStorage.php +++ b/src/Psalm/Storage/FunctionLikeStorage.php @@ -10,6 +10,7 @@ use Psalm\Type\Union; use function array_column; use function array_fill_keys; use function array_map; +use function count; use function implode; abstract class FunctionLikeStorage @@ -239,15 +240,18 @@ abstract class FunctionLikeStorage */ public function getHoverMarkdown(): string { - $symbol_text = 'function ' . $this->cased_name . '(' . "\n" . implode( - ',' . "\n", + $params = count($this->params) > 0 ? "\n" . implode( + ",\n", array_map( function (FunctionLikeParameter $param): string { - return ' ' . ($param->type ?: 'mixed') . ' $' . $param->name; + $realType = $param->type ?: 'mixed'; + return " {$realType} \${$param->name}"; }, $this->params ) - ) . "\n" . ') : ' . ($this->return_type ?: 'mixed'); + ) . "\n" : ''; + $return_type = $this->return_type ?: 'mixed'; + $symbol_text = "function {$this->cased_name}({$params}): {$return_type}"; if (!$this instanceof MethodStorage) { return $symbol_text;