1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Added more descriptive type for callables

Ref #1408
This commit is contained in:
Matthew Brown 2019-03-01 09:06:37 -05:00
parent 317f790bde
commit 4cc93644e5
3 changed files with 18 additions and 2 deletions

View File

@ -425,8 +425,8 @@ class ExpressionAnalyzer
$statements_analyzer->getCodebase(),
$atomic_type,
new TString(),
true,
false,
true,
$has_scalar_match
)
&& !$has_scalar_match

View File

@ -109,6 +109,13 @@ class FunctionLikeParameter
. ($this->is_optional ? '=' : '');
}
public function getId()
{
return ($this->type ? $this->type->getId() : 'mixed')
. ($this->is_variadic ? '...' : '')
. ($this->is_optional ? '=' : '');
}
public function __clone()
{
if ($this->type) {

View File

@ -141,7 +141,16 @@ trait CallableTrait
$return_type_string = '';
if ($this->params !== null) {
$param_string = '(' . implode(', ', $this->params) . ')';
$param_string .= '(';
foreach ($this->params as $i => $param) {
if ($i) {
$param_string .= ', ';
}
$param_string .= $param->getId();
}
$param_string .= ')';
}
if ($this->return_type !== null) {