mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Don’t complain about mutating call when it was inferred during reflection
This commit is contained in:
parent
d27935d109
commit
4cac8cd70f
@ -413,11 +413,18 @@ abstract class FunctionLikeAnalyzer extends SourceAnalyzer implements Statements
|
||||
$context->pure = true;
|
||||
}
|
||||
|
||||
if ($storage->mutation_free && $cased_method_id && !strpos($cased_method_id, '__construct')) {
|
||||
if ($storage->mutation_free
|
||||
&& $cased_method_id
|
||||
&& !strpos($cased_method_id, '__construct')
|
||||
&& !($storage instanceof MethodStorage && $storage->mutation_free_inferred)
|
||||
) {
|
||||
$context->mutation_free = true;
|
||||
}
|
||||
|
||||
if ($storage instanceof MethodStorage && $storage->external_mutation_free) {
|
||||
if ($storage instanceof MethodStorage
|
||||
&& $storage->external_mutation_free
|
||||
&& !$storage->mutation_free_inferred
|
||||
) {
|
||||
$context->external_mutation_free = true;
|
||||
}
|
||||
|
||||
|
@ -1807,6 +1807,7 @@ class ReflectorVisitor extends PhpParser\NodeVisitorAbstract implements PhpParse
|
||||
) {
|
||||
$storage->mutation_free = true;
|
||||
$storage->external_mutation_free = true;
|
||||
$storage->mutation_free_inferred = true;
|
||||
} elseif (strpos($stmt->name->name, 'assert') === 0) {
|
||||
$var_assertions = [];
|
||||
|
||||
|
@ -58,6 +58,11 @@ class MethodStorage extends FunctionLikeStorage
|
||||
*/
|
||||
public $external_mutation_free = false;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public $mutation_free_inferred = false;
|
||||
|
||||
/**
|
||||
* @var ?array<string, bool>
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user