Page MenuHomePhabricator

D14690.diff
No OneTemporary

D14690.diff

diff --git a/src/lint/linter/xhpast/rules/ArcanistBraceFormattingXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistBraceFormattingXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistBraceFormattingXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistBraceFormattingXHPASTLinterRule.php
@@ -24,14 +24,6 @@
if (!$before) {
$first = head($tokens);
- // Only insert the space if we're after a closing parenthesis. If
- // we're in a construct like "else{}", other rules will insert space
- // after the 'else' correctly.
- $prev = $first->getPrevToken();
- if (!$prev || $prev->getValue() !== ')') {
- continue;
- }
-
$this->raiseLintAtToken(
$first,
pht(
diff --git a/src/lint/linter/xhpast/rules/__tests__/brace-formatting/brace-formatting.lint-test b/src/lint/linter/xhpast/rules/__tests__/brace-formatting/brace-formatting.lint-test
deleted file mode 100644
--- a/src/lint/linter/xhpast/rules/__tests__/brace-formatting/brace-formatting.lint-test
+++ /dev/null
@@ -1,87 +0,0 @@
-<?php
-
-function f() {
-
-}
-
-function g()
-{
-
-}
-
-if (1)
-{}
-
-foreach (x() as $y)
-{}
-
-while (1)
-{}
-
-switch (1)
-{}
-
-try
-{}
-catch (Exception $x)
-{}
-
-function h(){}
-if ($x) foo();
-else bar();
-do baz(); while ($x);
-
-if ($x) {}
-else if ($y) {}
-else {}
-
-if ($x) {}else{}
-
-declare(ticks = 1);
-~~~~~~~~~~
-warning:7:13
-warning:12:7
-warning:15:20
-warning:18:10
-warning:21:11
-warning:24:4
-warning:26:21
-warning:29:13
-warning:30:9
-warning:31:6
-warning:32:4
-warning:34:11
-warning:35:16
-warning:38:11
-~~~~~~~~~~
-<?php
-
-function f() {
-
-}
-
-function g() {
-
-}
-
-if (1) {}
-
-foreach (x() as $y) {}
-
-while (1) {}
-
-switch (1) {}
-
-try {}
-catch (Exception $x) {}
-
-function h() {}
-if ($x) foo();
-else bar();
-do baz(); while ($x);
-
-if ($x) {} else if ($y) {} else {}
-
-if ($x) {} else{}
-
-declare(ticks = 1);
diff --git a/src/lint/linter/xhpast/rules/__tests__/brace-formatting/class.lint-test b/src/lint/linter/xhpast/rules/__tests__/brace-formatting/class.lint-test
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/xhpast/rules/__tests__/brace-formatting/class.lint-test
@@ -0,0 +1,14 @@
+<?php
+
+class SomeClass {}
+class SomeOtherClass{}
+class YetAnotherClass extends SomeClass{}
+~~~~~~~~~~
+warning:4:21
+warning:5:40
+~~~~~~~~~~
+<?php
+
+class SomeClass {}
+class SomeOtherClass {}
+class YetAnotherClass extends SomeClass {}
diff --git a/src/lint/linter/xhpast/rules/__tests__/brace-formatting/control-statement.lint-test b/src/lint/linter/xhpast/rules/__tests__/brace-formatting/control-statement.lint-test
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/xhpast/rules/__tests__/brace-formatting/control-statement.lint-test
@@ -0,0 +1,53 @@
+<?php
+
+if (1)
+{}
+
+foreach (x() as $y)
+{}
+
+while (1)
+{}
+
+switch (1)
+{}
+
+if ($x) foo();
+else bar();
+do baz(); while ($x);
+
+if ($x) {}
+else if ($y) {}
+else {}
+
+if ($x) {}else{}
+~~~~~~~~~~
+warning:3:7
+warning:6:20
+warning:9:10
+warning:12:11
+warning:15:9
+warning:16:6
+warning:17:4
+warning:19:11
+warning:20:16
+warning:23:11
+warning:23:15
+~~~~~~~~~~
+<?php
+
+if (1) {}
+
+foreach (x() as $y) {}
+
+while (1) {}
+
+switch (1) {}
+
+if ($x) foo();
+else bar();
+do baz(); while ($x);
+
+if ($x) {} else if ($y) {} else {}
+
+if ($x) {} else {}
diff --git a/src/lint/linter/xhpast/rules/__tests__/brace-formatting/declare.lint-test b/src/lint/linter/xhpast/rules/__tests__/brace-formatting/declare.lint-test
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/xhpast/rules/__tests__/brace-formatting/declare.lint-test
@@ -0,0 +1,4 @@
+<?php
+
+declare(ticks = 1);
+~~~~~~~~~~
diff --git a/src/lint/linter/xhpast/rules/__tests__/brace-formatting/function.lint-test b/src/lint/linter/xhpast/rules/__tests__/brace-formatting/function.lint-test
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/xhpast/rules/__tests__/brace-formatting/function.lint-test
@@ -0,0 +1,27 @@
+<?php
+
+function f() {
+
+}
+
+function g()
+{
+
+}
+
+function h(){}
+~~~~~~~~~~
+warning:7:13
+warning:12:13
+~~~~~~~~~~
+<?php
+
+function f() {
+
+}
+
+function g() {
+
+}
+
+function h() {}
diff --git a/src/lint/linter/xhpast/rules/__tests__/brace-formatting/try-catch.lint-test b/src/lint/linter/xhpast/rules/__tests__/brace-formatting/try-catch.lint-test
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/xhpast/rules/__tests__/brace-formatting/try-catch.lint-test
@@ -0,0 +1,14 @@
+<?php
+
+try
+{}
+catch (Exception $x)
+{}
+~~~~~~~~~~
+warning:3:4
+warning:5:21
+~~~~~~~~~~
+<?php
+
+try {}
+catch (Exception $x) {}

File Metadata

Mime Type
text/plain
Expires
Tue, Mar 11, 6:16 PM (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7542991
Default Alt Text
D14690.diff (4 KB)

Event Timeline