Skip to content

Commit

Permalink
Merge pull request #488 from rodrigoprimo/test-coverage-space-after-cast
Browse files Browse the repository at this point in the history
Generic/SpaceAfterCast: improve code coverage
  • Loading branch information
jrfnl authored May 13, 2024
2 parents c336428 + 16ca507 commit 63a8cbe
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,8 @@ $var = (int)
$var1 + (bool) $var2;
// phpcs:set Generic.Formatting.SpaceAfterCast ignoreNewlines false
// phpcs:set Generic.Formatting.SpaceAfterCast spacing 1

$var = (boolean)/* comment */ $var2;

$var = ( int )$spacesInsideParenthesis;
$var = ( int )$tabsInsideParenthesis;
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,8 @@ $var = (int)
$var1 + (bool)$var2;
// phpcs:set Generic.Formatting.SpaceAfterCast ignoreNewlines false
// phpcs:set Generic.Formatting.SpaceAfterCast spacing 1

$var = (boolean)/* comment */ $var2;

$var = ( int ) $spacesInsideParenthesis;
$var = ( int ) $tabsInsideParenthesis;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

$var = (int)
93 changes: 52 additions & 41 deletions src/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,50 +26,61 @@ final class SpaceAfterCastUnitTest 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 test file to run.
*
* @return array<int, int>
*/
public function getErrorList()
public function getErrorList($testFile='')
{
return [
4 => 1,
5 => 1,
8 => 1,
9 => 1,
12 => 1,
13 => 1,
16 => 1,
17 => 1,
20 => 1,
21 => 1,
24 => 1,
25 => 1,
28 => 1,
29 => 1,
32 => 1,
33 => 1,
36 => 1,
37 => 1,
40 => 1,
41 => 1,
44 => 1,
45 => 1,
51 => 1,
53 => 1,
55 => 1,
58 => 1,
64 => 1,
72 => 1,
73 => 1,
75 => 1,
76 => 1,
78 => 1,
82 => 1,
84 => 1,
85 => 1,
86 => 1,
88 => 1,
93 => 1,
];
switch ($testFile) {
case 'SpaceAfterCastUnitTest.1.inc':
return [
4 => 1,
5 => 1,
8 => 1,
9 => 1,
12 => 1,
13 => 1,
16 => 1,
17 => 1,
20 => 1,
21 => 1,
24 => 1,
25 => 1,
28 => 1,
29 => 1,
32 => 1,
33 => 1,
36 => 1,
37 => 1,
40 => 1,
41 => 1,
44 => 1,
45 => 1,
51 => 1,
53 => 1,
55 => 1,
58 => 1,
64 => 1,
72 => 1,
73 => 1,
75 => 1,
76 => 1,
78 => 1,
82 => 1,
84 => 1,
85 => 1,
86 => 1,
88 => 1,
93 => 1,
97 => 1,
99 => 1,
100 => 1,
];

default:
return [];
}//end switch

}//end getErrorList()

Expand Down

0 comments on commit 63a8cbe

Please sign in to comment.