Skip to content

Latest commit

 

History

History
38 lines (27 loc) · 900 Bytes

use_arrow_functions.rst

File metadata and controls

38 lines (27 loc) · 900 Bytes

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

--- Original
+++ New
@@ -1,4 +1,2 @@
 <?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

Using the @PHP74Migration:risky rule set will enable the use_arrow_functions rule.

@PHP80Migration:risky

Using the @PHP80Migration:risky rule set will enable the use_arrow_functions rule.