From 4ef68f7f30b484e24a2e0959ddf5d6c0368b9e15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=D0=B8=D0=BC=20=D0=A1=D0=BF=D0=B8?= =?UTF-8?q?=D1=80=D0=BA=D0=BE=D0=B2?= Date: Wed, 7 Jan 2026 14:52:09 +0400 Subject: [PATCH 1/4] Add an example for closure with an empty body --- spec.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spec.md b/spec.md index c478084..4b9cf6d 100644 --- a/spec.md +++ b/spec.md @@ -1399,6 +1399,13 @@ $closureWithArgsVarsAndReturn = function ($arg1, $arg2) use ($var1, $var2): bool }; ``` +If a closure contains no statements or comments then the body SHOULD be abbreviated +as `{}` and placed on the same line as the previous symbol, separated by a space. For example: + +```php +$noOpClosure = function () {}; +``` + Argument lists and variable lists MAY be split across multiple lines, where each subsequent line is indented once. When doing so, the first item in the list MUST be on the next line, and there MUST be only one argument or variable From 3bb12a7c21456bf329d847d3076a885b18a26968 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=D0=B8=D0=BC=20=D0=A1=D0=BF=D0=B8?= =?UTF-8?q?=D1=80=D0=BA=D0=BE=D0=B2?= Date: Thu, 15 Jan 2026 12:19:25 +0400 Subject: [PATCH 2/4] CR fix --- spec.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/spec.md b/spec.md index 4b9cf6d..b3fd357 100644 --- a/spec.md +++ b/spec.md @@ -1399,11 +1399,10 @@ $closureWithArgsVarsAndReturn = function ($arg1, $arg2) use ($var1, $var2): bool }; ``` -If a closure contains no statements or comments then the body SHOULD be abbreviated -as `{}` and placed on the same line as the previous symbol, separated by a space. For example: +If a closure contains no statements, MUST use the short-hand syntax: ```php -$noOpClosure = function () {}; +fn() => null; ``` Argument lists and variable lists MAY be split across multiple lines, where From 07e046712815594c9818a0c8010760d50ffbd6bf Mon Sep 17 00:00:00 2001 From: Maksim Spirkov <63721828+mspirkov@users.noreply.github.com> Date: Thu, 15 Jan 2026 20:06:34 +0400 Subject: [PATCH 3/4] Update spec.md Co-authored-by: Larry Garfield --- spec.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec.md b/spec.md index b3fd357..33989aa 100644 --- a/spec.md +++ b/spec.md @@ -1399,7 +1399,7 @@ $closureWithArgsVarsAndReturn = function ($arg1, $arg2) use ($var1, $var2): bool }; ``` -If a closure contains no statements, MUST use the short-hand syntax: +If a closure contains no statements, it MUST use the "arrow function" style syntax: ```php fn() => null; From 6794b0a4837180a20e6cc8dd5cd4970efeb61bd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=D0=B8=D0=BC=20=D0=A1=D0=BF=D0=B8?= =?UTF-8?q?=D1=80=D0=BA=D0=BE=D0=B2?= Date: Tue, 20 Jan 2026 23:55:20 +0400 Subject: [PATCH 4/4] Allow 2 syntaxes --- spec.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/spec.md b/spec.md index 33989aa..50fc26e 100644 --- a/spec.md +++ b/spec.md @@ -1399,10 +1399,17 @@ $closureWithArgsVarsAndReturn = function ($arg1, $arg2) use ($var1, $var2): bool }; ``` -If a closure contains no statements, it MUST use the "arrow function" style syntax: +If a closure contains no statements, then the body MUST be abbreviated as `{}` and placed on the same +line as the previous symbol, separated by a space: ```php -fn() => null; +$noOpFunction = function () {}; +``` + +If possible, empty-body closures SHOULD be replaced with arrow functions: + +```php +$noOpFunction = fn() => null; ``` Argument lists and variable lists MAY be split across multiple lines, where