* 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\Fixer\FunctionNotation; use PhpCsFixer\Tests\Test\AbstractFixerTestCase; /** * @author Dariusz Rumiński * * @internal * * @covers \PhpCsFixer\Fixer\FunctionNotation\RegularCallableCallFixer * * @extends AbstractFixerTestCase<\PhpCsFixer\Fixer\FunctionNotation\RegularCallableCallFixer> */ final class RegularCallableCallFixerTest extends AbstractFixerTestCase { /** * @dataProvider provideFixCases */ public function testFix(string $expected, ?string $input = null): void { $this->doTest($expected, $input); } /** * @return iterable */ public static function provideFixCases(): iterable { yield 'call by name - list' => [ ' [ ' [ ' [ ' [ ' [ '', '', ]; yield 'unsafe repeated variable' => [ ' [ 'c)(1, 2); ($f->{c})(1, 2); ($x["y"]->c)(1, 2); ($x["y"]->{"c"})(1, 2); ', 'c, 1, 2); call_user_func($f->{c}, 1, 2); call_user_func($x["y"]->c, 1, 2); call_user_func($x["y"]->{"c"}, 1, 2); ', ]; yield 'call by anon-function' => [ ' [ 'a)(1, 2, 3, 4); ($a::$b)(1, 2); ($a[1]::$b[2][3])([&$c], array(&$d)); ', 'a, 1, 2, 3, 4); call_user_func($a::$b, 1, 2); call_user_func($a[1]::$b[2][3], [&$c], array(&$d)); ', ]; yield [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ 'doTest($expected, $input); } /** * @return iterable */ public static function provideFixPre80Cases(): iterable { yield 'call by variable' => [ 'doTest($expected, $input); } /** * @return iterable */ public static function provideFix81Cases(): iterable { yield [ '', ]; } }