From a04d9c50ad8b00ac489001cf691b0183f985a8c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Wer=C5=82os?= Date: Mon, 3 May 2021 19:47:07 +0200 Subject: [PATCH] Remove TrailingCommaInMultilineArrayFixer --- UPGRADE-v3.md | 1 + .../trailing_comma_in_multiline_array.rst | 58 --- doc/rules/index.rst | 2 - .../TrailingCommaInMultilineArrayFixer.php | 108 ----- ...TrailingCommaInMultilineArrayFixerTest.php | 428 ------------------ tests/Fixtures/Integration/misc/PHP7_4.test | 2 +- 6 files changed, 2 insertions(+), 597 deletions(-) delete mode 100644 doc/rules/array_notation/trailing_comma_in_multiline_array.rst delete mode 100644 src/Fixer/ArrayNotation/TrailingCommaInMultilineArrayFixer.php delete mode 100644 tests/Fixer/ArrayNotation/TrailingCommaInMultilineArrayFixerTest.php diff --git a/UPGRADE-v3.md b/UPGRADE-v3.md index 826dd93c063..cd7cf0e2423 100644 --- a/UPGRADE-v3.md +++ b/UPGRADE-v3.md @@ -46,6 +46,7 @@ Old name | New name | Note `psr0` | `psr_autoloading` | use configuration `['dir' => x ]` `psr4` | `psr_autoloading` | `silenced_deprecation_error` | `error_suppression` | +`trailing_comma_in_multiline_array` | `trailing_comma_in_multiline` | use configuration `['elements' => ['arrays']]` ### Removed rootless configuration diff --git a/doc/rules/array_notation/trailing_comma_in_multiline_array.rst b/doc/rules/array_notation/trailing_comma_in_multiline_array.rst deleted file mode 100644 index 32f802097e3..00000000000 --- a/doc/rules/array_notation/trailing_comma_in_multiline_array.rst +++ /dev/null @@ -1,58 +0,0 @@ -========================================== -Rule ``trailing_comma_in_multiline_array`` -========================================== - -.. warning:: This rule is deprecated and will be removed on next major version. - - You should use ``trailing_comma_in_multiline`` instead. - -PHP multi-line arrays should have a trailing comma. - -Configuration -------------- - -``after_heredoc`` -~~~~~~~~~~~~~~~~~ - -Whether a trailing comma should also be placed after heredoc end. - -Allowed types: ``bool`` - -Default value: ``false`` - -Examples --------- - -Example #1 -~~~~~~~~~~ - -*Default* configuration. - -.. code-block:: diff - - --- Original - +++ New - true]``. - -.. code-block:: diff - - --- Original - +++ New - `_ Array index should always be written by using square braces. -- `trailing_comma_in_multiline_array <./array_notation/trailing_comma_in_multiline_array.rst>`_ *(deprecated)* - PHP multi-line arrays should have a trailing comma. - `trim_array_spaces <./array_notation/trim_array_spaces.rst>`_ Arrays should be formatted like function/method arguments, without leading or trailing single line space. - `whitespace_after_comma_in_array <./array_notation/whitespace_after_comma_in_array.rst>`_ diff --git a/src/Fixer/ArrayNotation/TrailingCommaInMultilineArrayFixer.php b/src/Fixer/ArrayNotation/TrailingCommaInMultilineArrayFixer.php deleted file mode 100644 index e362d15cd62..00000000000 --- a/src/Fixer/ArrayNotation/TrailingCommaInMultilineArrayFixer.php +++ /dev/null @@ -1,108 +0,0 @@ - - * 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\Fixer\ArrayNotation; - -use PhpCsFixer\AbstractProxyFixer; -use PhpCsFixer\Fixer\ConfigurableFixerInterface; -use PhpCsFixer\Fixer\ControlStructure\TrailingCommaInMultilineFixer; -use PhpCsFixer\Fixer\DeprecatedFixerInterface; -use PhpCsFixer\FixerConfiguration\FixerConfigurationResolver; -use PhpCsFixer\FixerConfiguration\FixerConfigurationResolverInterface; -use PhpCsFixer\FixerDefinition\CodeSample; -use PhpCsFixer\FixerDefinition\FixerDefinition; -use PhpCsFixer\FixerDefinition\FixerDefinitionInterface; -use PhpCsFixer\FixerDefinition\VersionSpecification; -use PhpCsFixer\FixerDefinition\VersionSpecificCodeSample; - -/** - * @author Sebastiaan Stok - * @author Dariusz Rumiński - * - * @deprecated - */ -final class TrailingCommaInMultilineArrayFixer extends AbstractProxyFixer implements ConfigurableFixerInterface, DeprecatedFixerInterface -{ - /** - * @var TrailingCommaInMultilineFixer - */ - private $fixer; - - /** - * {@inheritdoc} - */ - public function getDefinition(): FixerDefinitionInterface - { - return new FixerDefinition( - 'PHP multi-line arrays should have a trailing comma.', - [ - new CodeSample(" true] - ), - ] - ); - } - - public function configure(array $configuration): void - { - $configuration['elements'] = [TrailingCommaInMultilineFixer::ELEMENTS_ARRAYS]; - $this->getFixer()->configure($configuration); - $this->configuration = $configuration; - } - - public function getConfigurationDefinition(): FixerConfigurationResolverInterface - { - return new FixerConfigurationResolver([ - $this->getFixer()->getConfigurationDefinition()->getOptions()[0], - ]); - } - - /** - * {@inheritdoc} - */ - public function getSuccessorsNames(): array - { - return array_keys($this->proxyFixers); - } - - /** - * {@inheritdoc} - */ - protected function createProxyFixers(): array - { - return [$this->getFixer()]; - } - - private function getFixer() - { - if (null === $this->fixer) { - $this->fixer = new TrailingCommaInMultilineFixer(); - } - - return $this->fixer; - } -} diff --git a/tests/Fixer/ArrayNotation/TrailingCommaInMultilineArrayFixerTest.php b/tests/Fixer/ArrayNotation/TrailingCommaInMultilineArrayFixerTest.php deleted file mode 100644 index 1124e9a8b44..00000000000 --- a/tests/Fixer/ArrayNotation/TrailingCommaInMultilineArrayFixerTest.php +++ /dev/null @@ -1,428 +0,0 @@ - - * 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 Sebastiaan Stok - * - * @internal - * - * @covers \PhpCsFixer\Fixer\ArrayNotation\TrailingCommaInMultilineArrayFixer - */ -final class TrailingCommaInMultilineArrayFixerTest extends AbstractFixerTestCase -{ - /** - * @dataProvider provideFixCases - */ - public function testFix(string $expected, ?string $input = null): void - { - $this->doTest($expected, $input); - } - - public function provideFixCases() - { - return [ - // long syntax tests - [' array( - 2 => 3, - ), - );', - ' array( - 2 => 3 - ) - );', - ], - [ - " function ($b) { - return "bar".$b; - });', - ], - [ - ' 1, - "b" => 2, - );', - ' 1, - "b" => 2 - );', - ], - [ - ' function ($b) { - return "bar".$b; - }];', - ], - [ - ' 1, - "b" => 2, - ];', - ' 1, - "b" => 2 - ];', - ], - [ - ' 1, - "b" => 2, - ); -}', - ' 1, - "b" => 2 - ); -}', - ], - [ - ' 1, - "b" => 2, - ]; -}', - ' 1, - "b" => 2 - ]; -}', - ], - ]; - } - - /** - * @dataProvider provideFix73Cases - * @requires PHP 7.3 - */ - public function testFix73(string $expected, ?string $input = null, array $config = []): void - { - $this->fixer->configure($config); - $this->doTest($expected, $input); - } - - public function provideFix73Cases() - { - return [ - [ - <<<'EXPECTED' - true], - ], - ]; - } - - /** - * @dataProvider provideFixPhp74Cases - * @requires PHP 7.4 - */ - public function testFixPhp74(string $expected, ?string $input = null): void - { - $this->doTest($expected, $input); - } - - public function provideFixPhp74Cases() - { - return [ - [ - '