Skip to content
Permalink
Browse files

Fix #2456 - ignore UnusedFunctionCall when function asserts

  • Loading branch information
muglug committed Dec 11, 2019
1 parent af52590 commit 4b715cdbffea19a7eab6f72482027d2dd358aab2
@@ -712,7 +712,10 @@ public static function analyze(
$context->removeAllObjectVars();
}
} elseif ($function_id
&& (($function_storage && $function_storage->pure && $must_use)
&& (($function_storage
&& $function_storage->pure
&& !$function_storage->assertions
&& $must_use)
|| ($callmap_function_pure === true && $must_use))
&& $codebase->find_unused_variables
&& !$context->inside_conditional
@@ -620,6 +620,28 @@ function foo(array $arr) : array {
array_map(function($i) { echo $i;}, $a);'
],
'usedAssertFunction' => [
'<?php
/**
* @param mixed $v
* @psalm-pure
* @psalm-assert int $v
*/
function assertInt($v):void {
if (!is_int($v)) {
throw new \RuntimeException();
}
}
/**
* @psalm-pure
* @param mixed $i
*/
function takesMixed($i) : int {
assertInt($i);
return $i;
}'
],
];
}

0 comments on commit 4b715cd

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