Skip to content
Permalink
Browse files

Display function signature on multiple lines when it has parameters (#…

  • Loading branch information...
iluuu1994 authored and muglug committed Jun 22, 2019
1 parent aa6677a commit caca3e52c91f521948881e7da8e8527157d116cd
Showing with 14 additions and 4 deletions.
  1. +4 −4 src/Psalm/Storage/FunctionLikeStorage.php
  2. +10 −0 tests/LanguageServer/SymbolLookupTest.php
@@ -171,15 +171,15 @@ class FunctionLikeStorage
public function __toString()
{
$symbol_text = 'function ' . $this->cased_name . '(' . implode(
', ',
$symbol_text = 'function ' . $this->cased_name . '(' . (!empty($this->params) ? PHP_EOL : '') . implode(
',' . PHP_EOL,
array_map(
function (FunctionLikeParameter $param) : string {
return ($param->type ?: 'mixed') . ' $' . $param->name;
return ' ' . ($param->type ?: 'mixed') . ' $' . $param->name;
},
$this->params
)
) . ') : ' . ($this->return_type ?: 'mixed');
) . (!empty($this->params) ? PHP_EOL : '') . ') : ' . ($this->return_type ?: 'mixed');
if (!$this instanceof MethodStorage) {
return $symbol_text;
@@ -65,6 +65,14 @@ public function foo() : void {
function bar() : int {
return 5;
}
function baz(int $a) : int {
return $a;
}
function qux(int $a, int $b) : int {
return $a + $b;
}'
);
@@ -78,6 +86,8 @@ function bar() : int {
$this->assertSame('<?php protected int|null $a', $codebase->getSymbolInformation('somefile.php', 'B\A::$a'));
$this->assertSame('<?php function B\bar() : int', $codebase->getSymbolInformation('somefile.php', 'B\bar()'));
$this->assertSame('<?php BANANA', $codebase->getSymbolInformation('somefile.php', 'B\A::BANANA'));
$this->assertSame("<?php function B\baz(\n int \$a\n) : int", $codebase->getSymbolInformation('somefile.php', 'B\baz()'));
$this->assertSame("<?php function B\qux(\n int \$a,\n int \$b\n) : int", $codebase->getSymbolInformation('somefile.php', 'B\qux()'));
}
/**

0 comments on commit caca3e5

Please sign in to comment.
You can’t perform that action at this time.