* * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace Symfony\CS\Tests\Fixer\Contrib; use Symfony\CS\Tests\Fixer\AbstractFixerTestBase; /** * @author Carlos Cirello */ class AlignDoubleArrowFixerTest extends AbstractFixerTestBase { /** * @dataProvider provideFixCases */ public function testFix($expected, $input = null) { $this->makeTest($expected, $input); } public function provideFixCases() { return array( array( ' function ($param1, $param2) { return; } );', ), array( ' "OK", "html" => 1, array( "foo" => "bar", "foofoo" => array( "a" => 1, "b" => 2 ) ),) );', ' "OK", "html" => 1, array( "foo" => "bar", "foofoo" => array( "a" => 1, "b" => 2 ) ),) );', ), array( ' "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, )), ]);', ), array( ' "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", ]);', ), array( ' "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(), ];', ), 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]; }', ), array( ' "Bar", "main" => [array("baz" => "Test")], "bar" => array(), ];', ), array( ' "Bar", "main" => array("baz" => "Test"), "bar" => array(), );', ), array( ' "Bar", "main" => array(array("baz" => "Test")), "bar" => array(), );', ), array( ' $bar) { $var[] = /* Comment */ [$i => $bar]; }', ), array( ' $bar) { $var[] = [$i => $bar]; }', ), array( ' 2] as $k => $v) { $var[] = [$i => $bar]; }', ), array( ' $v){ $var[] = [$i => $bar]; }', ), array( ' $bar, $iaaa => $bar, ]; }', ), array( ' "Bar", "main" => [["baz" => "Test", "bar" => "Test2"]], "bar" => [], ];', ), array( ' "Bar", "main" => ["baz" => "Test"], "bar" => [], ];', ), array( ' 1, 10 /*Comment*/ => [ 1 => 2, 22 => 3, ], 100 => [ 1 => 2, 22 => 3, ] ];', ' 1, 10 /*Comment*/ => [ 1 => 2, 22 => 3, ], 100 => [ 1 => 2, 22 => 3, ] ];', ), array( ' 1, 10 => array( 1 => 2, 22 => 3, ), 100 => array( 1 => 2, 22 => 3, ) );', ), array( ' 1, $bbbb => \' $cccccccc = 3; \', );', ' 1, $bbbb => \' $cccccccc = 3; \', );', ), array( ' 1, $bbbb => \' $cccccccc = 3; \', ];', ' 1, $bbbb => \' $cccccccc = 3; \', ];', ), array( ' $v){ $arr = array($k => 1, $a => 1, $bbbb => \' $cccccccc = 3; \', ); }', ), array( ' 11, 20 => 22, 30 => 33, 40 => 44, );', ' 11, 20 => 22, 30=>33, 40 => 44, );', ), array( ' "", "\t" => "", "\n" => "", "\r" => "", "\0" => "", "\x0B" => "", );', ' "", "\t" => "", "\n" => "", "\r" => "", "\0" => "", "\x0B" => "", );', ), array( '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( ' array("symbol" => "?", "description" => "unknown"), self::STATUS_INVALID => array("symbol" => "III", "description" => "invalid file syntax, file ignored"), );', ' array("symbol" => "?", "description" => "unknown"), self::STATUS_INVALID => array("symbol" => "III", "description" => "invalid file syntax, file ignored"), );', ), array( ' 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, )), );', ), array( 'aaa(array(1 => 2))->bbb("a", "b"); ', ), array( ' "as", "ytė\b" => "is", "iūtė\b" => "ius", "utė\b" => "us", );', ' "as", "ytė\b" => "is", "iūtė\b" => "ius", "utė\b" => "us", );', ), array( 'add(\'foo\', null, [\'required\' => false]) ->add(\'dummy_field\', null, [\'required\' => false]) ; ', ), array( 'add(\'foo\', null, array(\'required\' => false)) ->add(\'dummy_field\', null, array(\'required\' => false)) ; ', ), array( 'get("doctrine")->getRepository("AppBundle:Entity")->findBy(["server1" => $object], ["addedAt" => "DESC"], 5); $foobar = $this->getDoctrine()->getRepository("AppBundle:Entity")->findBy(["server2" => $object], ["checkedAt" => "desc"], 50); ', ), array( '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); ', ), array( 'get("doctrine")->getRepository("AppBundle:Entity")->findBy($foo[123]); $foobar = $this->getDoctrine()->getRepository("AppBundle:Entity")->findBy($foo[123]); ', ), array( 'get("doctrine")->getRepository("AppBundle:Entity")->findBy([1, 2, 3]); $foobar = $this->getDoctrine()->getRepository("AppBundle:Entity")->findBy([1, 2, 3]); ', ), array( 'get("doctrine")->getRepository("AppBundle:Entity")->findBy((1 + 2)); $foobar = $this->getDoctrine()->getRepository("AppBundle:Entity")->findBy((1 + 2)); ', ), array( 'get("doctrine")->getRepository("AppBundle:Entity")->findBy(array(1, 2)); $foobar = $this->getDoctrine()->getRepository("AppBundle:Entity")->findBy(array(1, 2)); ', ), array( ' "foo", "foo" => $bar[123], "a" => foo(), "b" => 1, ]; ', ' "foo", "foo" => $bar[123], "a" => foo(), "b" => 1, ]; ', ), array( ' array("symbol" => "?", "description" => "unknown"), self::STATUS_INVALID => array("symbol123" => "III", "description" => "invalid file syntax, file ignored"), );', ' array("symbol" => "?", "description" => "unknown"), self::STATUS_INVALID => array("symbol123" => "III", "description" => "invalid file syntax, file ignored"), );', ), array( ' array((1+11)=> "?", "description" => "unknown"), self::STATUS_INVALID => array((2+3)=> "III", "description" => "invalid file syntax, file ignored"), );', ' array((1+11)=> "?", "description" => "unknown"), self::STATUS_INVALID => array((2+3)=> "III", "description" => "invalid file syntax, file ignored"), );', ), array( ' ["symbol" => "?", "description" => "unknown"], self::STATUS_INVALID => ["symbol123" => "III", "description" => "invalid file syntax, file ignored"], ];', ' ["symbol" => "?", "description" => "unknown"], self::STATUS_INVALID => ["symbol123" => "III", "description" => "invalid file syntax, file ignored"], ];', ), array( ' [(1+11)=> "?", "description" => "unknown"], self::STATUS_INVALID => [(2+3)=> "III", "description" => "invalid file syntax, file ignored"], ];', ' [(1+11)=> "?", "description" => "unknown"], self::STATUS_INVALID => [(2+3)=> "III", "description" => "invalid file syntax, file ignored"], ];', ), ); } }