* 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\NoWhitespaceBeforeCommaInArrayFixer * * @extends AbstractFixerTestCase<\PhpCsFixer\Fixer\ArrayNotation\NoWhitespaceBeforeCommaInArrayFixer> * * @phpstan-import-type _AutogeneratedInputConfiguration from \PhpCsFixer\Fixer\ArrayNotation\NoWhitespaceBeforeCommaInArrayFixer */ final class NoWhitespaceBeforeCommaInArrayFixerTest extends AbstractFixerTestCase { /** * @param _AutogeneratedInputConfiguration $config * * @dataProvider provideFixCases */ public function testFix(string $expected, ?string $input = null, array $config = []): void { $this->fixer->configure($config); $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 ];', '$a , "b"=> "b", 3 => $this->foo() , "d" => 30 ];', ]; // multi line array yield [ ' true], ]; yield [ '