Browse Source

ConfigurableFixerInterface::configure - param is now not nullable and not optional

Dariusz Ruminski 7 years ago
parent
commit
b2acbab97d

+ 1 - 1
.travis.yml

@@ -69,7 +69,7 @@ jobs:
             <<: *STANDARD_TEST_JOB
             stage: Test
             php: 7.1
-            env: SYMFONY_DEPRECATIONS_HELPER=weak PHP_CS_FIXER_TEST_USE_LEGACY_TOKENIZER=1 SYMFONY_VERSION="^4.0" MIN_STABILITY=dev
+            env: SYMFONY_DEPRECATIONS_HELPER=weak SYMFONY_VERSION="^4.0" MIN_STABILITY=dev
 
         -
             <<: *STANDARD_TEST_JOB

+ 21 - 0
UPGRADE-v3.md

@@ -2,3 +2,24 @@ UPGRADE GUIDE FROM 2.x to 3.0
 =============================
 
 This is guide for upgrade from version 2.x to 3.0 for using the CLI tool.
+
+Changes to rules
+----------------
+
+### Removed rootless configuration
+
+Rule                                 | Root option    | Note
+------------------------------------ | -------------- | ----
+`general_phpdoc_annotation_remove`   | `annotations`
+`no_extra_consecutive_blank_lines`   | `tokens`
+`no_spaces_around_offset`            | `positions`
+`no_unneeded_control_parentheses`    | `statements`
+`ordered_class_elements`             | `order`
+`php_unit_construct`                 | `assertions`
+`php_unit_dedicate_assert`           | `target`       | root option works differently than rootless configuration
+`php_unit_strict`                    | `assertions`
+`phpdoc_no_alias_tag`                | `replacements`
+`phpdoc_return_self_reference`       | `replacements`
+`random_api_migration`               | `replacements`
+`single_class_element_per_statement` | `elements`
+`visibility_required`                | `elements`

+ 0 - 1
phpunit.xml.dist

@@ -49,6 +49,5 @@
         <ini name="zend.enable_gc" value="0"/>
         <ini name="memory_limit" value="1G"/>
         <env name="SKIP_LINT_TEST_CASES" value="0"/>
-        <env name="PHP_CS_FIXER_TEST_USE_LEGACY_TOKENIZER" value="0"/>
     </php>
 </phpunit>

+ 1 - 14
src/AbstractFixer.php

@@ -109,25 +109,12 @@ abstract class AbstractFixer implements FixerInterface, DefinedFixerInterface
         return true;
     }
 
-    public function configure(array $configuration = null)
+    public function configure(array $configuration)
     {
         if (!$this instanceof ConfigurationDefinitionFixerInterface) {
             throw new \LogicException('Cannot configure using Abstract parent, child not implementing "PhpCsFixer\Fixer\ConfigurationDefinitionFixerInterface".');
         }
 
-        if (null === $configuration) {
-            if (getenv('PHP_CS_FIXER_FUTURE_MODE')) {
-                throw new \InvalidArgumentException('Parameter must not be `null`. This check was performed as `PHP_CS_FIXER_FUTURE_MODE` env var is set.');
-            }
-
-            @trigger_error(
-                'Passing NULL to set default configuration is deprecated and will not be supported in 3.0, use an empty array instead.',
-                E_USER_DEPRECATED
-            );
-
-            $configuration = [];
-        }
-
         try {
             $this->configuration = $this->getConfigurationDefinition()->resolve($configuration);
         } catch (MissingOptionsException $exception) {

+ 0 - 9
src/Console/Command/DescribeCommand.php

@@ -212,15 +212,6 @@ final class DescribeCommand extends Command
             $output->writeln('');
         } elseif ($fixer instanceof ConfigurableFixerInterface) {
             $output->writeln('<comment>Fixer is configurable.</comment>');
-
-            if ($definition->getConfigurationDescription()) {
-                $output->writeln($definition->getConfigurationDescription());
-            }
-
-            if ($definition->getDefaultConfiguration()) {
-                $output->writeln(sprintf('Default configuration: <comment>%s</comment>.', HelpCommand::toString($definition->getDefaultConfiguration())));
-            }
-
             $output->writeln('');
         }
 

+ 1 - 1
src/Fixer/Alias/NoMixedEchoPrintFixer.php

@@ -46,7 +46,7 @@ final class NoMixedEchoPrintFixer extends AbstractFixer implements Configuration
     /**
      * {@inheritdoc}
      */
-    public function configure(array $configuration = null)
+    public function configure(array $configuration)
     {
         parent::configure($configuration);
 

+ 3 - 3
src/Fixer/Alias/RandomApiMigrationFixer.php

@@ -14,7 +14,7 @@ namespace PhpCsFixer\Fixer\Alias;
 
 use PhpCsFixer\AbstractFunctionReferenceFixer;
 use PhpCsFixer\Fixer\ConfigurationDefinitionFixerInterface;
-use PhpCsFixer\FixerConfiguration\FixerConfigurationResolverRootless;
+use PhpCsFixer\FixerConfiguration\FixerConfigurationResolver;
 use PhpCsFixer\FixerConfiguration\FixerOptionBuilder;
 use PhpCsFixer\FixerDefinition\CodeSample;
 use PhpCsFixer\FixerDefinition\FixerDefinition;
@@ -41,7 +41,7 @@ final class RandomApiMigrationFixer extends AbstractFunctionReferenceFixer imple
     /**
      * {@inheritdoc}
      */
-    public function configure(array $configuration = null)
+    public function configure(array $configuration)
     {
         parent::configure($configuration);
 
@@ -133,7 +133,7 @@ final class RandomApiMigrationFixer extends AbstractFunctionReferenceFixer imple
      */
     protected function createConfigurationDefinition()
     {
-        return new FixerConfigurationResolverRootless('replacements', [
+        return new FixerConfigurationResolver([
             (new FixerOptionBuilder('replacements', 'Mapping between replaced functions with the new ones.'))
                 ->setAllowedTypes(['array'])
                 ->setAllowedValues([static function ($value) {

+ 1 - 1
src/Fixer/ArrayNotation/ArraySyntaxFixer.php

@@ -38,7 +38,7 @@ final class ArraySyntaxFixer extends AbstractFixer implements ConfigurationDefin
     /**
      * {@inheritdoc}
      */
-    public function configure(array $configuration = null)
+    public function configure(array $configuration)
     {
         parent::configure($configuration);
 

+ 1 - 1
src/Fixer/ClassNotation/ClassAttributesSeparationFixer.php

@@ -42,7 +42,7 @@ final class ClassAttributesSeparationFixer extends AbstractFixer implements Conf
     /**
      * {@inheritdoc}
      */
-    public function configure(array $configuration = null)
+    public function configure(array $configuration)
     {
         parent::configure($configuration);
 

+ 1 - 1
src/Fixer/ClassNotation/FinalInternalClassFixer.php

@@ -33,7 +33,7 @@ final class FinalInternalClassFixer extends AbstractFixer implements Configurati
     /**
      * {@inheritdoc}
      */
-    public function configure(array $configuration = null)
+    public function configure(array $configuration)
     {
         parent::configure($configuration);
 

Some files were not shown because too many files changed in this diff