Repository: prettier/plugin-php
Pull request #651 (2018-09-19 16:56:09)

fix: staticlookup newline with identifier


Patch:
diff --git a/src/printer.js b/src/printer.js
index e7c1c52..e252dc3 100644
--- a/src/printer.js
+++ b/src/printer.js
@@ -1970,7 +1970,7 @@ function printNode(path, options, print) {
             (firstNonMemberParent.kind === "assign" &&
               firstNonMemberParent.left.kind !== "variable"))) ||
         node.kind === "offsetlookup" ||
-        (node.what.kind === "variable" &&
+        ((node.what.kind === "identifier" || node.what.kind === "variable") &&
           (node.offset.kind === "constref" ||
             node.offset.kind === "variable") &&
           (parent && !isLookupNode(parent)));


Test patch:
diff --git a/tests/propertylookup/__snapshots__/jsfmt.spec.js.snap b/tests/propertylookup/__snapshots__/jsfmt.spec.js.snap
index 79353bb..51d6622 100644
--- a/tests/propertylookup/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/propertylookup/__snapshots__/jsfmt.spec.js.snap
@@ -23,6 +23,9 @@ $this->loooooooooooong->lookup = (int) $this->getRequest()->getParam(
 
 $obj->veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongProperty;
 $obj->veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongProperty();
+
+$var = $var->aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
+$var->aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = $var->aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 <?php
 
@@ -50,6 +53,11 @@ $this->loooooooooooong->lookup = (int) $this->getRequest()->getParam(
 $obj->veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongProperty;
 $obj->veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongProperty();
 
+$var =
+    $var->aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
+$var->aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =
+    $var->aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
+
 `;
 
 exports[`single.php - php-verify: single.php 1`] = `
diff --git a/tests/propertylookup/propertylookup.php b/tests/propertylookup/propertylookup.php
index 8d55180..f7fcb02 100644
--- a/tests/propertylookup/propertylookup.php
+++ b/tests/propertylookup/propertylookup.php
@@ -20,3 +20,6 @@ $this->loooooooooooong->lookup = (int) $this->getRequest()->getParam(
 
 $obj->veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongProperty;
 $obj->veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongProperty();
+
+$var = $var->aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
+$var->aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = $var->aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
diff --git a/tests/staticlookup/__snapshots__/jsfmt.spec.js.snap b/tests/staticlookup/__snapshots__/jsfmt.spec.js.snap
index 5468b84..11a17a5 100644
--- a/tests/staticlookup/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/staticlookup/__snapshots__/jsfmt.spec.js.snap
@@ -100,6 +100,8 @@ $obj::veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVe
 $obj::$veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongProperty();
 
 $var = ($this->modelClass)::where('name', 'like', strtoupper("%\${key}%"))->get();
+
+MyVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongClass::class;
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 <?php
 Foo::aStaticMethod();
@@ -199,4 +201,6 @@ $obj::$veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryV
 
 $var = $this->modelClass::where('name', 'like', strtoupper("%\${key}%"))->get();
 
+MyVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongClass::class;
+
 `;
diff --git a/tests/staticlookup/staticlookup.php b/tests/staticlookup/staticlookup.php
index 806575e..bfb3e35 100644
--- a/tests/staticlookup/staticlookup.php
+++ b/tests/staticlookup/staticlookup.php
@@ -79,3 +79,5 @@ $obj::veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVe
 $obj::$veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongProperty();
 
 $var = ($this->modelClass)::where('name', 'like', strtoupper("%${key}%"))->get();
+
+MyVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongClass::class;