Skip to content

Commit 6100f99

Browse files
committed
QA: minor code simplification
Replace a nested function call with a singular function call, which does the same.
1 parent 498a939 commit 6100f99

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

src/Config.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ public function __construct(array $cliArgs=[], $dieOnUnknownArg=true)
368368
}//end if
369369

370370
if (defined('STDIN') === false
371-
|| strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'
371+
|| stripos(PHP_OS, 'WIN') === 0
372372
) {
373373
return;
374374
}
@@ -1517,7 +1517,7 @@ public static function getExecutablePath($name)
15171517
return self::$executablePaths[$name];
15181518
}
15191519

1520-
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
1520+
if (stripos(PHP_OS, 'WIN') === 0) {
15211521
$cmd = 'where '.escapeshellarg($name).' 2> nul';
15221522
} else {
15231523
$cmd = 'which '.escapeshellarg($name).' 2> /dev/null';

src/Reports/Code.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false,
225225
if (strpos($tokenContent, "\t") !== false) {
226226
$token = $tokens[$i];
227227
$token['content'] = $tokenContent;
228-
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
228+
if (stripos(PHP_OS, 'WIN') === 0) {
229229
$tab = "\000";
230230
} else {
231231
$tab = "\033[30;1m»\033[0m";

src/Standards/Generic/Tests/Files/ExecutableFileUnitTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ protected function shouldSkipTest()
2525
// PEAR doesn't preserve the executable flag, so skip
2626
// tests when running in a PEAR install.
2727
// Also skip on Windows which doesn't have the concept of executable files.
28-
return ($GLOBALS['PHP_CODESNIFFER_PEAR'] || (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'));
28+
return ($GLOBALS['PHP_CODESNIFFER_PEAR'] || stripos(PHP_OS, 'WIN') === 0);
2929

3030
}//end shouldSkipTest()
3131

src/Tokenizers/PHP.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ protected function tokenize($string)
511511
if (PHP_CODESNIFFER_VERBOSITY > 1) {
512512
echo "\t*** START PHP TOKENIZING ***".PHP_EOL;
513513
$isWin = false;
514-
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
514+
if (stripos(PHP_OS, 'WIN') === 0) {
515515
$isWin = true;
516516
}
517517
}

src/Util/Common.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ public static function escapeshellcmd($cmd)
250250
{
251251
$cmd = escapeshellcmd($cmd);
252252

253-
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
253+
if (stripos(PHP_OS, 'WIN') === 0) {
254254
// Spaces are not escaped by escapeshellcmd on Windows, but need to be
255255
// for the command to be able to execute.
256256
$cmd = preg_replace('`(?<!^) `', '^ ', $cmd);
@@ -275,7 +275,7 @@ public static function escapeshellcmd($cmd)
275275
*/
276276
public static function prepareForOutput($content, $exclude=[])
277277
{
278-
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
278+
if (stripos(PHP_OS, 'WIN') === 0) {
279279
if (in_array("\r", $exclude, true) === false) {
280280
$content = str_replace("\r", '\r', $content);
281281
}

0 commit comments

Comments
 (0)