1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-12-22 21:40:54 +01:00

Modify the lint-test file format to allow for more powerful assertions

Summary:
Fixes T6854. The current format for `lint-test` files is somewhat inflexible and does not allow us to make assertions regarding the code or name of the linter messages (of class `ArcanistLintMessage`) that are raised. Specifically, the `${severity}:${line}:${char}` format is hardcoded in `ArcanistLinterTestCase`. In this diff, I extend the this format to achieve the following goals:

- Allow for the lint message code and name to be specified. Specifically, the full format is `${severity}:${line}:${char}:${code}:${name}`.
- Make all fields optional. `error:3:` will match any and all errors occuring on line 3.
- Provide more useful output when assertions fail. Specifically, output //all// lint messages that are missing and/or surplus. Previously, only the first lint message was output.

Test Plan: `arc unit`

Reviewers: #blessed_reviewers, epriestley, chad

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T6854

Differential Revision: https://secure.phabricator.com/D11176
This commit is contained in:
Joshua Spence 2019-05-21 11:27:37 +10:00
parent 82445bb605
commit dd514e268b
167 changed files with 580 additions and 512 deletions

View file

@ -75,8 +75,8 @@ abstract class ArcanistLinterTestCase extends PhutilTestCase {
$config,
array(
'config' => 'optional map<string, wild>',
'path' => 'optional string',
'mode' => 'optional string',
'path' => 'optional string',
'stopped' => 'optional bool',
));
@ -171,81 +171,131 @@ abstract class ArcanistLinterTestCase extends PhutilTestCase {
$this->compareTransform($xform, $after_lint);
}
private function compareLint($file, $expect, ArcanistLintResult $result) {
$seen = array();
$raised = array();
$message_map = array();
private function compareLint($file, $expect, ArcanistLintResult $results) {
$expected_results = new ArcanistLintResult();
foreach ($result->getMessages() as $message) {
$sev = $message->getSeverity();
$line = $message->getLine();
$char = $message->getChar();
$code = $message->getCode();
$name = $message->getName();
$message_key = $sev.':'.$line.':'.$char;
$message_map[$message_key] = $message;
$seen[] = $message_key;
$raised[] = sprintf(
' %s: %s %s',
pht('%s at line %d, char %d', $sev, $line, $char),
$code,
$name);
}
$expect = trim($expect);
if ($expect) {
$expect = explode("\n", $expect);
} else {
$expect = array();
}
foreach ($expect as $key => $expected) {
$expect[$key] = head(explode(' ', $expected));
foreach ($expect as $result) {
$parts = explode(':', $result);
$message = new ArcanistLintMessage();
$severity = idx($parts, 0);
$line = idx($parts, 1);
$char = idx($parts, 2);
$code = idx($parts, 3);
if ($severity !== null) {
$message->setSeverity($severity);
}
if ($line !== null) {
$message->setLine($line);
}
if ($char !== null) {
$message->setChar($char);
}
if ($code !== null) {
$message->setCode($code);
}
$expected_results->addMessage($message);
}
$expect = array_fill_keys($expect, true);
$seen = array_fill_keys($seen, true);
$missing = array();
$surprising = $results->getMessages();
if (!$raised) {
$raised = array(pht('No messages.'));
}
$raised = sprintf(
"%s:\n%s",
pht('Actually raised'),
implode("\n", $raised));
// TODO: Make this more efficient.
foreach ($expected_results->getMessages() as $expected_message) {
$found = false;
foreach (array_diff_key($expect, $seen) as $missing => $ignored) {
$missing = explode(':', $missing);
$sev = array_shift($missing);
$pos = $missing;
foreach ($results->getMessages() as $ii => $actual_message) {
if (!self::compareLintMessageProperty(
$expected_message->getSeverity(),
$actual_message->getSeverity())) {
$this->assertFailure(
pht(
"In '%s', expected lint to raise %s on line %d at char %d, ".
"but no %s was raised. %s",
$file,
$sev,
idx($pos, 0),
idx($pos, 1),
$sev,
$raised));
continue;
}
if (!self::compareLintMessageProperty(
$expected_message->getLine(),
$actual_message->getLine())) {
continue;
}
if (!self::compareLintMessageProperty(
$expected_message->getChar(),
$actual_message->getChar())) {
continue;
}
if (!self::compareLintMessageProperty(
$expected_message->getCode(),
$actual_message->getCode())) {
continue;
}
$found = true;
unset($surprising[$ii]);
}
if (!$found) {
$missing[] = $expected_message;
}
}
foreach (array_diff_key($seen, $expect) as $surprising => $ignored) {
$message = $message_map[$surprising];
$message_info = $message->getDescription();
if ($missing || $surprising) {
$expected = pht('EXPECTED MESSAGES');
if ($missing) {
foreach ($missing as $message) {
$expected .= sprintf(
"\n %s: %s %s",
pht(
'%s at line %d, char %d',
$message->getSeverity(),
$message->getLine(),
$message->getChar()),
$message->getCode(),
$message->getName());
}
} else {
$expected .= "\n ".pht('No messages');
}
$actual = pht('UNEXPECTED MESSAGES');
if ($surprising) {
foreach ($surprising as $message) {
$actual .= sprintf(
"\n %s: %s %s",
pht(
'%s at line %d, char %d',
$message->getSeverity(),
$message->getLine(),
$message->getChar()),
$message->getCode(),
$message->getName());
}
} else {
$actual .= "\n ".pht('No messages');
}
list($sev, $line, $char) = explode(':', $surprising);
$this->assertFailure(
sprintf(
"%s:\n\n%s\n\n%s",
pht(
"In '%s', lint raised %s on line %d at char %d, ".
"but nothing was expected",
$file,
$sev,
$line,
$char),
$message_info,
$raised));
"%s\n\n%s\n\n%s",
pht("Lint failed for '%s'.", $file),
$expected,
$actual));
}
}
@ -259,4 +309,18 @@ abstract class ArcanistLinterTestCase extends PhutilTestCase {
pht('File as patched by lint did not match the expected patched file.'));
}
/**
* Compare properties of @{class:ArcanistLintMessage} instances.
*
* The expectation is that if one (or both) of the properties is null, then
* we don't care about its value.
*
* @param wild
* @param wild
* @return bool
*/
private static function compareLintMessageProperty($x, $y) {
return $x === null || $y === null || $x === $y;
}
}

View file

@ -1,5 +1,5 @@
~~~~~~~~~~
warning::
warning:0:0:CHMOD1:Invalid Executable
~~~~~~~~~~
~~~~~~~~~~
{"mode": "0755"}

View file

@ -1,4 +1,4 @@
x = 1234
y = 1
~~~~~~~~~~
error:1:
error:1:0

View file

@ -1,5 +1,5 @@
~~~~~~~~~~
error::
error:0:0:NAME1:Bad Filename
~~~~~~~~~~
~~~~~~~~~~
{"path": "bad@filename"}

View file

@ -3,5 +3,5 @@ x = 'y'
def hello():
return foo
~~~~~~~~~~
error:3:1
error:4:12
error:3:1:E302
error:4:12:F821

View file

@ -2,5 +2,5 @@ var args = {};
args['foo'] = 'bar';
args['bar'] = 'baz';
~~~~~~~~~~
warning:2:5
warning:3:5
warning:2:5:W069
warning:3:5:W069

View file

@ -3,4 +3,4 @@ if (foo = 'bar') {
return true;
}
~~~~~~~~~~
warning:2:16
warning:2:16:W084

View file

@ -7,6 +7,6 @@ function f() {
{
~~~~~~~~~~
warning:3:8
error:7:1
error:9:1
warning:3:8:W033
error:7:1:E019
error:9:1:E041

View file

@ -1,3 +1,3 @@
console.log('foobar')
~~~~~~~~~~
warning:1:22
warning:1:22:W033

View file

@ -1,5 +1,5 @@
/* jshint maxerr: 1 */
console.log('foobar')
~~~~~~~~~~
disabled:2:22
warning:2:22
disabled:2:22:E043
warning:2:22:W033

View file

@ -2,4 +2,4 @@ function main() {
return 'Hello, World!';
};
~~~~~~~~~~
warning:3:2
warning:3:2:W032

View file

@ -7,4 +7,4 @@
>>>>>>> branch2
}
~~~~~~~~~~
error:5:1
error:5:1:MERGECONFLICT1:Unresolved merge conflict

View file

@ -1,3 +1,3 @@
import os, sys
~~~~~~~~~~
error:1:10
error:1:10:E401

View file

@ -4,4 +4,4 @@ function f() {
$this = "cannot be re-assigned";
}
~~~~~~~~~
error:4:
error:4:0:PHP2:Fatal Error

View file

@ -4,4 +4,4 @@ function f() {
this is bad syntax;
}
~~~~~~~~~
error:4:
error:4:0:PHP1:Parse Error

View file

@ -2,6 +2,6 @@ import sys, os
x += 1
~~~~~~~~~~
warning:1:
warning:1:
error:3:
warning:1:0
warning:1:0
error:3:0

View file

@ -3,4 +3,4 @@
"""
Useless string """
~~~~~~~~~~
warning:4:0 See T9257.
warning:4:0:W0105:Pointless String Statement

View file

@ -2,6 +2,8 @@ import sys, os
x += 1
~~~~~~~~~~
warning:1:0
advice:1:0
error:3:0
advice:1:0:C0111:Missing Docstring
advice:1:0:C0410:Multiple Imports
warning:1:0:W0611:Unused Import
warning:1:0:W0611:Unused Import
error:3:0:E0602:Undefined Variable

View file

@ -1,4 +1,4 @@
def hello()
end
~~~~~~~~~~
warning:1:10
warning:1:10:-

View file

@ -1,4 +1,4 @@
def hello()
puts "hello world"
~~~~~~~~~~
error:2:
error:2:0:RUBY:Syntax Error

View file

@ -10,11 +10,11 @@ didn't remove acording
Added ZZZZsupermnZZZZ
Added full batmn batmnZZZZ
~~~~~~~~~~
warning:2:1
warning:4:10
warning:5:15
warning:7:7
warning:7:12
warning:9:15
warning:10:11
warning:11:12
warning:2:1:SPELL1:Possible Spelling Mistake
warning:4:10:SPELL2:Possible Spelling Mistake
warning:5:15:SPELL2:Possible Spelling Mistake
warning:7:7:SPELL2:Possible Spelling Mistake
warning:7:12:SPELL2:Possible Spelling Mistake
warning:9:15:SPELL1:Possible Spelling Mistake
warning:10:11:SPELL2:Possible Spelling Mistake
warning:11:12:SPELL1:Possible Spelling Mistake

View file

@ -1,3 +1,3 @@
❤♎☀★☂♞
~~~~~~~~~~
error:1:1
error:1:1:TXT5:Bad Charset

View file

@ -4,6 +4,6 @@
The quick brown fox jumps over the lazy dog.
~~~~~~~~~~
autofix:1:1
autofix:1:1:TXT8:Leading Whitespace at BOF
~~~~~~~~~~
The quick brown fox jumps over the lazy dog.

View file

@ -1,7 +1,7 @@
The quick brown fox
jumps over the lazy dog.
~~~~~~~~~~
error:1:1
error:1:1:TXT1:DOS Newlines
~~~~~~~~~~
The quick brown fox
jumps over the lazy dog.

View file

@ -1,4 +1,4 @@
~~~~~~~~~~
error::
error:0:0:TXT10:Empty File

View file

@ -4,6 +4,6 @@ The quick brown fox jumps over the lazy dog.
~~~~~~~~~~
autofix:2:1
autofix:2:1:TXT9:Trailing Whitespace at EOF
~~~~~~~~~~
The quick brown fox jumps over the lazy dog.

View file

@ -1,6 +1,6 @@
The quick brown fox jumps over the lazy dog.
~~~~~~~~~~
warning:1:1
warning:1:1:TXT3:Line Too Long
~~~~~~~~~~
~~~~~~~~~~
{"config": {"text.max-line-length": 40}}

View file

@ -1,8 +1,8 @@
The quick brown fox
jumps over the lazy dog.
~~~~~~~~~~
autofix:1:20
autofix:2:25
autofix:1:20:TXT6:Trailing Whitespace
autofix:2:25:TXT6:Trailing Whitespace
~~~~~~~~~~
The quick brown fox
jumps over the lazy dog.

View file

@ -3,11 +3,11 @@ consectetur adipiscing elit.
Phasellus sodales nibh erat,
in hendrerit nulla dictum interdum.
~~~~~~~~~~
error:1:28
autofix:1:28
autofix:2:29
autofix:3:29
autofix:4:36
error:1:28:TXT2:Tab Literal
autofix:1:28:TXT6:Trailing Whitespace
autofix:2:29:TXT6:Trailing Whitespace
autofix:3:29:TXT6:Trailing Whitespace
autofix:4:36:TXT6:Trailing Whitespace
~~~~~~~~~~
Lorem ipsum dolor sit amet,
consectetur adipiscing elit.

View file

@ -3,11 +3,11 @@ consectetur adipiscing elit.
Phasellus sodales nibh erat,
in hendrerit nulla dictum interdum.
~~~~~~~~~~
error:1:28
autofix:1:28
autofix:2:29
autofix:3:29
autofix:4:36
error:1:28:TXT2:Tab Literal
autofix:1:28:TXT6:Trailing Whitespace
autofix:2:29:TXT6:Trailing Whitespace
autofix:3:29:TXT6:Trailing Whitespace
autofix:4:36:TXT6:Trailing Whitespace
~~~~~~~~~~
Lorem ipsum dolor sit amet,
consectetur adipiscing elit.

View file

@ -2,4 +2,4 @@
This shouldn't fatal the parser.
~~~~~~~~~~
disabled:2:1
disabled:2:1:XHP78:Inline HTML

View file

@ -1,4 +1,4 @@
<?php
~~~~~~~~~~
warning::
warning:0:0:XHP82:Empty File

View file

@ -3,5 +3,5 @@
abstract class A {}
final class F {}
~~~~~~~~~~
disabled:3:1
disabled:4:1
disabled:3:1:XHP88:Class Not Extending `Phobject`
disabled:4:1:XHP88:Class Not Extending `Phobject`

View file

@ -6,8 +6,12 @@ function f( ) {
g( );
}
~~~~~~~~~~
warning:5:12
warning:6:5
warning:5:12:XHP38:Declaration Formatting
warning:5:12:XHP25:Spaces Inside Parentheses
warning:5:12:XHP25:Spaces Inside Parentheses
warning:6:5:XHP37:Call Formatting
warning:6:5:XHP25:Spaces Inside Parentheses
warning:6:5:XHP25:Spaces Inside Parentheses
~~~~~~~~~~
<?php

View file

@ -1,4 +1,4 @@
<?php
char *buf = null;
~~~~~~~~~~
error:2:1
error:2:1:XHP1:PHP Syntax Error!

View file

@ -1,3 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
~~~~~~~~~~
error:2:1
error:2:1:XML4:LibXML Error

View file

@ -1,3 +1,3 @@
<bla>&#010100000000000000000000000000000000000000000000000060;</bla>
~~~~~~~~~~
error:1:63
error:1:63:XML9:LibXML Error

View file

@ -3,4 +3,4 @@
<>
</languages>
~~~~~~~~~~
error:3:6
error:3:6:XML68:LibXML Error

View file

@ -3,5 +3,5 @@
</lang>
</languages>
~~~~~~~~~~
error:3:16
error:4:1
error:3:16:XML76:LibXML Error
error:4:1:XML5:LibXML Error

View file

@ -2,4 +2,4 @@
function __lambda_func() {}
~~~~~~~~~~
error:3:1
error:3:1:XHP68:`__lambda_func` Function

View file

@ -24,4 +24,4 @@ abstract class SomeAbstractClass {
abstract public function __toString();
}
~~~~~~~~~~
error:6:7
error:6:7:XHP67:Throwing Exception in `__toString` Method

View file

@ -3,4 +3,4 @@ abstract class SomeClass {
abstract public function someMethod() {}
}
~~~~~~~~~~
error:3:41
error:3:41:XHP108:`abstract` Method Cannot Contain Body

View file

@ -3,4 +3,4 @@ abstract class SomeClass {
private abstract function someMethod();
}
~~~~~~~~~~
error:3:3
error:3:3:XHP107:`abstract` Method Cannot Be Declared `private`

View file

@ -5,9 +5,9 @@ sizeof($x);
die();
sizeOf($x);
~~~~~~~~~~
advice:4:1
advice:5:1
advice:6:1
advice:4:1:XHP65:Alias Functions
advice:5:1:XHP65:Alias Functions
advice:6:1:XHP65:Alias Functions
~~~~~~~~~~
<?php

View file

@ -3,4 +3,4 @@
array_combine($x, $x);
array_combine($x, $y);
~~~~~~~~~~
disabled:3:1
disabled:3:1:XHP84:`array_combine()` Unreliable

View file

@ -5,8 +5,8 @@ $a[] = 1;
$a[]=1;
$a [] = 1;
~~~~~~~~~~
warning:3:3
warning:6:3
warning:3:3:XHP28:Spacing Before Array Index
warning:6:3:XHP28:Spacing Before Array Index
~~~~~~~~~~
<?php

View file

@ -34,12 +34,12 @@ array(
2,
3, /* comment */ );
~~~~~~~~~~
advice:4:14
advice:13:3
advice:17:3
advice:27:3
advice:31:3
advice:35:20
advice:4:14:XHP48:Array Separator
advice:13:3:XHP48:Array Separator
advice:17:3:XHP48:Array Separator
advice:27:3:XHP48:Array Separator
advice:31:3:XHP48:Array Separator
advice:35:20:XHP48:Array Separator
~~~~~~~~~~
<?php

View file

@ -20,12 +20,12 @@ array(
array('quack',
);
~~~~~~~~~~
warning:4:5
warning:4:8
warning:8:18
warning:12:17
warning:12:32
warning:20:7
warning:4:5:XHP76:Array Element
warning:4:8:XHP76:Array Element
warning:8:18:XHP76:Array Element
warning:12:17:XHP76:Array Element
warning:12:32:XHP76:Array Element
warning:20:7:XHP76:Array Element
~~~~~~~~~~
<?php

View file

@ -16,10 +16,10 @@ array(
$x=>$y,
);
~~~~~~~~~~
warning:4:9
warning:5:10
warning:6:9
warning:16:5
warning:4:9:XHP27:Space Around Binary Operator
warning:5:10:XHP27:Space Around Binary Operator
warning:6:9:XHP27:Space Around Binary Operator
warning:16:5:XHP27:Space Around Binary Operator
~~~~~~~~~~
<?php

View file

@ -24,19 +24,19 @@ if ($x instanceof z &&$w) {}
if ($x instanceof z && $w) {}
f(1,2);
~~~~~~~~~~
warning:4:3
warning:5:4
warning:6:3
warning:8:3
warning:9:3
warning:10:4
warning:11:3
warning:12:3
warning:14:14
warning:21:52
warning:22:54
warning:23:21
warning:25:4
warning:4:3:XHP27:Space Around Binary Operator
warning:5:4:XHP27:Space Around Binary Operator
warning:6:3:XHP27:Space Around Binary Operator
warning:8:3:XHP27:Space Around Binary Operator
warning:9:3:XHP27:Space Around Binary Operator
warning:10:4:XHP27:Space Around Binary Operator
warning:11:3:XHP27:Space Around Binary Operator
warning:12:3:XHP27:Space Around Binary Operator
warning:14:14:XHP27:Space Around Binary Operator
warning:21:52:XHP27:Space Around Binary Operator
warning:22:54:XHP27:Space Around Binary Operator
warning:23:21:XHP27:Space Around Binary Operator
warning:25:4:XHP27:Space Around Binary Operator
~~~~~~~~~~
<?php

View file

@ -2,4 +2,4 @@
0b1;
0B1;
~~~~~~~~~~
warning:3:1
warning:3:1:XHP131:Binary Integer Casing

View file

@ -2,7 +2,7 @@
eval('evil code');
~~~~~~~~~~
error:3:1
error:3:1:XHP51:Use of Blacklisted Function
~~~~~~~~~~
~~~~~~~~~~
{

View file

@ -4,8 +4,8 @@ class SomeClass {}
class SomeOtherClass{}
class YetAnotherClass extends SomeClass{}
~~~~~~~~~~
warning:4:21
warning:5:40
warning:4:21:XHP24:Brace Placement
warning:5:40:XHP24:Brace Placement
~~~~~~~~~~
<?php

View file

@ -22,17 +22,17 @@ 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
warning:3:7:XHP24:Brace Placement
warning:6:20:XHP24:Brace Placement
warning:9:10:XHP24:Brace Placement
warning:12:11:XHP24:Brace Placement
warning:15:9:XHP24:Brace Placement
warning:16:6:XHP24:Brace Placement
warning:17:4:XHP24:Brace Placement
warning:19:11:XHP24:Brace Placement
warning:20:16:XHP24:Brace Placement
warning:23:11:XHP24:Brace Placement
warning:23:15:XHP24:Brace Placement
~~~~~~~~~~
<?php

View file

@ -11,8 +11,8 @@ function g()
function h(){}
~~~~~~~~~~
warning:7:13
warning:12:13
warning:7:13:XHP24:Brace Placement
warning:12:13:XHP24:Brace Placement
~~~~~~~~~~
<?php

View file

@ -5,8 +5,8 @@ try
catch (Exception $x)
{}
~~~~~~~~~~
warning:3:4
warning:5:21
warning:3:4:XHP24:Brace Placement
warning:5:21:XHP24:Brace Placement
~~~~~~~~~~
<?php

View file

@ -4,9 +4,9 @@ array ( 1, 2, 3 );
list ( $x, $y ) = array();
[ 1, 2 , 3 ];
~~~~~~~~~~
warning:3:6
warning:4:5
warning:4:14
warning:3:6:XHP37:Call Formatting
warning:4:5:XHP37:Call Formatting
warning:4:14:XHP37:Call Formatting
~~~~~~~~~~
<?php

View file

@ -18,9 +18,9 @@ EODOC
);
f (1);
~~~~~~~~~~
warning:4:4
warning:9:4
warning:19:2
warning:4:4:XHP37:Call Formatting
warning:9:4:XHP37:Call Formatting
warning:19:2:XHP37:Call Formatting
~~~~~~~~~~
<?php

View file

@ -25,9 +25,9 @@ $foo(&$myvar);
array_walk(array(), function () use (&$x) {});
MyClass::myfunc(array(&$x, &$y));
~~~~~~~~~~
error:10:8
error:13:15
error:16:17
error:19:24
error:19:39
error:23:6
error:10:8:XHP53:Call-Time Pass-By-Reference
error:13:15:XHP53:Call-Time Pass-By-Reference
error:16:17:XHP53:Call-Time Pass-By-Reference
error:19:24:XHP53:Call-Time Pass-By-Reference
error:19:39:XHP53:Call-Time Pass-By-Reference
error:23:6:XHP53:Call-Time Pass-By-Reference

View file

@ -4,8 +4,8 @@ echo (double)0;
echo (int) 1;
echo (string) 2;
~~~~~~~~~~
advice:4:11
advice:5:14
advice:4:11:XHP66:Cast Spacing
advice:5:14:XHP66:Cast Spacing
~~~~~~~~~~
<?php

View file

@ -4,4 +4,4 @@ abstract class A extends Phobject {}
final class B extends A {}
final class C {}
~~~~~~~~~~
disabled:5:1
disabled:5:1:XHP88:Class Not Extending `Phobject`

View file

@ -3,4 +3,4 @@ class SomeClass {
abstract public function someMethod();
}
~~~~~~~~~~
error:2:1
error:2:1:XHP113:`class` Containing `abstract` Methods Must Be Declared `abstract`

View file

@ -18,8 +18,8 @@ $c = new class {
}
};
~~~~~~~~~~
advice:5:12
advice:9:10
advice:5:12:XHP62:Class Name Literal
advice:9:10:XHP62:Class Name Literal
~~~~~~~~~~
<?php

View file

@ -21,11 +21,11 @@
/** yes */
/**** yes ****/
~~~~~~~~~~
error:3:1
error:4:1
error:6:1
error:7:11
error:16:1
error:3:1:XHP18:Comment Style
error:4:1:XHP18:Comment Style
error:6:1:XHP18:Comment Style
error:7:11:XHP18:Comment Style
error:16:1:XHP18:Comment Style
~~~~~~~~~~
<?php

View file

@ -9,10 +9,10 @@ $b;
$a. // This should be okay.
$b;
~~~~~~~~~~
warning:4:3
warning:4:5
warning:5:4
warning:6:3
warning:4:3:XHP44:Concatenation Spacing
warning:4:5:XHP44:Concatenation Spacing
warning:5:4:XHP44:Concatenation Spacing
warning:6:3:XHP44:Concatenation Spacing
~~~~~~~~~~
<?php

View file

@ -5,8 +5,8 @@ new Bar();
new Foo\Bar;
new class {};
~~~~~~~~~~
advice:3:5
advice:5:5
advice:3:5:XHP49:Constructor Parentheses
advice:5:5:XHP49:Constructor Parentheses
~~~~~~~~~~
<?php

View file

@ -18,4 +18,3 @@ do {
continue;
} while ($x);
~~~~~~~~~~
~~~~~~~~~~

View file

@ -21,4 +21,3 @@ switch ($x) {
break;
}
~~~~~~~~~~
~~~~~~~~~~

View file

@ -10,8 +10,8 @@ switch ($x) {
continue /* CRITICAL: Nuclear launch code is 1234. */ ;
}
~~~~~~~~~~
error:5:5
error:10:5
error:5:5:XHP128:Continue Inside Switch
error:10:5:XHP128:Continue Inside Switch
~~~~~~~~~~
<?php

View file

@ -26,18 +26,18 @@ do {
try {} catch(Exception $ex) {}
~~~~~~~~~~
warning:3:1
warning:4:1
warning:5:1
warning:6:1
warning:7:1
warning:8:1
warning:8:6
warning:9:1
warning:14:3
warning:15:3
warning:25:3
warning:27:8
warning:3:1:XHP26:Space After Control Statement
warning:4:1:XHP26:Space After Control Statement
warning:5:1:XHP26:Space After Control Statement
warning:6:1:XHP26:Space After Control Statement
warning:7:1:XHP26:Space After Control Statement
warning:8:1:XHP26:Space After Control Statement
warning:8:6:XHP26:Space After Control Statement
warning:9:1:XHP26:Space After Control Statement
warning:14:3:XHP26:Space After Control Statement
warning:15:3:XHP26:Space After Control Statement
warning:25:3:XHP26:Space After Control Statement
warning:27:8:XHP26:Space After Control Statement
~~~~~~~~~~
<?php

View file

@ -2,7 +2,7 @@
$x['key'];
$y{'key'};
~~~~~~~~~~
warning:3:1
warning:3:1:XHP119:Curly Brace Array Index
~~~~~~~~~~
<?php
$x['key'];

View file

@ -1,7 +1,7 @@
<?php
$x[$y{'key'}];
~~~~~~~~~~
warning:2:4
warning:2:4:XHP119:Curly Brace Array Index
~~~~~~~~~~
<?php
$x[$y['key']];

View file

@ -1,7 +1,7 @@
<?php
$x { 'key' /* comment */ };
~~~~~~~~~~
warning:2:1
warning:2:1:XHP119:Curly Brace Array Index
~~~~~~~~~~
<?php
$x [ 'key' /* comment */ ];

View file

@ -25,16 +25,16 @@ f(function ($x ) {});
f(function ($x ) use ($z) {});
f(function ($x)use($z) {});
~~~~~~~~~~
warning:4:14
warning:5:11
warning:8:15
warning:13:23
warning:16:31
warning:19:33
warning:24:15
warning:25:15
warning:26:16
warning:26:19
warning:4:14:XHP38:Declaration Formatting
warning:5:11:XHP38:Declaration Formatting
warning:8:15:XHP38:Declaration Formatting
warning:13:23:XHP38:Declaration Formatting
warning:16:31:XHP38:Declaration Formatting
warning:19:33:XHP38:Declaration Formatting
warning:24:15:XHP38:Declaration Formatting
warning:25:15:XHP38:Declaration Formatting
warning:26:16:XHP38:Declaration Formatting
warning:26:19:XHP38:Declaration Formatting
~~~~~~~~~~
<?php

View file

@ -8,5 +8,5 @@ class MyClass {
public function myMethod($x, $y = null, $z) {}
}
~~~~~~~~~~
warning:4:13
warning:8:27
warning:4:13:XHP60:Default Parameters
warning:8:27:XHP60:Default Parameters

View file

@ -3,7 +3,7 @@
deprecated_function();
modern_function();
~~~~~~~~~~
warning:3:1
warning:3:1:XHP85:Use of Deprecated Function
~~~~~~~~~~
~~~~~~~~~~
{

View file

@ -13,7 +13,7 @@ pht(
"This string also requires \123\345 double quotes, but ".
"this string does not. Here, they are used for consistency.");
~~~~~~~~~~
advice:4:1
advice:4:1:XHP41:Unnecessary Double Quotes
~~~~~~~~~~
<?php

View file

@ -35,9 +35,9 @@ $f = array(
$a => 'var2',
);
~~~~~~~~~~
error:6:3
error:9:3
error:16:3
error:21:3
error:26:3
error:35:3
error:6:3:XHP22:Duplicate Keys in Array
error:9:3:XHP22:Duplicate Keys in Array
error:16:3:XHP22:Duplicate Keys in Array
error:21:3:XHP22:Duplicate Keys in Array
error:26:3:XHP22:Duplicate Keys in Array
error:35:3:XHP22:Duplicate Keys in Array

View file

@ -25,5 +25,5 @@ switch ($x) {
break;
}
~~~~~~~~~~
error:16:3
error:23:7
error:16:3:XHP50:Duplicate Case Statements
error:23:7:XHP50:Duplicate Case Statements

View file

@ -5,5 +5,5 @@ define($pony, 'cute');
define('PONY', $cute);
define($pony, $cute);
~~~~~~~~~~
error:4:8 dynamic define
error:6:8 dynamic define
error:4:8:XHP12:Dynamic `define`
error:6:8:XHP12:Dynamic `define`

View file

@ -8,7 +8,7 @@ if (true) {
echo 'baz';
}
~~~~~~~~~~
advice:5:3
advice:5:3:XHP42:`elseif` Usage
~~~~~~~~~~
<?php

View file

@ -10,8 +10,8 @@ function z() {
}
~~~~~~~~~~
advice:7:14
advice:8:14
advice:7:14:XHP47:Empty Block Statement
advice:8:14:XHP47:Empty Block Statement
~~~~~~~~~~
<?php

View file

@ -4,5 +4,5 @@ exit(-1);
exit -1;
strtoupper(33 * exit - 6);
~~~~~~~~~~
error:4:1
error:5:17
error:4:1:XHP17:`exit` Used as Expression
error:5:17:XHP17:`exit` Used as Expression

View file

@ -2,4 +2,4 @@
extract();
~~~~~~~~~~
error:3:1
error:3:1:XHP4:Use of `extract`

View file

@ -12,11 +12,11 @@ queryfx(null, 'x', 'y');
foobar(null, null, '%s');
~~~~~~~~~~
error:3:1
error:7:1
error:8:1
error:11:1
error:13:1
error:3:1:XHP54:Formatted String
error:7:1:XHP54:Formatted String
error:8:1:XHP54:Formatted String
error:11:1:XHP54:Formatted String
error:13:1:XHP54:Formatted String
~~~~~~~~~~
~~~~~~~~~~
{

View file

@ -3,8 +3,8 @@ intval($x);
intval($x, 8);
intval($x, 10);
~~~~~~~~~~
advice:2:1
advice:4:1
advice:2:1:XHP105:Function Call Should Be Type Cast
advice:4:1:XHP105:Function Call Should Be Type Cast
~~~~~~~~~~
<?php
(int)$x;

View file

@ -1,7 +1,7 @@
<?php
intval($x / 2) + 1;
~~~~~~~~~~
advice:2:1
advice:2:1:XHP105:Function Call Should Be Type Cast
~~~~~~~~~~
<?php
(int)($x / 2) + 1;

View file

@ -5,11 +5,11 @@ floatval($x);
intval($x);
strval($x);
~~~~~~~~~~
advice:2:1
advice:3:1
advice:4:1
advice:5:1
advice:6:1
advice:2:1:XHP105:Function Call Should Be Type Cast
advice:3:1:XHP105:Function Call Should Be Type Cast
advice:4:1:XHP105:Function Call Should Be Type Cast
advice:5:1:XHP105:Function Call Should Be Type Cast
advice:6:1:XHP105:Function Call Should Be Type Cast
~~~~~~~~~~
<?php
(bool)$x;

View file

@ -3,7 +3,7 @@
// we don't provide an autofix.
strval($x, $y);
~~~~~~~~~~
advice:4:1
advice:4:1:XHP105:Function Call Should Be Type Cast
~~~~~~~~~~
<?php
// If the function call doesn't have exactly one parameter,

View file

@ -5,5 +5,5 @@ function foo() {
global $x, $y;
}
~~~~~~~~~~
warning:3:1
warning:5:3
warning:3:1:XHP79:Global Variables
warning:5:3:XHP79:Global Variables

View file

@ -3,8 +3,8 @@
0xff;
0XFF;
~~~~~~~~~~
warning:3:1
warning:4:1
warning:3:1:XHP127:Hexadecimal Integer Casing
warning:4:1:XHP127:Hexadecimal Integer Casing
~~~~~~~~~~
<?php
0xFF;

View file

@ -6,4 +6,4 @@ final class Platypus {
}
}
~~~~~~~~~~
error:4:19
error:4:19:XHP10:Implicit Constructor

View file

@ -84,13 +84,13 @@ switch ($x) {
throw_exception();
}
~~~~~~~~~~
warning:41:3
warning:48:3
warning:53:3
warning:57:3
warning:66:3
warning:71:3
warning:75:3
warning:41:3:XHP30:Implicit Fallthrough
warning:48:3:XHP30:Implicit Fallthrough
warning:53:3:XHP30:Implicit Fallthrough
warning:57:3:XHP30:Implicit Fallthrough
warning:66:3:XHP30:Implicit Fallthrough
warning:71:3:XHP30:Implicit Fallthrough
warning:75:3:XHP30:Implicit Fallthrough
~~~~~~~~~~
~~~~~~~~~~
{

View file

@ -11,10 +11,10 @@ final class Foo {
private $z;
}
~~~~~~~~~~
advice:5:3
advice:6:3
advice:9:3
advice:10:3
advice:5:3:XHP52:Implicit Method Visibility
advice:6:3:XHP52:Implicit Method Visibility
advice:9:3:XHP52:Implicit Method Visibility
advice:10:3:XHP52:Implicit Method Visibility
~~~~~~~~~~
<?php

View file

@ -1,4 +1,4 @@
#!/usr/bin/env php
<html>
~~~~~~~~~~
disabled:2:1
disabled:2:1:XHP78:Inline HTML

View file

@ -11,4 +11,4 @@ function my_func($foo) {
function () {};
}
~~~~~~~~~~
warning:5:5
warning:5:5:XHP59:Inner Functions

View file

@ -5,6 +5,6 @@ var_dump(123 instanceof stdClass);
var_dump(null instanceof stdClass);
var_dump($x instanceof stdClass);
~~~~~~~~~~
error:3:10
error:4:10
error:5:10
error:3:10:XHP69:`instanceof` Operator
error:4:10:XHP69:`instanceof` Operator
error:5:10:XHP69:`instanceof` Operator

View file

@ -4,4 +4,4 @@ interface SomeInterface {
abstract public function someMethod();
}
~~~~~~~~~~
error:4:3
error:4:3:XHP118:`interface` Methods Cannot Be Marked `abstract`

View file

@ -4,4 +4,4 @@ interface SomeInterface {
public function someMethod() {}
}
~~~~~~~~~~
error:4:32
error:4:32:XHP114:`interface` Method Cannot Contain Body

View file

@ -13,6 +13,6 @@ function func_eight(stdClass $x) {}
function func_nine(stdClass $x = null) {}
function func_ten(stdClass $x = array()) {}
~~~~~~~~~~
error:6:31
error:10:35
error:14:33
error:6:31:XHP70:Invalid Default Parameter
error:10:35:XHP70:Invalid Default Parameter
error:14:33:XHP70:Invalid Default Parameter

Some files were not shown because too many files have changed in this diff Show more