use_arrow_functions.rst 729 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. ============================
  2. Rule ``use_arrow_functions``
  3. ============================
  4. Anonymous functions with one-liner return statement must use arrow functions.
  5. Warning
  6. -------
  7. Using this rule is risky
  8. ~~~~~~~~~~~~~~~~~~~~~~~~
  9. Risky when using ``isset()`` on outside variables that are not imported with
  10. ``use ()``.
  11. Examples
  12. --------
  13. Example #1
  14. ~~~~~~~~~~
  15. .. code-block:: diff
  16. --- Original
  17. +++ New
  18. <?php
  19. -foo(function ($a) use ($b) {
  20. - return $a + $b;
  21. -});
  22. +foo(fn ($a) => $a + $b);
  23. Rule sets
  24. ---------
  25. The rule is part of the following rule sets:
  26. - `@PHP74Migration:risky <./../../ruleSets/PHP74MigrationRisky.rst>`_
  27. - `@PHP80Migration:risky <./../../ruleSets/PHP80MigrationRisky.rst>`_