diff --git a/src/Config.php b/src/Config.php index c0494dbabc..ac3cff705f 100644 --- a/src/Config.php +++ b/src/Config.php @@ -450,7 +450,7 @@ public function __construct(array $cliArgs=[], $dieOnUnknownArg=true) }//end if if (defined('STDIN') === false - || stripos(PHP_OS, 'WIN') === 0 + || PHP_OS_FAMILY === 'Windows' ) { return; } @@ -1614,7 +1614,7 @@ public static function getExecutablePath($name) return self::$executablePaths[$name]; } - if (stripos(PHP_OS, 'WIN') === 0) { + if (PHP_OS_FAMILY === 'Windows') { $cmd = 'where '.escapeshellarg($name).' 2> nul'; } else { $cmd = 'which '.escapeshellarg($name).' 2> /dev/null'; diff --git a/src/Fixer.php b/src/Fixer.php index 709d193aa1..cbdf687f49 100644 --- a/src/Fixer.php +++ b/src/Fixer.php @@ -284,7 +284,7 @@ public function generateDiff($filePath=null, $colors=true) ]; $options = null; - if (stripos(PHP_OS, 'WIN') === 0) { + if (PHP_OS_FAMILY === 'Windows') { $options = ['bypass_shell' => true]; } diff --git a/src/Reports/Code.php b/src/Reports/Code.php index 1a39f06f92..2299b018b1 100644 --- a/src/Reports/Code.php +++ b/src/Reports/Code.php @@ -230,7 +230,7 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false, if (strpos($tokenContent, "\t") !== false) { $token = $tokens[$i]; $token['content'] = $tokenContent; - if (stripos(PHP_OS, 'WIN') === 0) { + if (PHP_OS_FAMILY === 'Windows') { $tab = "\000"; } else { $tab = "\033[30;1m»\033[0m"; diff --git a/src/Standards/Generic/Tests/Files/ExecutableFileUnitTest.php b/src/Standards/Generic/Tests/Files/ExecutableFileUnitTest.php index 55d5ba1baa..1b15736b83 100644 --- a/src/Standards/Generic/Tests/Files/ExecutableFileUnitTest.php +++ b/src/Standards/Generic/Tests/Files/ExecutableFileUnitTest.php @@ -28,7 +28,7 @@ final class ExecutableFileUnitTest extends AbstractSniffTestCase protected function shouldSkipTest() { // Skip on Windows which doesn't have the concept of executable files. - return (stripos(PHP_OS, 'WIN') === 0); + return PHP_OS_FAMILY === 'Windows'; }//end shouldSkipTest() diff --git a/src/Tokenizers/PHP.php b/src/Tokenizers/PHP.php index 31015cac97..f4360d9e7a 100644 --- a/src/Tokenizers/PHP.php +++ b/src/Tokenizers/PHP.php @@ -528,7 +528,7 @@ protected function tokenize($string) if (PHP_CODESNIFFER_VERBOSITY > 1) { StatusWriter::write('*** START PHP TOKENIZING ***', 1); $isWin = false; - if (stripos(PHP_OS, 'WIN') === 0) { + if (PHP_OS_FAMILY === 'Windows') { $isWin = true; } } diff --git a/src/Util/Common.php b/src/Util/Common.php index 5ca34ded59..5216a24fad 100644 --- a/src/Util/Common.php +++ b/src/Util/Common.php @@ -253,7 +253,7 @@ public static function escapeshellcmd($cmd) { $cmd = escapeshellcmd($cmd); - if (stripos(PHP_OS, 'WIN') === 0) { + if (PHP_OS_FAMILY === 'Windows') { // Spaces are not escaped by escapeshellcmd on Windows, but need to be // for the command to be able to execute. $cmd = preg_replace('`(? 'ExpandRulesetReferenceCaseMismatch1Test.xml', 'replacement' => 'psr12.functions.nullabletypedeclaration', diff --git a/tests/Core/Util/Common/EscapeshellcmdTest.php b/tests/Core/Util/Common/EscapeshellcmdTest.php index 2844c4a320..213010de49 100644 --- a/tests/Core/Util/Common/EscapeshellcmdTest.php +++ b/tests/Core/Util/Common/EscapeshellcmdTest.php @@ -36,7 +36,7 @@ final class EscapeshellcmdTest extends TestCase */ public function testEscapeshellcmd($command, $expected, $expectedWin=null) { - if (stripos(PHP_OS, 'WIN') === 0 && empty($expectedWin) === false) { + if (PHP_OS_FAMILY === 'Windows' && empty($expectedWin) === false) { $expected = $expectedWin; }