Skip to content

Commit 2297dd5

Browse files
rodrigoprimojrfnl
authored andcommitted
Generic/DisallowLongArraySyntax: move an intentional parse error test
This commit moves an intentional parse error test to its own file. The parse error test did not trigger DisallowLongArraySyntaxSniff::process() as this sniff listen for T_ARRAY and the `array` keyword without parentheses is tokenized by PHPCS as T_STRING. Removing the semicolon fixes that and makes the test effective.
1 parent cc9a84b commit 2297dd5

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.1.inc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ $foo = array(
1010
3
1111
);
1212
$var = array/*comment*/(1,2,3);
13-
$var = array;
1413

1514
function foo(array $array) {}
1615

src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.1.inc.fixed

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ $foo = [
1010
3
1111
];
1212
$var = /*comment*/[1,2,3];
13-
$var = array;
1413

1514
function foo(array $array) {}
1615

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
// Intentional parse error (long array syntax missing parentheses).
4+
// This should be the only test in this file.
5+
// Testing that the sniff is *not* triggered.
6+
7+
$var = array

src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ public function getErrorList($testFile='')
4646
2 => 1,
4747
9 => 1,
4848
];
49+
case 'DisallowLongArraySyntaxUnitTest.3.inc':
50+
return [
51+
7 => 1,
52+
];
4953
default:
5054
return [];
5155
}//end switch

0 commit comments

Comments
 (0)