Skip to content

Commit 5c75670

Browse files
committed
Printer: always prints trailing comma [Closes #106]
1 parent 5de75b6 commit 5c75670

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/PhpGenerator/Printer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function printClosure(Closure $closure, ?PhpNamespace $namespace = null):
6363
}
6464

6565
$useStr = strlen($tmp = implode(', ', $uses)) > $this->wrapLength && count($uses) > 1
66-
? "\n" . $this->indentation . implode(",\n" . $this->indentation, $uses) . "\n"
66+
? "\n" . $this->indentation . implode(",\n" . $this->indentation, $uses) . ",\n"
6767
: $tmp;
6868
$body = Helpers::simplifyTaggedNames($closure->getBody(), $this->namespace);
6969

@@ -345,7 +345,7 @@ protected function printParameters(Closure|GlobalFunction|Method $function, int
345345
$line = implode(', ', $params);
346346

347347
return count($params) > 1 && ($special || strlen($line) + $column > $this->wrapLength)
348-
? "(\n" . $this->indent(implode(",\n", $params)) . ($special ? ',' : '') . "\n)"
348+
? "(\n" . $this->indent(implode(",\n", $params)) . ",\n)"
349349
: "($line)";
350350
}
351351

tests/PhpGenerator/Closure.long.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ same(
3333
$abcdq,
3434
$abcdr,
3535
$abcds,
36-
$abcdt
36+
$abcdt,
3737
) use (
3838
$abcde,
3939
$abcdf,
@@ -50,7 +50,7 @@ same(
5050
$abcdq,
5151
$abcdr,
5252
$abcds,
53-
$abcdt
53+
$abcdt,
5454
) {
5555
return null;
5656
}',

tests/PhpGenerator/Method.longParams.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ same(
2727
string $i,
2828
string $j,
2929
string $k,
30-
string $l
30+
string $l,
3131
) {
3232
return null;
3333
}

0 commit comments

Comments
 (0)