1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-26 00:32:41 +01:00

Improve brace formatting linter rule

Summary: Allow the brace formatting linter rule to complain about `class X{}`.

Test Plan: Updated unit tests.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D14690
This commit is contained in:
Joshua Spence 2015-12-07 20:20:57 +00:00 committed by joshuaspence
parent b52e9dc702
commit a6e81daad1
7 changed files with 112 additions and 95 deletions

View file

@ -24,14 +24,6 @@ final class ArcanistBraceFormattingXHPASTLinterRule
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(

View file

@ -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);

View file

@ -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 {}

View file

@ -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 {}

View file

@ -0,0 +1,4 @@
<?php
declare(ticks = 1);
~~~~~~~~~~

View file

@ -0,0 +1,27 @@
<?php
function f() {
}
function g()
{
}
function h(){}
~~~~~~~~~~
warning:7:13
warning:12:13
~~~~~~~~~~
<?php
function f() {
}
function g() {
}
function h() {}

View file

@ -0,0 +1,14 @@
<?php
try
{}
catch (Exception $x)
{}
~~~~~~~~~~
warning:3:4
warning:5:21
~~~~~~~~~~
<?php
try {}
catch (Exception $x) {}