* 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 */ final class NoWhitespaceBeforeCommaInArrayFixerTest extends AbstractFixerTestCase { /** * @param array $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 { return [ // old style array [ ' 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 [ ' new class implements Foo , Bar { const FOO = ["x", "y"]; }, $y];', ' new class implements Foo , Bar { const FOO = ["x" , "y"]; }, $y];', ], // associative array (old) [ ' $a, "b" => "b",3=>$this->foo(), "d" => 30);', ' $a , "b" => "b",3=>$this->foo() , "d" => 30);', ], // associative array (short) [ ' $a, "b"=>"b",3 => $this->foo(), "d" =>30 ];', ' $a , "b"=>"b",3 => $this->foo() , "d" =>30 ];', ], // nested arrays [ ' $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 [ '$a, "b"=> "b", 3 => $this->foo(), "d" => 30 ];', '$a , "b"=> "b", 3 => $this->foo() , "d" => 30 ];', ], // multi line array [ ' true], ], [ '