* 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\Operator; use PhpCsFixer\Fixer\Operator\BinaryOperatorSpacesFixer; use PhpCsFixer\Tests\Test\AbstractFixerTestCase; /** * @author Dariusz Rumiński * @author Gregor Harlan * @author Carlos Cirello * @author SpacePossum * * @internal * * @covers \PhpCsFixer\Fixer\Operator\BinaryOperatorSpacesFixer */ final class BinaryOperatorSpacesFixerTest extends AbstractFixerTestCase { /** * @param string $expected * @param null|string $input * * @dataProvider provideWithTabsCases */ public function testWithTabs($expected, $input = null, array $configuration = []) { $this->fixer->configure($configuration); $this->doTest($expected, $input); } public function provideWithTabsCases() { return [ [ " ['=' => BinaryOperatorSpacesFixer::ALIGN_SINGLE_SPACE_MINIMAL]], ], [ " ['=' => BinaryOperatorSpacesFixer::ALIGN]], ], ]; } /** * @param string $expected * @param null|string $input * * @dataProvider provideTestCases */ public function testConfigured($expected, $input = null, array $configuration = []) { $this->fixer->configure($configuration); $this->doTest($expected, $input); } public function provideTestCases() { return [ [ 'a = $this->b = 1 ;', 'a = $this->b = 1 ;', ['operators' => ['=' => BinaryOperatorSpacesFixer::ALIGN_SINGLE_SPACE_MINIMAL]], ], [ 'newName = $this->path = $this->randomName = $this->remoteFile = $this->tmpContent = null;', 'newName = $this->path = $this->randomName = $this->remoteFile = $this->tmpContent = null;', ['operators' => ['=' => BinaryOperatorSpacesFixer::ALIGN_SINGLE_SPACE_MINIMAL]], ], [ ' ['=' => BinaryOperatorSpacesFixer::SINGLE_SPACE]], ], [ ' 2, 2 => 3, ] as $k => $v) { $var[] = [$i => $bar]; }', ' 2, 2 =>3, ] as $k => $v) { $var[] = [$i => $bar]; }', ['operators' => ['=>' => BinaryOperatorSpacesFixer::ALIGN_SINGLE_SPACE_MINIMAL]], ], [ ' 2, 4 => 5, 5 => 2, 6 => 5, 7 => 8, 9 => 10, 11 => 1222, );', '2, 4=>5, 5=>2, 6 => 5, 7=>8, 9=>10, 11=>1222, );', ['operators' => ['=>' => BinaryOperatorSpacesFixer::ALIGN_SINGLE_SPACE_MINIMAL]], ], [ ' 2, 4 => 5);', '2, 4 => 5);', ['operators' => ['=>' => BinaryOperatorSpacesFixer::ALIGN_SINGLE_SPACE_MINIMAL]], ], [ ' 2, 4 => 5 && $b, 5 => 5 && $b, 6 => 5 && $b, 7 => 5 && $b);', ' 2, 4 => 5&&$b, 5 => 5 && $b, 6 => 5&& $b, 7 => 5 &&$b);', ['operators' => ['&&' => BinaryOperatorSpacesFixer::ALIGN_SINGLE_SPACE_MINIMAL]], ], [ ' "foo"]; [2 => "foo"]; [3 => "foo"]; ', ' "foo"]; [2 =>"foo"]; [3=>"foo"]; ', ['operators' => ['=>' => BinaryOperatorSpacesFixer::ALIGN_SINGLE_SPACE]], ], [ ' "foo"]; [2 => "foo"]; [3 => "foo"]; ', ' "foo"]; [2 =>"foo"]; [3=>"foo"]; ', ['operators' => ['=>' => BinaryOperatorSpacesFixer::ALIGN_SINGLE_SPACE_MINIMAL]], ], [ ' ['+=' => BinaryOperatorSpacesFixer::ALIGN_SINGLE_SPACE]], ], [ ' ['+=' => BinaryOperatorSpacesFixer::ALIGN_SINGLE_SPACE_MINIMAL]], ], [ ' ['+=' => BinaryOperatorSpacesFixer::ALIGN]], ], [ ' ['!==' => BinaryOperatorSpacesFixer::ALIGN_SINGLE_SPACE]], ], [ ' ['!==' => BinaryOperatorSpacesFixer::ALIGN_SINGLE_SPACE_MINIMAL]], ], [ ' [ 'and' => BinaryOperatorSpacesFixer::SINGLE_SPACE, '*=' => BinaryOperatorSpacesFixer::ALIGN, 'or' => null, ], ], ], [ ' ['!==' => BinaryOperatorSpacesFixer::ALIGN_SINGLE_SPACE_MINIMAL]], ], [ ' 2, 2 => 3, ];', '2, 2 => 3, ];', ['operators' => ['=>' => BinaryOperatorSpacesFixer::ALIGN_SINGLE_SPACE_MINIMAL]], ], [ ' "foo", 2 => "foo"]; ', ' "foo", 2 => "foo"]; ', ['operators' => ['=>' => BinaryOperatorSpacesFixer::ALIGN_SINGLE_SPACE_MINIMAL]], ], [ ' "foo"]; $i += 1; ', ' "foo"]; $i+= 1; ', ['operators' => ['+=' => BinaryOperatorSpacesFixer::ALIGN_SINGLE_SPACE_MINIMAL]], ], [ '3, 4 => 3, 5=>2, );', null, ['default' => null], ], [ ' $ø0ø0ø, $ø4 => $ø1ø1ø, $ø5 => $ø2ø2ø, ); $a = 12 + 1; $a = 13 + 41; ', '$ø0ø0ø, $ø4 => $ø1ø1ø, $ø5=>$ø2ø2ø, ); $a = 12 + 1; $a = 13+41; ', ['default' => BinaryOperatorSpacesFixer::ALIGN_SINGLE_SPACE_MINIMAL], ], 'do not align with nor touch strings' => [ ' ['=' => BinaryOperatorSpacesFixer::ALIGN_SINGLE_SPACE]], ], 'do not align with declare' => [ ' ['=' => BinaryOperatorSpacesFixer::ALIGN_SINGLE_SPACE_MINIMAL]], ], 'do not align with multibyte character in array key' => [ ' "oe", ]; ', null, ['operators' => ['=>' => BinaryOperatorSpacesFixer::ALIGN_SINGLE_SPACE]], ], 'align correctly with multibyte characters in array key' => [ ' "øasø", "ytė\b" => "øisø", "iūtė\b" => "øiusø", "utė\b" => array( "aitė\b" => "øas", "ytė\b" => "øis", "iūtė\b" => $øøius, "utė\b" => "us", ), );', ' "øasø", "ytė\b" => "øisø", "iūtė\b" => "øiusø", "utė\b" => array( "aitė\b" => "øas", "ytė\b" => "øis", "iūtė\b" => $øøius, "utė\b" => "us", ), );', ['operators' => ['=>' => BinaryOperatorSpacesFixer::ALIGN_SINGLE_SPACE]], ], [ ' BinaryOperatorSpacesFixer::NO_SPACE, 'operators' => ['=' => BinaryOperatorSpacesFixer::SINGLE_SPACE], ], ], [ ' null, 'operators' => [ '=' => BinaryOperatorSpacesFixer::SINGLE_SPACE, '|' => BinaryOperatorSpacesFixer::NO_SPACE, ], ], ], [ ' ['|' => BinaryOperatorSpacesFixer::NO_SPACE], ], ], ]; } /** * @param string $expected * @param null|string $input * * @dataProvider provideFixCases */ public function testFixDefaults($expected, $input = null) { $this->doTest($expected, $input); } public function provideFixCases() { return [ [ ' "c", );', '"c", );', ], [ ' "c", );', '"c", );', ], [ ' "c", );', ' "c", );', ], [ 'doTest($expected, $input); } public function provideUnalignEqualsCases() { return [ [ '', '', ], [ 'expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); $this->expectExceptionMessageRegExp( '/^\[binary_operator_spaces\] Invalid configuration: The option "foo" does not exist\. Defined options are: "default", "operators"\.$/' ); $this->fixer->configure(['foo' => true]); } public function testWrongConfigTypeForOperators() { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); $this->expectExceptionMessageRegExp( '/^\[binary_operator_spaces\] Invalid configuration: The option "operators" with value true is expected to be of type "array", but is of type "(bool|boolean)"\.$/' ); $this->fixer->configure(['operators' => true]); } public function testWrongConfigTypeForOperatorsKey() { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); $this->expectExceptionMessageRegExp('/^\[binary_operator_spaces\] Invalid configuration: Unexpected "operators" key, expected any of ".*", got "integer#123"\.$/'); $this->fixer->configure(['operators' => [123 => 1]]); } public function testWrongConfigTypeForOperatorsKeyValue() { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); $this->expectExceptionMessageRegExp('/^\[binary_operator_spaces\] Invalid configuration: Unexpected value for operator "\+", expected any of ".*", got "string#abc"\.$/'); $this->fixer->configure(['operators' => ['+' => 'abc']]); } /** * @param string $expected * @param null|string $input * * @dataProvider provideUnalignDoubleArrowCases */ public function testUnalignDoubleArrow($expected, $input = null) { $this->doTest($expected, $input); } public function provideUnalignDoubleArrowCases() { return [ [ ' "Bar", "main" => array( [ "baz" => "Test", "bazaa" => $a->{"Test"}, "bazaa" => $a["Test"], "bazaaaa" => b("Test"), ] ), "bar" => array(), ];', ' "Bar", "main" => array( [ "baz" => "Test", "bazaa" => $a->{"Test"}, "bazaa" => $a["Test"], "bazaaaa" => b("Test"), ] ), "bar" => array(), ];', ], [ ' "Bar", "main" => [array("baz" => "Test")], "bar" => array(), ]; $data = array( "foo" => "Bar", "main" => array("baz" => "Test"), "bar" => array(), ); $var = []; foreach ($foo as $i => $bar) { $var[] = /* Comment */ [$i => $bar]; }', ' "Bar", "main" => [array("baz" => "Test")], "bar" => array(), ]; $data = array( "foo" => "Bar", "main" => array("baz" => "Test"), "bar" => array(), ); $var = []; foreach ($foo as $i => $bar) { $var[] = /* Comment */ [$i => $bar]; }', ], [ ' "Bar", "main" => [array("baz" => "Test")], "bar" => array(), ];', ' "Bar", "main" => [array("baz" => "Test")], "bar" => array(), ];', ], [ ' "Bar", "main" => array("baz" => "Test"), "bar" => array(), );', ' "Bar", "main" => array("baz" => "Test"), "bar" => array(), );', ], [ ' "Bar", "main" => array(array("baz" => "Test")), "bar" => array(), );', ' "Bar", "main" => array(array("baz" => "Test")), "bar" => array(), );', ], [ ' $bar) { $var[] = /* Comment */ [$i => $bar]; }', ' $bar) { $var[] = /* Comment */ [$i => $bar]; }', ], [ ' $bar) { $var[] = [$i => $bar]; }', ], [ ' 2] as $k => $v) { $var[] = [$i => $bar]; }', ], [ ' $v){ $var[] = [$i => $bar]; }', ], [ ' $bar, $iaaa => $bar, ]; }', ' $bar, $iaaa => $bar, ]; }', ], [ ' "Bar", "main" => [["baz" => "Test", "bar" => "Test2"]], "bar" => [], ];', ' "Bar", "main" => [["baz" => "Test", "bar" => "Test2"]], "bar" => [], ];', ], [ ' 1, 10 /*Comment*/ => [ 1 => 2, 22 => 3, ], 100 => [ 1 => 2, 22 => 3, ] ];', ' 1, 10 /*Comment*/ => [ 1 => 2, 22 => 3, ], 100 => [ 1 => 2, 22 => 3, ] ];', ], [ ' 1, 10 => array( 1 => 2, 22 => 3, ), 100 => array( 1 => 2, 22 => 3, ) );', ' 1, 10 => array( 1 => 2, 22 => 3, ), 100 => array( 1 => 2, 22 => 3, ) );', ], [ ' 1, $bbbb => \' $cccccccc = 3; \', );', ' 1, $bbbb => \' $cccccccc = 3; \', );', ], [ ' 1, $bbbb => \' $cccccccc = 3; \', ];', ' 1, $bbbb => \' $cccccccc = 3; \', ];', ], [ ' $v){ $arr = array($k => 1, $a => 1, $bbbb => \' $cccccccc = 3; \', ); }', ' $v){ $arr = array($k => 1, $a => 1, $bbbb => \' $cccccccc = 3; \', ); }', ], [ ' 11, 20 => 22, 30 => 33, 40 => 44, );', ' 11, 20 => 22, 30=>33, 40 => 44, );', ], [ ' "", "\t" => "", "\n" => "", "\r" => "", "\0" => "", "\x0B" => "", );', ' "", "\t" => "", "\n" => "", "\r" => "", "\0" => "", "\x0B" => "", );', ], [ 'grabAttribsBeforeToken( $tokens, $index, $tokenAttribsMap, array( "abstract" => null, "final" => null, "visibility" => new Token(array(T_PUBLIC, "public")), "static" => null, ) );', 'grabAttribsBeforeToken( $tokens, $index, $tokenAttribsMap, array( "abstract" => null, "final" => null, "visibility" => new Token(array(T_PUBLIC, "public")), "static" => null, ) );', ], [ ' array("symbol" => "?", "description" => "unknown"), self::STATUS_INVALID_0 => array("symbol" => "III", "description" => "invalid file syntax, file ignored"), );', ' array("symbol" => "?", "description" => "unknown"), self::STATUS_INVALID_0 => array("symbol" => "III", "description" => "invalid file syntax, file ignored"), );', ], [ ' b(array( 1 => 2, 5 => [ 6 => 7, 8 => 9, ], 3 => 4, 10 => 11, )), );', ' b(array( 1 => 2, 5 => [ 6 => 7, 8 => 9, ], 3 => 4, 10 => 11, )), );', ], [ 'aaa(array(1 => 2))->bbb("a", "b"); ', ], [ ' 2; }', ], ]; } /** * @param string $expected * @param null|string $input * * @dataProvider provideAlignEqualsCases */ public function testFixAlignEquals($expected, $input = null) { $this->fixer->configure(['operators' => ['=' => BinaryOperatorSpacesFixer::ALIGN]]); $this->doTest($expected, $input); } public function provideAlignEqualsCases() { return [ [ 'fixer->configure(['operators' => ['=>' => BinaryOperatorSpacesFixer::ALIGN]]); $this->doTest($expected, $input); } public function provideAlignDoubleArrowCases() { return [ [ ' function ($param1, $param2) { return; } );', ], [ ' "OK", "html" => 1, /**/array( "foo" => "bar", "foofoo" => array( "a" => 1, "b" => 2 ) ),) );', ' "OK", "html" => 1, /**/array( "foo" => "bar", "foofoo" => array( "a" => 1, "b" => 2 ) ),) );', ], [ ' "OK", "html" => renderView("views/my_view.html.twig", array( "foo" => "bar", "foofoo" => 43, )), ]);', ' "OK", "html" => renderView("views/my_view.html.twig", array( "foo" => "bar", "foofoo" => 43, )), ]);', ], [ ' "OK", "html" => renderView("views/my_view.html.twig", [ "foo" => "bar", "foofoo" => 42, ]), "baz" => "OK", ]);', ' "OK", "html" => renderView("views/my_view.html.twig", [ "foo" => "bar", "foofoo" => 42, ]), "baz" => "OK", ]);', ], [ ' "Bar", "main" => array( [ "baz" => "Test", "bazaa" => $a->{"Test"}, "bazaa" => $a["Test"], "bazaaaa" => b("Test"), ] ), "bar" => array(), ];', ' "Bar", "main" => array( [ "baz" => "Test", "bazaa" => $a->{"Test"}, "bazaa" => $a["Test"], "bazaaaa" => b("Test"), ] ), "bar" => array(), ];', ], [ ' "Bar", "main" => [array("baz" => "Test")], "bar" => array(), ]; $data = array( "foo" => "Bar", "main" => array("baz" => "Test"), "bar" => array(), ); $var = []; foreach ($foo as $i => $bar) { $var[] = /* Comment */ [$i => $bar]; }', ], [ ' "Bar", "main" => [array("baz" => "Test")], "bar" => array(), ];', ], [ ' "Bar", "main" => array("baz" => "Test"), "bar" => array(), );', ], [ ' "Bar", "main" => array(array("baz" => "Test")), "bar" => array(), );', ], [ ' $bar) { $var[] = /* Comment */ [$i => $bar]; }', ], [ ' $bar) { $var[] = [$i => $bar]; }', ], [ ' 2] as $k => $v) { $var[] = [$i => $bar]; }', ], [ ' $v){ $var[] = [$i => $bar]; }', ], [ ' $bar, $iaaa => $bar, ]; }', ], [ ' "Bar", "main" => [["baz" => "Test", "bar" => "Test2"]], "bar" => [], ];', ], [ ' "Bar", "main" => ["baz" => "Test"], "bar" => [], ];', ], [ ' 1, 10 /*Comment*/ => [ 1 => 2, 22 => 3, ], 100 => [ 1 => 2, 22 => 3, ] ];', ' 1, 10 /*Comment*/ => [ 1 => 2, 22 => 3, ], 100 => [ 1 => 2, 22 => 3, ] ];', ], [ ' 1, 10 => array( 1 => 2, 22 => 3, ), 100 => array( 1 => 2, 22 => 3, ) );', ], [ ' 1, $bbbb => \' $cccccccc2 = 3; \', );', ' 1, $bbbb => \' $cccccccc2 = 3; \', );', ], [ ' 1, $bbbb => \' $cccccccc3 = 3; \', ];', ' 1, $bbbb => \' $cccccccc3 = 3; \', ];', ], [ ' $v){ $arr = array($k => 1, $a => 1, $bbbb => \' $cccccccc4 = 3; \', ); }', ], [ ' 11, 20 => 22, 30 => 33, 40 => 44, );', ' 11, 20 => 22, 30=>33, 40 => 44, );', ], [ ' "", "\t" => "", "\n" => "", "\r" => "", "\0" => "", "\x0B" => "", );', ' "", "\t" => "", "\n" => "", "\r" => "", "\0" => "", "\x0B" => "", );', ], [ 'grabAttribsBeforeToken( $tokens, $index, $tokenAttribsMap, array( "abstract" => null, "final" => null, "visibility" => new Token(array(T_PUBLIC, "public")), "static" => null, ) );', 'grabAttribsBeforeToken( $tokens, $index, $tokenAttribsMap, array( "abstract" => null, "final" => null, "visibility" => new Token(array(T_PUBLIC, "public")), "static" => null, ) );', ], [ ' array("symbol" => "?", "description" => "unknown"), self::STATUS_INVALID_1 => array("symbol" => "III", "description" => "invalid file syntax, file ignored"), );', ' array("symbol" => "?", "description" => "unknown"), self::STATUS_INVALID_1 => array("symbol" => "III", "description" => "invalid file syntax, file ignored"), );', ], [ ' b(array( 1 => 2, 5 => [ 6 => 7, 8 => 9, ], 3 => 4, 10 => 11, )), );', ' b(array( 1 => 2, 5 => [ 6 => 7, 8 => 9, ], 3 => 4, 10 => 11, )), );', ], [ 'aaa(array(1 => 2))->bbb("a", "b"); ', ], [ ' "as", "ytė\b" => "is", "iūtė\b" => "ius", "utė\b" => "us", );', ' "as", "ytė\b" => "is", "iūtė\b" => "ius", "utė\b" => "us", );', ], [ 'add(\'foo\', null, [\'required\' => false]) ->add(\'dummy_field\', null, [\'required\' => false]) ; ', ], [ 'add(\'foo\', null, array(\'required\' => false)) ->add(\'dummy_field\', null, array(\'required\' => false)) ; ', ], [ 'get("doctrine")->getRepository("AppBundle:Entity")->findBy(["server1" => $object], ["addedAt" => "DESC"], 5); $foobar = $this->getDoctrine()->getRepository("AppBundle:Entity")->findBy(["server2" => $object], ["checkedAt" => "desc"], 50); ', ], [ 'get("doctrine")->getRepository("AppBundle:Entity")->findBy(array("server1" => $object), array("addedAt" => "DESC"), 5); $foobar = $this->getDoctrine()->getRepository("AppBundle:Entity")->findBy(array("server2" => $object), array("checkedAt" => "desc"), 50); ', ], [ 'get("doctrine")->getRepository("AppBundle:Entity")->findBy($foo[123]); $foobar = $this->getDoctrine()->getRepository("AppBundle:Entity")->findBy($foo[123]); ', ], [ 'get("doctrine")->getRepository("AppBundle:Entity")->findBy([1, 2, 3]); $foobar = $this->getDoctrine()->getRepository("AppBundle:Entity")->findBy([1, 2, 3]); ', ], [ 'get("doctrine")->getRepository("AppBundle:Entity")->findBy((1 + 2)); $foobar = $this->getDoctrine()->getRepository("AppBundle:Entity")->findBy((1 + 2)); ', ], [ 'get("doctrine")->getRepository("AppBundle:Entity")->findBy(array(1, 2)); $foobar = $this->getDoctrine()->getRepository("AppBundle:Entity")->findBy(array(1, 2)); ', ], [ ' "foo", "foo" => $bar[123], "a" => foo(), "b" => 1, ]; ', ' "foo", "foo" => $bar[123], "a" => foo(), "b" => 1, ]; ', ], [ ' array("symbol" => "?", "description" => "unknown"), self::STATUS_INVALID_2 => array("symbol123" => "III", "description" => "invalid file syntax, file ignored"), );', ' array("symbol" => "?", "description" => "unknown"), self::STATUS_INVALID_2 => array("symbol123" => "III", "description" => "invalid file syntax, file ignored"), );', ], [ ' array((1 + 11)=> "?", "description" => "unknown"), self::STATUS_INVALID_3 => array((2 + 3)=> "III", "description" => "invalid file syntax, file ignored"), );', ' array((1+11)=> "?", "description" => "unknown"), self::STATUS_INVALID_3 => array((2+3)=> "III", "description" => "invalid file syntax, file ignored"), );', ], [ ' ["symbol" => "?", "description" => "unknown"], self::STATUS_INVALID_4 => ["symbol123" => "III", "description" => "invalid file syntax, file ignored"], ];', ' ["symbol" => "?", "description" => "unknown"], self::STATUS_INVALID_4 => ["symbol123" => "III", "description" => "invalid file syntax, file ignored"], ];', ], [ ' [(1 + 11)=> "?", "description" => "unknown"], self::STATUS_INVALID_7 => [(2 + 3)=> "III", "description" => "invalid file syntax, file ignored"], ];', ' [(1+11)=> "?", "description" => "unknown"], self::STATUS_INVALID_7 => [(2+3)=> "III", "description" => "invalid file syntax, file ignored"], ];', ], ]; } public function testDoNotTouchEqualsAndArrowByConfig() { $this->fixer->configure( [ 'operators' => [ '=' => null, '=>' => null, ], ] ); $this->doTest( ' 5, 2 => 4, 3 => 3, 4 => 2, 5 => 1, 6 => 7, ); ' ); } /** * @requires PHP 7.0 */ public function testPHP70Cases() { $this->fixer->configure(['operators' => ['=' => BinaryOperatorSpacesFixer::ALIGN_SINGLE_SPACE, '??' => BinaryOperatorSpacesFixer::ALIGN_SINGLE_SPACE_MINIMAL]]); $this->doTest( ' 1; echo 1 <=> 2; echo 2 <=> 1; echo 2 <=> 1; $a = $a ?? $b; $a = $ab ?? $b; $a = $ac ?? $b; $a = $ad ?? $b; $a = $ae ?? $b; ', '1; echo 1 <=>2; echo 2<=> 1; echo 2 <=> 1; $a = $a ?? $b; $a = $ab ?? $b; $a = $ac ?? $b; $a = $ad ?? $b; $a = $ae?? $b; ' ); } /** * @requires PHP 7.1 * * @param string $expected * @param null|string $input * * @dataProvider providePHP71Cases */ public function testPHP71Cases($expected, $input = null, array $configuration = []) { $this->fixer->configure($configuration); $this->doTest($expected, $input); } public function providePHP71Cases() { return [ 'align array destruction' => [ ' ['=' => BinaryOperatorSpacesFixer::ALIGN]], ], 'align array destruction with assignments' => [ ' $a, "b" => $b, "c" => $c ] = $array; ', '$a, "b" => $b, "c" => $c ] = $array; ', ['operators' => ['=>' => BinaryOperatorSpacesFixer::ALIGN_SINGLE_SPACE_MINIMAL]], ], 'multiple exceptions catch, default config' => [ ' [ ' ['|' => BinaryOperatorSpacesFixer::NO_SPACE]], ], ]; } /** * @param string $expected * @param null|string $input * * @dataProvider provideFixPhp74Cases * @requires PHP 7.4 */ public function testFixPhp74($expected, $input = null, array $configuration = null) { if (null !== $configuration) { $this->fixer->configure($configuration); } $this->doTest($expected, $input); } public function provideFixPhp74Cases() { return [ [ ' null; $b = fn() => null; ', ' null; $b = fn() => null; ', null, ['operators' => ['=>' => BinaryOperatorSpacesFixer::ALIGN_SINGLE_SPACE_MINIMAL]], ], [ ' ['??=' => BinaryOperatorSpacesFixer::ALIGN_SINGLE_SPACE]], ], ]; } }