Repository: prettier/plugin-php
Pull request #115 (2018-02-23 12:47:03)

Remove open brace option
Temporarily removing until we get more feedback on https://github.com/prettier/plugin-php/issues/107


Patch:
diff --git a/src/options.js b/src/options.js
index 6011883..56520c5 100644
--- a/src/options.js
+++ b/src/options.js
@@ -1,10 +1,11 @@
 "use strict";
 
 module.exports = {
-  openingBraceNewLine: {
-    type: "boolean",
-    category: "Global",
-    default: true,
-    description: "Move open brace for code blocks onto new line."
-  }
+  // see https://github.com/prettier/plugin-php/issues/107
+  // openingBraceNewLine: {
+  //   type: "boolean",
+  //   category: "Global",
+  //   default: true,
+  //   description: "Move open brace for code blocks onto new line."
+  // }
 };
diff --git a/src/printer.js b/src/printer.js
index b2bc969..e34fa8b 100644
--- a/src/printer.js
+++ b/src/printer.js
@@ -491,7 +491,9 @@ function printStatement(path, options, print) {
         // group has already broken
         bodyContents
           ? concat([
-              options.openingBraceNewLine ? hardline : " ",
+              hardline,
+              // see https://github.com/prettier/plugin-php/issues/107
+              // options.openingBraceNewLine ? hardline : " ",
               "{",
               indent(concat([hardline, bodyContents])),
               hardline,


Test patch:
diff --git a/tests/class/__snapshots__/jsfmt.spec.js.snap b/tests/class/__snapshots__/jsfmt.spec.js.snap
index ad7326e..7771bc5 100644
--- a/tests/class/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/class/__snapshots__/jsfmt.spec.js.snap
@@ -237,228 +237,3 @@ class A
 }
 
 `;
-
-exports[`class.php 2`] = `
-<?php
-
-class Foo extends Bar implements Baz, Buzz {
-  public $test;
-
-  function test() {
-    return "test";
-  }
-
-  public function &passByReferenceTest() {
-    $a = 1;
-    return $a;
-  }
-}
-
-$test = new Foo();
-
-abstract class ReallyReallyReallyLongClassName extends AbstractModelFactoryResourceController implements TooMuchObjectOrientation, ThisIsMadness {
-  // variable doc
-  public $test;
-  public $other = 1;
-  public static $staticTest = ['hi'];
-
-  /**
-   * test constructor
-   *
-   * @param \\Test\\Foo\\Bar $test        hi
-   * @param int           $test_int    test
-   * @param string        $test_string test
-   *
-   * @return \\Some\\Test
-   */
-  public function __construct($test, $test_int = null, $test_string = 'hi') {
-    parent::__construct($test_int ?: 1);
-    $this->other = $test_string;
-    $this->current_version = $current_version ?: new Content_Version_Model();
-    self::$staticTest = $test_int;
-  }
-
-  public static function test_static_constructor($test, $test_int, $test_string) {
-    $model = new self($test, $test_int, $test_string);
-    $model = new self($really_really_really_really_really_really_really_really_long_array, $test_int, $test_string);
-    return $model;
-  }
-
-  public function test_pass_by_reference(&$test)
-  {
-    $test + 1;
-  }
-
-  /**
-   * This is a function
-   */
-  private function hi($input) {
-    $test = 1;
-
-    //testing line spacing
-    $other_test = 2;
-
-
-    $one_more_test = 3;
-    return $input . $this->test;
-
-  }
-
-  public function reallyReallyReallyReallyReallyReallyReallyLongMethodName($input, $otherInput = 1) {
-    return true;
-  }
-
-  // doc test
-  public static function testStaticFunction($input) {
-    return self::$staticTest[0];
-  }
-
-  public function returnTypeTest() : string
-  {
-    return 'hi';
-  }
-
-  final public static function bar()
-  {
-    // Nothing
-  }
-
-  abstract protected function zim();
-
-  public function method(iterable $iterable): array {
-    // Parameter broadened and return type narrowed.
-  }
-
-  public function method1() { return 'hi'; }
-
-  public function method2() {
-      return 'hi'; }
-
-  public function method3()
-    { return 'hi'; }
-}
-
-$this->something->method($argument, $this->more->stuff($this->even->more->things->complicatedMethod()));
-
-class A {}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-<?php
-class Foo extends Bar implements Baz, Buzz {
-  public $test;
-
-  public function test() {
-    return "test";
-  }
-
-  public function &passByReferenceTest() {
-    $a = 1;
-    return $a;
-  }
-}
-
-$test = new Foo();
-
-abstract class ReallyReallyReallyLongClassName
-  extends AbstractModelFactoryResourceController
-  implements TooMuchObjectOrientation, ThisIsMadness {
-  // variable doc
-  public $test;
-  public $other = 1;
-  public static  $staticTest = ['hi'];
-
-  /**
-   * test constructor
-   *
-   * @param \\Test\\Foo\\Bar $test        hi
-   * @param int           $test_int    test
-   * @param string        $test_string test
-   *
-   * @return \\Some\\Test
-   */
-  public function __construct($test, $test_int = null, $test_string = 'hi') {
-    parent::__construct($test_int ?: 1);
-    $this->other = $test_string;
-    $this->current_version = $current_version ?: new Content_Version_Model();
-    self::$staticTest = $test_int;
-  }
-
-  public static function test_static_constructor(
-    $test,
-    $test_int,
-    $test_string
-  ) {
-    $model = new self($test, $test_int, $test_string);
-    $model = new self(
-      $really_really_really_really_really_really_really_really_long_array,
-      $test_int,
-      $test_string
-    );
-    return $model;
-  }
-
-  public function test_pass_by_reference(&$test) {
-    $test + 1;
-  }
-
-  /**
-   * This is a function
-   */
-  private function hi($input) {
-    $test = 1;
-
-    // testing line spacing
-    $other_test = 2;
-
-    $one_more_test = 3;
-    return $input . $this->test;
-  }
-
-  public function reallyReallyReallyReallyReallyReallyReallyLongMethodName(
-    $input,
-    $otherInput = 1
-  ) {
-    return true;
-  }
-
-  // doc test
-  public static function testStaticFunction($input) {
-    return self::$staticTest[0];
-  }
-
-  public function returnTypeTest(): string {
-    return 'hi';
-  }
-
-  final public static function bar() {
-    // Nothing
-  }
-
-  abstract protected function zim();
-
-  public function method(iterable $iterable): array {
-    // Parameter broadened and return type narrowed.
-  }
-
-  public function method1() {
-    return 'hi';
-  }
-
-  public function method2() {
-    return 'hi';
-  }
-
-  public function method3() {
-    return 'hi';
-  }
-}
-
-$this->something->method(
-  $argument,
-  $this->more->stuff($this->even->more->things->complicatedMethod())
-);
-
-class A {
-
-}
-
-`;
diff --git a/tests/class/jsfmt.spec.js b/tests/class/jsfmt.spec.js
index 9da7b3e..5378de1 100644
--- a/tests/class/jsfmt.spec.js
+++ b/tests/class/jsfmt.spec.js
@@ -1,2 +1,3 @@
 run_spec(__dirname, ["php"]);
-run_spec(__dirname, ["php"], { openingBraceNewLine: false });
+// see https://github.com/prettier/plugin-php/issues/107
+// run_spec(__dirname, ["php"], { openingBraceNewLine: false });
diff --git a/tests/functions/__snapshots__/jsfmt.spec.js.snap b/tests/functions/__snapshots__/jsfmt.spec.js.snap
index c9e6047..ff975fe 100644
--- a/tests/functions/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/functions/__snapshots__/jsfmt.spec.js.snap
@@ -171,163 +171,3 @@ function gen(): iterable
 }
 
 `;
-
-exports[`functions.php 2`] = `
-<?php
-
-function hello(){
-    return "hello";
-}
-
-function return_x($x){
-    return $x;
-}
-
-function two_args($x, $y) {
-    return $x;
-}
-
-function reeeeeeeeeeaaaaaaaallllllllyyyyyy_llloooooooonnnnnnggggg($soooooooooooo_looooooooonnnng, $eeeeeeeeevvveeeeeeeennnn_loooooonnngggeeeerrrr) {
-    return $soooooooooooo_looooooooonnnng;
-}
-
-function variadicTest($one, ...$others) {
-  // test
-  $hi = 2;
-  return count($others);
-}
-
-function pass_by_reference_test($x, int &$a) {
-  $a += 1;
-}
-
-function type_hinting_test(array $array_test, callable $callable_test, bool $bool_test, float $float_test, iterable $iterable_test, int $int_test, string $string_test = '') {
-  return $int_test;
-}
-
-$anonymous = function($name) use ($otherthing, &$reference_test){
-  printf("Hello %s", $name);
-  $reference_test += 1;
-};
-$anonymousLongVariableName = function($name, $more, $params, $looooooooooooooooooooooooooooooooong) use ($all, $kinds, $of, $stuff) {
-  printf("Hello %s", $name);
-};
-
-$arr = [1,2,3];
-array_map(function($entry) {
-  return $entry * 2;
-}, $arr);
-
-$silent = @hello();
-
-function returnTypeTest(): string {
-  return 'hi';
-}
-
-function &passByReferenceTest()
-{
-  $a = 1;
-  return $a;
-}
-
-function foo(iterable $iterable = []) {}
-
-function bar(): iterable {
-    return [1, 2, 3];
-}
-
-function gen(): iterable {
-    yield 1;
-    yield 2;
-    yield 3;
-}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-<?php
-function hello() {
-  return "hello";
-}
-
-function return_x($x) {
-  return $x;
-}
-
-function two_args($x, $y) {
-  return $x;
-}
-
-function reeeeeeeeeeaaaaaaaallllllllyyyyyy_llloooooooonnnnnnggggg(
-  $soooooooooooo_looooooooonnnng,
-  $eeeeeeeeevvveeeeeeeennnn_loooooonnngggeeeerrrr
-) {
-  return $soooooooooooo_looooooooonnnng;
-}
-
-function variadicTest($one, ...$others) {
-  // test
-  $hi = 2;
-  return count($others);
-}
-
-function pass_by_reference_test($x, int &$a) {
-  $a += 1;
-}
-
-function type_hinting_test(
-  array $array_test,
-  callable $callable_test,
-  bool $bool_test,
-  float $float_test,
-  iterable $iterable_test,
-  int $int_test,
-  string $string_test = ''
-) {
-  return $int_test;
-}
-
-$anonymous = function ($name) use ($otherthing, &$reference_test) {
-  printf("Hello %s", $name);
-  $reference_test += 1;
-};
-$anonymousLongVariableName = function (
-  $name,
-  $more,
-  $params,
-  $looooooooooooooooooooooooooooooooong
-) use ($all, $kinds, $of, $stuff) {
-  printf("Hello %s", $name);
-};
-
-$arr = [1, 2, 3];
-array_map(
-  function ($entry) {
-    return $entry * 2;
-  },
-  $arr
-);
-
-$silent = @hello();
-
-function returnTypeTest(): string {
-  return 'hi';
-}
-
-function &passByReferenceTest() {
-  $a = 1;
-  return $a;
-}
-
-function foo(iterable $iterable = []) {
-
-}
-
-function bar(): iterable {
-  return [1, 2, 3];
-}
-
-function gen(): iterable {
-  yield 1;
-  yield 2;
-  yield 3;
-}
-
-`;
diff --git a/tests/functions/jsfmt.spec.js b/tests/functions/jsfmt.spec.js
index 9da7b3e..5378de1 100644
--- a/tests/functions/jsfmt.spec.js
+++ b/tests/functions/jsfmt.spec.js
@@ -1,2 +1,3 @@
 run_spec(__dirname, ["php"]);
-run_spec(__dirname, ["php"], { openingBraceNewLine: false });
+// see https://github.com/prettier/plugin-php/issues/107
+// run_spec(__dirname, ["php"], { openingBraceNewLine: false });
diff --git a/tests/interface/__snapshots__/jsfmt.spec.js.snap b/tests/interface/__snapshots__/jsfmt.spec.js.snap
index b2581f1..4159d3e 100644
--- a/tests/interface/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/interface/__snapshots__/jsfmt.spec.js.snap
@@ -25,27 +25,3 @@ interface test2 extends testInterface
 }
 
 `;
-
-exports[`interface.php 2`] = `
-<?php
-
-interface testInterface {
-    public function setVariable($test);
-    public function method(array $array): iterable;
-}
-
-interface test2 extends testInterface {
-  public function other($hi);
-}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-<?php
-interface testInterface {
-  public function setVariable($test);
-  public function method(array $array): iterable;
-}
-
-interface test2 extends testInterface {
-  public function other($hi);
-}
-
-`;
diff --git a/tests/interface/jsfmt.spec.js b/tests/interface/jsfmt.spec.js
index 9da7b3e..5378de1 100644
--- a/tests/interface/jsfmt.spec.js
+++ b/tests/interface/jsfmt.spec.js
@@ -1,2 +1,3 @@
 run_spec(__dirname, ["php"]);
-run_spec(__dirname, ["php"], { openingBraceNewLine: false });
+// see https://github.com/prettier/plugin-php/issues/107
+// run_spec(__dirname, ["php"], { openingBraceNewLine: false });
diff --git a/tests/kitchen_sink/__snapshots__/jsfmt.spec.js.snap b/tests/kitchen_sink/__snapshots__/jsfmt.spec.js.snap
index 9091b1f..d6a6316 100644
--- a/tests/kitchen_sink/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/kitchen_sink/__snapshots__/jsfmt.spec.js.snap
@@ -114,7 +114,8 @@ do {
 } while ($really_really_really_really_really_really_really_really_long_array >= 10);
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 <?php
-function hello($input) {
+function hello($input)
+{
   return "hello" + $input;
 }
 
@@ -137,7 +138,8 @@ function really_long_function(
   $test2 = 1,
   $long_parameter_name,
   $even_longer_longer_longer_longer_longer_parameter_name
-) {
+)
+{
   return $test2;
 }
 
diff --git a/tests/traits/__snapshots__/jsfmt.spec.js.snap b/tests/traits/__snapshots__/jsfmt.spec.js.snap
index db4f827..3049716 100644
--- a/tests/traits/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/traits/__snapshots__/jsfmt.spec.js.snap
@@ -78,72 +78,3 @@ class ShortImplementingClass
 }
 
 `;
-
-exports[`traits.php 2`] = `
-<?php
-trait A {
-  function testFunction() { /*1*/ }
-  function otherTestFunction() { /*2*/ }
-}
-
-trait B extends otherTrait {
-  function someOtherTestFunction() { /*3*/ }
-}
-
-trait C extends A implements B {
-  function someOtherTestFunction() { /*4*/ }
-  function testFunction() { /*5*/ }
-}
-
-class ImplementingClass {
-    use testTrait, otherTrait;
-    use testTrait, implementingTrait {
-      A::testFunction insteadof C;
-      B::someOtherTestFunction as aliasedFunctionName;
-      C::testFunction as private testVisibility;
-    }
-}
-
-class ShortImplementingClass {
-  use testTrait { A::testFunction insteadof C; }
-}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-<?php
-trait A {
-  public function testFunction() {
-    // 1
-  }
-  public function otherTestFunction() {
-    // 2
-  }
-}
-
-trait B extends otherTrait {
-  public function someOtherTestFunction() {
-    // 3
-  }
-}
-
-trait C extends A implements B {
-  public function someOtherTestFunction() {
-    // 4
-  }
-  public function testFunction() {
-    // 5
-  }
-}
-
-class ImplementingClass {
-  use testTrait, otherTrait;
-  use testTrait, implementingTrait {
-    A::testFunction insteadof C;
-    B::someOtherTestFunction as aliasedFunctionName;
-    C::testFunction as private testVisibility;
-  }
-}
-
-class ShortImplementingClass {
-  use testTrait { A::testFunction insteadof C; }
-}
-
-`;
diff --git a/tests/traits/jsfmt.spec.js b/tests/traits/jsfmt.spec.js
index 9da7b3e..5378de1 100644
--- a/tests/traits/jsfmt.spec.js
+++ b/tests/traits/jsfmt.spec.js
@@ -1,2 +1,3 @@
 run_spec(__dirname, ["php"]);
-run_spec(__dirname, ["php"], { openingBraceNewLine: false });
+// see https://github.com/prettier/plugin-php/issues/107
+// run_spec(__dirname, ["php"], { openingBraceNewLine: false });