From 20a427de7c7f87bd3954779ef2009d3d7e0c6f09 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 29 Dec 2014 13:05:07 +0100 Subject: [PATCH] use value of DIRECTORY_SEPARATOR to detect Windows This commit unifies the detection of Windows builds across the Symfony codebase. --- .../Command/CacheClearCommand.php | 2 +- .../SecurityRoutingIntegrationTest.php | 4 +-- src/Symfony/Component/Console/Application.php | 2 +- .../Component/Console/Helper/DialogHelper.php | 2 +- .../Console/Tests/Helper/DialogHelperTest.php | 2 +- .../Component/Filesystem/Filesystem.php | 6 ++-- .../Filesystem/Tests/FilesystemTest.php | 14 ++++---- .../Finder/Iterator/PathFilterIterator.php | 2 +- .../Component/Finder/Tests/FinderTest.php | 4 +-- .../MimeType/FileBinaryMimeTypeGuesser.php | 2 +- .../Tests/File/MimeType/MimeTypeTest.php | 2 +- .../Component/HttpKernel/Tests/KernelTest.php | 2 +- .../Component/Process/ExecutableFinder.php | 4 +-- .../Component/Process/PhpExecutableFinder.php | 2 +- src/Symfony/Component/Process/Process.php | 22 ++++++------ .../Component/Process/ProcessUtils.php | 2 +- .../Process/Tests/AbstractProcessTest.php | 34 +++++++++---------- .../Process/Tests/ExecutableFinderTest.php | 6 ++-- .../Process/Tests/PhpExecutableFinderTest.php | 2 +- .../Process/Tests/ProcessBuilderTest.php | 12 +++---- .../Process/Tests/ProcessUtilsTest.php | 2 +- .../Tests/SigchildEnabledProcessTest.php | 2 +- .../Security/Core/Util/SecureRandom.php | 2 +- 23 files changed, 67 insertions(+), 67 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php index 45c1bcf98497..200f4a5b455c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php @@ -84,7 +84,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->warmup($warmupDir, $realCacheDir, !$input->getOption('no-optional-warmers')); $filesystem->rename($realCacheDir, $oldCacheDir); - if (defined('PHP_WINDOWS_VERSION_BUILD')) { + if ('\\' === DIRECTORY_SEPARATOR) { sleep(1); // workaround for Windows PHP rename bug } $filesystem->rename($warmupDir, $realCacheDir); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityRoutingIntegrationTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityRoutingIntegrationTest.php index 5ec56deb3677..8b879ce27854 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityRoutingIntegrationTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityRoutingIntegrationTest.php @@ -30,7 +30,7 @@ public function testRoutingErrorIsNotExposedForProtectedResourceWhenAnonymous($c */ public function testRoutingErrorIsExposedWhenNotProtected($config) { - if (defined('PHP_WINDOWS_VERSION_BUILD') && PHP_VERSION_ID < 50309) { + if ('\\' === DIRECTORY_SEPARATOR && PHP_VERSION_ID < 50309) { $this->markTestSkipped('Test hangs on Windows & PHP due to https://bugs.php.net/bug.php?id=60120 fixed in http://svn.php.net/viewvc?view=revision&revision=318366'); } @@ -46,7 +46,7 @@ public function testRoutingErrorIsExposedWhenNotProtected($config) */ public function testRoutingErrorIsNotExposedForProtectedResourceWhenLoggedInWithInsufficientRights($config) { - if (defined('PHP_WINDOWS_VERSION_BUILD') && PHP_VERSION_ID < 50309) { + if ('\\' === DIRECTORY_SEPARATOR && PHP_VERSION_ID < 50309) { $this->markTestSkipped('Test hangs on Windows & PHP due to https://bugs.php.net/bug.php?id=60120 fixed in http://svn.php.net/viewvc?view=revision&revision=318366'); } diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index f2943391b3dc..508e79f3f4e5 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -812,7 +812,7 @@ protected function getTerminalHeight() */ public function getTerminalDimensions() { - if (defined('PHP_WINDOWS_VERSION_BUILD')) { + if ('\\' === DIRECTORY_SEPARATOR) { // extract [w, H] from "wxh (WxH)" if (preg_match('/^(\d+)x\d+ \(\d+x(\d+)\)$/', trim(getenv('ANSICON')), $matches)) { return array((int) $matches[1], (int) $matches[2]); diff --git a/src/Symfony/Component/Console/Helper/DialogHelper.php b/src/Symfony/Component/Console/Helper/DialogHelper.php index 8c33518c24d7..3f31c430ca15 100644 --- a/src/Symfony/Component/Console/Helper/DialogHelper.php +++ b/src/Symfony/Component/Console/Helper/DialogHelper.php @@ -255,7 +255,7 @@ public function askConfirmation(OutputInterface $output, $question, $default = t */ public function askHiddenResponse(OutputInterface $output, $question, $fallback = true) { - if (defined('PHP_WINDOWS_VERSION_BUILD')) { + if ('\\' === DIRECTORY_SEPARATOR) { $exe = __DIR__.'/../Resources/bin/hiddeninput.exe'; // handle code running from a phar diff --git a/src/Symfony/Component/Console/Tests/Helper/DialogHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/DialogHelperTest.php index 7bd24ed03940..ce44fc773da7 100644 --- a/src/Symfony/Component/Console/Tests/Helper/DialogHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/DialogHelperTest.php @@ -99,7 +99,7 @@ public function testAskWithAutocomplete() */ public function testAskHiddenResponse() { - if (defined('PHP_WINDOWS_VERSION_BUILD')) { + if ('\\' === DIRECTORY_SEPARATOR) { $this->markTestSkipped('This test is not supported on Windows'); } diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php index af22c4fc84b6..135ffc959ca3 100644 --- a/src/Symfony/Component/Filesystem/Filesystem.php +++ b/src/Symfony/Component/Filesystem/Filesystem.php @@ -152,7 +152,7 @@ public function remove($files) } } else { // https://bugs.php.net/bug.php?id=52176 - if (defined('PHP_WINDOWS_VERSION_MAJOR') && is_dir($file)) { + if ('\\' === DIRECTORY_SEPARATOR && is_dir($file)) { if (true !== @rmdir($file)) { throw new IOException(sprintf('Failed to remove file %s', $file)); } @@ -295,7 +295,7 @@ public function symlink($originDir, $targetDir, $copyOnWindows = false) if (true !== @symlink($originDir, $targetDir)) { $report = error_get_last(); if (is_array($report)) { - if (defined('PHP_WINDOWS_VERSION_MAJOR') && false !== strpos($report['message'], 'error code(1314)')) { + if ('\\' === DIRECTORY_SEPARATOR && false !== strpos($report['message'], 'error code(1314)')) { throw new IOException('Unable to create symlink due to error code 1314: \'A required privilege is not held by the client\'. Do you have the required Administrator-rights?'); } } @@ -315,7 +315,7 @@ public function symlink($originDir, $targetDir, $copyOnWindows = false) public function makePathRelative($endPath, $startPath) { // Normalize separators on Windows - if (defined('PHP_WINDOWS_VERSION_MAJOR')) { + if ('\\' === DIRECTORY_SEPARATOR) { $endPath = strtr($endPath, '\\', '/'); $startPath = strtr($startPath, '\\', '/'); } diff --git a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php index f34c73cc19be..9f918c786608 100644 --- a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php +++ b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php @@ -32,7 +32,7 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase public static function setUpBeforeClass() { - if (defined('PHP_WINDOWS_VERSION_MAJOR')) { + if ('\\' === DIRECTORY_SEPARATOR) { self::$symlinkOnWindows = true; $originDir = tempnam(sys_get_temp_dir(), 'sl'); $targetDir = tempnam(sys_get_temp_dir(), 'sl'); @@ -798,7 +798,7 @@ public function providePathsForMakePathRelative() array('/a/aab/bb/', '/a/aa/', '../aab/bb/'), ); - if (defined('PHP_WINDOWS_VERSION_MAJOR')) { + if ('\\' === DIRECTORY_SEPARATOR) { $paths[] = array('c:\var\lib/symfony/src/Symfony/', 'c:/var/lib/symfony/', 'src/Symfony/'); } @@ -960,7 +960,7 @@ public function testDumpFile() $this->assertSame('bar', file_get_contents($filename)); // skip mode check on Windows - if (!defined('PHP_WINDOWS_VERSION_MAJOR')) { + if ('\\' !== DIRECTORY_SEPARATOR) { $this->assertEquals(753, $this->getFilePermissions($filename)); } } @@ -975,7 +975,7 @@ public function testDumpFileWithNullMode() $this->assertSame('bar', file_get_contents($filename)); // skip mode check on Windows - if (!defined('PHP_WINDOWS_VERSION_MAJOR')) { + if ('\\' !== DIRECTORY_SEPARATOR) { $this->assertEquals(600, $this->getFilePermissions($filename)); } } @@ -1031,21 +1031,21 @@ private function markAsSkippedIfSymlinkIsMissing() $this->markTestSkipped('symlink is not supported'); } - if (defined('PHP_WINDOWS_VERSION_MAJOR') && false === self::$symlinkOnWindows) { + if ('\\' === DIRECTORY_SEPARATOR && false === self::$symlinkOnWindows) { $this->markTestSkipped('symlink requires "Create symbolic links" privilege on Windows'); } } private function markAsSkippedIfChmodIsMissing() { - if (defined('PHP_WINDOWS_VERSION_MAJOR')) { + if ('\\' === DIRECTORY_SEPARATOR) { $this->markTestSkipped('chmod is not supported on Windows'); } } private 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'); } } diff --git a/src/Symfony/Component/Finder/Iterator/PathFilterIterator.php b/src/Symfony/Component/Finder/Iterator/PathFilterIterator.php index 00fd0c7d8f41..2bb8ebd223a9 100644 --- a/src/Symfony/Component/Finder/Iterator/PathFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/PathFilterIterator.php @@ -28,7 +28,7 @@ public function accept() { $filename = $this->current()->getRelativePathname(); - if (defined('PHP_WINDOWS_VERSION_MAJOR')) { + if ('\\' === DIRECTORY_SEPARATOR) { $filename = strtr($filename, '\\', '/'); } diff --git a/src/Symfony/Component/Finder/Tests/FinderTest.php b/src/Symfony/Component/Finder/Tests/FinderTest.php index 1b5d8da3019a..c2cb3d9930cb 100644 --- a/src/Symfony/Component/Finder/Tests/FinderTest.php +++ b/src/Symfony/Component/Finder/Tests/FinderTest.php @@ -734,7 +734,7 @@ public function getTestPathData() */ public function testAccessDeniedException(Adapter\AdapterInterface $adapter) { - if (defined('PHP_WINDOWS_VERSION_MAJOR')) { + if ('\\' === DIRECTORY_SEPARATOR) { $this->markTestSkipped('chmod is not supported on Windows'); } @@ -773,7 +773,7 @@ public function testAccessDeniedException(Adapter\AdapterInterface $adapter) */ public function testIgnoredAccessDeniedException(Adapter\AdapterInterface $adapter) { - if (defined('PHP_WINDOWS_VERSION_MAJOR')) { + if ('\\' === DIRECTORY_SEPARATOR) { $this->markTestSkipped('chmod is not supported on Windows'); } diff --git a/src/Symfony/Component/HttpFoundation/File/MimeType/FileBinaryMimeTypeGuesser.php b/src/Symfony/Component/HttpFoundation/File/MimeType/FileBinaryMimeTypeGuesser.php index 49448c3cbd3a..f917a06d6ccb 100644 --- a/src/Symfony/Component/HttpFoundation/File/MimeType/FileBinaryMimeTypeGuesser.php +++ b/src/Symfony/Component/HttpFoundation/File/MimeType/FileBinaryMimeTypeGuesser.php @@ -45,7 +45,7 @@ public function __construct($cmd = 'file -b --mime %s 2>/dev/null') */ public static function isSupported() { - return !defined('PHP_WINDOWS_VERSION_BUILD') && function_exists('passthru') && function_exists('escapeshellarg'); + return '\\' !== DIRECTORY_SEPARATOR && function_exists('passthru') && function_exists('escapeshellarg'); } /** diff --git a/src/Symfony/Component/HttpFoundation/Tests/File/MimeType/MimeTypeTest.php b/src/Symfony/Component/HttpFoundation/Tests/File/MimeType/MimeTypeTest.php index 1078fc2d414a..78d3e92af801 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/File/MimeType/MimeTypeTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/File/MimeType/MimeTypeTest.php @@ -74,7 +74,7 @@ public function testGuessWithIncorrectPath() public function testGuessWithNonReadablePath() { - if (defined('PHP_WINDOWS_VERSION_BUILD')) { + if ('\\' === DIRECTORY_SEPARATOR) { $this->markTestSkipped('Can not verify chmod operations on Windows'); } diff --git a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php index b68e37e39823..194d5e47d61f 100644 --- a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php @@ -341,7 +341,7 @@ public function doStuff() // Heredocs are preserved, making the output mixing Unix and Windows line // endings, switching to "\n" everywhere on Windows to avoid failure. - if (defined('PHP_WINDOWS_VERSION_MAJOR')) { + if ('\\' === DIRECTORY_SEPARATOR) { $expected = str_replace("\r\n", "\n", $expected); $output = str_replace("\r\n", "\n", $output); } diff --git a/src/Symfony/Component/Process/ExecutableFinder.php b/src/Symfony/Component/Process/ExecutableFinder.php index 6ae74dca174b..a9c0a5c8795b 100644 --- a/src/Symfony/Component/Process/ExecutableFinder.php +++ b/src/Symfony/Component/Process/ExecutableFinder.php @@ -72,13 +72,13 @@ public function find($name, $default = null, array $extraDirs = array()) } $suffixes = array(''); - if (defined('PHP_WINDOWS_VERSION_BUILD')) { + if ('\\' === DIRECTORY_SEPARATOR) { $pathExt = getenv('PATHEXT'); $suffixes = $pathExt ? explode(PATH_SEPARATOR, $pathExt) : $this->suffixes; } foreach ($suffixes as $suffix) { foreach ($dirs as $dir) { - if (is_file($file = $dir.DIRECTORY_SEPARATOR.$name.$suffix) && (defined('PHP_WINDOWS_VERSION_BUILD') || is_executable($file))) { + if (is_file($file = $dir.DIRECTORY_SEPARATOR.$name.$suffix) && ('\\' === DIRECTORY_SEPARATOR || is_executable($file))) { return $file; } } diff --git a/src/Symfony/Component/Process/PhpExecutableFinder.php b/src/Symfony/Component/Process/PhpExecutableFinder.php index 7854487a26b2..91d6d78a6703 100644 --- a/src/Symfony/Component/Process/PhpExecutableFinder.php +++ b/src/Symfony/Component/Process/PhpExecutableFinder.php @@ -60,7 +60,7 @@ public function find($includeArgs = true) } $dirs = array(PHP_BINDIR); - if (defined('PHP_WINDOWS_VERSION_BUILD')) { + if ('\\' === DIRECTORY_SEPARATOR) { $dirs[] = 'C:\xampp\php\\'; } diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 8c638d9fd23d..57c331998868 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -145,7 +145,7 @@ public function __construct($commandline, $cwd = null, array $env = null, $stdin // on Gnu/Linux, PHP builds with --enable-maintainer-zts are also affected // @see : https://bugs.php.net/bug.php?id=51800 // @see : https://bugs.php.net/bug.php?id=50524 - if (null === $this->cwd && (defined('ZEND_THREAD_SAFE') || defined('PHP_WINDOWS_VERSION_BUILD'))) { + if (null === $this->cwd && (defined('ZEND_THREAD_SAFE') || '\\' === DIRECTORY_SEPARATOR)) { $this->cwd = getcwd(); } if (null !== $env) { @@ -154,8 +154,8 @@ public function __construct($commandline, $cwd = null, array $env = null, $stdin $this->stdin = $stdin; $this->setTimeout($timeout); - $this->useFileHandles = defined('PHP_WINDOWS_VERSION_BUILD'); - $this->enhanceSigchildCompatibility = !defined('PHP_WINDOWS_VERSION_BUILD') && $this->isSigchildEnabled(); + $this->useFileHandles = '\\' === DIRECTORY_SEPARATOR; + $this->enhanceSigchildCompatibility = '\\' !== DIRECTORY_SEPARATOR && $this->isSigchildEnabled(); $this->options = array_replace(array('suppress_errors' => true, 'binary_pipes' => true), $options); } @@ -231,7 +231,7 @@ public function start($callback = null) $commandline = $this->commandline; - if (defined('PHP_WINDOWS_VERSION_BUILD') && $this->enhanceWindowsCompatibility) { + if ('\\' === DIRECTORY_SEPARATOR && $this->enhanceWindowsCompatibility) { $commandline = 'cmd /V:ON /E:ON /C "('.$commandline.')'; foreach ($this->processPipes->getFiles() as $offset => $filename) { $commandline .= ' '.$offset.'>'.ProcessUtils::escapeArgument($filename); @@ -314,8 +314,8 @@ public function wait($callback = null) do { $this->checkTimeout(); - $running = defined('PHP_WINDOWS_VERSION_BUILD') ? $this->isRunning() : $this->processPipes->hasOpenHandles(); - $close = !defined('PHP_WINDOWS_VERSION_BUILD') || !$running; + $running = '\\' === DIRECTORY_SEPARATOR ? $this->isRunning() : $this->processPipes->hasOpenHandles(); + $close = '\\' !== DIRECTORY_SEPARATOR || !$running; $this->readPipes(true, $close); } while ($running); @@ -379,7 +379,7 @@ public function getOutput() { $this->requireProcessIsStarted(__FUNCTION__); - $this->readPipes(false, defined('PHP_WINDOWS_VERSION_BUILD') ? !$this->processInformation['running'] : true); + $this->readPipes(false, '\\' === DIRECTORY_SEPARATOR ? !$this->processInformation['running'] : true); return $this->stdout; } @@ -419,7 +419,7 @@ public function getErrorOutput() { $this->requireProcessIsStarted(__FUNCTION__); - $this->readPipes(false, defined('PHP_WINDOWS_VERSION_BUILD') ? !$this->processInformation['running'] : true); + $this->readPipes(false, '\\' === DIRECTORY_SEPARATOR ? !$this->processInformation['running'] : true); return $this->stderr; } @@ -657,7 +657,7 @@ public function stop($timeout = 10, $signal = null) { $timeoutMicro = microtime(true) + $timeout; if ($this->isRunning()) { - if (defined('PHP_WINDOWS_VERSION_BUILD') && !$this->isSigchildEnabled()) { + if ('\\' === DIRECTORY_SEPARATOR && !$this->isSigchildEnabled()) { exec(sprintf("taskkill /F /T /PID %d 2>&1", $this->getPid()), $output, $exitCode); if ($exitCode > 0) { throw new RuntimeException('Unable to kill the process'); @@ -779,7 +779,7 @@ public function setTimeout($timeout) */ public function setTty($tty) { - if (defined('PHP_WINDOWS_VERSION_BUILD') && $tty) { + if ('\\' === DIRECTORY_SEPARATOR && $tty) { throw new RuntimeException('TTY mode is not supported on Windows platform.'); } @@ -1060,7 +1060,7 @@ protected function updateStatus($blocking) $this->processInformation = proc_get_status($this->process); $this->captureExitCode(); - $this->readPipes($blocking, defined('PHP_WINDOWS_VERSION_BUILD') ? !$this->processInformation['running'] : true); + $this->readPipes($blocking, '\\' === DIRECTORY_SEPARATOR ? !$this->processInformation['running'] : true); if (!$this->processInformation['running']) { $this->close(); diff --git a/src/Symfony/Component/Process/ProcessUtils.php b/src/Symfony/Component/Process/ProcessUtils.php index 547dee0138d4..748de2371a8b 100644 --- a/src/Symfony/Component/Process/ProcessUtils.php +++ b/src/Symfony/Component/Process/ProcessUtils.php @@ -42,7 +42,7 @@ public static function escapeArgument($argument) //Fix for PHP bug #49446 escapeshellarg doesn't work on Windows //@see https://bugs.php.net/bug.php?id=43784 //@see https://bugs.php.net/bug.php?id=49446 - if (defined('PHP_WINDOWS_VERSION_BUILD')) { + if ('\\' === DIRECTORY_SEPARATOR) { if ('' === $argument) { return escapeshellarg($argument); } diff --git a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php index 856e6485833f..7a4c96c83517 100644 --- a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php +++ b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php @@ -213,7 +213,7 @@ public function provideStdinValues() public function chainedCommandsOutputProvider() { - if (defined('PHP_WINDOWS_VERSION_BUILD')) { + if ('\\' === DIRECTORY_SEPARATOR) { return array( array("2 \r\n2\r\n", '&&', '2'), ); @@ -307,7 +307,7 @@ public function testGetIncrementalOutput() public function testZeroAsOutput() { - if (defined('PHP_WINDOWS_VERSION_BUILD')) { + if ('\\' === DIRECTORY_SEPARATOR) { // see http://stackoverflow.com/questions/7105433/windows-batch-echo-without-new-line $p = $this->getProcess('echo | set /p dummyName=0'); } else { @@ -320,7 +320,7 @@ public function testZeroAsOutput() public function testExitCodeCommandFailed() { - if (defined('PHP_WINDOWS_VERSION_BUILD')) { + if ('\\' === DIRECTORY_SEPARATOR) { $this->markTestSkipped('Windows does not support POSIX exit code'); } @@ -333,7 +333,7 @@ public function testExitCodeCommandFailed() public function testTTYCommand() { - if (defined('PHP_WINDOWS_VERSION_BUILD')) { + if ('\\' === DIRECTORY_SEPARATOR) { $this->markTestSkipped('Windows does have /dev/tty support'); } @@ -348,7 +348,7 @@ public function testTTYCommand() public function testTTYCommandExitCode() { - if (defined('PHP_WINDOWS_VERSION_BUILD')) { + if ('\\' === DIRECTORY_SEPARATOR) { $this->markTestSkipped('Windows does have /dev/tty support'); } @@ -361,7 +361,7 @@ public function testTTYCommandExitCode() public function testTTYInWindowsEnvironment() { - if (!defined('PHP_WINDOWS_VERSION_BUILD')) { + if ('\\' !== DIRECTORY_SEPARATOR) { $this->markTestSkipped('This test is for Windows platform only'); } @@ -491,7 +491,7 @@ public function testIsNotSuccessful() public function testProcessIsNotSignaled() { - if (defined('PHP_WINDOWS_VERSION_BUILD')) { + if ('\\' === DIRECTORY_SEPARATOR) { $this->markTestSkipped('Windows does not support POSIX signals'); } @@ -502,7 +502,7 @@ public function testProcessIsNotSignaled() public function testProcessWithoutTermSignalIsNotSignaled() { - if (defined('PHP_WINDOWS_VERSION_BUILD')) { + if ('\\' === DIRECTORY_SEPARATOR) { $this->markTestSkipped('Windows does not support POSIX signals'); } @@ -513,7 +513,7 @@ public function testProcessWithoutTermSignalIsNotSignaled() public function testProcessWithoutTermSignal() { - if (defined('PHP_WINDOWS_VERSION_BUILD')) { + if ('\\' === DIRECTORY_SEPARATOR) { $this->markTestSkipped('Windows does not support POSIX signals'); } @@ -524,7 +524,7 @@ public function testProcessWithoutTermSignal() public function testProcessIsSignaledIfStopped() { - if (defined('PHP_WINDOWS_VERSION_BUILD')) { + if ('\\' === DIRECTORY_SEPARATOR) { $this->markTestSkipped('Windows does not support POSIX signals'); } @@ -536,7 +536,7 @@ public function testProcessIsSignaledIfStopped() public function testProcessWithTermSignal() { - if (defined('PHP_WINDOWS_VERSION_BUILD')) { + if ('\\' === DIRECTORY_SEPARATOR) { $this->markTestSkipped('Windows does not support POSIX signals'); } @@ -552,7 +552,7 @@ public function testProcessWithTermSignal() public function testProcessThrowsExceptionWhenExternallySignaled() { - if (defined('PHP_WINDOWS_VERSION_BUILD')) { + if ('\\' === DIRECTORY_SEPARATOR) { $this->markTestSkipped('Windows does not support POSIX signals'); } @@ -613,7 +613,7 @@ public function testRunProcessWithTimeout() } $duration = microtime(true) - $start; - if (defined('PHP_WINDOWS_VERSION_BUILD')) { + if ('\\' === DIRECTORY_SEPARATOR) { // Windows is a bit slower as it read file handles, then allow twice the precision $maxDuration = $timeout + 2 * Process::TIMEOUT_PRECISION; } else { @@ -790,7 +790,7 @@ public function provideMethodsThatNeedATerminatedProcess() private function verifyPosixIsEnabled() { - if (defined('PHP_WINDOWS_VERSION_BUILD')) { + if ('\\' === DIRECTORY_SEPARATOR) { $this->markTestSkipped('POSIX signals do not work on Windows'); } if (!defined('SIGUSR1')) { @@ -803,7 +803,7 @@ private function verifyPosixIsEnabled() */ public function testSignalWithWrongIntSignal() { - if (defined('PHP_WINDOWS_VERSION_BUILD')) { + if ('\\' === DIRECTORY_SEPARATOR) { $this->markTestSkipped('POSIX signals do not work on Windows'); } @@ -817,7 +817,7 @@ public function testSignalWithWrongIntSignal() */ public function testSignalWithWrongNonIntSignal() { - if (defined('PHP_WINDOWS_VERSION_BUILD')) { + if ('\\' === DIRECTORY_SEPARATOR) { $this->markTestSkipped('POSIX signals do not work on Windows'); } @@ -843,7 +843,7 @@ public function pipesCodeProvider() 'include \''.__DIR__.'/PipeStdinInStdoutStdErrStreamSelect.php\';', ); - if (defined('PHP_WINDOWS_VERSION_BUILD')) { + if ('\\' === DIRECTORY_SEPARATOR) { // Avoid XL buffers on Windows because of https://bugs.php.net/bug.php?id=65650 $sizes = array(1, 2, 4, 8); } else { diff --git a/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php b/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php index 5fbe1e0aa70f..9af8082adf3f 100644 --- a/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php +++ b/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php @@ -94,7 +94,7 @@ public function testFindWithOpenBaseDir() $this->markTestSkipped('Requires the PHP_BINARY constant'); } - if (defined('PHP_WINDOWS_VERSION_BUILD')) { + if ('\\' === DIRECTORY_SEPARATOR) { $this->markTestSkipped('Cannot run test on windows'); } @@ -133,7 +133,7 @@ public function testFindProcessInOpenBasedir() private function assertSamePath($expected, $tested) { - if (defined('PHP_WINDOWS_VERSION_BUILD')) { + if ('\\' === DIRECTORY_SEPARATOR) { $this->assertEquals(strtolower($expected), strtolower($tested)); } else { $this->assertEquals($expected, $tested); @@ -142,6 +142,6 @@ private function assertSamePath($expected, $tested) private function getPhpBinaryName() { - return basename(PHP_BINARY, defined('PHP_WINDOWS_VERSION_BUILD') ? '.exe' : ''); + return basename(PHP_BINARY, '\\' === DIRECTORY_SEPARATOR ? '.exe' : ''); } } diff --git a/src/Symfony/Component/Process/Tests/PhpExecutableFinderTest.php b/src/Symfony/Component/Process/Tests/PhpExecutableFinderTest.php index 519c82dda7f3..3acccacc3b1e 100644 --- a/src/Symfony/Component/Process/Tests/PhpExecutableFinderTest.php +++ b/src/Symfony/Component/Process/Tests/PhpExecutableFinderTest.php @@ -89,7 +89,7 @@ public function testFindWithSuffix() $current = $f->find(); //TODO maybe php executable is custom or even Windows - if (defined('PHP_WINDOWS_VERSION_BUILD')) { + if ('\\' === DIRECTORY_SEPARATOR) { $this->assertTrue(is_executable($current)); $this->assertTrue((bool) preg_match('/'.addSlashes(DIRECTORY_SEPARATOR).'php\.(exe|bat|cmd|com)$/i', $current), '::find() returns the executable PHP with suffixes'); } diff --git a/src/Symfony/Component/Process/Tests/ProcessBuilderTest.php b/src/Symfony/Component/Process/Tests/ProcessBuilderTest.php index 70245e0a4272..e8ef6bc98a57 100644 --- a/src/Symfony/Component/Process/Tests/ProcessBuilderTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessBuilderTest.php @@ -126,14 +126,14 @@ public function testPrefixIsPrependedToAllGeneratedProcess() $pb->setPrefix('/usr/bin/php'); $proc = $pb->setArguments(array('-v'))->getProcess(); - if (defined('PHP_WINDOWS_VERSION_BUILD')) { + if ('\\' === DIRECTORY_SEPARATOR) { $this->assertEquals('"/usr/bin/php" "-v"', $proc->getCommandLine()); } else { $this->assertEquals("'/usr/bin/php' '-v'", $proc->getCommandLine()); } $proc = $pb->setArguments(array('-i'))->getProcess(); - if (defined('PHP_WINDOWS_VERSION_BUILD')) { + if ('\\' === DIRECTORY_SEPARATOR) { $this->assertEquals('"/usr/bin/php" "-i"', $proc->getCommandLine()); } else { $this->assertEquals("'/usr/bin/php' '-i'", $proc->getCommandLine()); @@ -145,7 +145,7 @@ public function testShouldEscapeArguments() $pb = new ProcessBuilder(array('%path%', 'foo " bar', '%baz%baz')); $proc = $pb->getProcess(); - if (defined('PHP_WINDOWS_VERSION_BUILD')) { + if ('\\' === DIRECTORY_SEPARATOR) { $this->assertSame('^%"path"^% "foo \\" bar" "%baz%baz"', $proc->getCommandLine()); } else { $this->assertSame("'%path%' 'foo \" bar' '%baz%baz'", $proc->getCommandLine()); @@ -158,7 +158,7 @@ public function testShouldEscapeArgumentsAndPrefix() $pb->setPrefix('%prefix%'); $proc = $pb->getProcess(); - if (defined('PHP_WINDOWS_VERSION_BUILD')) { + if ('\\' === DIRECTORY_SEPARATOR) { $this->assertSame('^%"prefix"^% "arg"', $proc->getCommandLine()); } else { $this->assertSame("'%prefix%' 'arg'", $proc->getCommandLine()); @@ -179,7 +179,7 @@ public function testShouldNotThrowALogicExceptionIfNoArgument() ->setPrefix('/usr/bin/php') ->getProcess(); - if (defined('PHP_WINDOWS_VERSION_BUILD')) { + if ('\\' === DIRECTORY_SEPARATOR) { $this->assertEquals('"/usr/bin/php"', $process->getCommandLine()); } else { $this->assertEquals("'/usr/bin/php'", $process->getCommandLine()); @@ -191,7 +191,7 @@ public function testShouldNotThrowALogicExceptionIfNoPrefix() $process = ProcessBuilder::create(array('/usr/bin/php')) ->getProcess(); - if (defined('PHP_WINDOWS_VERSION_BUILD')) { + if ('\\' === DIRECTORY_SEPARATOR) { $this->assertEquals('"/usr/bin/php"', $process->getCommandLine()); } else { $this->assertEquals("'/usr/bin/php'", $process->getCommandLine()); diff --git a/src/Symfony/Component/Process/Tests/ProcessUtilsTest.php b/src/Symfony/Component/Process/Tests/ProcessUtilsTest.php index 8ba94c114d26..e6564cde5ba6 100644 --- a/src/Symfony/Component/Process/Tests/ProcessUtilsTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessUtilsTest.php @@ -25,7 +25,7 @@ public function testEscapeArgument($result, $argument) public function dataArguments() { - if (defined('PHP_WINDOWS_VERSION_BUILD')) { + if ('\\' === DIRECTORY_SEPARATOR) { return array( array('"\"php\" \"-v\""', '"php" "-v"'), array('"foo bar"', 'foo bar'), diff --git a/src/Symfony/Component/Process/Tests/SigchildEnabledProcessTest.php b/src/Symfony/Component/Process/Tests/SigchildEnabledProcessTest.php index 37a064188f7d..55a50dfbd7ce 100644 --- a/src/Symfony/Component/Process/Tests/SigchildEnabledProcessTest.php +++ b/src/Symfony/Component/Process/Tests/SigchildEnabledProcessTest.php @@ -114,7 +114,7 @@ public function testExitCodeIsAvailableAfterSignal() public function testStartAfterATimeout() { - if (defined('PHP_WINDOWS_VERSION_BUILD')) { + if ('\\' === DIRECTORY_SEPARATOR) { $this->markTestSkipped('Restarting a timed-out process on Windows is not supported in sigchild environment'); } parent::testStartAfterATimeout(); diff --git a/src/Symfony/Component/Security/Core/Util/SecureRandom.php b/src/Symfony/Component/Security/Core/Util/SecureRandom.php index aefc88854a64..c0924df61f1f 100644 --- a/src/Symfony/Component/Security/Core/Util/SecureRandom.php +++ b/src/Symfony/Component/Security/Core/Util/SecureRandom.php @@ -43,7 +43,7 @@ public function __construct($seedFile = null, LoggerInterface $logger = null) $this->logger = $logger; // determine whether to use OpenSSL - if (defined('PHP_WINDOWS_VERSION_BUILD') && PHP_VERSION_ID < 50304) { + if ('\\' === DIRECTORY_SEPARATOR && PHP_VERSION_ID < 50304) { $this->useOpenSsl = false; } elseif (!function_exists('openssl_random_pseudo_bytes')) { if (null !== $this->logger) {