Skip to content

Commit 865d106

Browse files
committed
Printer: prints trailing comma in parameter lists when PHP 8 syntax is used
1 parent 9c8c125 commit 865d106

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

src/PhpGenerator/Printer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ public function printParameters($function, PhpNamespace $namespace = null): stri
280280
$line = implode(', ', $params);
281281

282282
return count($params) > 1 && ($special || strlen($line) > (new Dumper)->wrapLength)
283-
? "(\n" . $this->indent(implode(",\n", $params)) . "\n)"
283+
? "(\n" . $this->indent(implode(",\n", $params)) . ($special ? ',' : '') . "\n)"
284284
: "($line)";
285285
}
286286

tests/PhpGenerator/expected/ClassType.from.80.expect

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class Class8
33
public function __construct(
44
public $a,
55
public int $b = 10,
6-
$c = null
6+
$c = null,
77
) {
88
}
99
}

tests/PhpGenerator/expected/ClassType.promotion.expect

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class Example
44
$a,
55
public $b,
66
/** promo */
7-
#[Example] private string $c
7+
#[Example] private string $c,
88
) {
99
}
1010
}

tests/PhpGenerator/expected/PhpNamespace.expect

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class A implements A, C
1313
self $b,
1414
parent $c,
1515
array $d,
16-
callable $e
16+
callable $e,
1717
) {
1818
}
1919
}

0 commit comments

Comments
 (0)