Skip to content

Commit 1726b4f

Browse files
Merge pull request #140 from VincentLanglet/bug
Bug
2 parents 8d57fd9 + 8298b64 commit 1726b4f

File tree

6 files changed

+45
-10
lines changed

6 files changed

+45
-10
lines changed

SymfonyCustom/Sniffs/Arrays/ArrayDeclarationSniff.php

+10
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,16 @@ public function processMultiLineArray(File $phpcsFile, int $stackPtr, int $start
391391
$indexEnd = $phpcsFile->findPrevious(T_WHITESPACE, $nextToken - 1, $start, true);
392392
$indexStart = $phpcsFile->findStartOfStatement($indexEnd);
393393

394+
// Handle multi-lines index.
395+
while ($tokens[$indexStart]['line'] !== $tokens[$indexEnd]['line']) {
396+
$indexStart = $phpcsFile->findNext(
397+
Tokens::$emptyTokens,
398+
$indexStart + 1,
399+
$indexEnd + 1,
400+
true
401+
);
402+
}
403+
394404
if ($indexStart === $indexEnd) {
395405
$currentEntry['index'] = $indexEnd;
396406
$currentEntry['index_content'] = $tokens[$indexEnd]['content'];

SymfonyCustom/Tests/Arrays/ArrayDeclarationUnitTest.inc

+12
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,15 @@ return [
149149
];
150150

151151
[1 => 2 , 2=>3,4 => 5];
152+
153+
$array = [
154+
'lonnnnnnggggg' => 'good',
155+
'short'
156+
=> 'bad',
157+
];
158+
159+
$array = [
160+
'lonnnnnngggggg' => 'good',
161+
$ab .
162+
'second' => 'bad',
163+
];

SymfonyCustom/Tests/Arrays/ArrayDeclarationUnitTest.inc.fixed

+11
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,14 @@ return [
147147
];
148148

149149
[1 => 2, 2 => 3, 4 => 5];
150+
151+
$array = [
152+
'lonnnnnnggggg' => 'good',
153+
'short' => 'bad',
154+
];
155+
156+
$array = [
157+
'lonnnnnngggggg' => 'good',
158+
$ab .
159+
'second' => 'bad',
160+
];

SymfonyCustom/Tests/Arrays/ArrayDeclarationUnitTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ protected function getErrorList(): array
4747
142 => 1,
4848
148 => 1,
4949
151 => 7,
50+
156 => 1,
51+
162 => 1,
5052
];
5153
}
5254

build.xml

+2-5
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,10 @@
2929

3030
<target name="phpunit" depends="symlink-cs" description="Run unit tests with PHPUnit">
3131
<exec executable="${phpunit.bin}" failonerror="true" >
32-
<arg value="--verbose"/>
33-
<arg value="--filter=SymfonyCustom"/>
34-
<arg value="${phpcs.dir}/tests/AllTests.php"/>
32+
<arg value="--testsuite=SymfonyCustom"/>
3533
</exec>
3634
<exec executable="${phpunit.bin}" failonerror="true" >
37-
<arg value="--verbose"/>
38-
<arg value="TwigCS"/>
35+
<arg value="--testsuite=TwigCS"/>
3936
</exec>
4037
</target>
4138

phpunit.xml.dist

+8-5
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@
1010
stopOnFailure="false"
1111
bootstrap="./bootstrap.php"
1212
>
13-
<filter>
14-
<whitelist>
15-
<directory>./vendor/squizlabs/php_codesniffer/src/Standards/SymfonyCustom</directory>
16-
</whitelist>
17-
</filter>
13+
<testsuites>
14+
<testsuite name="SymfonyCustom">
15+
<file>./vendor/squizlabs/php_codesniffer/tests/Standards/AllSniffs.php</file>
16+
</testsuite>
17+
<testsuite name="TwigCS">
18+
<directory>./TwigCS</directory>
19+
</testsuite>
20+
</testsuites>
1821
</phpunit>

0 commit comments

Comments
 (0)