Repository: prettier/plugin-php
Pull request #560 (2018-08-31 12:53:20)

test: space in silent node
Just test


Patch:
diff --git a/src/util.js b/src/util.js
index cdd0f7f..9af1de1 100644
--- a/src/util.js
+++ b/src/util.js
@@ -326,30 +326,27 @@ function fileShouldEndWithHardline(path) {
   const node = path.getValue();
   const isProgramNode = node.kind === "program";
   const lastNode = node.children && getLast(node.children);
+
   if (!isProgramNode) {
     return false;
   }
-  if (
-    lastNode &&
-    lastNode.kind === "inline" &&
-    lastNode.raw[lastNode.raw.length - 1] === "\n"
-  ) {
+
+  if (lastNode && lastNode.kind === "inline") {
     return false;
   }
+
   if (
     lastNode &&
     (lastNode.kind === "declare" || lastNode.kind === "namespace")
   ) {
     const lastNestedNode =
       lastNode.children.length > 0 && getLast(lastNode.children);
-    if (
-      lastNestedNode &&
-      lastNestedNode.kind === "inline" &&
-      lastNestedNode.raw[lastNestedNode.raw.length - 1] === "\n"
-    ) {
+
+    if (lastNestedNode && lastNestedNode.kind === "inline") {
       return false;
     }
   }
+
   return true;
 }
 


Test patch:
diff --git a/tests/inline/__snapshots__/jsfmt.spec.js.snap b/tests/inline/__snapshots__/jsfmt.spec.js.snap
index 2b7e79d..33a7145 100644
--- a/tests/inline/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/inline/__snapshots__/jsfmt.spec.js.snap
@@ -638,7 +638,6 @@ text
     }
 } ?>
 text
-
 `;
 
 exports[`mixed-6.php 1`] = `
diff --git a/tests/markdown/__snapshots__/jsfmt.spec.js.snap b/tests/markdown/__snapshots__/jsfmt.spec.js.snap
index 5c59b73..ced3dca 100644
--- a/tests/markdown/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/markdown/__snapshots__/jsfmt.spec.js.snap
@@ -158,7 +158,6 @@ if (true) {
 }
 echo 'bar';
 ?>
-test
-\`\`\`
+test\`\`\`
 
 `;
diff --git a/tests/silent/__snapshots__/jsfmt.spec.js.snap b/tests/silent/__snapshots__/jsfmt.spec.js.snap
index defaae0..0a9695b 100644
--- a/tests/silent/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/silent/__snapshots__/jsfmt.spec.js.snap
@@ -13,6 +13,7 @@ $variable = @foo(['veryVeryVeryVeryVeryVeryVeryLongKey' => 'veryVeryVeryVeryVery
 $variable = @foo()->veryVeryVeryVeryVeryLongMethod()->veryVeryVeryVeryVeryLongMethod()->veryVeryVeryVeryVeryLongMethod();
 $variable = @foo('VeryVeryVeryVeryVeryVeryLongArgument', 'VeryVeryVeryVeryVeryVeryLongArgument', 'VeryVeryVeryVeryVeryVeryLongArgument');
 @trigger_error($error, E_USER_DEPRECATED);
+$value = @     $cache[$key];
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 <?php
 $variable = @foo();
@@ -36,5 +37,6 @@ $variable = @foo(
     'VeryVeryVeryVeryVeryVeryLongArgument'
 );
 @trigger_error($error, E_USER_DEPRECATED);
+$value = @$cache[$key];
 
 `;
diff --git a/tests/silent/silent.php b/tests/silent/silent.php
index 262b197..0273e48 100644
--- a/tests/silent/silent.php
+++ b/tests/silent/silent.php
@@ -10,3 +10,4 @@ $variable = @foo(['veryVeryVeryVeryVeryVeryVeryLongKey' => 'veryVeryVeryVeryVery
 $variable = @foo()->veryVeryVeryVeryVeryLongMethod()->veryVeryVeryVeryVeryLongMethod()->veryVeryVeryVeryVeryLongMethod();
 $variable = @foo('VeryVeryVeryVeryVeryVeryLongArgument', 'VeryVeryVeryVeryVeryVeryLongArgument', 'VeryVeryVeryVeryVeryVeryLongArgument');
 @trigger_error($error, E_USER_DEPRECATED);
+$value = @     $cache[$key];