Skip to content

✨ Better checks for array rule #49

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 3 commits into from
May 6, 2019
Merged
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
238 changes: 68 additions & 170 deletions SymfonyCustom/Sniffs/Arrays/ArrayDeclarationSniff.php

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class DocCommentForbiddenTagsSniff implements Sniff
public function register()
{
return [
T_DOC_COMMENT_TAG
T_DOC_COMMENT_TAG,
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class DocCommentGroupSameTypeSniff implements Sniff
public function register()
{
return [
T_DOC_COMMENT_OPEN_TAG
T_DOC_COMMENT_OPEN_TAG,
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class BlankLineBeforeReturnSniff implements Sniff
public function register()
{
return [
T_RETURN
T_RETURN,
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class DocCommentTagSpacingSniff implements Sniff
public function register()
{
return [
T_DOC_COMMENT_TAG
T_DOC_COMMENT_TAG,
];
}

Expand Down
2 changes: 1 addition & 1 deletion SymfonyCustom/Sniffs/WhiteSpace/EmptyLinesSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class EmptyLinesSniff implements Sniff
public function register()
{
return [
T_WHITESPACE
T_WHITESPACE,
];
}

Expand Down
36 changes: 34 additions & 2 deletions SymfonyCustom/Tests/Arrays/ArrayDeclarationUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,41 @@ class TestClass
'short_name' => 'big'
);

$array1 = [
[
'<span>',
]
,
[
'<span>',
],
];

$array2 = array(
[
'<span>',
],[
'<span>',
],
);

$array3 = array(
'a' => ['<span>']
,['<span>'],
'b' => ['<span>']
,['<span>'],
);

$array4 = array(
['<span>']
,'a' => ['<span>'],
['<span>']
,'b' => ['<span>']
);

$utf8 = array(
'/[áàâãªäå]/u' => 'a',
'/[ÁÀÂÃÄÅ]/u' => 'A',
'/[áàâãªäå]/u' => 'a'
,'/[ÁÀÂÃÄÅ]/u' => 'A',
'/[ÍÌÎÏ]/u' => 'I',
'/[íìîï]/u' => 'i',
'/[éèêë]/u' => 'e',
Expand Down
32 changes: 32 additions & 0 deletions SymfonyCustom/Tests/Arrays/ArrayDeclarationUnitTest.inc.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,38 @@ class TestClass
'short_name' => 'big',
);

$array1 = [
[
'<span>',
],
[
'<span>',
],
];

$array2 = array(
[
'<span>',
],
[
'<span>',
],
);

$array3 = array(
'a' => ['<span>'],
['<span>'],
'b' => ['<span>'],
['<span>'],
);

$array4 = array(
['<span>'],
'a' => ['<span>'],
['<span>'],
'b' => ['<span>'],
);

$utf8 = array(
'/[áàâãªäå]/u' => 'a',
'/[ÁÀÂÃÄÅ]/u' => 'A',
Expand Down
57 changes: 32 additions & 25 deletions SymfonyCustom/Tests/Arrays/ArrayDeclarationUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,38 @@ class ArrayDeclarationUnitTest extends AbstractSniffUnitTest
public function getErrorList()
{
return [
7 => 2,
9 => 1,
22 => 1,
23 => 1,
24 => 1,
25 => 1,
31 => 1,
35 => 1,
36 => 1,
41 => 1,
46 => 1,
47 => 1,
50 => 1,
51 => 1,
53 => 1,
58 => 1,
61 => 1,
62 => 1,
63 => 1,
64 => 1,
65 => 1,
66 => 2,
67 => 1,
68 => 1,
70 => 1,
7 => 2,
9 => 1,
22 => 1,
23 => 1,
24 => 2,
25 => 1,
31 => 1,
35 => 1,
36 => 1,
41 => 1,
46 => 1,
47 => 1,
50 => 1,
51 => 1,
53 => 1,
58 => 1,
61 => 1,
62 => 1,
63 => 1,
64 => 1,
65 => 1,
66 => 2,
67 => 1,
68 => 1,
70 => 1,
77 => 1,
86 => 1,
93 => 3,
95 => 3,
100 => 3,
102 => 4,
107 => 2,
];
}

Expand Down