* 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\Tokenizer\CT; /** * @internal * * @covers \PhpCsFixer\Tokenizer\Transformer\FirstClassCallableTransformer * * @phpstan-import-type _TransformerTestExpectedTokens from AbstractTransformerTestCase */ final class FirstClassCallableTransformerTest extends AbstractTransformerTestCase { /** * @param _TransformerTestExpectedTokens $expectedTokens * * @dataProvider provideProcessCases * * @requires PHP 8.1 */ public function testProcess(array $expectedTokens, string $source): void { $this->doTest($source, $expectedTokens, [CT::T_FIRST_CLASS_CALLABLE]); } public static function provideProcessCases(): iterable { yield 'set' => [ [ 3 => CT::T_FIRST_CLASS_CALLABLE, 9 => CT::T_FIRST_CLASS_CALLABLE, 15 => CT::T_FIRST_CLASS_CALLABLE, 23 => CT::T_FIRST_CLASS_CALLABLE, 31 => CT::T_FIRST_CLASS_CALLABLE, 41 => CT::T_FIRST_CLASS_CALLABLE, 49 => CT::T_FIRST_CLASS_CALLABLE, 57 => CT::T_FIRST_CLASS_CALLABLE, 71 => CT::T_FIRST_CLASS_CALLABLE, 77 => CT::T_FIRST_CLASS_CALLABLE, 88 => CT::T_FIRST_CLASS_CALLABLE, 101 => CT::T_FIRST_CLASS_CALLABLE, ], 'method(...); $obj->$methodStr(...); ($obj->property)(...); Foo::method(...); $classStr::$methodStr(...); self::{$complex . $expression}(...); \'strlen\'(...); [$obj, \'method\'](...); [Foo::class, \'method\'](...) ?>', ]; yield 'comments and spacing' => [ [ 4 => CT::T_FIRST_CLASS_CALLABLE, 12 => CT::T_FIRST_CLASS_CALLABLE, 18 => CT::T_FIRST_CLASS_CALLABLE, 28 => CT::T_FIRST_CLASS_CALLABLE, 40 => CT::T_FIRST_CLASS_CALLABLE, ], 'method( ... ); $obj->$methodStr( /* */ ... /* */ ); ', ]; yield 'not cases' => [ [], '