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