8000 PHPCS ignore will not break MultiLineArrayComma, fixes #175 (#177) · djoos/Symfony-coding-standard@2b418e3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2b418e3

Browse files
xaloppdjoos
authored andcommitted
PHPCS ignore will not break MultiLineArrayComma, fixes #175 (#177)
1 parent 369b5f2 commit 2b418e3

File tree

4 files changed

+33
-7
lines changed

4 files changed

+33
-7
lines changed

Symfony/Sniffs/Arrays/MultiLineArrayCommaSniff.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ public function process(File $phpcsFile, $stackPtr)
9797
$lastCommaPtr++;
9898

9999
if ($tokens[$lastCommaPtr]['code'] !== T_WHITESPACE
100+
&& $tokens[$lastCommaPtr]['code'] !== T_PHPCS_IGNORE
100101
&& $tokens[$lastCommaPtr]['code'] !== T_COMMENT
101102
) {
102103
$fix = $phpcsFile->addFixableError(
@@ -107,7 +108,7 @@ public function process(File $phpcsFile, $stackPtr)
107108

108109
if ($fix === true) {
109110
$ptr = $phpcsFile->findPrevious(
110-
array(T_WHITESPACE, T_COMMENT),
111+
array(T_WHITESPACE, T_COMMENT, T_PHPCS_IGNORE),
111112
$closePtr-1,
112113
$stackPtr,
113114
true

Symfony/Tests/Arrays/MultiLineArrayCommaUnitTest.inc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,15 @@ $arr = [
9696
$arr = [
9797
//'foo' => 'bar',
9898
];
99+
100+
$defaultOptions = [
101+
'some_default' => 'values',
102+
'another_default' => 'more values',
103+
'yet_another_default' => 'more values', //phpcs:ignore
104+
];
105+
106+
$defaultOptions = [
107+
'some_default' => 'values',
108+
'another_default' => 'more values',
109+
'yet_another_default' => 'more values' //phpcs:ignore
110+
];

Symfony/Tests/Arrays/MultiLineArrayCommaUnitTest.inc.fixed

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,15 @@ $arr = [
9696
$arr = [
9797
//'foo' => 'bar',
9898
];
99+
100+
$defaultOptions = [
101+
'some_default' => 'values',
102+
'another_default' => 'more values',
103+
'yet_another_default' => 'more values', //phpcs:ignore
104+
];
105+
106+
$defaultOptions = [
107+
'some_default' => 'values',
108+
'another_default' => 'more values',
109+
'yet_another_default' => 'more values', //phpcs:ignore
110+
];

Symfony/Tests/Arrays/MultiLineArrayCommaUnitTest.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,13 @@ class MultiLineArrayCommaUnitTest extends AbstractSniffUnitTest
4343
public function getErrorList()
4444
{
4545
return array(
46-
11 => 1,
47-
27 => 1,
48-
43 => 1,
49-
53 => 1,
50-
74 => 1,
51-
84 => 1,
46+
11 => 1,
47+
27 => 1,
48+
43 => 1,
49+
53 => 1,
50+
74 => 1,
51+
84 => 1,
52+
106 => 1,
5253
);
5354
}
5455

0 commit comments

Comments
 (0)
0