Skip to content

Commit 0d14a2d

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 9fe669b commit 0d14a2d

File tree

6 files changed

+11
-4
lines changed

6 files changed

+11
-4
lines changed

.github/workflows/cs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ 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

example.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
$loader = require_once __DIR__ . '/vendor/autoload.php';
34

45
$consoleColor = new PHP_Parallel_Lint\PhpConsoleColor\ConsoleColor();

src/ConsoleColor.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace PHP_Parallel_Lint\PhpConsoleColor;
34

45
class ConsoleColor
@@ -99,7 +100,7 @@ public function apply($style, $text)
99100
foreach ($style as $s) {
100101
if (isset($this->themes[$s])) {
101102
$sequences = array_merge($sequences, $this->themeSequence($s));
102-
} else if ($this->isValidStyle($s)) {
103+
} elseif ($this->isValidStyle($s)) {
103104
$sequences[] = $this->styleSequence($s);
104105
} else {
105106
throw new InvalidStyleException($s);
@@ -203,13 +204,15 @@ public function removeTheme($name)
203204
public function isSupported()
204205
{
205206
if (DIRECTORY_SEPARATOR === '\\') {
207+
// phpcs:ignore Generic.PHP.NoSilencedErrors,PHPCompatibility.FunctionUse.NewFunctions.sapi_windows_vt100_supportFound
206208
if (function_exists('sapi_windows_vt100_support') && @sapi_windows_vt100_support(STDOUT)) {
207209
return true;
208210
} elseif (getenv('ANSICON') !== false || getenv('ConEmuANSI') === 'ON') {
209211
return true;
210212
}
211213
return false;
212214
} else {
215+
// phpcs:ignore Generic.PHP.NoSilencedErrors
213216
return function_exists('posix_isatty') && @posix_isatty(STDOUT);
214217
}
215218
}
@@ -222,6 +225,7 @@ public function isSupported()
222225
public function are256ColorsSupported()
223226
{
224227
if (DIRECTORY_SEPARATOR === '\\') {
228+
// phpcs:ignore Generic.PHP.NoSilencedErrors,PHPCompatibility.FunctionUse.NewFunctions.sapi_windows_vt100_supportFound
225229
return function_exists('sapi_windows_vt100_support') && @sapi_windows_vt100_support(STDOUT);
226230
} else {
227231
return strpos(getenv('TERM'), '256color') !== false;

src/InvalidStyleException.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace PHP_Parallel_Lint\PhpConsoleColor;
34

45
class InvalidStyleException extends \Exception
@@ -7,4 +8,4 @@ public function __construct($styleName)
78
{
89
parent::__construct("Invalid style $styleName.");
910
}
10-
}
11+
}

tests/ConsoleColorTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace PHP_Parallel_Lint\PhpConsoleColor\Test;
34

45
use PHP_Parallel_Lint\PhpConsoleColor\ConsoleColor;
@@ -309,4 +310,3 @@ public function exceptionHelper($exception, $msg = null)
309310
}
310311
}
311312
}
312-

tests/Fixtures/ConsoleColorWithForceSupport.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace PHP_Parallel_Lint\PhpConsoleColor\Test\Fixtures;
34

45
use PHP_Parallel_Lint\PhpConsoleColor\ConsoleColor;

0 commit comments

Comments
 (0)