* Dariusz RumiƄski * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace PhpCsFixer\Tests\Tokenizer\Analyzer; use PhpCsFixer\Tests\TestCase; use PhpCsFixer\Tokenizer\Analyzer\GotoLabelAnalyzer; use PhpCsFixer\Tokenizer\Tokens; /** * @internal * * @covers \PhpCsFixer\Tokenizer\Analyzer\GotoLabelAnalyzer */ final class GotoLabelAnalyzerTest extends TestCase { /** * @param list $expectedTrue * * @dataProvider provideGotoLabelCases */ public function testGotoLabel(string $source, array $expectedTrue): void { $tokens = Tokens::fromCode($source); $analyzer = new GotoLabelAnalyzer(); foreach ($tokens as $index => $isClassy) { self::assertSame( \in_array($index, $expectedTrue, true), $analyzer->belongsToGoToLabel($tokens, $index) ); } } /** * @return iterable}> */ public static function provideGotoLabelCases(): iterable { yield 'no candidates' => [ 'fixer->configure($legacy ? [$statement] : [1]); ', [], ]; yield 'after php tag' => [ ' [ ' [ ' [ ' [ ' $expectedTrue * * @dataProvider provideGotoLabel80Cases * * @requires PHP 8.0 */ public function testGotoLabel80(string $source, array $expectedTrue): void { $this->testGotoLabel($source, $expectedTrue); } /** * @return iterable}> */ public static function provideGotoLabel80Cases(): iterable { yield [ '