File tree Expand file tree Collapse file tree 3 files changed +64
-0
lines changed Expand file tree Collapse file tree 3 files changed +64
-0
lines changed Original file line number Diff line number Diff line change 267
267
<rule ref =" SlevomatCodingStandard.Exceptions.DeadCatch" />
268
268
<!-- Require using Throwable instead of Exception -->
269
269
<rule ref =" SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly" />
270
+ <!-- Ensure Arrow Functions declaration format 9 -->
271
+ <rule ref =" SlevomatCodingStandard.Functions.ArrowFunctionDeclaration" >
272
+ <properties >
273
+ <property name =" spacesCountAfterKeyword" value =" 1" />
274
+ <property name =" spacesCountBeforeArrow" value =" 1" />
275
+ <property name =" spacesCountAfterArrow" value =" 1" />
276
+ </properties >
277
+ </rule >
270
278
<!-- Require closures not referencing $this be static -->
271
279
<rule ref =" SlevomatCodingStandard.Functions.StaticClosure" />
272
280
<!-- Forbid unused variables passed to closures via `use` -->
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ $ missingStatic = static fn ($ a , $ b ) => $ a + $ b ;
6
+
7
+ $ uselessParentheses = static fn ($ x ) => $ x + $ y ;
8
+
9
+ $ withReturnType = static fn (): int => 1 + 2 ;
10
+
11
+ $ withTypesInArguments = static fn (int $ a , int $ b ): int => $ a + $ b ;
12
+
13
+ $ spacing = static fn (int $ x ) => $ x * 2 ;
14
+
15
+ $ nested = static fn ($ x ) => static fn ($ y ) => $ x * $ y + $ z ;
16
+
17
+ $ returningObject = static fn () => new stdClass ();
18
+
19
+ Collection::from ([1 , 2 ])
20
+ ->map (static fn (int $ v ): int => $ v * 2 )
21
+ ->reduce (static fn (int $ tmp , int $ v ): int => $ tmp + $ v , 0 );
22
+
23
+ $ thisIsNotAnArrowFunction = [$ this ->fn => 'value ' ];
24
+
25
+ $ arrayWithArrowFunctions = [
26
+ 'true ' => static fn () => true ,
27
+ 'false ' => static fn () => false ,
28
+ ];
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ $ missingStatic = fn ($ a , $ b ) => $ a + $ b ;
6
+
7
+ $ uselessParentheses = static fn ($ x ) => ($ x + $ y );
8
+
9
+ $ withReturnType = static fn () : int => 1 + 2 ;
10
+
11
+ $ withTypesInArguments = static fn (int $ a , int $ b ): int => $ a + $ b ;
12
+
13
+ $ spacing = static fn (int $ x ) => $ x * 2 ;
14
+
15
+ $ nested = static fn ($ x )=>static fn ($ y ) => $ x * $ y + $ z ;
16
+
17
+ $ returningObject = static fn () => new stdClass ();
18
+
19
+ Collection::from ([1 , 2 ])
20
+ ->map (static fn (int $ v ): int => $ v * 2 )
21
+ ->reduce (static fn (int $ tmp , int $ v ): int => $ tmp + $ v , 0 );
22
+
23
+ $ thisIsNotAnArrowFunction = [$ this ->fn => 'value ' ];
24
+
25
+ $ arrayWithArrowFunctions = [
26
+ 'true ' => static fn () => true ,
27
+ 'false ' => static fn () => false ,
28
+ ];
You can’t perform that action at this time.
0 commit comments