mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Report use of impure closures
This commit is contained in:
parent
bb1d257aff
commit
63b74276c6
@ -675,7 +675,7 @@ class TypeParser
|
||||
},
|
||||
$parse_tree->children
|
||||
);
|
||||
$pure = strpos($parse_tree->value, 'pure-') === 0;
|
||||
$pure = strpos($parse_tree->value, 'pure-') === 0 ? true : null;
|
||||
|
||||
if (in_array(strtolower($parse_tree->value), ['closure', '\closure'], true)) {
|
||||
return new TFn('Closure', $params, null, $pure);
|
||||
|
@ -43,7 +43,7 @@ trait CallableTrait
|
||||
$value = 'callable',
|
||||
array $params = null,
|
||||
Union $return_type = null,
|
||||
bool $is_pure = false
|
||||
?bool $is_pure = null
|
||||
) {
|
||||
$this->value = $value;
|
||||
$this->params = $params;
|
||||
@ -187,7 +187,8 @@ trait CallableTrait
|
||||
. $this->return_type->getId() . ($return_type_multiple ? ')' : '');
|
||||
}
|
||||
|
||||
return ($this->is_pure ? 'pure-' : '') . $this->value . $param_string . $return_type_string;
|
||||
return ($this->is_pure ? 'pure-' : ($this->is_pure === null ? '' : 'impure-'))
|
||||
. $this->value . $param_string . $return_type_string;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
|
Loading…
Reference in New Issue
Block a user