Browse Source

Mark NoUnreachableDefaultArgumentValueFixer as risky.

SpacePossum 8 years ago
parent
commit
bae7bc8956
2 changed files with 24 additions and 8 deletions
  1. 2 1
      README.rst
  2. 22 7
      src/Fixer/FunctionNotation/NoUnreachableDefaultArgumentValueFixer.php

+ 2 - 1
README.rst

@@ -426,8 +426,9 @@ Choose from the list of available rules:
    | *Rule is: configurable.*
 
 * **no_unreachable_default_argument_value**
-   | In method arguments there must not be arguments with default values
+   | In function arguments there must not be arguments with default values
    | before non-default ones.
+   | *Rule is: risky.*
 
 * **no_unused_imports** [@Symfony]
    | Unused use statements must be removed.

+ 22 - 7
src/Fixer/FunctionNotation/NoUnreachableDefaultArgumentValueFixer.php

@@ -25,11 +25,6 @@ use PhpCsFixer\Tokenizer\Tokens;
  */
 final class NoUnreachableDefaultArgumentValueFixer extends AbstractFixer
 {
-    public function isCandidate(Tokens $tokens)
-    {
-        return $tokens->isTokenKindFound(T_FUNCTION);
-    }
-
     /**
      * {@inheritdoc}
      */
@@ -53,17 +48,37 @@ final class NoUnreachableDefaultArgumentValueFixer extends AbstractFixer
     public function getDefinition()
     {
         return new FixerDefinition(
-            'In method arguments there must not be arguments with default values before non-default ones.',
+            'In function arguments there must not be arguments with default values before non-default ones.',
             array(
                 new CodeSample(
                     '<?php
 function example($foo = "two words", $bar) {}
 '
                 ),
-            )
+            ),
+            null,
+            null,
+            null,
+            'Modifies the signature of functions; therefor risky when using systems (such as some Symfony components) that rely on those (for example through reflection).'
         );
     }
 
+    /**
+     * {@inheritdoc}
+     */
+    public function isCandidate(Tokens $tokens)
+    {
+        return $tokens->isTokenKindFound(T_FUNCTION);
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function isRisky()
+    {
+        return true;
+    }
+
     /**
      * @param Tokens $tokens
      * @param int    $startIndex