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
2375a3b2cd
commit
ca1b29b1dd
@ -675,7 +675,7 @@ class TypeParser
|
|||||||
},
|
},
|
||||||
$parse_tree->children
|
$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)) {
|
if (in_array(strtolower($parse_tree->value), ['closure', '\closure'], true)) {
|
||||||
return new TFn('Closure', $params, null, $pure);
|
return new TFn('Closure', $params, null, $pure);
|
||||||
|
@ -43,7 +43,7 @@ trait CallableTrait
|
|||||||
$value = 'callable',
|
$value = 'callable',
|
||||||
array $params = null,
|
array $params = null,
|
||||||
Union $return_type = null,
|
Union $return_type = null,
|
||||||
bool $is_pure = false
|
?bool $is_pure = null
|
||||||
) {
|
) {
|
||||||
$this->value = $value;
|
$this->value = $value;
|
||||||
$this->params = $params;
|
$this->params = $params;
|
||||||
@ -187,7 +187,8 @@ trait CallableTrait
|
|||||||
. $this->return_type->getId() . ($return_type_multiple ? ')' : '');
|
. $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()
|
public function __toString()
|
||||||
|
Loading…
Reference in New Issue
Block a user