no_unreachable_default_argument_value.rst 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. ==============================================
  2. Rule ``no_unreachable_default_argument_value``
  3. ==============================================
  4. In function arguments there must not be arguments with default values before
  5. non-default ones.
  6. Warning
  7. -------
  8. Using this rule is risky
  9. ~~~~~~~~~~~~~~~~~~~~~~~~
  10. Modifies the signature of functions; therefore risky when using systems (such as
  11. some Symfony components) that rely on those (for example through reflection).
  12. Examples
  13. --------
  14. Example #1
  15. ~~~~~~~~~~
  16. .. code-block:: diff
  17. --- Original
  18. +++ New
  19. <?php
  20. -function example($foo = "two words", $bar) {}
  21. +function example($foo, $bar) {}
  22. Rule sets
  23. ---------
  24. The rule is part of the following rule sets:
  25. - `@PER-CS1.0:risky <./../../ruleSets/PER-CS1.0Risky.rst>`_
  26. - `@PER-CS2.0:risky <./../../ruleSets/PER-CS2.0Risky.rst>`_
  27. - `@PER-CS:risky <./../../ruleSets/PER-CSRisky.rst>`_
  28. - `@PER:risky <./../../ruleSets/PERRisky.rst>`_
  29. - `@PHP80Migration:risky <./../../ruleSets/PHP80MigrationRisky.rst>`_
  30. - `@PSR12:risky <./../../ruleSets/PSR12Risky.rst>`_
  31. - `@PhpCsFixer:risky <./../../ruleSets/PhpCsFixerRisky.rst>`_
  32. - `@Symfony:risky <./../../ruleSets/SymfonyRisky.rst>`_
  33. References
  34. ----------
  35. - Fixer class: `PhpCsFixer\\Fixer\\FunctionNotation\\NoUnreachableDefaultArgumentValueFixer <./../../../src/Fixer/FunctionNotation/NoUnreachableDefaultArgumentValueFixer.php>`_
  36. - Test class: `PhpCsFixer\\Tests\\Fixer\\FunctionNotation\\NoUnreachableDefaultArgumentValueFixerTest <./../../../tests/Fixer/FunctionNotation/NoUnreachableDefaultArgumentValueFixerTest.php>`_
  37. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.