Skip to content
Permalink
Browse files

The current method is used

Fixes #2540
  • Loading branch information
muglug committed Jan 1, 2020
1 parent 608ca41 commit 25e7039f0216f7b37710079ffa63adcb3bbf76de
Showing with 18 additions and 0 deletions.
  1. +4 −0 src/Psalm/Internal/Analyzer/Statements/Block/ForeachAnalyzer.php
  2. +14 −0 tests/UnusedCodeTest.php
@@ -860,12 +860,16 @@ public static function handleIterable(
$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']);
}
@@ -669,6 +669,20 @@ public function unserialize($_serialized) : void {}
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) {}'
],
];
}

0 comments on commit 25e7039

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