Skip to content

Generic/ArbitraryParenthesesSpacing: improve sniff code coverage #174

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
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
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,8 @@ class NonArbitraryParenthesesWithKeywords {
$d = new parent( $foo,$bar );
}
}

// Test that the match expression does not trigger the sniff.
$b = match ( $a ) {
1 => true,
};
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,8 @@ class NonArbitraryParenthesesWithKeywords {
$d = new parent( $foo,$bar );
}
}

// Test that the match expression does not trigger the sniff.
$b = match ( $a ) {
1 => true,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php

// Intentional parse error. Testing that the sniff is *not* triggered in this case.
function something $param ) {}
Original file line number Diff line number Diff line change
Expand Up @@ -26,45 +26,53 @@ class ArbitraryParenthesesSpacingUnitTest extends AbstractSniffUnitTest
* The key of the array should represent the line number and the value
* should represent the number of errors that should occur on that line.
*
* @param string $testFile The name of the file being tested.
*
* @return array<int, int>
*/
public function getErrorList()
public function getErrorList($testFile='')
{
return [
64 => 4,
66 => 1,
68 => 1,
69 => 1,
72 => 2,
73 => 2,
77 => 2,
81 => 4,
90 => 4,
94 => 1,
95 => 1,
97 => 1,
100 => 2,
101 => 2,
104 => 2,
107 => 2,
109 => 4,
111 => 4,
113 => 2,
115 => 2,
123 => 1,
125 => 2,
127 => 1,
131 => 1,
133 => 1,
137 => 1,
139 => 2,
141 => 1,
144 => 1,
146 => 1,
163 => 1,
164 => 1,
165 => 1,
];
switch ($testFile) {
case 'ArbitraryParenthesesSpacingUnitTest.1.inc':
return [
64 => 4,
66 => 1,
68 => 1,
69 => 1,
72 => 2,
73 => 2,
77 => 2,
81 => 4,
90 => 4,
94 => 1,
95 => 1,
97 => 1,
100 => 2,
101 => 2,
104 => 2,
107 => 2,
109 => 4,
111 => 4,
113 => 2,
115 => 2,
123 => 1,
125 => 2,
127 => 1,
131 => 1,
133 => 1,
137 => 1,
139 => 2,
141 => 1,
144 => 1,
146 => 1,
163 => 1,
164 => 1,
165 => 1,
];

default:
return [];
}//end switch

}//end getErrorList()

Expand All @@ -75,14 +83,22 @@ public function getErrorList()
* The key of the array should represent the line number and the value
* should represent the number of warnings that should occur on that line.
*
* @param string $testFile The name of the file being tested.
*
* @return array<int, int>
*/
public function getWarningList()
public function getWarningList($testFile='')
{
return [
55 => 1,
56 => 1,
];
switch ($testFile) {
case 'ArbitraryParenthesesSpacingUnitTest.1.inc':
return [
55 => 1,
56 => 1,
];

default:
return [];
}//end switch

}//end getWarningList()

Expand Down