@@ -57,10 +57,11 @@ foreach ($defaultEnvs as $envName => $envValue) {
57
57
}
58
58
}
59
59
60
+ $ isWindows = '\\' === DIRECTORY_SEPARATOR ;
60
61
$ COMPOSER = file_exists ($ COMPOSER = $ oldPwd .'/composer.phar ' )
61
- || ($ COMPOSER = rtrim ('\\' === DIRECTORY_SEPARATOR ? preg_replace ('/[\r\n].*/ ' , '' , `where.exe composer.phar `) : `which composer.phar 2> /dev/null `))
62
- || ($ COMPOSER = rtrim ('\\' === DIRECTORY_SEPARATOR ? preg_replace ('/[\r\n].*/ ' , '' , `where.exe composer `) : `which composer 2> /dev/null `))
63
- ? $ PHP .' ' .escapeshellarg ($ COMPOSER )
62
+ || ($ COMPOSER = rtrim ($ isWindows ? preg_replace ('/[\r\n].*/ ' , '' , `where.exe composer.phar `) : `which composer.phar 2> /dev/null `))
63
+ || ($ COMPOSER = rtrim ($ isWindows ? preg_replace ('/[\r\n].*/ ' , '' , `where.exe composer `) : `which composer 2> /dev/null `))
64
+ ? (! $ isWindows && ( strpos (` file $ COMPOSER 2> /dev/null `, ' binary data ' ) === false ) ? '' : $ PHP ) .' ' .escapeshellarg ($ COMPOSER )
64
65
: 'composer ' ;
65
66
66
67
if (false === $ SYMFONY_PHPUNIT_REMOVE = getenv ('SYMFONY_PHPUNIT_REMOVE ' )) {
@@ -73,9 +74,9 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__
73
74
@mkdir ($ PHPUNIT_DIR , 0777 , true );
74
75
chdir ($ PHPUNIT_DIR );
75
76
if (file_exists ("phpunit- $ PHPUNIT_VERSION " )) {
76
- passthru (sprintf ('\\' === DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s > NUL ' : 'rm -rf %s ' , "phpunit- $ PHPUNIT_VERSION .old " ));
77
+ passthru (sprintf ($ isWindows ? 'rmdir /S /Q %s > NUL ' : 'rm -rf %s ' , "phpunit- $ PHPUNIT_VERSION .old " ));
77
78
rename ("phpunit- $ PHPUNIT_VERSION " , "phpunit- $ PHPUNIT_VERSION .old " );
78
- passthru (sprintf ('\\' === DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s ' : 'rm -rf %s ' , "phpunit- $ PHPUNIT_VERSION .old " ));
79
+ passthru (sprintf ($ isWindows ? 'rmdir /S /Q %s ' : 'rm -rf %s ' , "phpunit- $ PHPUNIT_VERSION .old " ));
79
80
}
80
81
passthru ("$ COMPOSER create-project --no-install --prefer-dist --no-scripts --no-plugins --no-progress --ansi phpunit/phpunit phpunit- $ PHPUNIT_VERSION \"$ PHPUNIT_VERSION .* \"" );
81
82
@copy ("phpunit- $ PHPUNIT_VERSION /phpunit.xsd " , 'phpunit.xsd ' );
@@ -91,15 +92,15 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__
91
92
if (file_exists ($ path = $ root .'/vendor/symfony/phpunit-bridge ' )) {
92
93
passthru ("$ COMPOSER require --no-update symfony/phpunit-bridge \"*@dev \"" );
93
94
passthru ("$ COMPOSER config repositories.phpunit-bridge path " .escapeshellarg (str_replace ('/ ' , DIRECTORY_SEPARATOR , $ path )));
94
- if ('\\' === DIRECTORY_SEPARATOR ) {
95
+ if ($ isWindows ) {
95
96
file_put_contents ('composer.json ' , preg_replace ('/^( {8})"phpunit-bridge": \{$/m ' , "$0 \n$1 " .'"options": {"symlink": false}, ' , file_get_contents ('composer.json ' )));
96
97
}
97
98
} else {
98
99
passthru ("$ COMPOSER require --no-update symfony/phpunit-bridge \"* \"" );
99
100
}
100
101
$ prevRoot = getenv ('COMPOSER_ROOT_VERSION ' );
101
102
putenv ("COMPOSER_ROOT_VERSION= $ PHPUNIT_VERSION .99 " );
102
- $ q = '\\' === DIRECTORY_SEPARATOR ? '" ' : '' ;
103
+ $ q = $ isWindows ? '" ' : '' ;
103
104
// --no-suggest is not in the list to keep compat with composer 1.0, which is shipped with Ubuntu 16.04LTS
104
105
$ exit = proc_close (proc_open ("$ q$ COMPOSER install --no-dev --prefer-dist --no-progress --ansi $ q " , array (), $ p , getcwd ()));
105
106
putenv ('COMPOSER_ROOT_VERSION ' .(false !== $ prevRoot ? '= ' .$ prevRoot : '' ));
@@ -171,7 +172,7 @@ if (isset($argv[1]) && is_dir($argv[1]) && !file_exists($argv[1].'/phpunit.xml.d
171
172
$ cmd [0 ] = sprintf ('%s %s --colors=always ' , $ PHP , escapeshellarg ("$ PHPUNIT_DIR /phpunit- $ PHPUNIT_VERSION /phpunit " ));
172
173
$ cmd = str_replace ('% ' , '%% ' , implode (' ' , $ cmd )).' %1$s ' ;
173
174
174
- if ('\\' === DIRECTORY_SEPARATOR ) {
175
+ if ($ isWindows ) {
175
176
$ cmd = 'cmd /v:on /d /c "( ' .$ cmd .')%2$s" ' ;
176
177
} else {
177
178
$ cmd .= '%2$s ' ;
0 commit comments