Skip to content

Commit a1932b7

Browse files
committed
Merge pull request #467 from adriaanzon/php-fix-double-errors
PHP: Fix double errors and support fatal errors
1 parent a55f941 commit a1932b7

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

ale_linters/php/php.vim

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
" Author: Spencer Wood <https://github.com/scwood>
1+
" Author: Spencer Wood <https://github.com/scwood>, Adriaan Zonnenberg <[email protected]>
22
" Description: This file adds support for checking PHP with php-cli
33

44
function! ale_linters#php#php#Handle(buffer, lines) abort
55
" Matches patterns like the following:
66
"
77
" PHP Parse error: syntax error, unexpected ';', expecting ']' in - on line 15
8-
let l:pattern = '\vParse error:\s+(.+unexpected ''(.+)%(expecting.+)@<!''.*|.+) in - on line (\d+)'
8+
let l:pattern = '\vPHP %(Fatal|Parse) error:\s+(.+unexpected ''(.+)%(expecting.+)@<!''.*|.+) in - on line (\d+)'
99

1010
let l:output = []
1111

test/handler/test_php_handler.vader

+10
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Given (Some invalid lines of PHP):
33
class Foo { / }
44
$foo)
55
['foo' 'bar']
6+
function count() {}
67

78
Execute(The php handler should parse lines correctly):
89
runtime ale_linters/php/php.vim
@@ -39,6 +40,13 @@ Execute(The php handler should parse lines correctly):
3940
\ },
4041
\ {
4142
\ 'bufnr': 347,
43+
\ 'lnum': 5,
44+
\ 'col': 0,
45+
\ 'text': "Cannot redeclare count()",
46+
\ 'type': 'E',
47+
\ },
48+
\ {
49+
\ 'bufnr': 347,
4250
\ 'lnum': 21,
4351
\ 'col': 0,
4452
\ 'text': "syntax error, unexpected end of file",
@@ -54,10 +62,12 @@ Execute(The php handler should parse lines correctly):
5462
\ ],
5563
\ ale_linters#php#php#Handle(347, [
5664
\ 'This line should be ignored completely',
65+
\ "Parse error: syntax error, This line should be ignored completely in - on line 1",
5766
\ "PHP Parse error: syntax error, unexpected ';', expecting ']' in - on line 1",
5867
\ "PHP Parse error: syntax error, unexpected '/', expecting function (T_FUNCTION) or const (T_CONST) in - on line 2",
5968
\ "PHP Parse error: syntax error, unexpected ')' in - on line 3",
6069
\ "PHP Parse error: syntax error, unexpected ''bar'' (T_CONSTANT_ENCAPSED_STRING), expecting ']' in - on line 4",
70+
\ "PHP Fatal error: Cannot redeclare count() in - on line 5",
6171
\ 'PHP Parse error: syntax error, unexpected end of file in - on line 21',
6272
\ 'PHP Parse error: Invalid numeric literal in - on line 47',
6373
\ ])

0 commit comments

Comments
 (0)