* 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\ArrayNotation; use PhpCsFixer\Tests\Test\AbstractFixerTestCase; /** * @author Adam Marczuk * * @internal * * @covers \PhpCsFixer\Fixer\ArrayNotation\WhitespaceAfterCommaInArrayFixer * * @extends AbstractFixerTestCase<\PhpCsFixer\Fixer\ArrayNotation\WhitespaceAfterCommaInArrayFixer> * * @phpstan-import-type _AutogeneratedInputConfiguration from \PhpCsFixer\Fixer\ArrayNotation\WhitespaceAfterCommaInArrayFixer */ final class WhitespaceAfterCommaInArrayFixerTest extends AbstractFixerTestCase { /** * @dataProvider provideFixCases * * @param _AutogeneratedInputConfiguration $configuration */ public function testFix(string $expected, ?string $input = null, ?array $configuration = null): void { if (null !== $configuration) { $this->fixer->configure($configuration); } $this->doTest($expected, $input); } public static function provideFixCases(): iterable { // old style array yield [ ' function( $x ,$y) { return [$x , $y]; }, $y ];', ' function( $x ,$y) { return [$x ,$y]; },$y ];', ]; // don't change anonymous class implements list but change array inside yield [ ' new class implements Foo ,Bar { const FOO = ["x", "y"]; }, $y ];', ' new class implements Foo ,Bar { const FOO = ["x","y"]; },$y ];', ]; // associative array (old) yield [ ' $a , "b" => "b", 3=>$this->foo(), "d" => 30 );', ' $a , "b" => "b",3=>$this->foo(), "d" => 30 );', ]; // associative array (short) yield [ ' $a , "b"=>"b", 3 => $this->foo(), "d" =>30];', ' $a , "b"=>"b",3 => $this->foo(), "d" =>30];', ]; // nested arrays yield [ ' $a, "b" => "b", 3=> [5, 6, 7] , "d" => array(1, 2, 3 , 4)];', ' $a, "b" => "b",3=> [5,6, 7] , "d" => array(1, 2,3 ,4)];', ]; // multi line array yield [ '$a, "b"=> "b", 3 => $this->foo(), "d" => 30];', ]; // multi line array yield [ ' true], ]; yield [ ' true], ]; yield [ ' true], ]; yield [ ' true], ]; } }