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

The current method is used

Fixes #2540
This commit is contained in:
Matthew Brown 2020-01-01 18:33:12 -05:00
parent 608ca417bc
commit 25e7039f02
2 changed files with 18 additions and 0 deletions

View File

@ -860,12 +860,16 @@ class ForeachAnalyzer
$statements_analyzer->addSuppressedIssues(['PossiblyInvalidMethodCall']);
}
$context->inside_call = true;
\Psalm\Internal\Analyzer\Statements\Expression\Call\MethodCallAnalyzer::analyze(
$statements_analyzer,
$fake_method_call,
$context
);
$context->inside_call = false;
if (!in_array('PossiblyInvalidMethodCall', $suppressed_issues, true)) {
$statements_analyzer->removeSuppressedIssues(['PossiblyInvalidMethodCall']);
}

View File

@ -669,6 +669,20 @@ class UnusedCodeTest extends TestCase
new Foo();'
],
'useIteratorMethodsWhenCallingForeach' => [
'<?php
/** @psalm-suppress UnimplementedInterfaceMethod */
class IterableResult implements \Iterator {
public function current() {
return $this->current;
}
}
$items = new IterableResult();
/** @psalm-suppress MixedAssignment */
foreach ($items as $_item) {}'
],
];
}