Skip to content

Bug #140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 24, 2020
Merged

Bug #140

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions SymfonyCustom/Sniffs/Arrays/ArrayDeclarationSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,16 @@ public function processMultiLineArray(File $phpcsFile, int $stackPtr, int $start
$indexEnd = $phpcsFile->findPrevious(T_WHITESPACE, $nextToken - 1, $start, true);
$indexStart = $phpcsFile->findStartOfStatement($indexEnd);

// Handle multi-lines index.
while ($tokens[$indexStart]['line'] !== $tokens[$indexEnd]['line']) {
$indexStart = $phpcsFile->findNext(
Tokens::$emptyTokens,
$indexStart + 1,
$indexEnd + 1,
true
);
}

if ($indexStart === $indexEnd) {
$currentEntry['index'] = $indexEnd;
$currentEntry['index_content'] = $tokens[$indexEnd]['content'];
Expand Down
12 changes: 12 additions & 0 deletions SymfonyCustom/Tests/Arrays/ArrayDeclarationUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,15 @@ return [
];

[1 => 2 , 2=>3,4 => 5];

$array = [
'lonnnnnnggggg' => 'good',
'short'
=> 'bad',
];

$array = [
'lonnnnnngggggg' => 'good',
$ab .
'second' => 'bad',
];
11 changes: 11 additions & 0 deletions SymfonyCustom/Tests/Arrays/ArrayDeclarationUnitTest.inc.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,14 @@ return [
];

[1 => 2, 2 => 3, 4 => 5];

$array = [
'lonnnnnnggggg' => 'good',
'short' => 'bad',
];

$array = [
'lonnnnnngggggg' => 'good',
$ab .
'second' => 'bad',
];
2 changes: 2 additions & 0 deletions SymfonyCustom/Tests/Arrays/ArrayDeclarationUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ protected function getErrorList(): array
142 => 1,
148 => 1,
151 => 7,
156 => 1,
162 => 1,
];
}

Expand Down
7 changes: 2 additions & 5 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,10 @@

<target name="phpunit" depends="symlink-cs" description="Run unit tests with PHPUnit">
<exec executable="${phpunit.bin}" failonerror="true" >
<arg value="--verbose"/>
<arg value="--filter=SymfonyCustom"/>
<arg value="${phpcs.dir}/tests/AllTests.php"/>
<arg value="--testsuite=SymfonyCustom"/>
</exec>
<exec executable="${phpunit.bin}" failonerror="true" >
<arg value="--verbose"/>
<arg value="TwigCS"/>
<arg value="--testsuite=TwigCS"/>
</exec>
</target>

Expand Down
13 changes: 8 additions & 5 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@
stopOnFailure="false"
bootstrap="./bootstrap.php"
>
<filter>
<whitelist>
<directory>./vendor/squizlabs/php_codesniffer/src/Standards/SymfonyCustom</directory>
</whitelist>
</filter>
<testsuites>
<testsuite name="SymfonyCustom">
<file>./vendor/squizlabs/php_codesniffer/tests/Standards/AllSniffs.php</file>
</testsuite>
<testsuite name="TwigCS">
<directory>./TwigCS</directory>
</testsuite>
</testsuites>
</phpunit>