Skip to content

Commit

Permalink
Prioritize "Before Class End" of Blank Lines Option apache#4611
Browse files Browse the repository at this point in the history
- apache#4611
- Fix unit tests
  • Loading branch information
junichi11 committed Mar 28, 2023
1 parent 4a63ce5 commit f6a67e8
Show file tree
Hide file tree
Showing 433 changed files with 2,607 additions and 542 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ public void visit(Block node) {
formatTokens.add(new FormatToken.IndentToken(ts.offset(), options.indentSize));
}

if (parent instanceof ClassDeclaration || parent instanceof InterfaceDeclaration || parent instanceof TraitDeclaration) {
if (isTypeNode(parent)) {
formatTokens.add(new FormatToken(FormatToken.Kind.WHITESPACE_AFTER_CLASS_LEFT_BRACE, ts.offset()));
} else if (isAnonymousClass(parent)) {
formatTokens.add(new FormatToken(FormatToken.Kind.WHITESPACE_AFTER_ANONYMOUS_CLASS_LEFT_BRACE, ts.offset()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ public void run() {
indentRule = true;
ws = countWhiteSpaceBeforeRightBrace(
docOptions.classDeclBracePlacement,
newLines,
docOptions.blankLinesBeforeClassEnd + 1, // GH-46111 ignore existing newLines to prioritize this option
docOptions.blankLinesBeforeClassEnd,
indent,
formatTokens,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ class Example {
echo 'Caught exception: ' . $e->getMessage() . "\n";
}
}

}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ class Example {
echo 'Caught exception: ' . $e->getMessage() . "\n";
}
}

}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ class Example
echo 'Caught exception: ' . $e->getMessage() . "\n";
}
}

}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ class Example
echo 'Caught exception: ' . $e->getMessage() . "\n";
}
}

}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class test {
"shor" => 222
);
}

}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class test {
"shor" => 222
);
}

}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class Foo {
//
}
}

}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class A {

$quiteLongVariable = "long";
}

}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ abstract
function functionName3() {

}

}

class Foo {
Expand All @@ -52,7 +51,6 @@ trait Trt {
function foo() {

}

}

interface Iface {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ class Dummy {
private $barbarbarbar = 'b';
protected $snafu = 'c';
public $foo = 'a';

}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class MyClass extends BaseClass {
}
};
}

}

$anonClass = new class {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class Test {
"Item 3" => 3
);
public $number2 = 1;

}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class Test {
echo "false";
}
}

}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,4 @@ class ArrowFunctions {
public static function new() {
return new ArrowFunctions();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ class Example
echo 'Caught exception: ' . $e->getMessage() . "\n";
}
}

}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ class Example
echo 'Caught exception: ' . $e->getMessage() . "\n";
}
}

}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class Example {
echo 'Caught exception: ' . $e->getMessage() . "\n";
}
}

}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class BaseClass {
final public function moreTesting() {
echo "BaseClass::moreTesting() called\n";
}

}

final class ChildClass extends BaseClass {
Expand All @@ -21,13 +20,11 @@ final class ChildClass extends BaseClass {
public function method1() {

}

}

final class ChildClass2 extends BaseClass {

public $field2 = 22;

}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ class Example
echo 'Caught exception: ' . $e->getMessage() . "\n";
}
}

}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ class ClassConstantVisibility {
public const PUBLIC_CONST = 1;
private const PRIVATE_CONST = [1, 2];
protected const PROTECTED_CONST = "";

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ class ClassConstantVisibility {
public const PUBLIC_CONST = 1;
private const PRIVATE_CONST = [1, 2];
protected const PROTECTED_CONST = "";

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ class ClassConstantVisibility {
* PROTECTED_CONST
*/
protected const PROTECTED_CONST = "";

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ class ClassConstantVisibility {
* PROTECTED_CONST
*/
protected const PROTECTED_CONST = "";

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ class ClassConstantVisibility {
private const PRIVATE_CONST = [1, 2];

protected const PROTECTED_CONST = "";

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ class ClassConstantVisibility {
private const PRIVATE_CONST = [1, 2];

protected const PROTECTED_CONST = "";

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ class ClassConstantVisibility {
public function publicFunction() {

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ class ClassConstantVisibility {
public function publicFunction() {

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
class Simple {

public $field1 = 22;

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ class Simple {

public $field1 = 22;
public $field2 = "ahoj";

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ class Simple {
* @var int
*/
public $field1 = 22;

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ class Simple {
* @var int
*/
public $field1 = 22;

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ class Simple {
// comment 3

public $field2;

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ class Simple {
public function method01() {

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ class Simple {
public function method01() {

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,4 @@ class Test {
$this->field2 = $field2;
$this->field3 = $field3;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,4 @@ class Test {
$this->field2 = $field2;
$this->field3 = $field3;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class Connection {
* comment for field2
*/
public $field2;

}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class Connection {


public $field2;

}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ final class TestFianl extends Bla {
public function test2() {

}

}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class SimpleClass {
public function displayVar() {
echo $this->var;
}

}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class SimpleClass {
public function displayVar() {
echo $this->var;
}

}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class Item {
return "You ordered ($this->qty) '$this->name'" . ($this->qty == 1 ? "" : "s") .
" at \$$this->price, for a total of: \$$this->total.";
}

}

echo (new Item("Widget 22", 4.90, 2));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ class class_name {
public function test() {

}

}
?>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ class class_name { // test
public function test() {

}

}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ class class_name {
public function test() {

}

}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ class class_name {
public function test() {

}

}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class class_name
{

}

}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
{

}

}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ trait SimpleClass {
public function displayVar() {
echo $this->var;
}

}

?>
Loading

0 comments on commit f6a67e8

Please sign in to comment.