* 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\ReferenceAnalyzer; use PhpCsFixer\Tokenizer\Tokens; /** * @author Kuba Werłos * * @covers \PhpCsFixer\Tokenizer\Analyzer\ReferenceAnalyzer * * @internal */ final class ReferenceAnalyzerTest extends TestCase { public function testNonAmpersand(): void { $analyzer = new ReferenceAnalyzer(); self::assertFalse($analyzer->isReference(Tokens::fromCode('isReference($tokens, 5)); self::assertFalse($analyzer->isReference($tokens, 12)); } /** * @dataProvider provideReferenceCases */ public function testReference(string $code): void { $this->doTestCode(true, $code); } /** * @return iterable */ public static function provideReferenceCases(): iterable { yield ['value; } }']; yield [' &$foo) {}']; yield ['doTestCode(false, $code); } /** * @return iterable */ public static function provideNonReferenceCases(): iterable { yield ['baz & $qux);']; yield ['doTestCode(false, $code); } /** * @return iterable */ public static function provideNonReferencePre84Cases(): iterable { yield [' $token) { if ('&' === $token->getContent()) { self::assertSame($expected, $analyzer->isReference($tokens, $index)); } } } }