* 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\Transformer; use PhpCsFixer\Tests\Test\AbstractTransformerTestCase; use PhpCsFixer\Tests\Test\Assert\AssertTokensTrait; use PhpCsFixer\Tokenizer\CT; use PhpCsFixer\Tokenizer\Token; use PhpCsFixer\Tokenizer\Tokens; /** * @internal * * @requires PHP 8.0 * * @covers \PhpCsFixer\Tokenizer\Transformer\NameQualifiedTransformer */ final class NameQualifiedTransformerTest extends AbstractTransformerTestCase { use AssertTokensTrait; /** * @param list $expected * @param null|list $input * * @dataProvider provideProcessCases * * @requires PHP 8.0 */ public function testProcess(array $expected, ?array $input = null): void { $expectedTokens = Tokens::fromArray($expected); $tokens = null === $input ? Tokens::fromArray($expected) : Tokens::fromArray($input); $tokenCount = \count($tokens); for ($i = 0; $i < $tokenCount; ++$i) { $this->transformer->process($tokens, $tokens[$i], $i); } self::assertTokens($expectedTokens, $tokens); if (null === $input) { self::assertFalse($tokens->isChanged()); } else { self::testProcess($expected); self::assertTrue($tokens->isChanged()); } } public static function provideProcessCases(): iterable { yield 'string' => [ [ new Token([T_OPEN_TAG, " [ [ new Token([T_OPEN_TAG, " [ [ new Token([T_OPEN_TAG, " [ [ new Token([T_OPEN_TAG, " [ [ new Token([T_OPEN_TAG, " [ [ new Token([T_OPEN_TAG, " $expected * * @dataProvider providePriorityCases */ public function testPriority(array $expected, string $source): void { self::assertTokens(Tokens::fromArray($expected), Tokens::fromCode($source)); } public static function providePriorityCases(): iterable { yield [ [ new Token([T_OPEN_TAG, '