1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Fix #3215 - suppress PossiblyUndefinedMethod in synthetic call

This commit is contained in:
Brown 2020-04-24 00:11:32 -04:00
parent e9666372d0
commit e1c6fcc707
2 changed files with 16 additions and 0 deletions

View File

@ -735,6 +735,10 @@ class ForeachAnalyzer
$statements_analyzer->addSuppressedIssues(['PossiblyInvalidMethodCall']);
}
if (!in_array('PossiblyUndefinedMethod', $suppressed_issues, true)) {
$statements_analyzer->addSuppressedIssues(['PossiblyUndefinedMethod']);
}
\Psalm\Internal\Analyzer\Statements\Expression\Call\MethodCallAnalyzer::analyze(
$statements_analyzer,
$fake_method_call,
@ -745,6 +749,10 @@ class ForeachAnalyzer
$statements_analyzer->removeSuppressedIssues(['PossiblyInvalidMethodCall']);
}
if (!in_array('PossiblyUndefinedMethod', $suppressed_issues, true)) {
$statements_analyzer->removeSuppressedIssues(['PossiblyUndefinedMethod']);
}
$iterator_class_type = $statements_analyzer->node_data->getType($fake_method_call) ?: null;
$statements_analyzer->node_data = $old_data_provider;

View File

@ -223,6 +223,14 @@ class GeneratorTest extends TestCase
return 5;
}'
],
'iteratorUnion' => [
'<?php
/** @return Iterator|IteratorAggregate */
function getIteratorOrAggregate() {
yield 2;
}
echo json_encode(iterator_to_array(getIteratorOrAggregate()));'
],
];
}