Skip to content

Commit 82d99c2

Browse files
jrfnlgrogy
authored andcommitted
CS: various minor fixes
Fix up the issues which will be flagged by PHP-Code-Style 2.0 and explicitly ignore a couple of (non-)issues. Includes no longer allowing warnings in the GH Actions build.
1 parent ca5295a commit 82d99c2

File tree

6 files changed

+15
-10
lines changed

6 files changed

+15
-10
lines changed

.github/workflows/cs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
run: vendor/bin/phpcs --report-full --report-checkstyle=./checkstyle.xml
3939

4040
- name: Show PHPCS results in PR
41-
run: cs2pr ./checkstyle.xml --graceful-warnings
41+
run: cs2pr ./checkstyle.xml
4242

4343
- name: Make sure no vardumps remain
4444
run: composer vardumpcheck

examples/snippet.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
use PHP_Parallel_Lint\PhpConsoleColor\ConsoleColor;
34
use PHP_Parallel_Lint\PhpConsoleHighlighter\Highlighter;
45

@@ -7,4 +8,4 @@
78
$highlighter = new Highlighter(new ConsoleColor());
89

910
$fileContent = file_get_contents(__FILE__);
10-
echo $highlighter->getCodeSnippet($fileContent, 3);
11+
echo $highlighter->getCodeSnippet($fileContent, 3);

examples/whole_file.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
use PHP_Parallel_Lint\PhpConsoleColor\ConsoleColor;
34
use PHP_Parallel_Lint\PhpConsoleHighlighter\Highlighter;
45

@@ -7,4 +8,4 @@
78
$highlighter = new Highlighter(new ConsoleColor());
89

910
$fileContent = file_get_contents(__FILE__);
10-
echo $highlighter->getWholeFile($fileContent);
11+
echo $highlighter->getWholeFile($fileContent);

examples/whole_file_line_numbers.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
use PHP_Parallel_Lint\PhpConsoleColor\ConsoleColor;
34
use PHP_Parallel_Lint\PhpConsoleHighlighter\Highlighter;
45

@@ -7,4 +8,4 @@
78
$highlighter = new Highlighter(new ConsoleColor());
89

910
$fileContent = file_get_contents(__FILE__);
10-
echo $highlighter->getWholeFileWithLineNumbers($fileContent);
11+
echo $highlighter->getWholeFileWithLineNumbers($fileContent);

src/Highlighter.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace PHP_Parallel_Lint\PhpConsoleHighlighter;
34

45
use PHP_Parallel_Lint\PhpConsoleColor\ConsoleColor;
@@ -157,7 +158,6 @@ private function getTokenType($arrayToken)
157158
case T_CLOSE_TAG:
158159
case T_STRING:
159160
case T_VARIABLE:
160-
161161
// Constants
162162
case T_DIR:
163163
case T_FILE:
@@ -183,6 +183,8 @@ private function getTokenType($arrayToken)
183183
return self::TOKEN_HTML;
184184
}
185185

186+
// phpcs:disable PHPCompatibility.Constants.NewConstants -- The new token constants are only used when defined.
187+
186188
// Handle PHP >= 8.0 namespaced name tokens.
187189
// https://www.php.net/manual/en/migration80.incompatible.php#migration80.incompatible.tokenizer
188190
if (defined('T_NAME_QUALIFIED') && $arrayToken[0] === T_NAME_QUALIFIED) {
@@ -195,6 +197,8 @@ private function getTokenType($arrayToken)
195197
return self::TOKEN_DEFAULT;
196198
}
197199

200+
// phpcs:enable
201+
198202
return self::TOKEN_KEYWORD;
199203
}
200204

tests/HighlighterTest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
2+
23
namespace PHP_Parallel_Lint\PhpConsoleHighlighter\Test;
34

45
use PHP_Parallel_Lint\PhpConsoleHighlighter\Highlighter;
5-
66
use PHPUnit\Framework\TestCase;
77

88
class HighlighterTest extends TestCase
@@ -267,17 +267,15 @@ public function testHashComment()
267267
public function testEmpty()
268268
{
269269
$this->compare(
270-
''
271-
,
270+
'',
272271
''
273272
);
274273
}
275274

276275
public function testWhitespace()
277276
{
278277
$this->compare(
279-
' '
280-
,
278+
' ',
281279
'<token_html> </token_html>'
282280
);
283281
}

0 commit comments

Comments
 (0)