no_unreachable_default_argument_value.rst 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. - `@PHP82Migration:risky <./../../ruleSets/PHP82MigrationRisky.rst>`_
  31. - `@PSR12:risky <./../../ruleSets/PSR12Risky.rst>`_
  32. - `@PhpCsFixer:risky <./../../ruleSets/PhpCsFixerRisky.rst>`_
  33. - `@Symfony:risky <./../../ruleSets/SymfonyRisky.rst>`_
  34. References
  35. ----------
  36. - Fixer class: `PhpCsFixer\\Fixer\\FunctionNotation\\NoUnreachableDefaultArgumentValueFixer <./../../../src/Fixer/FunctionNotation/NoUnreachableDefaultArgumentValueFixer.php>`_
  37. - Test class: `PhpCsFixer\\Tests\\Fixer\\FunctionNotation\\NoUnreachableDefaultArgumentValueFixerTest <./../../../tests/Fixer/FunctionNotation/NoUnreachableDefaultArgumentValueFixerTest.php>`_
  38. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.