Skip to content
Permalink
Browse files

Handle iterators better

  • Loading branch information
muglug committed Jan 2, 2020
1 parent 314db95 commit ca1e65b29bbcb4773d1f3d603086913397361f39
@@ -860,6 +860,8 @@ public static function handleIterable(
$statements_analyzer->addSuppressedIssues(['PossiblyInvalidMethodCall']);
}

$was_inside_call = $context->inside_call;

$context->inside_call = true;

\Psalm\Internal\Analyzer\Statements\Expression\Call\MethodCallAnalyzer::analyze(
@@ -868,7 +870,7 @@ public static function handleIterable(
$context
);

$context->inside_call = false;
$context->inside_call = $was_inside_call;

if (!in_array('PossiblyInvalidMethodCall', $suppressed_issues, true)) {
$statements_analyzer->removeSuppressedIssues(['PossiblyInvalidMethodCall']);
@@ -86,16 +86,12 @@ public static function analyze(
$context->inside_call = true;

if (ExpressionAnalyzer::analyze($statements_analyzer, $stmt->name, $context) === false) {
if (!$was_in_call) {
$context->inside_call = false;
}
$context->inside_call = $was_in_call;

return;
}

if (!$was_in_call) {
$context->inside_call = false;
}
$context->inside_call = $was_in_call;

if ($stmt_name_type = $statements_analyzer->node_data->getType($stmt->name)) {
if ($stmt_name_type->isNull()) {
@@ -915,9 +911,10 @@ function (Assertion $assertion) use ($generic_params) : Assertion {

if ($fq_const_name !== null) {
$second_arg = $stmt->args[1];
$was_in_call = $context->inside_call;
$context->inside_call = true;
ExpressionAnalyzer::analyze($statements_analyzer, $second_arg->value, $context);
$context->inside_call = false;
$context->inside_call = $was_in_call;

$statements_analyzer->setConstType(
$fq_const_name,
@@ -78,19 +78,15 @@ public static function analyze(
return false;
}

if (!$was_inside_call) {
$context->inside_call = false;
}
$context->inside_call = $was_inside_call;

if (!$stmt->name instanceof PhpParser\Node\Identifier) {
$was_inside_call = $context->inside_call;
$context->inside_call = true;
if (ExpressionAnalyzer::analyze($statements_analyzer, $stmt->name, $context) === false) {
return false;
}
if (!$was_inside_call) {
$context->inside_call = false;
}
$context->inside_call = $was_inside_call;
}

if ($stmt->var instanceof PhpParser\Node\Expr\Variable) {

0 comments on commit ca1e65b

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