You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by ju...@apache.org on 2020/12/31 18:47:07 UTC

[netbeans] branch master updated: [NETBEANS-5172] Fix anonymous function formatting

This is an automated email from the ASF dual-hosted git repository.

junichi11 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git


The following commit(s) were added to refs/heads/master by this push:
     new 3a8f505  [NETBEANS-5172] Fix anonymous function formatting
     new bad721a  Merge pull request #2614 from KacerCZ/netbeans-5172-anonymous-function-format
3a8f505 is described below

commit 3a8f50588194ee4d03453060c455817947116188
Author: Tomas Prochazka <ka...@razdva.cz>
AuthorDate: Tue Dec 29 09:49:07 2020 +0100

    [NETBEANS-5172] Fix anonymous function formatting
    
    https://issues.apache.org/jira/browse/NETBEANS-5172
    
    - Enabled and fixed tests for spaces around keyword.
    - Fixed formatting of anonymous functions.
    - Updated expected formatting results in rest of tests.
    
    Sample code:
    ```php
    $lambda = function($param) use($parent) {
        echo "$param\n";
    };
    ```
    
    Formatted after fix:
    ```php
    $lambda = function ($param) use ($parent) {
        echo "$param\n";
    };
    ```
---
 .../modules/php/editor/indent/CodeStyle.java       |  4 ++
 .../modules/php/editor/indent/FmtOptions.java      |  2 +
 .../modules/php/editor/indent/FormatToken.java     |  1 +
 .../modules/php/editor/indent/FormatVisitor.java   |  1 +
 .../modules/php/editor/indent/TokenFormatter.java  |  5 ++
 .../modules/php/editor/indent/ui/Bundle.properties |  1 +
 .../modules/php/editor/indent/ui/FmtSpaces.java    |  1 +
 .../modules/php/editor/indent/ui/Spaces.php        |  4 ++
 .../formatting/arrowFunctions01.php.formatted      |  6 +-
 .../testfiles/formatting/issue176453.php.formatted |  2 +-
 .../testfiles/formatting/issue247047.php.formatted |  2 +-
 .../testfiles/formatting/issue259111.php.formatted | 10 +--
 ...spaceAroundUnionTypeSeparator_01a.php.formatted |  2 +-
 ...spaceAroundUnionTypeSeparator_01b.php.formatted |  2 +-
 ...spaceAroundUnionTypeSeparator_02a.php.formatted |  2 +-
 ...spaceAroundUnionTypeSeparator_02b.php.formatted |  2 +-
 .../spaces/spaceAroundReturnType04.php.formatted   |  2 +-
 .../spaces/spaceAroundReturnType05.php.formatted   |  2 +-
 .../spaces/spaceAroundReturnType06.php.formatted   |  2 +-
 .../spaces/spaceBeforeAnonymousFunction01.php      | 12 ++++
 .../spaceBeforeAnonymousFunction01.php.formatted   | 10 +++
 .../spaces/spaceBeforeAnonymousFunction02.php      | 12 ++++
 .../spaceBeforeAnonymousFunction02.php.formatted   | 10 +++
 .../spaces/spaceCheckAfterKeywords01.php           |  5 ++
 .../spaces/spaceCheckAfterKeywords01.php.formatted | 11 +++-
 .../spaces/spaceCheckAfterKeywords02.php           |  8 +++
 .../spaces/spaceCheckAfterKeywords02.php.formatted | 24 +++++---
 .../functionCallTrailingCommas01.php.formatted     |  2 +-
 .../functionCallTrailingCommas02.php.formatted     |  2 +-
 .../functionCallTrailingCommas03.php.formatted     |  2 +-
 .../functionCallTrailingCommas04.php.formatted     |  2 +-
 .../closureInArrayAlways01.php.formatted           | 64 +++++++++----------
 .../closureInArrayAlways02.php.formatted           | 72 +++++++++++-----------
 .../closureInArrayNever01.php.formatted            | 64 +++++++++----------
 .../closureInArrayNever02.php.formatted            | 72 +++++++++++-----------
 .../declarationsAlways01.php.formatted             | 10 +--
 .../declarationsAlways02.php.formatted             | 10 +--
 .../declarationsNever01.php.formatted              | 10 +--
 .../declarationsNever02.php.formatted              | 10 +--
 .../php/editor/indent/PHPFormatterSpacesTest.java  | 15 ++++-
 40 files changed, 290 insertions(+), 190 deletions(-)

diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/indent/CodeStyle.java b/php/php.editor/src/org/netbeans/modules/php/editor/indent/CodeStyle.java
index 8230a2a..f57740f 100644
--- a/php/php.editor/src/org/netbeans/modules/php/editor/indent/CodeStyle.java
+++ b/php/php.editor/src/org/netbeans/modules/php/editor/indent/CodeStyle.java
@@ -262,6 +262,10 @@ public final class CodeStyle {
         return preferences.getBoolean(SPACE_BEFORE_ANONYMOUS_CLASS_PAREN, getDefaultAsBoolean(SPACE_BEFORE_ANONYMOUS_CLASS_PAREN));
     }
 
+    public boolean spaceBeforeAnonymousFunctionParen() {
+        return preferences.getBoolean(SPACE_BEFORE_ANONYMOUS_FUNCTION_PAREN, getDefaultAsBoolean(SPACE_BEFORE_ANONYMOUS_FUNCTION_PAREN));
+    }
+
     public boolean spaceBeforeMethodDeclParen() {
         return preferences.getBoolean(SPACE_BEFORE_METHOD_DECL_PAREN, getDefaultAsBoolean(SPACE_BEFORE_METHOD_DECL_PAREN));
     }
diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/indent/FmtOptions.java b/php/php.editor/src/org/netbeans/modules/php/editor/indent/FmtOptions.java
index 5d600fc..6d92b78 100644
--- a/php/php.editor/src/org/netbeans/modules/php/editor/indent/FmtOptions.java
+++ b/php/php.editor/src/org/netbeans/modules/php/editor/indent/FmtOptions.java
@@ -114,6 +114,7 @@ public final class FmtOptions {
     public static final String SPACE_BEFORE_CATCH = "spaceBeforeCatch"; //NOI18N
     public static final String SPACE_BEFORE_FINALLY = "spaceBeforeFinally"; //NOI18N
     public static final String SPACE_BEFORE_ANONYMOUS_CLASS_PAREN = "spaceBeforeAnonymousClassParen"; //NOI18N
+    public static final String SPACE_BEFORE_ANONYMOUS_FUNCTION_PAREN = "spaceBeforeAnonymousFunctionParen"; //NOI18N
     public static final String SPACE_BEFORE_METHOD_DECL_PAREN = "spaceBeforeMethodDeclParen"; //NOI18N
     public static final String SPACE_BEFORE_METHOD_CALL_PAREN = "spaceBeforeMethodCallParen"; //NOI18N
     public static final String SPACE_BEFORE_IF_PAREN = "spaceBeforeIfParen"; //NOI18N
@@ -292,6 +293,7 @@ public final class FmtOptions {
             {SPACE_BEFORE_CATCH, TRUE},
             {SPACE_BEFORE_FINALLY, TRUE},
             {SPACE_BEFORE_ANONYMOUS_CLASS_PAREN, FALSE},
+            {SPACE_BEFORE_ANONYMOUS_FUNCTION_PAREN, TRUE},
             {SPACE_BEFORE_METHOD_DECL_PAREN, FALSE},
             {SPACE_BEFORE_METHOD_CALL_PAREN, FALSE},
             {SPACE_BEFORE_IF_PAREN, TRUE},
diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/indent/FormatToken.java b/php/php.editor/src/org/netbeans/modules/php/editor/indent/FormatToken.java
index 16b5c60..1f8144d 100644
--- a/php/php.editor/src/org/netbeans/modules/php/editor/indent/FormatToken.java
+++ b/php/php.editor/src/org/netbeans/modules/php/editor/indent/FormatToken.java
@@ -60,6 +60,7 @@ public class FormatToken {
         WHITESPACE_AFTER_ASSIGN_OP,
         WHITESPACE_AROUND_KEY_VALUE_OP,
         WHITESPACE_BEFORE_ANONYMOUS_CLASS_PAREN,
+        WHITESPACE_BEFORE_ANONYMOUS_FUNCTION_PAREN,
         WHITESPACE_BEFORE_METHOD_DEC_PAREN,
         WHITESPACE_BEFORE_METHOD_CALL_PAREN,
         WHITESPACE_BEFORE_IF_PAREN,
diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/indent/FormatVisitor.java b/php/php.editor/src/org/netbeans/modules/php/editor/indent/FormatVisitor.java
index 9172ede..09f89ab 100644
--- a/php/php.editor/src/org/netbeans/modules/php/editor/indent/FormatVisitor.java
+++ b/php/php.editor/src/org/netbeans/modules/php/editor/indent/FormatVisitor.java
@@ -2080,6 +2080,7 @@ public class FormatVisitor extends DefaultVisitor {
                         tokens.add(new FormatToken(FormatToken.Kind.TEXT, ts.offset(), ts.token().text().toString()));
                         tokens.add(new FormatToken(FormatToken.Kind.WHITESPACE_WITHIN_METHOD_DECL_PARENS, ts.offset() + ts.token().length()));
                     } else if (parent instanceof LambdaFunctionDeclaration) {
+                        tokens.add(new FormatToken(FormatToken.Kind.WHITESPACE_BEFORE_ANONYMOUS_FUNCTION_PAREN, ts.offset()));
                         tokens.add(new FormatToken(FormatToken.Kind.TEXT, ts.offset(), ts.token().text().toString()));
                         tokens.add(new FormatToken(FormatToken.Kind.WHITESPACE_WITHIN_METHOD_DECL_PARENS, ts.offset() + ts.token().length()));
                     } else if (parent instanceof FunctionInvocation || parent instanceof MethodInvocation || parent instanceof ClassInstanceCreation) {
diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/indent/TokenFormatter.java b/php/php.editor/src/org/netbeans/modules/php/editor/indent/TokenFormatter.java
index 62f8f0f..60682cf 100644
--- a/php/php.editor/src/org/netbeans/modules/php/editor/indent/TokenFormatter.java
+++ b/php/php.editor/src/org/netbeans/modules/php/editor/indent/TokenFormatter.java
@@ -94,6 +94,7 @@ public class TokenFormatter {
         public boolean spaceBeforeFinallyLeftBrace;
         public boolean spaceBeforeUseTraitBodyLeftBrace;
         public boolean spaceBeforeAnonymousClassParen;
+        public boolean spaceBeforeAnonymousFunctionParen;
         public boolean spaceBeforeMethodDeclParen;
         public boolean spaceBeforeMethodCallParen;
         public boolean spaceBeforeIfParen;
@@ -240,6 +241,7 @@ public class TokenFormatter {
             spaceBeforeUseTraitBodyLeftBrace = codeStyle.spaceBeforeUseTraitBodyLeftBrace();
 
             spaceBeforeAnonymousClassParen = codeStyle.spaceBeforeAnonymousClassParen();
+            spaceBeforeAnonymousFunctionParen = codeStyle.spaceBeforeAnonymousFunctionParen();
             spaceBeforeMethodDeclParen = codeStyle.spaceBeforeMethodDeclParen();
             spaceBeforeMethodCallParen = codeStyle.spaceBeforeMethodCallParen();
             spaceBeforeIfParen = codeStyle.spaceBeforeIfParen();
@@ -1201,6 +1203,9 @@ public class TokenFormatter {
                                     case WHITESPACE_BEFORE_ANONYMOUS_CLASS_PAREN:
                                         countSpaces = docOptions.spaceBeforeAnonymousClassParen ? 1 : 0;
                                         break;
+                                    case WHITESPACE_BEFORE_ANONYMOUS_FUNCTION_PAREN:
+                                        countSpaces = docOptions.spaceBeforeAnonymousFunctionParen ? 1 : 0;
+                                        break;
                                     case WHITESPACE_BEFORE_METHOD_DEC_PAREN:
                                         countSpaces = docOptions.spaceBeforeMethodDeclParen ? 1 : 0;
                                         break;
diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/indent/ui/Bundle.properties b/php/php.editor/src/org/netbeans/modules/php/editor/indent/ui/Bundle.properties
index 29d24f8..9473b4f 100644
--- a/php/php.editor/src/org/netbeans/modules/php/editor/indent/ui/Bundle.properties
+++ b/php/php.editor/src/org/netbeans/modules/php/editor/indent/ui/Bundle.properties
@@ -62,6 +62,7 @@ LBL_spaceBeforeFinally="finally"
 
 LBL_BeforeParentheses=Before Parentheses
 LBL_spaceBeforeAnonymousClassParen=Anonymous Class
+LBL_spaceBeforeAnonymousFunctionParen=Anonymous Function
 LBL_spaceBeforeMethodDeclParen=Method / Function Declaration
 LBL_spaceBeforeMethodCallParen=Method / Function Call
 LBL_spaceBeforeIfParen="if", "elseif"
diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/indent/ui/FmtSpaces.java b/php/php.editor/src/org/netbeans/modules/php/editor/indent/ui/FmtSpaces.java
index 765187e..114336e 100644
--- a/php/php.editor/src/org/netbeans/modules/php/editor/indent/ui/FmtSpaces.java
+++ b/php/php.editor/src/org/netbeans/modules/php/editor/indent/ui/FmtSpaces.java
@@ -250,6 +250,7 @@ public final class FmtSpaces extends JPanel implements TreeCellRenderer, MouseLi
 
             new Item("BeforeParentheses",                       // NOI18N
                 new Item(SPACE_BEFORE_ANONYMOUS_CLASS_PAREN),
+                new Item(SPACE_BEFORE_ANONYMOUS_FUNCTION_PAREN),
                 new Item(SPACE_BEFORE_METHOD_DECL_PAREN),
                 new Item(SPACE_BEFORE_METHOD_CALL_PAREN),
                 new Item(SPACE_BEFORE_IF_PAREN),
diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/indent/ui/Spaces.php b/php/php.editor/src/org/netbeans/modules/php/editor/indent/ui/Spaces.php
index 8510702..bcb7c52 100644
--- a/php/php.editor/src/org/netbeans/modules/php/editor/indent/ui/Spaces.php
+++ b/php/php.editor/src/org/netbeans/modules/php/editor/indent/ui/Spaces.php
@@ -106,6 +106,10 @@ public function nullsafeOperatorExample(object $object){
 }
 }
 
+$anonymousFunc = function ($arg) use ($param):int {
+    return 1;
+};
+
 // Wrapping: Method Call Arguments must be set
 (new Example())->alignParamsExample('one',
         'two', 'three',
diff --git a/php/php.editor/test/unit/data/testfiles/formatting/arrowFunctions01.php.formatted b/php/php.editor/test/unit/data/testfiles/formatting/arrowFunctions01.php.formatted
index 71d22e5..94610de 100644
--- a/php/php.editor/test/unit/data/testfiles/formatting/arrowFunctions01.php.formatted
+++ b/php/php.editor/test/unit/data/testfiles/formatting/arrowFunctions01.php.formatted
@@ -26,7 +26,7 @@ $fn0 = fn() => 100;
 
 $fn1a = fn(int $x) => $x + $y;
 
-$fn1b = function($x) use ($y) {
+$fn1b = function ($x) use ($y) {
     return $x + $y;
 };
 
@@ -63,13 +63,13 @@ $af = fn() => fn() => $y;
 $af = fn() =>
         fn() => $y;
 (fn() => fn() => $y)()();
-(fn() => function() use ($y) {
+(fn() => function () use ($y) {
     return $y;
 })()();
 
 $af = fn(int $x): callable => fn(int $z): int => $x + $y * $z;
 $af = fn(ArrowFunctions $x): callable => fn(?ArrowFunctions $z): ?ArrowFunctions => new ArrowFunctions();
-fn() => function($x) use ($y) {
+fn() => function ($x) use ($y) {
     return $x + $y;
 };
 
diff --git a/php/php.editor/test/unit/data/testfiles/formatting/issue176453.php.formatted b/php/php.editor/test/unit/data/testfiles/formatting/issue176453.php.formatted
index 95b061d..da2c95e 100644
--- a/php/php.editor/test/unit/data/testfiles/formatting/issue176453.php.formatted
+++ b/php/php.editor/test/unit/data/testfiles/formatting/issue176453.php.formatted
@@ -4,7 +4,7 @@ echo preg_replace_callback('~-([a-z])~', function ($match) {
   return strtoupper($match[1]);
 }, 'hello-world');
 
-$greet = function($name) {
+$greet = function ($name) {
   printf("Hello %s\r\n", $name);
 };
 ?>
diff --git a/php/php.editor/test/unit/data/testfiles/formatting/issue247047.php.formatted b/php/php.editor/test/unit/data/testfiles/formatting/issue247047.php.formatted
index 824e981..857b5db 100644
--- a/php/php.editor/test/unit/data/testfiles/formatting/issue247047.php.formatted
+++ b/php/php.editor/test/unit/data/testfiles/formatting/issue247047.php.formatted
@@ -13,7 +13,7 @@ class A {
 
     public function func() {
         [
-            'func' => function() {
+            'func' => function () {
                 $array = [];
             }
         ];
diff --git a/php/php.editor/test/unit/data/testfiles/formatting/issue259111.php.formatted b/php/php.editor/test/unit/data/testfiles/formatting/issue259111.php.formatted
index 50e5d97..e88d1ee 100644
--- a/php/php.editor/test/unit/data/testfiles/formatting/issue259111.php.formatted
+++ b/php/php.editor/test/unit/data/testfiles/formatting/issue259111.php.formatted
@@ -1,22 +1,22 @@
 <?php
 
-$func1 = function() {
+$func1 = function () {
     echo "anonymous function1" . PHP_EOL;
 };
 ($func1)();
 
-$func2 = function() {
-    return function() {
+$func2 = function () {
+    return function () {
         echo "anonymous function2" . PHP_EOL;
     };
 };
 (($func2)())();
 
-(function() {
+(function () {
     echo "anonymous function3" . PHP_EOL;
 })();
 
-(function($param1, $param2) {
+(function ($param1, $param2) {
     echo "anonymous function4" . PHP_EOL;
 })("param1", "param2");
 
diff --git a/php/php.editor/test/unit/data/testfiles/formatting/spaces/php80/spaceAroundUnionTypeSeparator_01a.php.formatted b/php/php.editor/test/unit/data/testfiles/formatting/spaces/php80/spaceAroundUnionTypeSeparator_01a.php.formatted
index c074b5e..f330241 100644
--- a/php/php.editor/test/unit/data/testfiles/formatting/spaces/php80/spaceAroundUnionTypeSeparator_01a.php.formatted
+++ b/php/php.editor/test/unit/data/testfiles/formatting/spaces/php80/spaceAroundUnionTypeSeparator_01a.php.formatted
@@ -23,7 +23,7 @@ function union_types(int | float | bool | string | array | object | iterable | c
     return null;
 }
 
-$closure = function(Type1 | \Union\Type2 | null $param1, callable | false $prame2): \Union\Type1 | int | float | null {
+$closure = function (Type1 | \Union\Type2 | null $param1, callable | false $prame2): \Union\Type1 | int | float | null {
     return null;
 };
 
diff --git a/php/php.editor/test/unit/data/testfiles/formatting/spaces/php80/spaceAroundUnionTypeSeparator_01b.php.formatted b/php/php.editor/test/unit/data/testfiles/formatting/spaces/php80/spaceAroundUnionTypeSeparator_01b.php.formatted
index 0301cf5..7cd3f8a 100644
--- a/php/php.editor/test/unit/data/testfiles/formatting/spaces/php80/spaceAroundUnionTypeSeparator_01b.php.formatted
+++ b/php/php.editor/test/unit/data/testfiles/formatting/spaces/php80/spaceAroundUnionTypeSeparator_01b.php.formatted
@@ -23,7 +23,7 @@ function union_types(int|float|bool|string|array|object|iterable|callable|Type1|
     return null;
 }
 
-$closure = function(Type1|\Union\Type2|null $param1, callable|false $prame2): \Union\Type1|int|float|null {
+$closure = function (Type1|\Union\Type2|null $param1, callable|false $prame2): \Union\Type1|int|float|null {
     return null;
 };
 
diff --git a/php/php.editor/test/unit/data/testfiles/formatting/spaces/php80/spaceAroundUnionTypeSeparator_02a.php.formatted b/php/php.editor/test/unit/data/testfiles/formatting/spaces/php80/spaceAroundUnionTypeSeparator_02a.php.formatted
index c074b5e..f330241 100644
--- a/php/php.editor/test/unit/data/testfiles/formatting/spaces/php80/spaceAroundUnionTypeSeparator_02a.php.formatted
+++ b/php/php.editor/test/unit/data/testfiles/formatting/spaces/php80/spaceAroundUnionTypeSeparator_02a.php.formatted
@@ -23,7 +23,7 @@ function union_types(int | float | bool | string | array | object | iterable | c
     return null;
 }
 
-$closure = function(Type1 | \Union\Type2 | null $param1, callable | false $prame2): \Union\Type1 | int | float | null {
+$closure = function (Type1 | \Union\Type2 | null $param1, callable | false $prame2): \Union\Type1 | int | float | null {
     return null;
 };
 
diff --git a/php/php.editor/test/unit/data/testfiles/formatting/spaces/php80/spaceAroundUnionTypeSeparator_02b.php.formatted b/php/php.editor/test/unit/data/testfiles/formatting/spaces/php80/spaceAroundUnionTypeSeparator_02b.php.formatted
index 0301cf5..7cd3f8a 100644
--- a/php/php.editor/test/unit/data/testfiles/formatting/spaces/php80/spaceAroundUnionTypeSeparator_02b.php.formatted
+++ b/php/php.editor/test/unit/data/testfiles/formatting/spaces/php80/spaceAroundUnionTypeSeparator_02b.php.formatted
@@ -23,7 +23,7 @@ function union_types(int|float|bool|string|array|object|iterable|callable|Type1|
     return null;
 }
 
-$closure = function(Type1|\Union\Type2|null $param1, callable|false $prame2): \Union\Type1|int|float|null {
+$closure = function (Type1|\Union\Type2|null $param1, callable|false $prame2): \Union\Type1|int|float|null {
     return null;
 };
 
diff --git a/php/php.editor/test/unit/data/testfiles/formatting/spaces/spaceAroundReturnType04.php.formatted b/php/php.editor/test/unit/data/testfiles/formatting/spaces/spaceAroundReturnType04.php.formatted
index cc247f0..6ca5d95 100644
--- a/php/php.editor/test/unit/data/testfiles/formatting/spaces/spaceAroundReturnType04.php.formatted
+++ b/php/php.editor/test/unit/data/testfiles/formatting/spaces/spaceAroundReturnType04.php.formatted
@@ -1,5 +1,5 @@
 <?php
 
-function(): array {
+function (): array {
     
 };
diff --git a/php/php.editor/test/unit/data/testfiles/formatting/spaces/spaceAroundReturnType05.php.formatted b/php/php.editor/test/unit/data/testfiles/formatting/spaces/spaceAroundReturnType05.php.formatted
index c315647..84a2a2d 100644
--- a/php/php.editor/test/unit/data/testfiles/formatting/spaces/spaceAroundReturnType05.php.formatted
+++ b/php/php.editor/test/unit/data/testfiles/formatting/spaces/spaceAroundReturnType05.php.formatted
@@ -1,5 +1,5 @@
 <?php
 
-function(): MyClass {
+function (): MyClass {
     
 };
diff --git a/php/php.editor/test/unit/data/testfiles/formatting/spaces/spaceAroundReturnType06.php.formatted b/php/php.editor/test/unit/data/testfiles/formatting/spaces/spaceAroundReturnType06.php.formatted
index e896e4d..04ab09c 100644
--- a/php/php.editor/test/unit/data/testfiles/formatting/spaces/spaceAroundReturnType06.php.formatted
+++ b/php/php.editor/test/unit/data/testfiles/formatting/spaces/spaceAroundReturnType06.php.formatted
@@ -1,5 +1,5 @@
 <?php
 
-function(): \Company\MyClass {
+function (): \Company\MyClass {
     
 };
diff --git a/php/php.editor/test/unit/data/testfiles/formatting/spaces/spaceBeforeAnonymousFunction01.php b/php/php.editor/test/unit/data/testfiles/formatting/spaces/spaceBeforeAnonymousFunction01.php
new file mode 100644
index 0000000..f3259c8
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/formatting/spaces/spaceBeforeAnonymousFunction01.php
@@ -0,0 +1,12 @@
+<?php
+
+$func1 =    function      ($arg)   use  ($param) {
+    echo "$param\n";
+};
+
+
+$func2 =    function($arg)   use($param) {
+    echo "$param\n";
+};
+
+?>
diff --git a/php/php.editor/test/unit/data/testfiles/formatting/spaces/spaceBeforeAnonymousFunction01.php.formatted b/php/php.editor/test/unit/data/testfiles/formatting/spaces/spaceBeforeAnonymousFunction01.php.formatted
new file mode 100644
index 0000000..bc45d8a
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/formatting/spaces/spaceBeforeAnonymousFunction01.php.formatted
@@ -0,0 +1,10 @@
+<?php
+
+$func1 = function ($arg) use ($param) {
+    echo "$param\n";
+};
+
+$func2 = function ($arg) use ($param) {
+    echo "$param\n";
+};
+?>
diff --git a/php/php.editor/test/unit/data/testfiles/formatting/spaces/spaceBeforeAnonymousFunction02.php b/php/php.editor/test/unit/data/testfiles/formatting/spaces/spaceBeforeAnonymousFunction02.php
new file mode 100644
index 0000000..f3259c8
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/formatting/spaces/spaceBeforeAnonymousFunction02.php
@@ -0,0 +1,12 @@
+<?php
+
+$func1 =    function      ($arg)   use  ($param) {
+    echo "$param\n";
+};
+
+
+$func2 =    function($arg)   use($param) {
+    echo "$param\n";
+};
+
+?>
diff --git a/php/php.editor/test/unit/data/testfiles/formatting/spaces/spaceBeforeAnonymousFunction02.php.formatted b/php/php.editor/test/unit/data/testfiles/formatting/spaces/spaceBeforeAnonymousFunction02.php.formatted
new file mode 100644
index 0000000..f55c50d
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/formatting/spaces/spaceBeforeAnonymousFunction02.php.formatted
@@ -0,0 +1,10 @@
+<?php
+
+$func1 = function($arg) use($param) {
+    echo "$param\n";
+};
+
+$func2 = function($arg) use($param) {
+    echo "$param\n";
+};
+?>
diff --git a/php/php.editor/test/unit/data/testfiles/formatting/spaces/spaceCheckAfterKeywords01.php b/php/php.editor/test/unit/data/testfiles/formatting/spaces/spaceCheckAfterKeywords01.php
index 2840e32..1267c56 100644
--- a/php/php.editor/test/unit/data/testfiles/formatting/spaces/spaceCheckAfterKeywords01.php
+++ b/php/php.editor/test/unit/data/testfiles/formatting/spaces/spaceCheckAfterKeywords01.php
@@ -13,4 +13,9 @@ class               /*fjlajdfla*/           ClassName {
         return   "test"   ;
     }
 }
+
+$lambda =    function      ($param)   use  ($parent) {
+    echo "$param\n";
+};
+
 ?>
diff --git a/php/php.editor/test/unit/data/testfiles/formatting/spaces/spaceCheckAfterKeywords01.php.formatted b/php/php.editor/test/unit/data/testfiles/formatting/spaces/spaceCheckAfterKeywords01.php.formatted
index e183d65..0387037 100644
--- a/php/php.editor/test/unit/data/testfiles/formatting/spaces/spaceCheckAfterKeywords01.php.formatted
+++ b/php/php.editor/test/unit/data/testfiles/formatting/spaces/spaceCheckAfterKeywords01.php.formatted
@@ -1,17 +1,22 @@
 <?php
+
 for (;;) {
     echo "ha";
 }
 
-class /*fjlajdfla*/ ClassName {
-    
+class /* fjlajdfla */ ClassName {
+
     function __construct() {
         
     }
-    
+
     public function test() {
         return "test";
     }
+
 }
 
+$lambda = function ($param) use ($parent) {
+    echo "$param\n";
+};
 ?>
diff --git a/php/php.editor/test/unit/data/testfiles/formatting/spaces/spaceCheckAfterKeywords02.php b/php/php.editor/test/unit/data/testfiles/formatting/spaces/spaceCheckAfterKeywords02.php
index 12a1d78..83d4b3e 100644
--- a/php/php.editor/test/unit/data/testfiles/formatting/spaces/spaceCheckAfterKeywords02.php
+++ b/php/php.editor/test/unit/data/testfiles/formatting/spaces/spaceCheckAfterKeywords02.php
@@ -33,6 +33,14 @@ $greet = function($name) {
       printf("Hello %s\r\n", $name);
     };
 
+$lambda = function($param) use($parent) {
+    echo "$param\n";
+};
+
+$staticLambda = static function($param) use($parent) {
+    echo "$param\n";
+};
+
 
 ?>
 
diff --git a/php/php.editor/test/unit/data/testfiles/formatting/spaces/spaceCheckAfterKeywords02.php.formatted b/php/php.editor/test/unit/data/testfiles/formatting/spaces/spaceCheckAfterKeywords02.php.formatted
index fe87299..fc6ff24 100644
--- a/php/php.editor/test/unit/data/testfiles/formatting/spaces/spaceCheckAfterKeywords02.php.formatted
+++ b/php/php.editor/test/unit/data/testfiles/formatting/spaces/spaceCheckAfterKeywords02.php.formatted
@@ -1,5 +1,6 @@
 <?php
-for ($index = 0;$index < count($array);$index++) {
+
+for ($index = 0; $index < count($array); $index++) {
 //    $a = $index;
 //    $b = $index + 1;
 }
@@ -8,30 +9,37 @@ for (;;) {
     echo "ha";
 }
 
-require_once("DBClass.php");
+require_once ("DBClass.php");
 require_once 'TestClass.php';
 
 $obj = new namespac\Another;
 
-class /*fjlajdfla*/ ClassName {
-    
+class /* fjlajdfla */ ClassName {
+
     function __construct() {
         
     }
-    
+
     public function test() {
         return "test";
     }
-    
+
     private function test2() {
         return;
     }
+
 }
 
 $greet = function ($name) {
-            printf("Hello %s\r\n", $name);
-        };
+    printf("Hello %s\r\n", $name);
+};
 
+$lambda = function ($param) use ($parent) {
+    echo "$param\n";
+};
 
+$staticLambda = static function ($param) use ($parent) {
+    echo "$param\n";
+};
 ?>
 
diff --git a/php/php.editor/test/unit/data/testfiles/formatting/wrapping/functionCallTrailingCommas01.php.formatted b/php/php.editor/test/unit/data/testfiles/formatting/wrapping/functionCallTrailingCommas01.php.formatted
index 1308d34..2dbe7a0 100644
--- a/php/php.editor/test/unit/data/testfiles/formatting/wrapping/functionCallTrailingCommas01.php.formatted
+++ b/php/php.editor/test/unit/data/testfiles/formatting/wrapping/functionCallTrailingCommas01.php.formatted
@@ -30,7 +30,7 @@ $foo->bar(
         'bar',
 );
 
-$bar = function(...$args) {
+$bar = function (...$args) {
     echo "closure" . PHP_EOL;
 };
 $bar(
diff --git a/php/php.editor/test/unit/data/testfiles/formatting/wrapping/functionCallTrailingCommas02.php.formatted b/php/php.editor/test/unit/data/testfiles/formatting/wrapping/functionCallTrailingCommas02.php.formatted
index 615ef75..a8983a3 100644
--- a/php/php.editor/test/unit/data/testfiles/formatting/wrapping/functionCallTrailingCommas02.php.formatted
+++ b/php/php.editor/test/unit/data/testfiles/formatting/wrapping/functionCallTrailingCommas02.php.formatted
@@ -21,7 +21,7 @@ $foo = new Foo('constructor',
 $foo->bar('method',
         'bar',);
 
-$bar = function(...$args) {
+$bar = function (...$args) {
     echo "closure" . PHP_EOL;
 };
 $bar('closure',
diff --git a/php/php.editor/test/unit/data/testfiles/formatting/wrapping/functionCallTrailingCommas03.php.formatted b/php/php.editor/test/unit/data/testfiles/formatting/wrapping/functionCallTrailingCommas03.php.formatted
index 8ff8628..2c6eafe 100644
--- a/php/php.editor/test/unit/data/testfiles/formatting/wrapping/functionCallTrailingCommas03.php.formatted
+++ b/php/php.editor/test/unit/data/testfiles/formatting/wrapping/functionCallTrailingCommas03.php.formatted
@@ -30,7 +30,7 @@ $foo->bar(
         'bar',
 );
 
-$bar = function(...$args) {
+$bar = function (...$args) {
     echo "closure" . PHP_EOL;
 };
 $bar(
diff --git a/php/php.editor/test/unit/data/testfiles/formatting/wrapping/functionCallTrailingCommas04.php.formatted b/php/php.editor/test/unit/data/testfiles/formatting/wrapping/functionCallTrailingCommas04.php.formatted
index 8e3c668..a7b5a09 100644
--- a/php/php.editor/test/unit/data/testfiles/formatting/wrapping/functionCallTrailingCommas04.php.formatted
+++ b/php/php.editor/test/unit/data/testfiles/formatting/wrapping/functionCallTrailingCommas04.php.formatted
@@ -14,7 +14,7 @@ $foo = new Foo('constructor', 'foo',);
 
 $foo->bar('method', 'bar',);
 
-$bar = function(...$args) {
+$bar = function (...$args) {
     echo "closure" . PHP_EOL;
 };
 $bar('closure', 'bar',);
diff --git a/php/php.editor/test/unit/data/testfiles/formatting/wrapping/php80/AllowTrailingCommaInParameterList/closureInArrayAlways01.php.formatted b/php/php.editor/test/unit/data/testfiles/formatting/wrapping/php80/AllowTrailingCommaInParameterList/closureInArrayAlways01.php.formatted
index 1c028a7..9c84a6e 100644
--- a/php/php.editor/test/unit/data/testfiles/formatting/wrapping/php80/AllowTrailingCommaInParameterList/closureInArrayAlways01.php.formatted
+++ b/php/php.editor/test/unit/data/testfiles/formatting/wrapping/php80/AllowTrailingCommaInParameterList/closureInArrayAlways01.php.formatted
@@ -21,13 +21,13 @@
 
 // no parameters
 $array = [
-    "test", function() {
+    "test", function () {
         echo "test";
     },
 ];
 
 $array = [
-    "test", function() use (
+    "test", function () use (
             $var1,
             $var2
     ) {
@@ -36,7 +36,7 @@ $array = [
 ];
 
 $array = [
-    "test", function()
+    "test", function ()
     use (
             $var1,
             $var2
@@ -46,7 +46,7 @@ $array = [
 ];
 
 $array = [
-    "test", function() use (
+    "test", function () use (
             $var1,
             $var2
     ): void {
@@ -55,7 +55,7 @@ $array = [
 ];
 
 $array = [
-    "test", function()
+    "test", function ()
     use (
             $var1,
             $var2
@@ -66,14 +66,14 @@ $array = [
 
 $array = [
     "test",
-    function() {
+    function () {
         echo "test";
     },
 ];
 
 $array = [
     "test",
-    function() use (
+    function () use (
             $var1,
             $var2
     ) {
@@ -83,7 +83,7 @@ $array = [
 
 $array = [
     "test",
-    function()
+    function ()
     use (
             $var1,
             $var2
@@ -94,7 +94,7 @@ $array = [
 
 $array = [
     "test",
-    function() use (
+    function () use (
             $var1,
             $var2
     ): void {
@@ -104,7 +104,7 @@ $array = [
 
 $array = [
     "test",
-    function()
+    function ()
     use (
             $var1,
             $var2
@@ -115,7 +115,7 @@ $array = [
 
 // has parameters
 $array = [
-    "test", function(
+    "test", function (
             $param1,
             $param2,
     ) {
@@ -124,7 +124,7 @@ $array = [
 ];
 
 $array = [
-    "test", function(
+    "test", function (
             $param1,
             $param2,
     ) use (
@@ -136,7 +136,7 @@ $array = [
 ];
 
 $array = [
-    "test", function(
+    "test", function (
             $param1,
             $param2,
     ) use (
@@ -150,7 +150,7 @@ $array = [
 
 $array = [
     "test",
-    function(
+    function (
             $param1,
             $param2,
     ) {
@@ -160,7 +160,7 @@ $array = [
 
 $array = [
     "test",
-    function(
+    function (
             $param1,
             $param2,
     ) use (
@@ -173,7 +173,7 @@ $array = [
 
 $array = [
     "test",
-    function(
+    function (
             $param1,
             $param2,
     ) use (
@@ -187,13 +187,13 @@ $array = [
 // key => value
 // no parameters
 $array = [
-    "test", "key" => function() {
+    "test", "key" => function () {
         echo "test";
     }, $test
 ];
 
 $array = [
-    "test", "key" => function() use (
+    "test", "key" => function () use (
             $var1,
             $var2
     ) {
@@ -202,7 +202,7 @@ $array = [
 ];
 
 $array = [
-    "test", "key" => function()
+    "test", "key" => function ()
     use (
             $var1,
             $var2
@@ -212,7 +212,7 @@ $array = [
 ];
 
 $array = [
-    "test", "key" => function() use (
+    "test", "key" => function () use (
             $var1,
             $var2
     ): void {
@@ -221,7 +221,7 @@ $array = [
 ];
 
 $array = [
-    "test", "key" => function()
+    "test", "key" => function ()
     use (
             $var1,
             $var2
@@ -232,14 +232,14 @@ $array = [
 
 $array = [
     "test",
-    "key" => function() {
+    "key" => function () {
         echo "test";
     },
 ];
 
 $array = [
     "test",
-    "key" => function() use (
+    "key" => function () use (
             $var1,
             $var2
     ) {
@@ -249,7 +249,7 @@ $array = [
 
 $array = [
     "test",
-    "key" => function()
+    "key" => function ()
     use (
             $var1,
             $var2
@@ -260,7 +260,7 @@ $array = [
 
 $array = [
     "test",
-    "key" => function() use (
+    "key" => function () use (
             $var1,
             $var2
     ): void {
@@ -270,7 +270,7 @@ $array = [
 
 $array = [
     "test",
-    "key" => function()
+    "key" => function ()
     use (
             $var1,
             $var2
@@ -281,7 +281,7 @@ $array = [
 
 // has parameters
 $array = [
-    "test", "key" => function(
+    "test", "key" => function (
             $param1,
             $param2,
     ) {
@@ -290,7 +290,7 @@ $array = [
 ];
 
 $array = [
-    "test", "key" => function(
+    "test", "key" => function (
             $param1,
             $param2,
     ) use (
@@ -302,7 +302,7 @@ $array = [
 ];
 
 $array = [
-    "test", "key" => function(
+    "test", "key" => function (
             $param1,
             $param2,
     ) use (
@@ -316,7 +316,7 @@ $array = [
 
 $array = [
     "test",
-    "key" => function(
+    "key" => function (
             $param1,
             $param2,
     ) {
@@ -326,7 +326,7 @@ $array = [
 
 $array = [
     "test",
-    "key" => function(
+    "key" => function (
             $param1,
             $param2,
     ) use (
@@ -340,7 +340,7 @@ $array = [
 
 $array = [
     "test",
-    "key" => function(
+    "key" => function (
             $param1,
             $param2,
     ) use (
diff --git a/php/php.editor/test/unit/data/testfiles/formatting/wrapping/php80/AllowTrailingCommaInParameterList/closureInArrayAlways02.php.formatted b/php/php.editor/test/unit/data/testfiles/formatting/wrapping/php80/AllowTrailingCommaInParameterList/closureInArrayAlways02.php.formatted
index 6425adf..d2b9da7 100644
--- a/php/php.editor/test/unit/data/testfiles/formatting/wrapping/php80/AllowTrailingCommaInParameterList/closureInArrayAlways02.php.formatted
+++ b/php/php.editor/test/unit/data/testfiles/formatting/wrapping/php80/AllowTrailingCommaInParameterList/closureInArrayAlways02.php.formatted
@@ -21,14 +21,14 @@
 
 // no parameters
 $array = [
-    "test", function() use ($var1,
+    "test", function () use ($var1,
             $var2) {
         echo "test";
     },
 ];
 
 $array = [
-    "test", function()
+    "test", function ()
     use ($var1,
             $var2) {
         echo "test";
@@ -36,14 +36,14 @@ $array = [
 ];
 
 $array = [
-    "test", function() use ($var1,
+    "test", function () use ($var1,
             $var2): void {
         echo "test";
     },
 ];
 
 $array = [
-    "test", function()
+    "test", function ()
     use ($var1,
             $var2): void {
         echo "test";
@@ -52,7 +52,7 @@ $array = [
 
 $array = [
     "test",
-    function() use ($var1,
+    function () use ($var1,
             $var2) {
         echo "test";
     },
@@ -60,7 +60,7 @@ $array = [
 
 $array = [
     "test",
-    function()
+    function ()
     use ($var1,
             $var2) {
         echo "test";
@@ -69,7 +69,7 @@ $array = [
 
 $array = [
     "test",
-    function() use ($var1,
+    function () use ($var1,
             $var2): void {
         echo "test";
     },
@@ -77,7 +77,7 @@ $array = [
 
 $array = [
     "test",
-    function()
+    function ()
     use ($var1,
             $var2): void {
         echo "test";
@@ -86,14 +86,14 @@ $array = [
 
 // has parameters
 $array = [
-    "test", function($param1,
+    "test", function ($param1,
             $param2,) {
         echo "test";
     }, $test,
 ];
 
 $array = [
-    "test", function($param1,
+    "test", function ($param1,
             $param2,) use ($var1,
             $var2) {
         echo "test";
@@ -101,7 +101,7 @@ $array = [
 ];
 
 $array = [
-    "test", function($param1,
+    "test", function ($param1,
             $param2,) use (
             $var1,
             $var2
@@ -111,7 +111,7 @@ $array = [
 ];
 
 $array = [
-    "test", function($param1,
+    "test", function ($param1,
             $param2,) use ($var1,
             $var2): void {
         echo "test";
@@ -120,7 +120,7 @@ $array = [
 ];
 
 $array = [
-    "test", function($param1,
+    "test", function ($param1,
             $param2,) use (
             $var1,
             $var2
@@ -132,7 +132,7 @@ $array = [
 
 $array = [
     "test",
-    function($param1,
+    function ($param1,
             $param2,) {
         echo "test";
     },
@@ -140,7 +140,7 @@ $array = [
 
 $array = [
     "test",
-    function($param1,
+    function ($param1,
             $param2,) use ($var1,
             $var2) {
         echo "test";
@@ -149,7 +149,7 @@ $array = [
 
 $array = [
     "test",
-    function($param1,
+    function ($param1,
             $param2,) use (
             $var1,
             $var2
@@ -160,7 +160,7 @@ $array = [
 
 $array = [
     "test",
-    function($param1,
+    function ($param1,
             $param2,) use ($var1,
             $var2): void {
         echo "test";
@@ -169,7 +169,7 @@ $array = [
 
 $array = [
     "test",
-    function($param1,
+    function ($param1,
             $param2,) use (
             $var1,
             $var2
@@ -181,14 +181,14 @@ $array = [
 // key => value
 // no parameters
 $array = [
-    "test", "key" => function() use ($var1,
+    "test", "key" => function () use ($var1,
             $var2) {
         echo "test";
     },
 ];
 
 $array = [
-    "test", "key" => function()
+    "test", "key" => function ()
     use ($var1,
             $var2) {
         echo "test";
@@ -196,14 +196,14 @@ $array = [
 ];
 
 $array = [
-    "test", "key" => function() use ($var1,
+    "test", "key" => function () use ($var1,
             $var2): void {
         echo "test";
     },
 ];
 
 $array = [
-    "test", "key" => function()
+    "test", "key" => function ()
     use ($var1,
             $var2): void {
         echo "test";
@@ -212,7 +212,7 @@ $array = [
 
 $array = [
     "test",
-    "key" => function() use ($var1,
+    "key" => function () use ($var1,
             $var2) {
         echo "test";
     },
@@ -220,7 +220,7 @@ $array = [
 
 $array = [
     "test",
-    "key" => function()
+    "key" => function ()
     use ($var1,
             $var2) {
         echo "test";
@@ -229,7 +229,7 @@ $array = [
 
 $array = [
     "test",
-    "key" => function() use ($var1,
+    "key" => function () use ($var1,
             $var2): void {
         echo "test";
     },
@@ -237,7 +237,7 @@ $array = [
 
 $array = [
     "test",
-    "key" => function()
+    "key" => function ()
     use ($var1,
             $var2): void {
         echo "test";
@@ -246,14 +246,14 @@ $array = [
 
 // has parameters
 $array = [
-    "test", "key" => function($param1,
+    "test", "key" => function ($param1,
             $param2,) {
         echo "test";
     }, $test,
 ];
 
 $array = [
-    "test", "key" => function($param1,
+    "test", "key" => function ($param1,
             $param2,) use ($var1,
             $var2) {
         echo "test";
@@ -261,7 +261,7 @@ $array = [
 ];
 
 $array = [
-    "test", "key" => function($param1,
+    "test", "key" => function ($param1,
             $param2,) use (
             $var1,
             $var2
@@ -271,7 +271,7 @@ $array = [
 ];
 
 $array = [
-    "test", "key" => function($param1,
+    "test", "key" => function ($param1,
             $param2,) use ($var1,
             $var2): void {
         echo "test";
@@ -280,7 +280,7 @@ $array = [
 ];
 
 $array = [
-    "test", "key" => function($param1,
+    "test", "key" => function ($param1,
             $param2,) use (
             $var1,
             $var2
@@ -292,7 +292,7 @@ $array = [
 
 $array = [
     "test",
-    "key" => function($param1,
+    "key" => function ($param1,
             $param2,) {
         echo "test";
     },
@@ -300,7 +300,7 @@ $array = [
 
 $array = [
     "test",
-    "key" => function($param1,
+    "key" => function ($param1,
             $param2,) use ($var1,
             $var2) {
         echo "test";
@@ -310,7 +310,7 @@ $array = [
 
 $array = [
     "test",
-    "key" => function($param1,
+    "key" => function ($param1,
             $param2,) use (
             $var1,
             $var2
@@ -322,7 +322,7 @@ $array = [
 
 $array = [
     "test",
-    "key" => function($param1,
+    "key" => function ($param1,
             $param2,) use ($var1,
             $var2): void {
         echo "test";
@@ -331,7 +331,7 @@ $array = [
 
 $array = [
     "test",
-    "key" => function($param1,
+    "key" => function ($param1,
             $param2,) use (
             $var1,
             $var2
diff --git a/php/php.editor/test/unit/data/testfiles/formatting/wrapping/php80/AllowTrailingCommaInParameterList/closureInArrayNever01.php.formatted b/php/php.editor/test/unit/data/testfiles/formatting/wrapping/php80/AllowTrailingCommaInParameterList/closureInArrayNever01.php.formatted
index 1c028a7..9c84a6e 100644
--- a/php/php.editor/test/unit/data/testfiles/formatting/wrapping/php80/AllowTrailingCommaInParameterList/closureInArrayNever01.php.formatted
+++ b/php/php.editor/test/unit/data/testfiles/formatting/wrapping/php80/AllowTrailingCommaInParameterList/closureInArrayNever01.php.formatted
@@ -21,13 +21,13 @@
 
 // no parameters
 $array = [
-    "test", function() {
+    "test", function () {
         echo "test";
     },
 ];
 
 $array = [
-    "test", function() use (
+    "test", function () use (
             $var1,
             $var2
     ) {
@@ -36,7 +36,7 @@ $array = [
 ];
 
 $array = [
-    "test", function()
+    "test", function ()
     use (
             $var1,
             $var2
@@ -46,7 +46,7 @@ $array = [
 ];
 
 $array = [
-    "test", function() use (
+    "test", function () use (
             $var1,
             $var2
     ): void {
@@ -55,7 +55,7 @@ $array = [
 ];
 
 $array = [
-    "test", function()
+    "test", function ()
     use (
             $var1,
             $var2
@@ -66,14 +66,14 @@ $array = [
 
 $array = [
     "test",
-    function() {
+    function () {
         echo "test";
     },
 ];
 
 $array = [
     "test",
-    function() use (
+    function () use (
             $var1,
             $var2
     ) {
@@ -83,7 +83,7 @@ $array = [
 
 $array = [
     "test",
-    function()
+    function ()
     use (
             $var1,
             $var2
@@ -94,7 +94,7 @@ $array = [
 
 $array = [
     "test",
-    function() use (
+    function () use (
             $var1,
             $var2
     ): void {
@@ -104,7 +104,7 @@ $array = [
 
 $array = [
     "test",
-    function()
+    function ()
     use (
             $var1,
             $var2
@@ -115,7 +115,7 @@ $array = [
 
 // has parameters
 $array = [
-    "test", function(
+    "test", function (
             $param1,
             $param2,
     ) {
@@ -124,7 +124,7 @@ $array = [
 ];
 
 $array = [
-    "test", function(
+    "test", function (
             $param1,
             $param2,
     ) use (
@@ -136,7 +136,7 @@ $array = [
 ];
 
 $array = [
-    "test", function(
+    "test", function (
             $param1,
             $param2,
     ) use (
@@ -150,7 +150,7 @@ $array = [
 
 $array = [
     "test",
-    function(
+    function (
             $param1,
             $param2,
     ) {
@@ -160,7 +160,7 @@ $array = [
 
 $array = [
     "test",
-    function(
+    function (
             $param1,
             $param2,
     ) use (
@@ -173,7 +173,7 @@ $array = [
 
 $array = [
     "test",
-    function(
+    function (
             $param1,
             $param2,
     ) use (
@@ -187,13 +187,13 @@ $array = [
 // key => value
 // no parameters
 $array = [
-    "test", "key" => function() {
+    "test", "key" => function () {
         echo "test";
     }, $test
 ];
 
 $array = [
-    "test", "key" => function() use (
+    "test", "key" => function () use (
             $var1,
             $var2
     ) {
@@ -202,7 +202,7 @@ $array = [
 ];
 
 $array = [
-    "test", "key" => function()
+    "test", "key" => function ()
     use (
             $var1,
             $var2
@@ -212,7 +212,7 @@ $array = [
 ];
 
 $array = [
-    "test", "key" => function() use (
+    "test", "key" => function () use (
             $var1,
             $var2
     ): void {
@@ -221,7 +221,7 @@ $array = [
 ];
 
 $array = [
-    "test", "key" => function()
+    "test", "key" => function ()
     use (
             $var1,
             $var2
@@ -232,14 +232,14 @@ $array = [
 
 $array = [
     "test",
-    "key" => function() {
+    "key" => function () {
         echo "test";
     },
 ];
 
 $array = [
     "test",
-    "key" => function() use (
+    "key" => function () use (
             $var1,
             $var2
     ) {
@@ -249,7 +249,7 @@ $array = [
 
 $array = [
     "test",
-    "key" => function()
+    "key" => function ()
     use (
             $var1,
             $var2
@@ -260,7 +260,7 @@ $array = [
 
 $array = [
     "test",
-    "key" => function() use (
+    "key" => function () use (
             $var1,
             $var2
     ): void {
@@ -270,7 +270,7 @@ $array = [
 
 $array = [
     "test",
-    "key" => function()
+    "key" => function ()
     use (
             $var1,
             $var2
@@ -281,7 +281,7 @@ $array = [
 
 // has parameters
 $array = [
-    "test", "key" => function(
+    "test", "key" => function (
             $param1,
             $param2,
     ) {
@@ -290,7 +290,7 @@ $array = [
 ];
 
 $array = [
-    "test", "key" => function(
+    "test", "key" => function (
             $param1,
             $param2,
     ) use (
@@ -302,7 +302,7 @@ $array = [
 ];
 
 $array = [
-    "test", "key" => function(
+    "test", "key" => function (
             $param1,
             $param2,
     ) use (
@@ -316,7 +316,7 @@ $array = [
 
 $array = [
     "test",
-    "key" => function(
+    "key" => function (
             $param1,
             $param2,
     ) {
@@ -326,7 +326,7 @@ $array = [
 
 $array = [
     "test",
-    "key" => function(
+    "key" => function (
             $param1,
             $param2,
     ) use (
@@ -340,7 +340,7 @@ $array = [
 
 $array = [
     "test",
-    "key" => function(
+    "key" => function (
             $param1,
             $param2,
     ) use (
diff --git a/php/php.editor/test/unit/data/testfiles/formatting/wrapping/php80/AllowTrailingCommaInParameterList/closureInArrayNever02.php.formatted b/php/php.editor/test/unit/data/testfiles/formatting/wrapping/php80/AllowTrailingCommaInParameterList/closureInArrayNever02.php.formatted
index 20b061b..aa6b5bc 100644
--- a/php/php.editor/test/unit/data/testfiles/formatting/wrapping/php80/AllowTrailingCommaInParameterList/closureInArrayNever02.php.formatted
+++ b/php/php.editor/test/unit/data/testfiles/formatting/wrapping/php80/AllowTrailingCommaInParameterList/closureInArrayNever02.php.formatted
@@ -21,26 +21,26 @@
 
 // no parameters
 $array = [
-    "test", function() use ($var1, $var2) {
+    "test", function () use ($var1, $var2) {
         echo "test";
     },
 ];
 
 $array = [
-    "test", function()
+    "test", function ()
     use ($var1, $var2) {
         echo "test";
     },
 ];
 
 $array = [
-    "test", function() use ($var1, $var2): void {
+    "test", function () use ($var1, $var2): void {
         echo "test";
     },
 ];
 
 $array = [
-    "test", function()
+    "test", function ()
     use ($var1, $var2): void {
         echo "test";
     },
@@ -48,14 +48,14 @@ $array = [
 
 $array = [
     "test",
-    function() use ($var1, $var2) {
+    function () use ($var1, $var2) {
         echo "test";
     },
 ];
 
 $array = [
     "test",
-    function()
+    function ()
     use ($var1, $var2) {
         echo "test";
     },
@@ -63,14 +63,14 @@ $array = [
 
 $array = [
     "test",
-    function() use ($var1, $var2): void {
+    function () use ($var1, $var2): void {
         echo "test";
     },
 ];
 
 $array = [
     "test",
-    function()
+    function ()
     use ($var1, $var2): void {
         echo "test";
     },
@@ -78,19 +78,19 @@ $array = [
 
 // has parameters
 $array = [
-    "test", function($param1, $param2,) {
+    "test", function ($param1, $param2,) {
         echo "test";
     }, $test,
 ];
 
 $array = [
-    "test", function($param1, $param2,) use ($var1, $var2) {
+    "test", function ($param1, $param2,) use ($var1, $var2) {
         echo "test";
     },
 ];
 
 $array = [
-    "test", function($param1, $param2,) use (
+    "test", function ($param1, $param2,) use (
             $var1,
             $var2
     ) {
@@ -99,14 +99,14 @@ $array = [
 ];
 
 $array = [
-    "test", function($param1, $param2,) use ($var1, $var2): void {
+    "test", function ($param1, $param2,) use ($var1, $var2): void {
         echo "test";
     },
     $test
 ];
 
 $array = [
-    "test", function($param1, $param2,) use (
+    "test", function ($param1, $param2,) use (
             $var1,
             $var2
     ): void {
@@ -117,21 +117,21 @@ $array = [
 
 $array = [
     "test",
-    function($param1, $param2,) {
+    function ($param1, $param2,) {
         echo "test";
     },
 ];
 
 $array = [
     "test",
-    function($param1, $param2,) use ($var1, $var2) {
+    function ($param1, $param2,) use ($var1, $var2) {
         echo "test";
     },
 ];
 
 $array = [
     "test",
-    function($param1, $param2,) use (
+    function ($param1, $param2,) use (
             $var1,
             $var2
     ) {
@@ -141,14 +141,14 @@ $array = [
 
 $array = [
     "test",
-    function($param1, $param2,) use ($var1, $var2): void {
+    function ($param1, $param2,) use ($var1, $var2): void {
         echo "test";
     },
 ];
 
 $array = [
     "test",
-    function($param1, $param2,) use (
+    function ($param1, $param2,) use (
             $var1,
             $var2
     ): void {
@@ -159,26 +159,26 @@ $array = [
 // key => value
 // no parameters
 $array = [
-    "test", "key" => function() use ($var1, $var2) {
+    "test", "key" => function () use ($var1, $var2) {
         echo "test";
     },
 ];
 
 $array = [
-    "test", "key" => function()
+    "test", "key" => function ()
     use ($var1, $var2) {
         echo "test";
     },
 ];
 
 $array = [
-    "test", "key" => function() use ($var1, $var2): void {
+    "test", "key" => function () use ($var1, $var2): void {
         echo "test";
     },
 ];
 
 $array = [
-    "test", "key" => function()
+    "test", "key" => function ()
     use ($var1, $var2): void {
         echo "test";
     },
@@ -186,14 +186,14 @@ $array = [
 
 $array = [
     "test",
-    "key" => function() use ($var1, $var2) {
+    "key" => function () use ($var1, $var2) {
         echo "test";
     },
 ];
 
 $array = [
     "test",
-    "key" => function()
+    "key" => function ()
     use ($var1, $var2) {
         echo "test";
     },
@@ -201,14 +201,14 @@ $array = [
 
 $array = [
     "test",
-    "key" => function() use ($var1, $var2): void {
+    "key" => function () use ($var1, $var2): void {
         echo "test";
     },
 ];
 
 $array = [
     "test",
-    "key" => function()
+    "key" => function ()
     use ($var1, $var2): void {
         echo "test";
     },
@@ -216,19 +216,19 @@ $array = [
 
 // has parameters
 $array = [
-    "test", "key" => function($param1, $param2,) {
+    "test", "key" => function ($param1, $param2,) {
         echo "test";
     }, $test,
 ];
 
 $array = [
-    "test", "key" => function($param1, $param2,) use ($var1, $var2) {
+    "test", "key" => function ($param1, $param2,) use ($var1, $var2) {
         echo "test";
     },
 ];
 
 $array = [
-    "test", "key" => function($param1, $param2,) use (
+    "test", "key" => function ($param1, $param2,) use (
             $var1,
             $var2
     ) {
@@ -237,14 +237,14 @@ $array = [
 ];
 
 $array = [
-    "test", "key" => function($param1, $param2,) use ($var1, $var2): void {
+    "test", "key" => function ($param1, $param2,) use ($var1, $var2): void {
         echo "test";
     },
     $test
 ];
 
 $array = [
-    "test", "key" => function($param1, $param2,) use (
+    "test", "key" => function ($param1, $param2,) use (
             $var1,
             $var2
     ): void {
@@ -255,14 +255,14 @@ $array = [
 
 $array = [
     "test",
-    "key" => function($param1, $param2,) {
+    "key" => function ($param1, $param2,) {
         echo "test";
     },
 ];
 
 $array = [
     "test",
-    "key" => function($param1, $param2,) use ($var1, $var2) {
+    "key" => function ($param1, $param2,) use ($var1, $var2) {
         echo "test";
     },
     "key2" => "value2"
@@ -270,7 +270,7 @@ $array = [
 
 $array = [
     "test",
-    "key" => function($param1, $param2,) use (
+    "key" => function ($param1, $param2,) use (
             $var1,
             $var2
     ) {
@@ -281,14 +281,14 @@ $array = [
 
 $array = [
     "test",
-    "key" => function($param1, $param2,) use ($var1, $var2): void {
+    "key" => function ($param1, $param2,) use ($var1, $var2): void {
         echo "test";
     }, $test => "value",
 ];
 
 $array = [
     "test",
-    "key" => function($param1, $param2,) use (
+    "key" => function ($param1, $param2,) use (
             $var1,
             $var2
     ): void {
diff --git a/php/php.editor/test/unit/data/testfiles/formatting/wrapping/php80/AllowTrailingCommaInParameterList/declarationsAlways01.php.formatted b/php/php.editor/test/unit/data/testfiles/formatting/wrapping/php80/AllowTrailingCommaInParameterList/declarationsAlways01.php.formatted
index 20f0eb8..0efec9e 100644
--- a/php/php.editor/test/unit/data/testfiles/formatting/wrapping/php80/AllowTrailingCommaInParameterList/declarationsAlways01.php.formatted
+++ b/php/php.editor/test/unit/data/testfiles/formatting/wrapping/php80/AllowTrailingCommaInParameterList/declarationsAlways01.php.formatted
@@ -62,7 +62,7 @@ class Test {
 
 }
 
-$closure = function(
+$closure = function (
         $param1,
         $param2,
         $param3,
@@ -71,28 +71,28 @@ $closure = function(
     echo "Trailing Comma in Parameter List" . PHP_EOL;
 };
 
-$closureWithLexical = function(
+$closureWithLexical = function (
         $param1,
         $param2,
 ) use ($lexical) {
     echo "Trailing Comma in Parameter List" . PHP_EOL;
 };
 
-$closureWithReturnType = function(
+$closureWithReturnType = function (
         int $param1,
         $param2,
 ): void {
     echo "Trailing Comma in Parameter List" . PHP_EOL;
 };
 
-$closureWithLexixalAndReturnType = function(
+$closureWithLexixalAndReturnType = function (
         $param1,
         $param2,
 ) use ($lexical): void {
     echo "Trailing Comma in Parameter List" . PHP_EOL;
 };
 
-$closureWithLexixalAndReturnType = function(
+$closureWithLexixalAndReturnType = function (
         $param1,
         $param2,
 ) use (
diff --git a/php/php.editor/test/unit/data/testfiles/formatting/wrapping/php80/AllowTrailingCommaInParameterList/declarationsAlways02.php.formatted b/php/php.editor/test/unit/data/testfiles/formatting/wrapping/php80/AllowTrailingCommaInParameterList/declarationsAlways02.php.formatted
index 2e8d695..53cc5ac 100644
--- a/php/php.editor/test/unit/data/testfiles/formatting/wrapping/php80/AllowTrailingCommaInParameterList/declarationsAlways02.php.formatted
+++ b/php/php.editor/test/unit/data/testfiles/formatting/wrapping/php80/AllowTrailingCommaInParameterList/declarationsAlways02.php.formatted
@@ -54,29 +54,29 @@ class Test {
 
 }
 
-$closure = function($param1,
+$closure = function ($param1,
         $param2,
         $param3,
         $param4,) {
     echo "Trailing Comma in Parameter List" . PHP_EOL;
 };
 
-$closureWithLexical = function($param1,
+$closureWithLexical = function ($param1,
         $param2,) use ($lexical) {
     echo "Trailing Comma in Parameter List" . PHP_EOL;
 };
 
-$closureWithReturnType = function(int $param1,
+$closureWithReturnType = function (int $param1,
         $param2,): void {
     echo "Trailing Comma in Parameter List" . PHP_EOL;
 };
 
-$closureWithLexixalAndReturnType = function($param1,
+$closureWithLexixalAndReturnType = function ($param1,
         $param2,) use ($lexical): void {
     echo "Trailing Comma in Parameter List" . PHP_EOL;
 };
 
-$closureWithLexixalAndReturnType = function($param1,
+$closureWithLexixalAndReturnType = function ($param1,
         $param2,) use (&$lexical1,
         $lexical2): void {
     echo "Trailing Comma in Parameter List" . PHP_EOL;
diff --git a/php/php.editor/test/unit/data/testfiles/formatting/wrapping/php80/AllowTrailingCommaInParameterList/declarationsNever01.php.formatted b/php/php.editor/test/unit/data/testfiles/formatting/wrapping/php80/AllowTrailingCommaInParameterList/declarationsNever01.php.formatted
index 20f0eb8..0efec9e 100644
--- a/php/php.editor/test/unit/data/testfiles/formatting/wrapping/php80/AllowTrailingCommaInParameterList/declarationsNever01.php.formatted
+++ b/php/php.editor/test/unit/data/testfiles/formatting/wrapping/php80/AllowTrailingCommaInParameterList/declarationsNever01.php.formatted
@@ -62,7 +62,7 @@ class Test {
 
 }
 
-$closure = function(
+$closure = function (
         $param1,
         $param2,
         $param3,
@@ -71,28 +71,28 @@ $closure = function(
     echo "Trailing Comma in Parameter List" . PHP_EOL;
 };
 
-$closureWithLexical = function(
+$closureWithLexical = function (
         $param1,
         $param2,
 ) use ($lexical) {
     echo "Trailing Comma in Parameter List" . PHP_EOL;
 };
 
-$closureWithReturnType = function(
+$closureWithReturnType = function (
         int $param1,
         $param2,
 ): void {
     echo "Trailing Comma in Parameter List" . PHP_EOL;
 };
 
-$closureWithLexixalAndReturnType = function(
+$closureWithLexixalAndReturnType = function (
         $param1,
         $param2,
 ) use ($lexical): void {
     echo "Trailing Comma in Parameter List" . PHP_EOL;
 };
 
-$closureWithLexixalAndReturnType = function(
+$closureWithLexixalAndReturnType = function (
         $param1,
         $param2,
 ) use (
diff --git a/php/php.editor/test/unit/data/testfiles/formatting/wrapping/php80/AllowTrailingCommaInParameterList/declarationsNever02.php.formatted b/php/php.editor/test/unit/data/testfiles/formatting/wrapping/php80/AllowTrailingCommaInParameterList/declarationsNever02.php.formatted
index 124b156..d5bf309 100644
--- a/php/php.editor/test/unit/data/testfiles/formatting/wrapping/php80/AllowTrailingCommaInParameterList/declarationsNever02.php.formatted
+++ b/php/php.editor/test/unit/data/testfiles/formatting/wrapping/php80/AllowTrailingCommaInParameterList/declarationsNever02.php.formatted
@@ -43,22 +43,22 @@ class Test {
 
 }
 
-$closure = function($param1, $param2, $param3, $param4,) {
+$closure = function ($param1, $param2, $param3, $param4,) {
     echo "Trailing Comma in Parameter List" . PHP_EOL;
 };
 
-$closureWithLexical = function($param1, $param2,) use ($lexical) {
+$closureWithLexical = function ($param1, $param2,) use ($lexical) {
     echo "Trailing Comma in Parameter List" . PHP_EOL;
 };
 
-$closureWithReturnType = function(int $param1, $param2,): void {
+$closureWithReturnType = function (int $param1, $param2,): void {
     echo "Trailing Comma in Parameter List" . PHP_EOL;
 };
 
-$closureWithLexixalAndReturnType = function($param1, $param2,) use ($lexical): void {
+$closureWithLexixalAndReturnType = function ($param1, $param2,) use ($lexical): void {
     echo "Trailing Comma in Parameter List" . PHP_EOL;
 };
 
-$closureWithLexixalAndReturnType = function($param1, $param2,) use (&$lexical1, $lexical2): void {
+$closureWithLexixalAndReturnType = function ($param1, $param2,) use (&$lexical1, $lexical2): void {
     echo "Trailing Comma in Parameter List" . PHP_EOL;
 };
diff --git a/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/indent/PHPFormatterSpacesTest.java b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/indent/PHPFormatterSpacesTest.java
index 85772c4..22637f2 100644
--- a/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/indent/PHPFormatterSpacesTest.java
+++ b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/indent/PHPFormatterSpacesTest.java
@@ -204,18 +204,29 @@ public class PHPFormatterSpacesTest extends PHPFormatterTestBase {
         reformatFileContents("testfiles/formatting/spaces/spaceBeforeAfterSemi04.php", options);
     }
 
-    public void xxxtestSpacesCheckAfterKeywords01() throws Exception {
+    public void testSpacesCheckAfterKeywords01() throws Exception {
         HashMap<String, Object> options = new HashMap<String, Object>(FmtOptions.getDefaults());
         options.put(FmtOptions.SPACE_CHECK_AFTER_KEYWORDS, true);
         reformatFileContents("testfiles/formatting/spaces/spaceCheckAfterKeywords01.php", options);
     }
 
-    public void xxxtestSpacesCheckAfterKeywords02() throws Exception {
+    public void testSpacesCheckAfterKeywords02() throws Exception {
         HashMap<String, Object> options = new HashMap<String, Object>(FmtOptions.getDefaults());
         options.put(FmtOptions.SPACE_CHECK_AFTER_KEYWORDS, true);
         reformatFileContents("testfiles/formatting/spaces/spaceCheckAfterKeywords02.php", options);
     }
 
+    public void testSpacesBeforeAnonymousFunctionParen01() throws Exception {
+        HashMap<String, Object> options = new HashMap<String, Object>(FmtOptions.getDefaults());
+        reformatFileContents("testfiles/formatting/spaces/spaceBeforeAnonymousFunction01.php", options);
+    }
+
+    public void testSpacesBeforeAnonymousFunctionParen02() throws Exception {
+        HashMap<String, Object> options = new HashMap<String, Object>(FmtOptions.getDefaults());
+        options.put(FmtOptions.SPACE_BEFORE_ANONYMOUS_FUNCTION_PAREN, false);
+        reformatFileContents("testfiles/formatting/spaces/spaceBeforeAnonymousFunction02.php", options);
+    }
+
     public void testIssue210617() throws Exception {
         HashMap<String, Object> options = new HashMap<String, Object>(FmtOptions.getDefaults());
         options.put(FmtOptions.GROUP_ALIGNMENT_ARRAY_INIT, true);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists