From f38a72a2fb8607605ec5d8f7ec5f5c08a30fd799 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 29 Dec 2014 13:15:05 +0100 Subject: [PATCH] use value of DIRECTORY_SEPARATOR to detect Windows This commit unifies the detection of Windows builds across the Symfony codebase. --- .../Component/Console/Tests/Helper/ProcessHelperTest.php | 2 +- src/Symfony/Component/Filesystem/Filesystem.php | 2 +- src/Symfony/Component/Filesystem/Tests/FilesystemTest.php | 4 ++-- src/Symfony/Component/Process/Process.php | 2 +- src/Symfony/Component/VarDumper/Dumper/CliDumper.php | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Component/Console/Tests/Helper/ProcessHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/ProcessHelperTest.php index 327247c3d8..2e333dc05e 100644 --- a/src/Symfony/Component/Console/Tests/Helper/ProcessHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/ProcessHelperTest.php @@ -84,7 +84,7 @@ EOT; EOT; $errorMessage = 'An error occurred'; - if (defined('PHP_WINDOWS_VERSION_BUILD')) { + if ('\\' === DIRECTORY_SEPARATOR) { $successOutputProcessDebug = str_replace("'", '"', $successOutputProcessDebug); } diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php index f2145e6417..ca2778cf56 100644 --- a/src/Symfony/Component/Filesystem/Filesystem.php +++ b/src/Symfony/Component/Filesystem/Filesystem.php @@ -286,7 +286,7 @@ class Filesystem */ public function symlink($originDir, $targetDir, $copyOnWindows = false) { - if (defined('PHP_WINDOWS_VERSION_MAJOR') && $copyOnWindows) { + if ('\\' === DIRECTORY_SEPARATOR && $copyOnWindows) { $this->mirror($originDir, $targetDir); return; diff --git a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php index 2dadb51f20..6d284c0c0a 100644 --- a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php +++ b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php @@ -59,7 +59,7 @@ class FilesystemTest extends FilesystemTestCase public function testCopyUnreadableFileFails() { // skip test on Windows; PHP can't easily set file as unreadable on Windows - if (defined('PHP_WINDOWS_VERSION_MAJOR')) { + if ('\\' === DIRECTORY_SEPARATOR) { $this->markTestSkipped('This test cannot run on Windows.'); } @@ -133,7 +133,7 @@ class FilesystemTest extends FilesystemTestCase public function testCopyWithOverrideWithReadOnlyTargetFails() { // skip test on Windows; PHP can't easily set file as unwritable on Windows - if (defined('PHP_WINDOWS_VERSION_MAJOR')) { + if ('\\' === DIRECTORY_SEPARATOR) { $this->markTestSkipped('This test cannot run on Windows.'); } diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index fb45b00637..1cd801f11e 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -1249,7 +1249,7 @@ class Process */ private function getDescriptors() { - if (defined('PHP_WINDOWS_VERSION_BUILD')) { + if ('\\' === DIRECTORY_SEPARATOR) { $this->processPipes = WindowsPipes::create($this, $this->input); } else { $this->processPipes = UnixPipes::create($this, $this->input); diff --git a/src/Symfony/Component/VarDumper/Dumper/CliDumper.php b/src/Symfony/Component/VarDumper/Dumper/CliDumper.php index 6a171649bf..9b1be7c01b 100644 --- a/src/Symfony/Component/VarDumper/Dumper/CliDumper.php +++ b/src/Symfony/Component/VarDumper/Dumper/CliDumper.php @@ -52,7 +52,7 @@ class CliDumper extends AbstractDumper { parent::__construct($output); - if (defined('PHP_WINDOWS_VERSION_MAJOR') && false !== @getenv('ANSICON')) { + if ('\\' === DIRECTORY_SEPARATOR && false !== @getenv('ANSICON')) { // Use only the base 16 xterm colors when using ANSICON $this->setStyles(array( 'default' => '31', @@ -394,7 +394,7 @@ class CliDumper extends AbstractDumper } } - if (defined('PHP_WINDOWS_VERSION_MAJOR')) { + if ('\\' === DIRECTORY_SEPARATOR) { static::$defaultColors = @(false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI')); } elseif (function_exists('posix_isatty')) { $h = stream_get_meta_data($this->outputStream) + array('wrapper_type' => null);