From 319840e2de36d8528eedac31ae2811f251cee88a Mon Sep 17 00:00:00 2001 From: Christian Zosel Date: Fri, 22 Dec 2017 18:00:18 +0100 Subject: [PATCH] Class: Add support for abstract, final, extends, implements --- src/printer-php.js | 24 ++++++++++++++++++- .../__snapshots__/jsfmt.spec.js.snap | 24 ++++++++++++++++--- tests/php_class/class.php | 11 ++++++++- 3 files changed, 54 insertions(+), 5 deletions(-) diff --git a/src/printer-php.js b/src/printer-php.js index 967453efe561..5919278261c2 100644 --- a/src/printer-php.js +++ b/src/printer-php.js @@ -309,7 +309,29 @@ function printStatement(node) { switch (node.kind) { case "class": return concat([ - group(concat(["class ", node.name, " {"])), + group( + concat([ + node.isAbstract ? "abstract " : "", + node.isFinal ? "final " : "", + "class ", + node.name, + indent( + concat([ + node.extends + ? concat([line, "extends ", printNode(node.extends)]) + : "", + node.implements + ? concat([ + line, + "implements ", + join(", ", node.implements.map(printNode)) + ]) + : "" + ]) + ), + " {" + ]) + ), hardline, indent( concat(node.body.map(child => concat([hardline, printNode(child)]))) diff --git a/tests/php_class/__snapshots__/jsfmt.spec.js.snap b/tests/php_class/__snapshots__/jsfmt.spec.js.snap index 23600c3904ad..9c01deffe05c 100644 --- a/tests/php_class/__snapshots__/jsfmt.spec.js.snap +++ b/tests/php_class/__snapshots__/jsfmt.spec.js.snap @@ -1,8 +1,17 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`class.php 1`] = ` +exports[`class.php - php-verify: class.php 1`] = `