* * 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\PSR2; use Symfony\CS\Tests\Fixer\AbstractFixerTestBase; /** * @author Dariusz RumiƄski */ class BracesFixerTest extends AbstractFixerTestBase { /** * @dataProvider provideFixControlContinuationBracesCases */ public function testFixControlContinuationBraces($expected, $input = null) { $this->makeTest($expected, $input); } public function provideFixControlContinuationBracesCases() { return array( array( 'makeTest($expected, $input); } public function provideFixMissingBracesAndIndentCases() { return array( array( 'next());', ), array( 'getTest());', 'getTest());', ), array( 'getTest());', 'getTest());', ), array( 'c()}d"; }', ), array( '{$c->d}($e); $f->{$g} = $h; $i->{$j}[$k] = $l; $m = $n->{$o}; $p = array($q->{$r}, $s->{$t}); $u->{$v}->w = 1; }', ), array( '{"a{$c}d"}(); }', ), array( '{"a{$c->{\'foo-bar\'}()}d"}(); }', ), array( '{"a{$c->{\'foo-bar\'}()}d"}(); }', ), array( 'x', 'x', ), array( 'phoneNumbers->filter(function ($phone) { $a = 1; $b = 1; $c = 1; return ($phone->getType() === 1) ? true : false; }); } } }', 'phoneNumbers->filter(function ($phone) { $a = 1; $b = 1; $c = 1; return ($phone->getType() === 1) ? true : false; }); } }', ), array( 'makeTest($expected, $input); } public function provideFixClassyBracesCases() { return array( array( 'makeTest($expected, $input); } public function provideFixClassyBraces54Cases() { return array( array( 'makeTest($expected, $input); } public function provideFixAnonFunctionInShortArraySyntax54Cases() { return array( array( ' function ($data) { return true; } ], [ "callback" => function ($data) { return true; }, ], ]; }', ), ); } /** * @dataProvider provideFixCommentBeforeBraceCases */ public function testFixCommentBeforeBrace($expected, $input = null) { $this->makeTest($expected, $input); } public function provideFixCommentBeforeBraceCases() { return array( array( 'makeTest($expected, $input); } public function provideFixWhitespaceBeforeBraceCases() { return array( array( 'getFile()) { }', 'getFile()) { }', ), array( 'makeTest($expected, $input); } public function provideFixFunctionsCases() { return array( array( 'fixers, function &($a, $b) use ($selfName) { return 1; });', ), array( 'fixers, function &($a, $b) use ($selfName) { return 1; } );', ), array( 'makeTest($expected, $input); } public function provideFixSpaceAroundTokenCases() { return array( array( 'tesT ($test)) { }', 'tesT ($test)) { }', ), array( 'makeTest($expected, $input); } public function provide55Cases() { return array( array( 'makeTest($expected, $input); } public function providePreserveLineAfterControlBrace() { return array( array( '