File tree Expand file tree Collapse file tree 2 files changed +56
-1
lines changed Expand file tree Collapse file tree 2 files changed +56
-1
lines changed Original file line number Diff line number Diff line change @@ -41,10 +41,14 @@ public function __toString(): string
41
41
foreach ($ this ->uses as $ param ) {
42
42
$ uses [] = ($ param ->isReference () ? '& ' : '' ) . '$ ' . $ param ->getName ();
43
43
}
44
+ $ useStr = strlen ($ tmp = implode (', ' , $ uses )) > Helpers::WRAP_LENGTH && count ($ uses ) > 1
45
+ ? "\n\t" . implode (", \n\t" , $ uses ) . "\n"
46
+ : $ tmp ;
47
+
44
48
return 'function '
45
49
. ($ this ->returnReference ? '& ' : '' )
46
50
. $ this ->parametersToString ()
47
- . ($ this ->uses ? ' use ( ' . implode ( ' , ' , $ uses ) . ' ) ' : '' )
51
+ . ($ this ->uses ? " use ( $ useStr ) " : '' )
48
52
. $ this ->returnTypeToString ()
49
53
. " { \n" . Nette \Utils \Strings::indent (ltrim (rtrim ($ this ->body ) . "\n" ), 1 ) . '} ' ;
50
54
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ use Nette \PhpGenerator \Closure ;
6
+ use Tester \Assert ;
7
+
8
+
9
+ require __DIR__ . '/../bootstrap.php ' ;
10
+
11
+
12
+ $ function = new Closure ;
13
+ $ function ->setBody ('return null; ' );
14
+
15
+ for ($ name = 'abcde ' ; $ name < 'abcdr ' ; $ name ++) {
16
+ $ function ->addParameter ($ name );
17
+ $ function ->addUse ($ name );
18
+ }
19
+
20
+ Assert::match (
21
+ 'function (
22
+ $abcde,
23
+ $abcdf,
24
+ $abcdg,
25
+ $abcdh,
26
+ $abcdi,
27
+ $abcdj,
28
+ $abcdk,
29
+ $abcdl,
30
+ $abcdm,
31
+ $abcdn,
32
+ $abcdo,
33
+ $abcdp,
34
+ $abcdq
35
+ ) use (
36
+ $abcde,
37
+ $abcdf,
38
+ $abcdg,
39
+ $abcdh,
40
+ $abcdi,
41
+ $abcdj,
42
+ $abcdk,
43
+ $abcdl,
44
+ $abcdm,
45
+ $abcdn,
46
+ $abcdo,
47
+ $abcdp,
48
+ $abcdq
49
+ ) {
50
+ return null;
51
+ } ' , (string ) $ function );
You can’t perform that action at this time.
0 commit comments