nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: prettier/plugin-php
Pull request #351 (2018-04-06 19:48:31)

fix: interface comments
https://github.com/prettier/plugin-php/issues/325


Patch:
diff --git a/src/index.js b/src/index.js
index b2dd03f..48e4fdd 100644
--- a/src/index.js
+++ b/src/index.js
@@ -151,6 +151,10 @@ const printers = {
           kinds: ["trait", "class"],
           children: { listNodes: ["implements", "body"], nodes: ["extends"] }
         },
+        {
+          kinds: ["interface"],
+          children: { listNodes: ["extends", "body"], nodes: [] }
+        },
         {
           kinds: ["function", "method", "closure"],
           children: { listNodes: ["arguments", "uses"], nodes: ["body"] }


Test patch:
diff --git a/tests/comments/__snapshots__/jsfmt.spec.js.snap b/tests/comments/__snapshots__/jsfmt.spec.js.snap
index d02d1d0..1e8627d 100644
--- a/tests/comments/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/comments/__snapshots__/jsfmt.spec.js.snap
@@ -228,6 +228,25 @@ $test = new class($arg1) extends Test {
 $test = new class {
   //some comment
 };
+
+
+namespace Tribe\\Project\\Twig;
+
+interface Template_Interface {
+	/**
+	 * Build the data that will be available to the template
+	 *
+	 * @return array
+	 */
+	public function get_data(): array;
+
+	/**
+	 * Render the template and return it as a string
+	 *
+	 * @return string The rendered template
+	 */
+	public function render(): string;
+}
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 <?php
 namespace Test\\test\\test;
@@ -273,6 +292,25 @@ $test = new class
     //some comment
 };
 
+namespace Tribe\\Project\\Twig;
+
+interface Template_Interface
+{
+    /**
+     * Build the data that will be available to the template
+     *
+     * @return array
+     */
+    public function get_data(): array;
+
+    /**
+     * Render the template and return it as a string
+     *
+     * @return string The rendered template
+     */
+    public function render(): string;
+}
+
 `;
 
 exports[`clone.php 1`] = `
diff --git a/tests/comments/class.php b/tests/comments/class.php
index 0d8d61a..c2962fb 100644
--- a/tests/comments/class.php
+++ b/tests/comments/class.php
@@ -35,3 +35,22 @@ $test = new class($arg1) extends Test {
 $test = new class {
   //some comment
 };
+
+
+namespace Tribe\Project\Twig;
+
+interface Template_Interface {
+	/**
+	 * Build the data that will be available to the template
+	 *
+	 * @return array
+	 */
+	public function get_data(): array;
+
+	/**
+	 * Render the template and return it as a string
+	 *
+	 * @return string The rendered template
+	 */
+	public function render(): string;
+}
Repository: prettier/plugin-php
Pull request #353 (2018-04-07 13:49:51)

fix: output comments in `silent` node


Patch:
diff --git a/src/index.js b/src/index.js
index 48e4fdd..e53cbc2 100644
--- a/src/index.js
+++ b/src/index.js
@@ -222,6 +222,10 @@ const printers = {
         {
           kinds: ["traitalias"],
           children: { listNodes: [], nodes: ["trait"] }
+        },
+        {
+          kinds: ["silent"],
+          children: { listNodes: [], nodes: ["expr"] }
         }
       ];
       const children = nodeMap.reduce((currentChildren, map) => {


Test patch:
diff --git a/tests/comments/__snapshots__/jsfmt.spec.js.snap b/tests/comments/__snapshots__/jsfmt.spec.js.snap
index 1e8627d..f35fa87 100644
--- a/tests/comments/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/comments/__snapshots__/jsfmt.spec.js.snap
@@ -1053,6 +1053,17 @@ $a->bar();
 
 `;
 
+exports[`silent.php 1`] = `
+<?php
+
+@/*comment*/test();
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+<?php
+@/*comment*/
+test();
+
+`;
+
 exports[`static.php 1`] = `
 <?php
 static /* Comment */ $a /* Comment */, /* Comment */ $b /* Comment */;
diff --git a/tests/comments/silent.php b/tests/comments/silent.php
new file mode 100644
index 0000000..91946e0
--- /dev/null
+++ b/tests/comments/silent.php
@@ -0,0 +1,3 @@
+<?php
+
+@/*comment*/test();
Repository: prettier/plugin-php
Pull request #354 (2018-04-07 14:45:53)

fix: output comments in `exit` node


Patch:
diff --git a/src/index.js b/src/index.js
index e53cbc2..861c900 100644
--- a/src/index.js
+++ b/src/index.js
@@ -226,6 +226,10 @@ const printers = {
         {
           kinds: ["silent"],
           children: { listNodes: [], nodes: ["expr"] }
+        },
+        {
+          kinds: ["exit"],
+          children: { listNodes: [], nodes: ["status"] }
         }
       ];
       const children = nodeMap.reduce((currentChildren, map) => {


Test patch:
diff --git a/tests/comments/__snapshots__/jsfmt.spec.js.snap b/tests/comments/__snapshots__/jsfmt.spec.js.snap
index f35fa87..8a3f52f 100644
--- a/tests/comments/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/comments/__snapshots__/jsfmt.spec.js.snap
@@ -756,6 +756,19 @@ eval(
 
 `;
 
+exports[`exit.php 1`] = `
+<?php
+
+exit(/* Comment */1/* Comment */);
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+<?php
+exit(
+    /* Comment */
+    1 /* Comment */
+);
+
+`;
+
 exports[`for.php 1`] = `
 <?php
 for // Comment
diff --git a/tests/comments/exit.php b/tests/comments/exit.php
new file mode 100644
index 0000000..e1fa28a
--- /dev/null
+++ b/tests/comments/exit.php
@@ -0,0 +1,3 @@
+<?php
+
+exit(/* Comment */1/* Comment */);
Repository: prettier/plugin-php
Pull request #481 (2018-07-23 16:55:01)

fix: better print empty declare node
Rare use case, but found in our docs :smile:  


Patch:
diff --git a/src/printer.js b/src/printer.js
index 2b89808..7ce411d 100644
--- a/src/printer.js
+++ b/src/printer.js
@@ -2047,8 +2047,9 @@ function printStatement(path, options, print) {
           "declare(",
           printDeclareArguments(path),
           "):",
-          hardline,
-          concat(path.map(print, "children")),
+          node.children.length > 0
+            ? concat([hardline, concat(path.map(print, "children"))])
+            : "",
           hardline,
           "enddeclare;"
         ]);
@@ -2057,7 +2058,9 @@ function printStatement(path, options, print) {
           "declare(",
           printDeclareArguments(path),
           ") {",
-          indent(concat([hardline, concat(path.map(print, "children"))])),
+          node.children.length > 0
+            ? indent(concat([hardline, concat(path.map(print, "children"))]))
+            : "",
           hardline,
           "}"
         ]);


Test patch:
diff --git a/tests/declare/__snapshots__/jsfmt.spec.js.snap b/tests/declare/__snapshots__/jsfmt.spec.js.snap
index 1e91c41..7b4351d 100644
--- a/tests/declare/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/declare/__snapshots__/jsfmt.spec.js.snap
@@ -22,6 +22,12 @@ $test = 1;
 if ($var) {
     declare(ticks=1);
 }
+
+declare(ticks=1) {
+}
+
+declare(ticks=1):
+enddeclare;
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 <?php
 declare(ticks=1):
@@ -45,4 +51,10 @@ if ($var) {
     declare(ticks=1);
 }
 
+declare(ticks=1) {
+}
+
+declare(ticks=1):
+enddeclare;
+
 `;
diff --git a/tests/declare/declare.php b/tests/declare/declare.php
index 0fc4896..df097d1 100644
--- a/tests/declare/declare.php
+++ b/tests/declare/declare.php
@@ -19,3 +19,9 @@ $test = 1;
 if ($var) {
     declare(ticks=1);
 }
+
+declare(ticks=1) {
+}
+
+declare(ticks=1):
+enddeclare;
Repository: prettier/plugin-php
Pull request #554 (2018-08-31 10:32:18)

test: deep $
Just test


Patch:
diff --git a/src/printer.js b/src/printer.js
index 1dd99b3..6d04bed 100644
--- a/src/printer.js
+++ b/src/printer.js
@@ -1675,6 +1675,7 @@ function printNode(path, options, print) {
 
       return concat([
         "function ",
+        node.byref ? "&" : "",
         printArgumentsList(path, options, print),
         node.uses && node.uses.length > 0
           ? group(


Test patch:
diff --git a/tests/closure/__snapshots__/jsfmt.spec.js.snap b/tests/closure/__snapshots__/jsfmt.spec.js.snap
index 5b00d47..0364257 100644
--- a/tests/closure/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/closure/__snapshots__/jsfmt.spec.js.snap
@@ -127,6 +127,11 @@ $rTDWLU = function(array $array) use ($longLongLongLongLongLongLongVar1, $longer
     return array_sum($array);
 };
 
+$var = function &() {
+    static $collection = array();
+
+    return $collection;
+};
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 <?php
 
@@ -253,4 +258,10 @@ $rTDWLU = function (array $array) use (
     return array_sum($array);
 };
 
+$var = function &() {
+    static $collection = array();
+
+    return $collection;
+};
+
 `;
diff --git a/tests/closure/closure.php b/tests/closure/closure.php
index 0bb1c8c..ab14c9b 100644
--- a/tests/closure/closure.php
+++ b/tests/closure/closure.php
@@ -124,3 +124,8 @@ $rTDWLU = function(array $array) use ($longLongLongLongLongLongLongVar1, $longer
     return array_sum($array);
 };
 
+$var = function &() {
+    static $collection = array();
+
+    return $collection;
+};
diff --git a/tests/variable/__snapshots__/jsfmt.spec.js.snap b/tests/variable/__snapshots__/jsfmt.spec.js.snap
index caa3b8b..fb2f480 100644
--- a/tests/variable/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/variable/__snapshots__/jsfmt.spec.js.snap
@@ -50,6 +50,8 @@ $var = ($$foo)['bar']['baz'];
 $var = ($foo->$bar)['baz'];
 $var = ($foo->$bar)['baz']();
 $var = (Foo::$bar)['baz']();
+
+$$$$$$$$$$var = "I like playing in the park";
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 <?php
 
@@ -93,4 +95,6 @@ $var = ($foo->$bar)['baz'];
 $var = ($foo->$bar)['baz']();
 $var = (Foo::$bar)['baz']();
 
+$$$$$$$$$$var = "I like playing in the park";
+
 `;
diff --git a/tests/variable/variable.php b/tests/variable/variable.php
index 13c97ff..f68bb77 100644
--- a/tests/variable/variable.php
+++ b/tests/variable/variable.php
@@ -38,3 +38,5 @@ $var = ($$foo)['bar']['baz'];
 $var = ($foo->$bar)['baz'];
 $var = ($foo->$bar)['baz']();
 $var = (Foo::$bar)['baz']();
+
+$$$$$$$$$$var = "I like playing in the park";
Repository: prettier/plugin-php
Pull request #555 (2018-08-31 11:03:07)

fix: don't add extra newline in last inline node
this bug also exists in https://github.com/prettier/plugin-php/pull/550

evilebottnawi: Looks all code in markdown now interpreted as inline :confused: It is big bug
evilebottnawi: Merge as is, we can't fix prettier bug here, feel free to feedback

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\`\`\`
 
 `;
Repository: prettier/plugin-php
Pull request #581 (2018-09-06 17:35:45)

feat: avoid unnecessary parens around new node

evilebottnawi: Feel free to feedback

Patch:
diff --git a/src/needs-parens.js b/src/needs-parens.js
index ecefeb4..708e517 100644
--- a/src/needs-parens.js
+++ b/src/needs-parens.js
@@ -1,5 +1,7 @@
 "use strict";
 
+const { isLookupNode } = require("./util");
+
 function needsParens(path) {
   const parent = path.getParentNode();
 
@@ -38,8 +40,16 @@ function needsParens(path) {
           );
         case "bin":
           return parent.type === "**" && name === "left";
+        default:
+          return false;
+      }
+    case "new": {
+      if (isLookupNode(parent)) {
+        return true;
       }
-    // else fallthrough
+
+      return false;
+    }
     case "boolean":
     case "string":
     case "number":


Test patch:
diff --git a/tests/parens/__snapshots__/jsfmt.spec.js.snap b/tests/parens/__snapshots__/jsfmt.spec.js.snap
index 9e244ef..27507c0 100644
--- a/tests/parens/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/parens/__snapshots__/jsfmt.spec.js.snap
@@ -402,6 +402,17 @@ exports[`new.php 1`] = `
     ['foo' => 'bar']
 ))
 ?>
+<?php
+
+$var = new Foo();
+$var = (new Foo());
+$var = (new Foo())->c();
+$var = (new class {
+    public function log($msg)
+    {
+        echo $msg;
+    }
+});
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 <?php
 new Translator(
@@ -420,8 +431,18 @@ new Translator(
 ); ?>
 <?php new Translator($container, new MessageFormatter(), 'en', $someOtherVar, [
     'foo' => 'bar'
-]);
-?>
+]); ?>
+<?php
+$var = new Foo();
+$var = new Foo();
+$var = (new Foo())->c();
+$var = new class {
+    public function log($msg)
+    {
+        echo $msg;
+    }
+};
+
 
 `;
 
diff --git a/tests/parens/new.php b/tests/parens/new.php
index 37bb40e..cd49f94 100644
--- a/tests/parens/new.php
+++ b/tests/parens/new.php
@@ -25,3 +25,14 @@
     ['foo' => 'bar']
 ))
 ?>
+<?php
+
+$var = new Foo();
+$var = (new Foo());
+$var = (new Foo())->c();
+$var = (new class {
+    public function log($msg)
+    {
+        echo $msg;
+    }
+});
Repository: prettier/plugin-php
Pull request #602 (2018-09-11 15:51:32)

feat: avoid unnecessary parens around silent node

evilebottnawi: Feel free to feedback

Patch:
diff --git a/src/needs-parens.js b/src/needs-parens.js
index 8f250ae..1a25ef6 100644
--- a/src/needs-parens.js
+++ b/src/needs-parens.js
@@ -132,6 +132,7 @@ function needsParens(path) {
     case "variable":
     case "isset":
     case "empty":
+    case "silent":
       return false;
     case "string":
     case "array":


Test patch:
diff --git a/tests/parens/__snapshots__/jsfmt.spec.js.snap b/tests/parens/__snapshots__/jsfmt.spec.js.snap
index 2def9b6..da7dbb7 100644
--- a/tests/parens/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/parens/__snapshots__/jsfmt.spec.js.snap
@@ -1551,6 +1551,25 @@ return 'veryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongString'
 
 `;
 
+exports[`silent.php 1`] = `
+<?php
+
+@foo();
+(@foo());
+
+$var = @foo();
+$var = (@foo());
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+<?php
+
+@foo();
+@foo();
+
+$var = @foo();
+$var = @foo();
+
+`;
+
 exports[`unary.php 1`] = `
 <?php
 
diff --git a/tests/parens/silent.php b/tests/parens/silent.php
new file mode 100644
index 0000000..837a566
--- /dev/null
+++ b/tests/parens/silent.php
@@ -0,0 +1,7 @@
+<?php
+
+@foo();
+(@foo());
+
+$var = @foo();
+$var = (@foo());
Repository: prettier/plugin-php
Pull request #635 (2018-09-13 17:29:18)

feat: avoid unnecessary parens around pre and post nodes
From prettier


Patch:
diff --git a/src/needs-parens.js b/src/needs-parens.js
index b627914..97416b8 100644
--- a/src/needs-parens.js
+++ b/src/needs-parens.js
@@ -50,8 +50,9 @@ function needsParens(path) {
     case "post":
       if (parent.kind === "unary") {
         return (
-          (node.type === "+" && parent.type === "+") ||
-          (node.type === "-" && parent.type === "-")
+          node.kind === "pre" &&
+          ((node.type === "+" && parent.type === "+") ||
+            (node.type === "-" && parent.type === "-"))
         );
       }
     // else fallthrough


Test patch:
diff --git a/tests/parens/__snapshots__/jsfmt.spec.js.snap b/tests/parens/__snapshots__/jsfmt.spec.js.snap
index 5dd3aab..1e6cd15 100644
--- a/tests/parens/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/parens/__snapshots__/jsfmt.spec.js.snap
@@ -2043,10 +2043,18 @@ $var = +(++$var);
 $var = -(++$var);
 $var = ~(++$var);
 
+$var = +(--$var);
+$var = -(--$var);
+$var = ~(--$var);
+
 $var = +($var++);
 $var = -($var++);
 $var = ~($var++);
 
+$var = +($var--);
+$var = -($var--);
+$var = ~($var--);
+
 $var = ++$var ** 2;
 $var = (++$var) ** 2;
 
@@ -2094,10 +2102,18 @@ $var = +(++$var);
 $var = -++$var;
 $var = ~++$var;
 
-$var = +($var++);
+$var = +--$var;
+$var = -(--$var);
+$var = ~--$var;
+
+$var = +$var++;
 $var = -$var++;
 $var = ~$var++;
 
+$var = +$var--;
+$var = -$var--;
+$var = ~$var--;
+
 $var = (++$var) ** 2;
 $var = (++$var) ** 2;
 
@@ -2105,7 +2121,7 @@ $var = ($var++) ** 2;
 $var = ($var++) ** 2;
 
 $var = +(+(++$var));
-$var = +(+($var++));
+$var = +(+$var++);
 $var = ~-++$var;
 $var = ~-$var++;
 
@@ -2457,6 +2473,9 @@ $var = +(+$var);
 $var = (-$var);
 $var = -(-$var);
 
+$var = -(+$var);
+$var = +(-$var);
+
 $var = (~$var);
 $var = ~(~$var);
 
@@ -2517,6 +2536,9 @@ $var = +(+$var);
 $var = -$var;
 $var = -(-$var);
 
+$var = -+$var;
+$var = +-$var;
+
 $var = ~$var;
 $var = ~~$var;
 
diff --git a/tests/parens/pre-post.php b/tests/parens/pre-post.php
index 645681a..840e50c 100644
--- a/tests/parens/pre-post.php
+++ b/tests/parens/pre-post.php
@@ -19,10 +19,18 @@ $var = +(++$var);
 $var = -(++$var);
 $var = ~(++$var);
 
+$var = +(--$var);
+$var = -(--$var);
+$var = ~(--$var);
+
 $var = +($var++);
 $var = -($var++);
 $var = ~($var++);
 
+$var = +($var--);
+$var = -($var--);
+$var = ~($var--);
+
 $var = ++$var ** 2;
 $var = (++$var) ** 2;
 
diff --git a/tests/parens/unary.php b/tests/parens/unary.php
index 0ef7667..8a1c449 100644
--- a/tests/parens/unary.php
+++ b/tests/parens/unary.php
@@ -27,6 +27,9 @@ $var = +(+$var);
 $var = (-$var);
 $var = -(-$var);
 
+$var = -(+$var);
+$var = +(-$var);
+
 $var = (~$var);
 $var = ~(~$var);
Repository: prettier/plugin-php
Pull request #640 (2018-09-17 12:29:18)

feat: better handle entry comments
From prettier, same logic for `{prop: value}` handlePropertyComments

evilebottnawi: Feel free to feedback

Patch:
diff --git a/src/comments.js b/src/comments.js
index a50ad26..e7e12d3 100644
--- a/src/comments.js
+++ b/src/comments.js
@@ -54,6 +54,7 @@ function handleEndOfLineComment(comment, text, options, ast, isLastComment) {
     handleFunctionParameter(text, enclosingNode, comment, options) ||
     handleFunction(text, enclosingNode, followingNode, comment, options) ||
     handleTryCatch(enclosingNode, comment) ||
+    handleEntryComments(enclosingNode, comment) ||
     handleOnlyComments(enclosingNode, ast, comment, isLastComment) ||
     handleHalt(enclosingNode, precedingNode, comment) ||
     handleVariableComments(enclosingNode, followingNode, comment)
@@ -301,6 +302,14 @@ function handleInlineComments(
   return false;
 }
 
+function handleEntryComments(enclosingNode, comment) {
+  if (enclosingNode && enclosingNode.kind === "entry") {
+    addLeadingComment(enclosingNode, comment);
+    return true;
+  }
+  return false;
+}
+
 function handleOnlyComments(enclosingNode, ast, comment, isLastComment) {
   if (
     enclosingNode &&


Test patch:
diff --git a/tests/comments/__snapshots__/jsfmt.spec.js.snap b/tests/comments/__snapshots__/jsfmt.spec.js.snap
index 6ec9c84..dedda24 100644
--- a/tests/comments/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/comments/__snapshots__/jsfmt.spec.js.snap
@@ -56,6 +56,24 @@ $array = []; // Comment
 /* Comment */
 $array /* Comment */ = /* Comment */ []; /* Comment */
 /* Comment */
+
+$array = [
+    'key' =>
+        // Comment A
+        // Comment B
+        'string'
+];
+
+$array = [
+     'key' => // Comment A
+        // Comment B
+         'string'
+];
+
+$array = [
+    'key' => // Comment A
+        'string'
+];
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 <?php
 $array = [
@@ -131,6 +149,25 @@ $array = []; // Comment
 $array /* Comment */ = /* Comment */ []; /* Comment */
 /* Comment */
 
+$array = [
+    'key' =>
+        // Comment A
+        // Comment B
+        'string'
+];
+
+$array = [
+    // Comment A
+    'key' =>
+        // Comment B
+        'string'
+];
+
+$array = [
+    // Comment A
+    'key' => 'string'
+];
+
 `;
 
 exports[`assign.php 1`] = `
diff --git a/tests/comments/array.php b/tests/comments/array.php
index 8ce5500..9963d31 100644
--- a/tests/comments/array.php
+++ b/tests/comments/array.php
@@ -53,3 +53,21 @@ $array = []; // Comment
 /* Comment */
 $array /* Comment */ = /* Comment */ []; /* Comment */
 /* Comment */
+
+$array = [
+    'key' =>
+        // Comment A
+        // Comment B
+        'string'
+];
+
+$array = [
+     'key' => // Comment A
+        // Comment B
+         'string'
+];
+
+$array = [
+    'key' => // Comment A
+        'string'
+];
Repository: prettier/plugin-php
Pull request #713 (2018-10-03 11:12:38)

fix: pseudo inline node with CRLF
I think we have more problem with this in some cases, WIP on this

evilebottnawi: Feel free to feedback

Patch:
diff --git a/.gitattributes b/.gitattributes
index e73e926..47c3a7c 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,2 +1,3 @@
 tests/newline/CRLF.php text eol=crlf
 tests/newline/html-CRLF.php text eol=crlf
+tests/newline/mixed-CRLF.php text eol=crlf
diff --git a/src/parser.js b/src/parser.js
index fb4d7f8..98d6bf5 100644
--- a/src/parser.js
+++ b/src/parser.js
@@ -9,7 +9,7 @@ function parse(text, parsers, opts) {
   }
 
   // Todo https://github.com/glayzzle/php-parser/issues/170
-  text = text.replace(/\?>\n<\?/g, "?>\n___PSEUDO_INLINE_PLACEHOLDER___<?");
+  text = text.replace(/\?>\r?\n<\?/g, "?>\n___PSEUDO_INLINE_PLACEHOLDER___<?");
 
   // initialize a new parser instance
   const parser = new engine({


Test patch:
diff --git a/tests/newline/__snapshots__/jsfmt.spec.js.snap b/tests/newline/__snapshots__/jsfmt.spec.js.snap
index 0296969..380e6ea 100644
--- a/tests/newline/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/newline/__snapshots__/jsfmt.spec.js.snap
@@ -114,3 +114,29 @@ exports[`html-LF.php - php-verify: html-LF.php 1`] = `
 </html>
 
 `;
+
+exports[`mixed-CRLF.php - php-verify: mixed-CRLF.php 1`] = `
+Text
+<?php echo 1; ?>
+<?php echo 2; ?>
+Test
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Text
+<?php echo 1; ?>
+<?php echo 2; ?>
+Test
+
+`;
+
+exports[`mixed-LF.php - php-verify: mixed-LF.php 1`] = `
+Text
+<?php echo 1; ?>
+<?php echo 2; ?>
+Test
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Text
+<?php echo 1; ?>
+<?php echo 2; ?>
+Test
+
+`;
diff --git a/tests/newline/mixed-CRLF.php b/tests/newline/mixed-CRLF.php
new file mode 100644
index 0000000..80d4222
--- /dev/null
+++ b/tests/newline/mixed-CRLF.php
@@ -0,0 +1,4 @@
+Text
+<?php echo 1; ?>
+<?php echo 2; ?>
+Test
diff --git a/tests/newline/mixed-LF.php b/tests/newline/mixed-LF.php
new file mode 100644
index 0000000..80d4222
--- /dev/null
+++ b/tests/newline/mixed-LF.php
@@ -0,0 +1,4 @@
+Text
+<?php echo 1; ?>
+<?php echo 2; ?>
+Test