* 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\Analysis\NamespaceAnalysis; use PhpCsFixer\Tokenizer\Analyzer\Analysis\NamespaceUseAnalysis; use PhpCsFixer\Tokenizer\Analyzer\NamespaceUsesAnalyzer; use PhpCsFixer\Tokenizer\Tokens; /** * @author VeeWee * * @internal * * @covers \PhpCsFixer\Tokenizer\Analyzer\NamespaceUsesAnalyzer */ final class NamespaceUsesAnalyzerTest extends TestCase { /** * @param list $expected * * @dataProvider provideUsesFromTokensCases */ public function testUsesFromTokens(string $code, array $expected, bool $allowMulti = false): void { $tokens = Tokens::fromCode($code); $analyzer = new NamespaceUsesAnalyzer(); self::assertSame( serialize($expected), serialize($analyzer->getDeclarationsFromTokens($tokens, $allowMulti)) ); } /** * @return iterable, 2?: bool}> */ public static function provideUsesFromTokensCases(): iterable { yield [' [' [' [' [' [' [' [' [' [ <<<'PHP' [ <<<'PHP' [ <<<'PHP' $expected * * @dataProvider provideGetDeclarationsInNamespaceCases */ public function testGetDeclarationsInNamespace(string $code, NamespaceAnalysis $namespace, array $expected): void { $tokens = Tokens::fromCode($code); $analyzer = new NamespaceUsesAnalyzer(); self::assertSame( serialize($expected), serialize($analyzer->getDeclarationsInNamespace($tokens, $namespace)) ); } /** * @return iterable}> */ public static function provideGetDeclarationsInNamespaceCases(): iterable { yield [ '