no_unreachable_default_argument_value.rst 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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:: Using this rule is risky.
  7. Modifies the signature of functions; therefore risky when using systems (such
  8. as some Symfony components) that rely on those (for example through
  9. reflection).
  10. Examples
  11. --------
  12. Example #1
  13. ~~~~~~~~~~
  14. .. code-block:: diff
  15. --- Original
  16. +++ New
  17. @@ -1,2 +1,2 @@
  18. <?php
  19. -function example($foo = "two words", $bar) {}
  20. +function example($foo, $bar) {}
  21. Rule sets
  22. ---------
  23. The rule is part of the following rule sets:
  24. @PHP80Migration:risky
  25. Using the `@PHP80Migration:risky <./../../ruleSets/PHP80MigrationRisky.rst>`_ rule set will enable the ``no_unreachable_default_argument_value`` rule.
  26. @PhpCsFixer:risky
  27. Using the `@PhpCsFixer:risky <./../../ruleSets/PhpCsFixerRisky.rst>`_ rule set will enable the ``no_unreachable_default_argument_value`` rule.