Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit aedb247

Browse files
committed
Merge branch '2.6' into 2.7
* 2.6: [Form] Remove a redundant test. use value of DIRECTORY_SEPARATOR to detect Windows
2 parents a86d4e3 + 67904e1 commit aedb247

24 files changed

+63
-94
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
9191
$this->warmup($warmupDir, $realCacheDir, !$input->getOption('no-optional-warmers'));
9292

9393
$filesystem->rename($realCacheDir, $oldCacheDir);
94-
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
94+
if ('\\' === DIRECTORY_SEPARATOR) {
9595
sleep(1); // workaround for Windows PHP rename bug
9696
}
9797
$filesystem->rename($warmupDir, $realCacheDir);

src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityRoutingIntegrationTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function testRoutingErrorIsNotExposedForProtectedResourceWhenAnonymous($c
3030
*/
3131
public function testRoutingErrorIsExposedWhenNotProtected($config)
3232
{
33-
if (defined('PHP_WINDOWS_VERSION_BUILD') && PHP_VERSION_ID < 50309) {
33+
if ('\\' === DIRECTORY_SEPARATOR && PHP_VERSION_ID < 50309) {
3434
$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');
3535
}
3636

@@ -46,7 +46,7 @@ public function testRoutingErrorIsExposedWhenNotProtected($config)
4646
*/
4747
public function testRoutingErrorIsNotExposedForProtectedResourceWhenLoggedInWithInsufficientRights($config)
4848
{
49-
if (defined('PHP_WINDOWS_VERSION_BUILD') && PHP_VERSION_ID < 50309) {
49+
if ('\\' === DIRECTORY_SEPARATOR && PHP_VERSION_ID < 50309) {
5050
$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');
5151
}
5252

src/Symfony/Component/Console/Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ public function getTerminalDimensions()
770770
return $this->terminalDimensions;
771771
}
772772

773-
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
773+
if ('\\' === DIRECTORY_SEPARATOR) {
774774
// extract [w, H] from "wxh (WxH)"
775775
if (preg_match('/^(\d+)x\d+ \(\d+x(\d+)\)$/', trim(getenv('ANSICON')), $matches)) {
776776
return array((int) $matches[1], (int) $matches[2]);

src/Symfony/Component/Console/Helper/DialogHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ public function askConfirmation(OutputInterface $output, $question, $default = t
269269
*/
270270
public function askHiddenResponse(OutputInterface $output, $question, $fallback = true)
271271
{
272-
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
272+
if ('\\' === DIRECTORY_SEPARATOR) {
273273
$exe = __DIR__.'/../Resources/bin/hiddeninput.exe';
274274

275275
// handle code running from a phar

src/Symfony/Component/Console/Tests/Helper/DialogHelperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function testAskWithAutocomplete()
100100
*/
101101
public function testAskHiddenResponse()
102102
{
103-
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
103+
if ('\\' === DIRECTORY_SEPARATOR) {
104104
$this->markTestSkipped('This test is not supported on Windows');
105105
}
106106

src/Symfony/Component/Filesystem/Filesystem.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public function remove($files)
164164
}
165165
} else {
166166
// https://bugs.php.net/bug.php?id=52176
167-
if (defined('PHP_WINDOWS_VERSION_MAJOR') && is_dir($file)) {
167+
if ('\\' === DIRECTORY_SEPARATOR && is_dir($file)) {
168168
if (true !== @rmdir($file)) {
169169
throw new IOException(sprintf('Failed to remove file "%s".', $file), 0, null, $file);
170170
}
@@ -307,7 +307,7 @@ public function symlink($originDir, $targetDir, $copyOnWindows = false)
307307
if (true !== @symlink($originDir, $targetDir)) {
308308
$report = error_get_last();
309309
if (is_array($report)) {
310-
if (defined('PHP_WINDOWS_VERSION_MAJOR') && false !== strpos($report['message'], 'error code(1314)')) {
310+
if ('\\' === DIRECTORY_SEPARATOR && false !== strpos($report['message'], 'error code(1314)')) {
311311
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?');
312312
}
313313
}
@@ -327,7 +327,7 @@ public function symlink($originDir, $targetDir, $copyOnWindows = false)
327327
public function makePathRelative($endPath, $startPath)
328328
{
329329
// Normalize separators on Windows
330-
if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
330+
if ('\\' === DIRECTORY_SEPARATOR) {
331331
$endPath = strtr($endPath, '\\', '/');
332332
$startPath = strtr($startPath, '\\', '/');
333333
}

src/Symfony/Component/Filesystem/Tests/FilesystemTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ public function providePathsForMakePathRelative()
803803
array('/a/aab/bb/', '/a/aa/', '../aab/bb/'),
804804
);
805805

806-
if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
806+
if ('\\' === DIRECTORY_SEPARATOR) {
807807
$paths[] = array('c:\var\lib/symfony/src/Symfony/', 'c:/var/lib/symfony/', 'src/Symfony/');
808808
}
809809

@@ -965,7 +965,7 @@ public function testDumpFile()
965965
$this->assertSame('bar', file_get_contents($filename));
966966

967967
// skip mode check on Windows
968-
if (!defined('PHP_WINDOWS_VERSION_MAJOR')) {
968+
if ('\\' !== DIRECTORY_SEPARATOR) {
969969
$this->assertFilePermissions(753, $filename);
970970
}
971971
}
@@ -980,7 +980,7 @@ public function testDumpFileWithNullMode()
980980
$this->assertSame('bar', file_get_contents($filename));
981981

982982
// skip mode check on Windows
983-
if (!defined('PHP_WINDOWS_VERSION_MAJOR')) {
983+
if ('\\' !== DIRECTORY_SEPARATOR) {
984984
$this->assertFilePermissions(600, $filename);
985985
}
986986
}

src/Symfony/Component/Finder/Iterator/PathFilterIterator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function accept()
2828
{
2929
$filename = $this->current()->getRelativePathname();
3030

31-
if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
31+
if ('\\' === DIRECTORY_SEPARATOR) {
3232
$filename = strtr($filename, '\\', '/');
3333
}
3434

src/Symfony/Component/Finder/Tests/FinderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ public function getTestPathData()
745745
*/
746746
public function testAccessDeniedException(Adapter\AdapterInterface $adapter)
747747
{
748-
if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
748+
if ('\\' === DIRECTORY_SEPARATOR) {
749749
$this->markTestSkipped('chmod is not supported on Windows');
750750
}
751751

@@ -784,7 +784,7 @@ public function testAccessDeniedException(Adapter\AdapterInterface $adapter)
784784
*/
785785
public function testIgnoredAccessDeniedException(Adapter\AdapterInterface $adapter)
786786
{
787-
if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
787+
if ('\\' === DIRECTORY_SEPARATOR) {
788788
$this->markTestSkipped('chmod is not supported on Windows');
789789
}
790790

src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -279,37 +279,6 @@ public function testValidateTokenOnSubmitIfRootAndCompoundUsesTypeClassAsIntenti
279279
$this->assertSame($valid, $form->isValid());
280280
}
281281

282-
/**
283-
* @dataProvider provideBoolean
284-
*/
285-
public function testValidateTokenOnBindIfRootAndCompoundUsesTypeClassAsIntentionIfEmptyFormName($valid)
286-
{
287-
$this->tokenManager->expects($this->once())
288-
->method('isTokenValid')
289-
->with(new CsrfToken('Symfony\Component\Form\Extension\Core\Type\FormType', 'token'))
290-
->will($this->returnValue($valid));
291-
292-
$form = $this->factory
293-
->createNamedBuilder('', 'form', null, array(
294-
'csrf_field_name' => 'csrf',
295-
'csrf_token_manager' => $this->tokenManager,
296-
'compound' => true,
297-
))
298-
->add('child', 'text')
299-
->getForm();
300-
301-
$form->submit(array(
302-
'child' => 'foobar',
303-
'csrf' => 'token',
304-
));
305-
306-
// Remove token from data
307-
$this->assertSame(array('child' => 'foobar'), $form->getData());
308-
309-
// Validate accordingly
310-
$this->assertSame($valid, $form->isValid());
311-
}
312-
313282
public function testFailIfRootAndCompoundAndTokenMissing()
314283
{
315284
$this->tokenManager->expects($this->never())

src/Symfony/Component/HttpFoundation/File/MimeType/FileBinaryMimeTypeGuesser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function __construct($cmd = 'file -b --mime %s 2>/dev/null')
4545
*/
4646
public static function isSupported()
4747
{
48-
return !defined('PHP_WINDOWS_VERSION_BUILD') && function_exists('passthru') && function_exists('escapeshellarg');
48+
return '\\' !== DIRECTORY_SEPARATOR && function_exists('passthru') && function_exists('escapeshellarg');
4949
}
5050

5151
/**

src/Symfony/Component/HttpFoundation/Tests/File/MimeType/MimeTypeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function testGuessWithIncorrectPath()
7171

7272
public function testGuessWithNonReadablePath()
7373
{
74-
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
74+
if ('\\' === DIRECTORY_SEPARATOR) {
7575
$this->markTestSkipped('Can not verify chmod operations on Windows');
7676
}
7777

src/Symfony/Component/HttpKernel/Tests/KernelTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ public function doStuff()
271271

272272
// Heredocs are preserved, making the output mixing Unix and Windows line
273273
// endings, switching to "\n" everywhere on Windows to avoid failure.
274-
if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
274+
if ('\\' === DIRECTORY_SEPARATOR) {
275275
$expected = str_replace("\r\n", "\n", $expected);
276276
$output = str_replace("\r\n", "\n", $output);
277277
}

src/Symfony/Component/Process/ExecutableFinder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ public function find($name, $default = null, array $extraDirs = array())
7272
}
7373

7474
$suffixes = array('');
75-
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
75+
if ('\\' === DIRECTORY_SEPARATOR) {
7676
$pathExt = getenv('PATHEXT');
7777
$suffixes = $pathExt ? explode(PATH_SEPARATOR, $pathExt) : $this->suffixes;
7878
}
7979
foreach ($suffixes as $suffix) {
8080
foreach ($dirs as $dir) {
81-
if (is_file($file = $dir.DIRECTORY_SEPARATOR.$name.$suffix) && (defined('PHP_WINDOWS_VERSION_BUILD') || is_executable($file))) {
81+
if (is_file($file = $dir.DIRECTORY_SEPARATOR.$name.$suffix) && ('\\' === DIRECTORY_SEPARATOR || is_executable($file))) {
8282
return $file;
8383
}
8484
}

src/Symfony/Component/Process/PhpExecutableFinder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function find($includeArgs = true)
6060
}
6161

6262
$dirs = array(PHP_BINDIR);
63-
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
63+
if ('\\' === DIRECTORY_SEPARATOR) {
6464
$dirs[] = 'C:\xampp\php\\';
6565
}
6666

src/Symfony/Component/Process/Process.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public function __construct($commandline, $cwd = null, array $env = null, $input
155155
// on Gnu/Linux, PHP builds with --enable-maintainer-zts are also affected
156156
// @see : https://bugs.php.net/bug.php?id=51800
157157
// @see : https://bugs.php.net/bug.php?id=50524
158-
if (null === $this->cwd && (defined('ZEND_THREAD_SAFE') || defined('PHP_WINDOWS_VERSION_BUILD'))) {
158+
if (null === $this->cwd && (defined('ZEND_THREAD_SAFE') || '\\' === DIRECTORY_SEPARATOR)) {
159159
$this->cwd = getcwd();
160160
}
161161
if (null !== $env) {
@@ -164,10 +164,10 @@ public function __construct($commandline, $cwd = null, array $env = null, $input
164164

165165
$this->input = $input;
166166
$this->setTimeout($timeout);
167-
$this->useFileHandles = defined('PHP_WINDOWS_VERSION_BUILD');
167+
$this->useFileHandles = '\\' === DIRECTORY_SEPARATOR;
168168
$this->pty = false;
169169
$this->enhanceWindowsCompatibility = true;
170-
$this->enhanceSigchildCompatibility = !defined('PHP_WINDOWS_VERSION_BUILD') && $this->isSigchildEnabled();
170+
$this->enhanceSigchildCompatibility = '\\' !== DIRECTORY_SEPARATOR && $this->isSigchildEnabled();
171171
$this->options = array_replace(array('suppress_errors' => true, 'binary_pipes' => true), $options);
172172
}
173173

@@ -276,7 +276,7 @@ public function start($callback = null)
276276

277277
$commandline = $this->commandline;
278278

279-
if (defined('PHP_WINDOWS_VERSION_BUILD') && $this->enhanceWindowsCompatibility) {
279+
if ('\\' === DIRECTORY_SEPARATOR && $this->enhanceWindowsCompatibility) {
280280
$commandline = 'cmd /V:ON /E:ON /C "('.$commandline.')';
281281
foreach ($this->processPipes->getFiles() as $offset => $filename) {
282282
$commandline .= ' '.$offset.'>'.ProcessUtils::escapeArgument($filename);
@@ -356,8 +356,8 @@ public function wait($callback = null)
356356

357357
do {
358358
$this->checkTimeout();
359-
$running = defined('PHP_WINDOWS_VERSION_BUILD') ? $this->isRunning() : $this->processPipes->areOpen();
360-
$close = !defined('PHP_WINDOWS_VERSION_BUILD') || !$running;
359+
$running = '\\' === DIRECTORY_SEPARATOR ? $this->isRunning() : $this->processPipes->areOpen();
360+
$close = '\\' !== DIRECTORY_SEPARATOR || !$running;
361361
$this->readPipes(true, $close);
362362
} while ($running);
363363

@@ -476,7 +476,7 @@ public function getOutput()
476476

477477
$this->requireProcessIsStarted(__FUNCTION__);
478478

479-
$this->readPipes(false, defined('PHP_WINDOWS_VERSION_BUILD') ? !$this->processInformation['running'] : true);
479+
$this->readPipes(false, '\\' === DIRECTORY_SEPARATOR ? !$this->processInformation['running'] : true);
480480

481481
return $this->stdout;
482482
}
@@ -535,7 +535,7 @@ public function getErrorOutput()
535535

536536
$this->requireProcessIsStarted(__FUNCTION__);
537537

538-
$this->readPipes(false, defined('PHP_WINDOWS_VERSION_BUILD') ? !$this->processInformation['running'] : true);
538+
$this->readPipes(false, '\\' === DIRECTORY_SEPARATOR ? !$this->processInformation['running'] : true);
539539

540540
return $this->stderr;
541541
}
@@ -787,7 +787,7 @@ public function stop($timeout = 10, $signal = null)
787787
{
788788
$timeoutMicro = microtime(true) + $timeout;
789789
if ($this->isRunning()) {
790-
if (defined('PHP_WINDOWS_VERSION_BUILD') && !$this->isSigchildEnabled()) {
790+
if ('\\' === DIRECTORY_SEPARATOR && !$this->isSigchildEnabled()) {
791791
exec(sprintf("taskkill /F /T /PID %d 2>&1", $this->getPid()), $output, $exitCode);
792792
if ($exitCode > 0) {
793793
throw new RuntimeException('Unable to kill the process');
@@ -936,7 +936,7 @@ public function setIdleTimeout($timeout)
936936
*/
937937
public function setTty($tty)
938938
{
939-
if (defined('PHP_WINDOWS_VERSION_BUILD') && $tty) {
939+
if ('\\' === DIRECTORY_SEPARATOR && $tty) {
940940
throw new RuntimeException('TTY mode is not supported on Windows platform.');
941941
}
942942

@@ -1314,7 +1314,7 @@ protected function updateStatus($blocking)
13141314
$this->processInformation = proc_get_status($this->process);
13151315
$this->captureExitCode();
13161316

1317-
$this->readPipes($blocking, defined('PHP_WINDOWS_VERSION_BUILD') ? !$this->processInformation['running'] : true);
1317+
$this->readPipes($blocking, '\\' === DIRECTORY_SEPARATOR ? !$this->processInformation['running'] : true);
13181318

13191319
if (!$this->processInformation['running']) {
13201320
$this->close();

src/Symfony/Component/Process/ProcessUtils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static function escapeArgument($argument)
4242
//Fix for PHP bug #49446 escapeshellarg doesn't work on Windows
4343
//@see https://bugs.php.net/bug.php?id=43784
4444
//@see https://bugs.php.net/bug.php?id=49446
45-
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
45+
if ('\\' === DIRECTORY_SEPARATOR) {
4646
if ('' === $argument) {
4747
return escapeshellarg($argument);
4848
}

0 commit comments

Comments
 (0)