Skip to content

Latest commit

 

History

History
47 lines (33 loc) · 1.22 KB

use_arrow_functions.rst

File metadata and controls

47 lines (33 loc) · 1.22 KB

Rule use_arrow_functions

Anonymous functions with return as the only 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
 <?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:

References

The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.