Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15419940
D13534.id33534.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
21 KB
Referenced Files
None
Subscribers
None
D13534.id33534.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -170,6 +170,7 @@
'ArcanistMissingLinterException' => 'lint/linter/exception/ArcanistMissingLinterException.php',
'ArcanistModifierOrderingXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistModifierOrderingXHPASTLinterRule.php',
'ArcanistNamingConventionsXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistNamingConventionsXHPASTLinterRule.php',
+ 'ArcanistNewlineAfterOpenTagXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistNewlineAfterOpenTagXHPASTLinterRule.php',
'ArcanistNoEffectException' => 'exception/usage/ArcanistNoEffectException.php',
'ArcanistNoEngineException' => 'exception/usage/ArcanistNoEngineException.php',
'ArcanistNoLintLinter' => 'lint/linter/ArcanistNoLintLinter.php',
@@ -453,6 +454,7 @@
'ArcanistMissingLinterException' => 'Exception',
'ArcanistModifierOrderingXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
'ArcanistNamingConventionsXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
+ 'ArcanistNewlineAfterOpenTagXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
'ArcanistNoEffectException' => 'ArcanistUsageException',
'ArcanistNoEngineException' => 'ArcanistUsageException',
'ArcanistNoLintLinter' => 'ArcanistLinter',
diff --git a/src/lint/linter/__tests__/xhpast/array-index.lint-test b/src/lint/linter/__tests__/xhpast/array-index.lint-test
--- a/src/lint/linter/__tests__/xhpast/array-index.lint-test
+++ b/src/lint/linter/__tests__/xhpast/array-index.lint-test
@@ -1,15 +1,17 @@
<?php
+
$a []= 1;
$a[] = 1;
$a[]=1;
$a [] = 1;
~~~~~~~~~~
-warning:2:3
-warning:2:6
-warning:4:5
-warning:5:3
+warning:3:3
+warning:3:6
+warning:5:5
+warning:6:3
~~~~~~~~~~
<?php
+
$a[] = 1;
$a[] = 1;
$a[] = 1;
diff --git a/src/lint/linter/__tests__/xhpast/call-time-pass-by-reference.lint-test b/src/lint/linter/__tests__/xhpast/call-time-pass-by-reference.lint-test
--- a/src/lint/linter/__tests__/xhpast/call-time-pass-by-reference.lint-test
+++ b/src/lint/linter/__tests__/xhpast/call-time-pass-by-reference.lint-test
@@ -1,4 +1,5 @@
<?php
+
class MyClass {
public function myfunc($var) {
echo $var;
@@ -24,10 +25,10 @@
array_walk(array(), function () use (&$x) {});
MyClass::myfunc(array(&$x, &$y));
~~~~~~~~~~
-error:2:7 XHP19
-error:9:8
-error:12:15
-error:15:17
-error:18:24
-error:18:39
-error:22:6
+error:3:7 XHP19
+error:10:8
+error:13:15
+error:16:17
+error:19:24
+error:19:39
+error:23:6
diff --git a/src/lint/linter/__tests__/xhpast/class-name-literal.lint-test b/src/lint/linter/__tests__/xhpast/class-name-literal.lint-test
--- a/src/lint/linter/__tests__/xhpast/class-name-literal.lint-test
+++ b/src/lint/linter/__tests__/xhpast/class-name-literal.lint-test
@@ -1,4 +1,5 @@
<?php
+
class MyClass {
public function someMethod() {
return 'MyClass';
@@ -11,11 +12,12 @@
}
}
~~~~~~~~~~
-error:2:7
-advice:4:12
-advice:8:10
+error:3:7
+advice:5:12
+advice:9:10
~~~~~~~~~~
<?php
+
class MyClass {
public function someMethod() {
return __CLASS__;
diff --git a/src/lint/linter/__tests__/xhpast/constructor-parentheses.lint-test b/src/lint/linter/__tests__/xhpast/constructor-parentheses.lint-test
--- a/src/lint/linter/__tests__/xhpast/constructor-parentheses.lint-test
+++ b/src/lint/linter/__tests__/xhpast/constructor-parentheses.lint-test
@@ -1,12 +1,14 @@
<?php
+
new Foo;
new Bar();
new Foo\Bar;
~~~~~~~~~~
-advice:2:5
-advice:4:5
+advice:3:5
+advice:5:5
~~~~~~~~~~
<?php
+
new Foo();
new Bar();
new Foo\Bar();
diff --git a/src/lint/linter/__tests__/xhpast/double-quote.lint-test b/src/lint/linter/__tests__/xhpast/double-quote.lint-test
--- a/src/lint/linter/__tests__/xhpast/double-quote.lint-test
+++ b/src/lint/linter/__tests__/xhpast/double-quote.lint-test
@@ -1,4 +1,5 @@
<?php
+
'foobar';
"foo\"bar";
"foobar\n";
@@ -12,9 +13,10 @@
"This string also requires \123\345 double quotes, but ".
"this string does not. Here, they are used for consistency.");
~~~~~~~~~~
-advice:3:1
+advice:4:1
~~~~~~~~~~
<?php
+
'foobar';
'foo"bar';
"foobar\n";
diff --git a/src/lint/linter/__tests__/xhpast/duplicate-switch-case.lint-test b/src/lint/linter/__tests__/xhpast/duplicate-switch-case.lint-test
--- a/src/lint/linter/__tests__/xhpast/duplicate-switch-case.lint-test
+++ b/src/lint/linter/__tests__/xhpast/duplicate-switch-case.lint-test
@@ -1,4 +1,5 @@
<?php
+
$x = null;
$y = null;
switch ($x) {}
@@ -24,5 +25,5 @@
break;
}
~~~~~~~~~~
-error:15:3
-error:22:7
+error:16:3
+error:23:7
diff --git a/src/lint/linter/__tests__/xhpast/elseif.lint-test b/src/lint/linter/__tests__/xhpast/elseif.lint-test
--- a/src/lint/linter/__tests__/xhpast/elseif.lint-test
+++ b/src/lint/linter/__tests__/xhpast/elseif.lint-test
@@ -1,4 +1,5 @@
<?php
+
if (true) {
echo 'foo';
} elseif (false) {
@@ -7,9 +8,10 @@
echo 'baz';
}
~~~~~~~~~~
-advice:4:3
+advice:7:3
~~~~~~~~~~
<?php
+
if (true) {
echo 'foo';
} else if (false) {
diff --git a/src/lint/linter/__tests__/xhpast/empty-block-statement.lint-test b/src/lint/linter/__tests__/xhpast/empty-block-statement.lint-test
--- a/src/lint/linter/__tests__/xhpast/empty-block-statement.lint-test
+++ b/src/lint/linter/__tests__/xhpast/empty-block-statement.lint-test
@@ -1,4 +1,5 @@
<?php
+
function w() {}
function x() {
// This is deliberately empty.
@@ -9,10 +10,11 @@
}
~~~~~~~~~~
-advice:6:14
advice:7:14
+advice:8:14
~~~~~~~~~~
<?php
+
function w() {}
function x() {
// This is deliberately empty.
diff --git a/src/lint/linter/__tests__/xhpast/empty-statement.lint-test b/src/lint/linter/__tests__/xhpast/empty-statement.lint-test
--- a/src/lint/linter/__tests__/xhpast/empty-statement.lint-test
+++ b/src/lint/linter/__tests__/xhpast/empty-statement.lint-test
@@ -1,11 +1,13 @@
<?php
+
final class Foo {};
$x = null;;
~~~~~~~~~~
-error:2:13 XHP19
-advice:2:19
-advice:3:11
+error:3:13 XHP19
+advice:3:19
+advice:4:11
~~~~~~~~~~
<?php
+
final class Foo {}
$x = null;
diff --git a/src/lint/linter/__tests__/xhpast/formatted-string.lint-test b/src/lint/linter/__tests__/xhpast/formatted-string.lint-test
--- a/src/lint/linter/__tests__/xhpast/formatted-string.lint-test
+++ b/src/lint/linter/__tests__/xhpast/formatted-string.lint-test
@@ -1,4 +1,5 @@
<?php
+
printf();
printf(null);
printf('');
@@ -11,11 +12,11 @@
foobar(null, null, '%s');
~~~~~~~~~~
-error:2:1
-error:6:1
+error:3:1
error:7:1
-error:10:1
-error:12:1
+error:8:1
+error:11:1
+error:13:1
~~~~~~~~~~
~~~~~~~~~~
{
diff --git a/src/lint/linter/__tests__/xhpast/global-variables.lint-test b/src/lint/linter/__tests__/xhpast/global-variables.lint-test
--- a/src/lint/linter/__tests__/xhpast/global-variables.lint-test
+++ b/src/lint/linter/__tests__/xhpast/global-variables.lint-test
@@ -1,8 +1,9 @@
<?php
+
global $BASE_URL;
function foo() {
global $x, $y;
}
~~~~~~~~~~
-warning:2:1
-warning:4:3
+warning:3:1
+warning:5:3
diff --git a/src/lint/linter/__tests__/xhpast/hash-comments.lint-test b/src/lint/linter/__tests__/xhpast/hash-comments.lint-test
--- a/src/lint/linter/__tests__/xhpast/hash-comments.lint-test
+++ b/src/lint/linter/__tests__/xhpast/hash-comments.lint-test
@@ -1,4 +1,5 @@
<?php
+
# no
#no
// yes
@@ -20,17 +21,18 @@
/** yes */
/**** yes ****/
~~~~~~~~~~
-error:2:1
error:3:1
-error:5:1
-error:6:11
-advice:13:1
+error:4:1
+error:6:1
+error:7:11
advice:14:1
-error:15:1
-advice:18:1
+advice:15:1
+error:16:1
advice:19:1
+advice:20:1
~~~~~~~~~~
<?php
+
// no
// no
// yes
diff --git a/src/lint/linter/__tests__/xhpast/implicit-visibility.lint-test b/src/lint/linter/__tests__/xhpast/implicit-visibility.lint-test
--- a/src/lint/linter/__tests__/xhpast/implicit-visibility.lint-test
+++ b/src/lint/linter/__tests__/xhpast/implicit-visibility.lint-test
@@ -1,4 +1,5 @@
<?php
+
final class Foo {
public function bar() {}
function baz() {}
@@ -10,13 +11,14 @@
private $z;
}
~~~~~~~~~~
-error:2:13 XHP19
-advice:4:3
+error:3:13 XHP19
advice:5:3
-advice:8:3
+advice:6:3
advice:9:3
+advice:10:3
~~~~~~~~~~
<?php
+
final class Foo {
public function bar() {}
public function baz() {}
diff --git a/src/lint/linter/__tests__/xhpast/index-function.lint-test b/src/lint/linter/__tests__/xhpast/index-function.lint-test
--- a/src/lint/linter/__tests__/xhpast/index-function.lint-test
+++ b/src/lint/linter/__tests__/xhpast/index-function.lint-test
@@ -1,7 +1,8 @@
<?php
+
f()[0];
~~~~~~~~~~
-error:2:5
+error:3:5
~~~~~~~~~~
~~~~~~~~~~
{
diff --git a/src/lint/linter/__tests__/xhpast/invalid-default-paramter.lint-test b/src/lint/linter/__tests__/xhpast/invalid-default-parameter.lint-test
rename from src/lint/linter/__tests__/xhpast/invalid-default-paramter.lint-test
rename to src/lint/linter/__tests__/xhpast/invalid-default-parameter.lint-test
--- a/src/lint/linter/__tests__/xhpast/invalid-default-paramter.lint-test
+++ b/src/lint/linter/__tests__/xhpast/invalid-default-parameter.lint-test
@@ -1,4 +1,5 @@
<?php
+
function func_one(array $x) {}
function func_two(array $x = null) {}
function func_three(array $x = array()) {}
@@ -12,6 +13,6 @@
function func_nine(stdClass $x = null) {}
function func_ten(stdClass $x = array()) {}
~~~~~~~~~~
-error:5:31
-error:9:35
-error:13:33
+error:6:31
+error:10:35
+error:14:33
diff --git a/src/lint/linter/__tests__/xhpast/invalid-modifiers.lint-test b/src/lint/linter/__tests__/xhpast/invalid-modifiers.lint-test
--- a/src/lint/linter/__tests__/xhpast/invalid-modifiers.lint-test
+++ b/src/lint/linter/__tests__/xhpast/invalid-modifiers.lint-test
@@ -1,4 +1,5 @@
<?php
+
class SomeClass {
public $a;
public public $b;
@@ -10,9 +11,9 @@
abstract final public function baz() {}
}
~~~~~~~~~~
-error:2:7 XHP19
-error:4:10
+error:3:7 XHP19
error:5:10
-error:6:11
-error:9:10
-error:10:12
+error:6:10
+error:7:11
+error:10:10
+error:11:12
diff --git a/src/lint/linter/__tests__/xhpast/language-construct-parentheses.lint-test b/src/lint/linter/__tests__/xhpast/language-construct-parentheses.lint-test
--- a/src/lint/linter/__tests__/xhpast/language-construct-parentheses.lint-test
+++ b/src/lint/linter/__tests__/xhpast/language-construct-parentheses.lint-test
@@ -1,4 +1,5 @@
<?php
+
include 'foo.php';
include_once 'foo.php';
require 'foo.php';
@@ -17,18 +18,19 @@
require_once ('baz.php');
echo ('baz');
~~~~~~~~~~
-warning:8:8
-warning:9:13
-warning:10:8
-warning:11:13
-warning:12:5
-warning:14:9
-warning:15:14
-warning:16:9
-warning:17:14
-warning:18:6
+warning:9:8
+warning:10:13
+warning:11:8
+warning:12:13
+warning:13:5
+warning:15:9
+warning:16:14
+warning:17:9
+warning:18:14
+warning:19:6
~~~~~~~~~~
<?php
+
include 'foo.php';
include_once 'foo.php';
require 'foo.php';
diff --git a/src/lint/linter/__tests__/xhpast/lowercase-functions.lint-test b/src/lint/linter/__tests__/xhpast/lowercase-functions.lint-test
--- a/src/lint/linter/__tests__/xhpast/lowercase-functions.lint-test
+++ b/src/lint/linter/__tests__/xhpast/lowercase-functions.lint-test
@@ -1,9 +1,11 @@
<?php
+
var_dump('');
Var_Dump('');
~~~~~~~~~~
-advice:3:1
+advice:4:1
~~~~~~~~~~
<?php
+
var_dump('');
var_dump('');
diff --git a/src/lint/linter/__tests__/xhpast/modifier-ordering.lint-test b/src/lint/linter/__tests__/xhpast/modifier-ordering.lint-test
--- a/src/lint/linter/__tests__/xhpast/modifier-ordering.lint-test
+++ b/src/lint/linter/__tests__/xhpast/modifier-ordering.lint-test
@@ -1,4 +1,5 @@
<?php
+
class Foo {
public $x;
static protected $y;
@@ -8,12 +9,13 @@
static final public function foobar() {}
}
~~~~~~~~~~
-error:2:7 XHP19
-advice:4:3
-advice:6:3
-advice:8:3
+error:3:7 XHP19
+advice:5:3
+advice:7:3
+advice:9:3
~~~~~~~~~~
<?php
+
class Foo {
public $x;
protected static $y;
diff --git a/src/lint/linter/__tests__/xhpast/naming-conventions.lint-test b/src/lint/linter/__tests__/xhpast/naming-conventions.lint-test
--- a/src/lint/linter/__tests__/xhpast/naming-conventions.lint-test
+++ b/src/lint/linter/__tests__/xhpast/naming-conventions.lint-test
@@ -1,4 +1,5 @@
<?php
+
final class a {
const b = 1, c = d;
protected $E, $H;
@@ -56,21 +57,21 @@
}
~~~~~~~~~~
-warning:2:13
-warning:3:9
-warning:3:16
-warning:4:13
-warning:4:17
-warning:5:19
-warning:5:21
-warning:5:25
-warning:8:11
-warning:12:10
-warning:12:13
-warning:26:13
-warning:29:3
+warning:3:13
+warning:4:9
+warning:4:16
+warning:5:13
+warning:5:17
+warning:6:19
+warning:6:21
+warning:6:25
+warning:9:11
+warning:13:10
+warning:13:13
+warning:27:13
warning:30:3
warning:31:3
-warning:33:3
+warning:32:3
+warning:34:3
warning:37:3
-warning:55:3
+warning:56:3
diff --git a/src/lint/linter/__tests__/xhpast/newline-after-open-tag.lint-test b/src/lint/linter/__tests__/xhpast/newline-after-open-tag.lint-test
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/__tests__/xhpast/newline-after-open-tag.lint-test
@@ -0,0 +1,25 @@
+<?php phpinfo() ?>
+<? phpinfo(); ?>
+
+<?php
+phpinfo();
+?>
+
+<?
+phpinfo();
+~~~~~~~~~~
+disabled:3:1
+advice:4:6
+disabled:7:1
+advice:8:3
+~~~~~~~~~~
+<?php phpinfo() ?>
+
+<?php
+
+phpinfo();
+?>
+
+<?
+
+phpinfo();
diff --git a/src/lint/linter/__tests__/xhpast/no-segfault-on-abstract.lint-test b/src/lint/linter/__tests__/xhpast/no-segfault-on-abstract.lint-test
--- a/src/lint/linter/__tests__/xhpast/no-segfault-on-abstract.lint-test
+++ b/src/lint/linter/__tests__/xhpast/no-segfault-on-abstract.lint-test
@@ -1,4 +1,5 @@
<?php
+
abstract class A {}
final class F {}
~~~~~~~~~~
diff --git a/src/lint/linter/__tests__/xhpast/no-segfault-on-exit.lint-test b/src/lint/linter/__tests__/xhpast/no-segfault-on-exit.lint-test
--- a/src/lint/linter/__tests__/xhpast/no-segfault-on-exit.lint-test
+++ b/src/lint/linter/__tests__/xhpast/no-segfault-on-exit.lint-test
@@ -1,3 +1,4 @@
<?php
+
exit();
~~~~~~~~~~
diff --git a/src/lint/linter/__tests__/xhpast/php54-incompat.lint-test b/src/lint/linter/__tests__/xhpast/php54-incompat.lint-test
--- a/src/lint/linter/__tests__/xhpast/php54-incompat.lint-test
+++ b/src/lint/linter/__tests__/xhpast/php54-incompat.lint-test
@@ -1,4 +1,5 @@
<?php
+
break;
break 0;
break 1;
@@ -8,10 +9,10 @@
continue 1;
continue 1 + foo() * $bar;
~~~~~~~~~~
-error:3:7
-error:5:7
-error:7:10
-error:9:10
+error:4:7
+error:6:7
+error:8:10
+error:10:10
~~~~~~~~~~
~~~~~~~~~~
{"config": {"xhpast.php-version": "5.4.0"}}
diff --git a/src/lint/linter/__tests__/xhpast/semicolon-spacing.lint-test b/src/lint/linter/__tests__/xhpast/semicolon-spacing.lint-test
--- a/src/lint/linter/__tests__/xhpast/semicolon-spacing.lint-test
+++ b/src/lint/linter/__tests__/xhpast/semicolon-spacing.lint-test
@@ -1,14 +1,16 @@
<?php
+
foo();
bar() ;
baz()
;
~~~~~~~~~~
-advice:3:6
advice:4:6
+advice:5:6
~~~~~~~~~~
<?php
+
foo();
bar();
baz();
diff --git a/src/lint/linter/__tests__/xhpast/space-after-control-keywords.lint-test b/src/lint/linter/__tests__/xhpast/space-after-control-keywords.lint-test
--- a/src/lint/linter/__tests__/xhpast/space-after-control-keywords.lint-test
+++ b/src/lint/linter/__tests__/xhpast/space-after-control-keywords.lint-test
@@ -1,4 +1,5 @@
<?php
+
if($x) {}
else{}
for(;;) {}
@@ -25,23 +26,24 @@
try {} catch(Exception $ex) {}
~~~~~~~~~~
-warning:2:1
-warning:2:10
warning:3:1
+warning:3:10
warning:4:1
warning:5:1
warning:6:1
warning:7:1
-warning:7:6
warning:8:1
-warning:9:11
-warning:10:16
-warning:13:3
+warning:8:6
+warning:9:1
+warning:10:11
+warning:11:16
warning:14:3
-warning:24:3
-warning:26:8
+warning:15:3
+warning:25:3
+warning:27:8
~~~~~~~~~~
<?php
+
if ($x) {} else {}
for (;;) {}
foreach ($x as $y) {}
diff --git a/src/lint/linter/__tests__/xhpast/space-around-more-operators.lint-test b/src/lint/linter/__tests__/xhpast/space-around-more-operators.lint-test
--- a/src/lint/linter/__tests__/xhpast/space-around-more-operators.lint-test
+++ b/src/lint/linter/__tests__/xhpast/space-around-more-operators.lint-test
@@ -1,4 +1,5 @@
<?php
+
$a.$b;
$a . $b;
$a. $b;
@@ -24,16 +25,17 @@
$x=>$y,
);
~~~~~~~~~~
-warning:3:3
-warning:3:5
-warning:4:4
-warning:5:3
-warning:12:9
-warning:13:10
-warning:14:9
-warning:24:5
+warning:4:3
+warning:4:5
+warning:5:4
+warning:6:3
+warning:13:9
+warning:14:10
+warning:15:9
+warning:25:5
~~~~~~~~~~
<?php
+
$a.$b;
$a.$b;
$a.$b;
diff --git a/src/lint/linter/__tests__/xhpast/space-around-operators.lint-test b/src/lint/linter/__tests__/xhpast/space-around-operators.lint-test
--- a/src/lint/linter/__tests__/xhpast/space-around-operators.lint-test
+++ b/src/lint/linter/__tests__/xhpast/space-around-operators.lint-test
@@ -1,4 +1,5 @@
<?php
+
$a + $b;
$a+$b;
$a +$b;
@@ -23,21 +24,22 @@
if ($x instanceof z && $w) {}
f(1,2);
~~~~~~~~~~
-warning:3:3
-warning:4:4
-warning:5:3
-warning:7:3
+warning:4:3
+warning:5:4
+warning:6:3
warning:8:3
-warning:9:4
-warning:10:3
+warning:9:3
+warning:10:4
warning:11:3
-warning:13:14
-warning:20:52
-warning:21:54
-warning:22:21
-warning:24:4
+warning:12:3
+warning:14:14
+warning:21:52
+warning:22:54
+warning:23:21
+warning:25:4
~~~~~~~~~~
<?php
+
$a + $b;
$a + $b;
$a + $b;
diff --git a/src/lint/linter/__tests__/xhpast/surprising-constructors.lint-test b/src/lint/linter/__tests__/xhpast/surprising-constructors.lint-test
--- a/src/lint/linter/__tests__/xhpast/surprising-constructors.lint-test
+++ b/src/lint/linter/__tests__/xhpast/surprising-constructors.lint-test
@@ -1,9 +1,10 @@
<?php
+
final class Platypus {
public function platypus() {
// This method must be renamed to __construct().
}
}
~~~~~~~~~~
-error:2:13 XHP19 Class-Filename Mismatch
-error:3:19
+error:3:13 XHP19 Class-Filename Mismatch
+error:4:19
diff --git a/src/lint/linter/__tests__/xhpast/unary-prefix-expression-spacing.lint-test b/src/lint/linter/__tests__/xhpast/unary-prefix-expression-spacing.lint-test
--- a/src/lint/linter/__tests__/xhpast/unary-prefix-expression-spacing.lint-test
+++ b/src/lint/linter/__tests__/xhpast/unary-prefix-expression-spacing.lint-test
@@ -1,12 +1,14 @@
<?php
+
$f = @ fopen($path, 'rb');
@fclose($f);
exit ();
~~~~~~~~~~
-warning:2:7
-warning:4:5
+warning:3:7
+warning:5:5
~~~~~~~~~~
<?php
+
$f = @fopen($path, 'rb');
@fclose($f);
exit();
diff --git a/src/lint/linter/__tests__/xhpast/unnecessary-final-modifier.lint-test b/src/lint/linter/__tests__/xhpast/unnecessary-final-modifier.lint-test
--- a/src/lint/linter/__tests__/xhpast/unnecessary-final-modifier.lint-test
+++ b/src/lint/linter/__tests__/xhpast/unnecessary-final-modifier.lint-test
@@ -1,8 +1,9 @@
<?php
+
final class Foo {
public function bar() {}
final public function baz() {}
}
~~~~~~~~~~
-error:2:13 XHP19
-advice:4:3
+error:3:13 XHP19
+advice:5:3
diff --git a/src/lint/linter/__tests__/xhpast/unreasonably-deep-nesting.lint-test b/src/lint/linter/__tests__/xhpast/unreasonably-deep-nesting.lint-test
--- a/src/lint/linter/__tests__/xhpast/unreasonably-deep-nesting.lint-test
+++ b/src/lint/linter/__tests__/xhpast/unreasonably-deep-nesting.lint-test
@@ -1,4 +1,5 @@
<?php
+
// This test is just verifying the parseability of files with a large number
// (>500) of string concatenations. We emit n_CONCATENATION_LIST instead of
// n_BINARY_EXPRESSION to avoid various call-depth traps in PHP, HPHP, and the
@@ -43,6 +44,7 @@
~~~~~~~~~~
~~~~~~~~~~
<?php
+
// This test is just verifying the parseability of files with a large number
// (>500) of string concatenations. We emit n_CONCATENATION_LIST instead of
// n_BINARY_EXPRESSION to avoid various call-depth traps in PHP, HPHP, and the
diff --git a/src/lint/linter/__tests__/xhpast/variable-variables.lint-test b/src/lint/linter/__tests__/xhpast/variable-variables.lint-test
--- a/src/lint/linter/__tests__/xhpast/variable-variables.lint-test
+++ b/src/lint/linter/__tests__/xhpast/variable-variables.lint-test
@@ -1,5 +1,6 @@
<?php
+
$$foo;
$obj->$bar; // okay
~~~~~~~~~~
-error:2:1
+error:3:1
diff --git a/src/lint/linter/__tests__/xhpast/wrong-concat-operator.lint-test b/src/lint/linter/__tests__/xhpast/wrong-concat-operator.lint-test
--- a/src/lint/linter/__tests__/xhpast/wrong-concat-operator.lint-test
+++ b/src/lint/linter/__tests__/xhpast/wrong-concat-operator.lint-test
@@ -1,9 +1,10 @@
<?php
+
'a'.'b';
'a' + 'b';
'a' + $x;
$x + $y + $z + 'q' + 0;
~~~~~~~~~~
-error:3:1
error:4:1
error:5:1
+error:6:1
diff --git a/src/lint/linter/xhpast/rules/ArcanistNewlineAfterOpenTagXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistNewlineAfterOpenTagXHPASTLinterRule.php
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/xhpast/rules/ArcanistNewlineAfterOpenTagXHPASTLinterRule.php
@@ -0,0 +1,46 @@
+<?php
+
+final class ArcanistNewlineAfterOpenTagXHPASTLinterRule
+ extends ArcanistXHPASTLinterRule {
+
+ const ID = 81;
+
+ public function getLintName() {
+ return pht('Newline After PHP Open Tag');
+ }
+
+ public function getLintSeverity() {
+ return ArcanistLintSeverity::SEVERITY_ADVICE;
+ }
+
+ public function process(XHPASTNode $root) {
+ $tokens = $root->selectTokensOfType('T_OPEN_TAG');
+
+ foreach ($tokens as $token) {
+ for ($next = $token->getNextToken();
+ $next;
+ $next = $next->getNextToken()) {
+
+ if ($next->getTypeName() == 'T_WHITESPACE' &&
+ preg_match('/\n\s*\n/', $next->getValue())) {
+ continue 2;
+ }
+
+ if ($token->getLineNumber() != $next->getLineNumber()) {
+ break;
+ }
+
+ if ($next->getTypeName() == 'T_CLOSE_TAG') {
+ continue 2;
+ }
+ }
+
+ $next = $token->getNextToken();
+ $this->raiseLintAtToken(
+ $next,
+ pht('`%s` should be separated from code by an empty line.', '<?php'),
+ "\n".$next->getValue());
+ }
+ }
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 22, 10:00 AM (2 d, 20 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7706268
Default Alt Text
D13534.id33534.diff (21 KB)
Attached To
Mode
D13534: Add a linter rule for newlines after PHP open tags
Attached
Detach File
Event Timeline
Log In to Comment