1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- ============================
- Rule ``use_arrow_functions``
- ============================
- Anonymous functions with one-liner return statement must use arrow functions.
- Warning
- -------
- Using this rule is risky
- ~~~~~~~~~~~~~~~~~~~~~~~~
- Risky when using ``isset()`` on outside variables that are not imported with
- ``use ()``.
- Examples
- --------
- Example #1
- ~~~~~~~~~~
- .. code-block:: diff
- --- Original
- +++ New
- <?php
- -foo(function ($a) use ($b) {
- - return $a + $b;
- -});
- +foo(fn ($a) => $a + $b);
- Rule sets
- ---------
- The rule is part of the following rule sets:
- - `@PHP74Migration:risky <./../../ruleSets/PHP74MigrationRisky.rst>`_
- - `@PHP80Migration:risky <./../../ruleSets/PHP80MigrationRisky.rst>`_
- - `@PHP82Migration:risky <./../../ruleSets/PHP82MigrationRisky.rst>`_
- References
- ----------
- - Fixer class: `PhpCsFixer\\Fixer\\FunctionNotation\\UseArrowFunctionsFixer <./../../../src/Fixer/FunctionNotation/UseArrowFunctionsFixer.php>`_
- - Test class: `PhpCsFixer\\Tests\\Fixer\\FunctionNotation\\UseArrowFunctionsFixerTest <./../../../tests/Fixer/FunctionNotation/UseArrowFunctionsFixerTest.php>`_
- The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.
|