|
@@ -402,22 +402,12 @@ $expressionResult = match ($condition) {
|
|
|
$this->expectException(\InvalidArgumentException::class);
|
|
|
$this->expectExceptionMessage(sprintf('Unexpected type "%d".', T_IF));
|
|
|
|
|
|
- foreach (ControlCaseStructuresAnalyzer::findControlStructures($tokens, [T_IF]) as $analysis) {
|
|
|
- echo 1; // we need to use `foreach` here to prevent PHP removing the call as optimization
|
|
|
- }
|
|
|
+ // we use `iterator_to_array` to ensure generator is consumed and it has possibility to raise exception
|
|
|
+ iterator_to_array(ControlCaseStructuresAnalyzer::findControlStructures($tokens, [T_IF]));
|
|
|
}
|
|
|
|
|
|
private static function assertAnalysis(AbstractControlCaseStructuresAnalysis $expectedAnalysis, AbstractControlCaseStructuresAnalysis $analysis): void
|
|
|
{
|
|
|
- $serializeExpected = serialize($expectedAnalysis);
|
|
|
- $serializeActual = serialize($analysis);
|
|
|
-
|
|
|
- if ($serializeExpected === $serializeActual) {
|
|
|
- self::assertTrue(true);
|
|
|
-
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
self::assertSame($expectedAnalysis->getIndex(), $analysis->getIndex(), 'index');
|
|
|
self::assertSame($expectedAnalysis->getOpenIndex(), $analysis->getOpenIndex(), 'open index');
|
|
|
self::assertSame($expectedAnalysis->getCloseIndex(), $analysis->getCloseIndex(), 'close index');
|
|
@@ -447,6 +437,9 @@ $expressionResult = match ($condition) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- self::assertSame($serializeExpected, $serializeActual);
|
|
|
+ self::assertSame(
|
|
|
+ serialize($expectedAnalysis),
|
|
|
+ serialize($analysis)
|
|
|
+ );
|
|
|
}
|
|
|
}
|