* 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; /** * @internal * * @covers \PhpCsFixer\Fixer\FunctionNotation\NoTrailingCommaInSinglelineFunctionCallFixer * * @extends AbstractFixerTestCase<\PhpCsFixer\Fixer\FunctionNotation\NoTrailingCommaInSinglelineFunctionCallFixer> */ final class NoTrailingCommaInSinglelineFunctionCallFixerTest 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 'simple var' => [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ 'abc($a);', 'abc($a,);', ]; yield 'nested call' => [ 'abc($a,foo(1));', 'abc($a,foo(1,));', ]; yield 'wrapped' => [ 'getOutput(1);', 'getOutput(1,);', ]; yield 'dynamic function and method calls' => [ '$a(1); $c("");', '$a(1,); $c("",);', ]; yield 'static function call' => [ 'bar); $b = isset($foo->bar); list($a,$b) = $a; ', 'bar,); $b = isset($foo->bar,); list($a,$b,) = $a; ', ]; yield 'unset' => [ ' [ ' [ ' static function(int $a): void{ echo $a;}, "d" => [ [2 => static function(int $a): void{ echo $a;}] ] ]; $a["e"](1); $a["d"][0][2](1); $z = new class { public static function b(int $a): void {echo $a; }}; $z::b(1); ${$e}(1); $$e(2); $f(0)(1); $g["e"](1); // foo', ' static function(int $a): void{ echo $a;}, "d" => [ [2 => static function(int $a): void{ echo $a;}] ] ]; $a["e"](1,); $a["d"][0][2](1,); $z = new class { public static function b(int $a): void {echo $a; }}; $z::b(1,); ${$e}(1,); $$e(2,); $f(0,)(1,); $g["e"](1,); // foo', ]; yield 'do not fix' => [ 'doTest($expected, $input); } /** * @return iterable */ public static function provideFix80Cases(): iterable { yield [ 'doTest($expected, $input); } /** * @return iterable */ public static function provideFix81Cases(): iterable { yield [ 'method(1); strlen(...);', 'method(1,); strlen(...);', ]; } }