Skip to content
Permalink
Browse files

Don’t complain about mutating call when it was inferred during reflec…

…tion
  • Loading branch information...
muglug committed Sep 8, 2019
1 parent d27935d commit 4cac8cd70fe987a04db118f4206903e932ab16ac
@@ -413,11 +413,18 @@ function (FunctionLikeParameter $p) {
$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 @@ private function registerFunctionLike(PhpParser\Node\FunctionLike $stmt, $fake_m
) {
$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>
*/

0 comments on commit 4cac8cd

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