Skip to content

Commit e1f0e46

Browse files
rodrigoprimojrfnl
authored andcommitted
Generic/DisallowLongArraySyntax: improve code coverage
This commit adds two safeguard tests that do not trigger the sniff as they use the array keyword in a method definition and a method call. It also updates one of the existing tests to declare an array using array in uppercase. This is already handled correctly by PHPCS but it was not documented in a test.
1 parent 2000a32 commit e1f0e46

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ $var = array();
33
$var = [1,2,3];
44
$var = array(1,2,3);
55
echo $var[1];
6-
$foo = array($var[1],$var[2]);
6+
$foo = ARRAY($var[1],$var[2]);
77
$foo = array(
88
1,
99
2,
@@ -25,3 +25,9 @@ array_map(
2525
static fn (array $value): array => array_filter($value),
2626
[]
2727
);
28+
29+
class Foo {
30+
function array() {}
31+
}
32+
33+
$obj->array( 1, 2, 3 );

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,9 @@ array_map(
2525
static fn (array $value): array => array_filter($value),
2626
[]
2727
);
28+
29+
class Foo {
30+
function array() {}
31+
}
32+
33+
$obj->array( 1, 2, 3 );

0 commit comments

Comments
 (0)