* 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 Jared Henderson * * @internal * * @covers \PhpCsFixer\Fixer\ArrayNotation\TrimArraySpacesFixer * * @extends AbstractFixerTestCase<\PhpCsFixer\Fixer\ArrayNotation\TrimArraySpacesFixer> */ final class TrimArraySpacesFixerTest 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 [ ' "bar");', ' "bar" );', ]; yield [ ' "bar"];', ' "bar" ];', ]; yield [ 'method(), Foo::doSomething());', 'method(), Foo::doSomething() );', ]; yield [ 'method(), Foo::doSomething()];', 'method(), Foo::doSomething() ];', ]; yield [ "method( \$a,\$b, \$c,\t\t \$d ), Foo::doSomething()];", "method( \$a,\$b, \$c,\t\t \$d ), Foo::doSomething() ];", ]; yield [ "method( \$a,\$b, \$c,\t\t \$d ), \$bar -> doSomething( ['baz']));", "method( \$a,\$b, \$c,\t\t \$d ), \$bar -> doSomething( [ 'baz']) );", ]; yield [ ' 'bar', 'baz' => \$x[ 4], 'hash' => array(1,2,3)));", " 'bar', 'baz' => \$x[ 4], 'hash' => array(1,2,3 )) );", ]; // crazy nested garbage pile #2 yield [ ' 2, // comment ); ', ]; yield [ ' 1, "b" => 2); }', ' 1, "b" => 2 ); }', ]; yield [ ' 1, "b" => 2]; }', ' 1, "b" => 2 ]; }', ]; yield 'array destructuring' => [ " \$url] = \$data;", " \$url ] = \$data;", ]; yield 'array destructuring with comments' => [ " \$url /* bar */] = \$data;", " \$url /* bar */ ] = \$data;", ]; yield 'multiline array destructuring' => [ ' $url, \'token\' => $token, ] = $data; ', ]; } }