minor #13148 [2.5] for consistency, use DIRECTORY_SEPARATOR to detect Windows (xabbuh)

This PR was merged into the 2.5 branch.

Discussion
----------

[2.5] for consistency, use DIRECTORY_SEPARATOR to detect Windows

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

This commit unifies the detection of Windows builds across the Symfony
codebase.

Specific changes for Symfony 2.5 not included in #13147.

Commits
-------

559273e use PHP_WINDOWS_VERSION_BUILD to detect Windows
This commit is contained in:
Fabien Potencier 2014-12-31 10:00:18 +01:00
commit 3df409650c
6 changed files with 10 additions and 10 deletions

View File

@ -289,7 +289,7 @@ class QuestionHelper extends Helper
*/
private function getHiddenResponse(OutputInterface $output, $inputStream)
{
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
if ('\\' === DIRECTORY_SEPARATOR) {
$exe = __DIR__.'/../Resources/bin/hiddeninput.exe';
// handle code running from a phar

View File

@ -130,7 +130,7 @@ class QuestionHelperTest extends \PHPUnit_Framework_TestCase
public function testAskHiddenResponse()
{
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
if ('\\' === DIRECTORY_SEPARATOR) {
$this->markTestSkipped('This test is not supported on Windows');
}

View File

@ -22,7 +22,7 @@ class FilesystemTestCase extends \PHPUnit_Framework_TestCase
public static function setUpBeforeClass()
{
if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
if ('\\' === DIRECTORY_SEPARATOR) {
static::$symlinkOnWindows = true;
$originDir = tempnam(sys_get_temp_dir(), 'sl');
$targetDir = tempnam(sys_get_temp_dir(), 'sl');
@ -106,21 +106,21 @@ class FilesystemTestCase extends \PHPUnit_Framework_TestCase
$this->markTestSkipped('symlink is not supported');
}
if (defined('PHP_WINDOWS_VERSION_MAJOR') && false === static::$symlinkOnWindows) {
if ('\\' === DIRECTORY_SEPARATOR && false === static::$symlinkOnWindows) {
$this->markTestSkipped('symlink requires "Create symbolic links" privilege on windows');
}
}
protected function markAsSkippedIfChmodIsMissing()
{
if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
if ('\\' === DIRECTORY_SEPARATOR) {
$this->markTestSkipped('chmod is not supported on windows');
}
}
protected function markAsSkippedIfPosixIsMissing()
{
if (defined('PHP_WINDOWS_VERSION_MAJOR') || !function_exists('posix_isatty')) {
if ('\\' === DIRECTORY_SEPARATOR || !function_exists('posix_isatty')) {
$this->markTestSkipped('Posix is not supported');
}
}

View File

@ -1229,7 +1229,7 @@ class Process
return $result;
}
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
if ('\\' === DIRECTORY_SEPARATOR) {
return $result = false;
}

View File

@ -115,7 +115,7 @@ class ProcessPipes
public function getDescriptors()
{
if ($this->disableOutput) {
$nullstream = fopen(defined('PHP_WINDOWS_VERSION_BUILD') ? 'NUL' : '/dev/null', 'c');
$nullstream = fopen('\\' === DIRECTORY_SEPARATOR ? 'NUL' : '/dev/null', 'c');
return array(
array('pipe', 'r'),

View File

@ -122,14 +122,14 @@ class ProcessBuilderTest extends \PHPUnit_Framework_TestCase
$pb->setPrefix(array('/usr/bin/php', 'composer.phar'));
$proc = $pb->setArguments(array('-v'))->getProcess();
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
if ('\\' === DIRECTORY_SEPARATOR) {
$this->assertEquals('"/usr/bin/php" "composer.phar" "-v"', $proc->getCommandLine());
} else {
$this->assertEquals("'/usr/bin/php' 'composer.phar' '-v'", $proc->getCommandLine());
}
$proc = $pb->setArguments(array('-i'))->getProcess();
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
if ('\\' === DIRECTORY_SEPARATOR) {
$this->assertEquals('"/usr/bin/php" "composer.phar" "-i"', $proc->getCommandLine());
} else {
$this->assertEquals("'/usr/bin/php' 'composer.phar' '-i'", $proc->getCommandLine());