Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

Expand Down
2 changes: 1 addition & 1 deletion src/Reports/Code.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion src/Tokenizers/PHP.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Util/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -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('`(?<!^) `', '^ ', $cmd);
Expand All @@ -278,7 +278,7 @@ public static function escapeshellcmd($cmd)
*/
public static function prepareForOutput($content, $exclude=[])
{
if (stripos(PHP_OS, 'WIN') === 0) {
if (PHP_OS_FAMILY === 'Windows') {
if (in_array("\r", $exclude, true) === false) {
$content = str_replace("\r", '\r', $content);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Core/Ruleset/ExpandRulesetReferenceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public static function dataUnresolvableReferenceThrowsException()
];

// Add tests which are only relevant for case-sensitive OSes.
if (stripos(PHP_OS, 'WIN') === false) {
if (PHP_OS_FAMILY !== 'Windows') {
$data['Referencing an existing sniff, but there is a case mismatch (OS-dependent) [1]'] = [
'standard' => 'ExpandRulesetReferenceCaseMismatch1Test.xml',
'replacement' => 'psr12.functions.nullabletypedeclaration',
Expand Down
2 changes: 1 addition & 1 deletion tests/Core/Util/Common/EscapeshellcmdTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down