|
30 | 30 | return null;
|
31 | 31 | }
|
32 | 32 | if (is_dir($probableConfig)) {
|
33 |
| - return $getPhpUnitConfig($probableConfig.DIRECTORY_SEPARATOR.'phpunit.xml'); |
| 33 | + return $getPhpUnitConfig($probableConfig.\DIRECTORY_SEPARATOR.'phpunit.xml'); |
34 | 34 | }
|
35 | 35 |
|
36 | 36 | if (file_exists($probableConfig)) {
|
|
93 | 93 | }
|
94 | 94 | };
|
95 | 95 |
|
96 |
| -if (PHP_VERSION_ID >= 80000) { |
| 96 | +if (\PHP_VERSION_ID >= 80000) { |
97 | 97 | // PHP 8 requires PHPUnit 9.3+
|
98 | 98 | $PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '9.3');
|
99 |
| -} elseif (PHP_VERSION_ID >= 70200) { |
| 99 | +} elseif (\PHP_VERSION_ID >= 70200) { |
100 | 100 | // PHPUnit 8 requires PHP 7.2+
|
101 | 101 | $PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '8.3');
|
102 |
| -} elseif (PHP_VERSION_ID >= 70100) { |
| 102 | +} elseif (\PHP_VERSION_ID >= 70100) { |
103 | 103 | // PHPUnit 7 requires PHP 7.1+
|
104 | 104 | $PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '7.5');
|
105 |
| -} elseif (PHP_VERSION_ID >= 70000) { |
| 105 | +} elseif (\PHP_VERSION_ID >= 70000) { |
106 | 106 | // PHPUnit 6 requires PHP 7.0+
|
107 | 107 | $PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '6.5');
|
108 |
| -} elseif (PHP_VERSION_ID >= 50600) { |
| 108 | +} elseif (\PHP_VERSION_ID >= 50600) { |
109 | 109 | // PHPUnit 4 does not support PHP 7
|
110 | 110 | $PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '5.7');
|
111 | 111 | } else {
|
112 | 112 | // PHPUnit 5.1 requires PHP 5.6+
|
113 | 113 | $PHPUNIT_VERSION = '4.8';
|
114 | 114 | }
|
115 | 115 |
|
116 |
| -$PHPUNIT_REMOVE_RETURN_TYPEHINT = filter_var($getEnvVar('SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT', '0'), FILTER_VALIDATE_BOOLEAN); |
| 116 | +$PHPUNIT_REMOVE_RETURN_TYPEHINT = filter_var($getEnvVar('SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT', '0'), \FILTER_VALIDATE_BOOLEAN); |
117 | 117 |
|
118 | 118 | $COMPOSER_JSON = getenv('COMPOSER') ?: 'composer.json';
|
119 | 119 |
|
|
127 | 127 |
|
128 | 128 | $oldPwd = getcwd();
|
129 | 129 | $PHPUNIT_DIR = $getEnvVar('SYMFONY_PHPUNIT_DIR', $root.'/vendor/bin/.phpunit');
|
130 |
| -$PHP = defined('PHP_BINARY') ? PHP_BINARY : 'php'; |
| 130 | +$PHP = defined('PHP_BINARY') ? \PHP_BINARY : 'php'; |
131 | 131 | $PHP = escapeshellarg($PHP);
|
132 |
| -if ('phpdbg' === PHP_SAPI) { |
| 132 | +if ('phpdbg' === \PHP_SAPI) { |
133 | 133 | $PHP .= ' -qrr';
|
134 | 134 | }
|
135 | 135 |
|
|
147 | 147 | }
|
148 | 148 |
|
149 | 149 | $COMPOSER = file_exists($COMPOSER = $oldPwd.'/composer.phar')
|
150 |
| - || ($COMPOSER = rtrim('\\' === DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer.phar`) : `which composer.phar 2> /dev/null`)) |
151 |
| - || ($COMPOSER = rtrim('\\' === DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer`) : `which composer 2> /dev/null`)) |
152 |
| - || file_exists($COMPOSER = rtrim('\\' === DIRECTORY_SEPARATOR ? `git rev-parse --show-toplevel 2> NUL` : `git rev-parse --show-toplevel 2> /dev/null`).DIRECTORY_SEPARATOR.'composer.phar') |
| 150 | + || ($COMPOSER = rtrim('\\' === \DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer.phar`) : `which composer.phar 2> /dev/null`)) |
| 151 | + || ($COMPOSER = rtrim('\\' === \DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer`) : `which composer 2> /dev/null`)) |
| 152 | + || file_exists($COMPOSER = rtrim('\\' === \DIRECTORY_SEPARATOR ? `git rev-parse --show-toplevel 2> NUL` : `git rev-parse --show-toplevel 2> /dev/null`).\DIRECTORY_SEPARATOR.'composer.phar') |
153 | 153 | ? ('#!/usr/bin/env php' === file_get_contents($COMPOSER, false, null, 0, 18) ? $PHP : '').' '.escapeshellarg($COMPOSER) // detect shell wrappers by looking at the shebang
|
154 | 154 | : 'composer';
|
155 | 155 |
|
156 | 156 | $SYMFONY_PHPUNIT_REMOVE = $getEnvVar('SYMFONY_PHPUNIT_REMOVE', 'phpspec/prophecy'.($PHPUNIT_VERSION < 6.0 ? ' symfony/yaml' : ''));
|
157 |
| -$configurationHash = md5(implode(PHP_EOL, [md5_file(__FILE__), $SYMFONY_PHPUNIT_REMOVE, (int) $PHPUNIT_REMOVE_RETURN_TYPEHINT])); |
| 157 | +$configurationHash = md5(implode(\PHP_EOL, [md5_file(__FILE__), $SYMFONY_PHPUNIT_REMOVE, (int) $PHPUNIT_REMOVE_RETURN_TYPEHINT])); |
158 | 158 | $PHPUNIT_VERSION_DIR = sprintf('phpunit-%s-%d', $PHPUNIT_VERSION, $PHPUNIT_REMOVE_RETURN_TYPEHINT);
|
159 | 159 | if (!file_exists("$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR/phpunit") || $configurationHash !== @file_get_contents("$PHPUNIT_DIR/.$PHPUNIT_VERSION_DIR.md5")) {
|
160 | 160 | // Build a standalone phpunit without symfony/yaml nor prophecy by default
|
161 | 161 |
|
162 | 162 | @mkdir($PHPUNIT_DIR, 0777, true);
|
163 | 163 | chdir($PHPUNIT_DIR);
|
164 | 164 | if (file_exists("$PHPUNIT_VERSION_DIR")) {
|
165 |
| - passthru(sprintf('\\' === DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s > NUL' : 'rm -rf %s', "$PHPUNIT_VERSION_DIR.old")); |
| 165 | + passthru(sprintf('\\' === \DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s > NUL' : 'rm -rf %s', "$PHPUNIT_VERSION_DIR.old")); |
166 | 166 | rename("$PHPUNIT_VERSION_DIR", "$PHPUNIT_VERSION_DIR.old");
|
167 |
| - passthru(sprintf('\\' === DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s' : 'rm -rf %s', "$PHPUNIT_VERSION_DIR.old")); |
| 167 | + passthru(sprintf('\\' === \DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s' : 'rm -rf %s', "$PHPUNIT_VERSION_DIR.old")); |
168 | 168 | }
|
169 | 169 |
|
170 | 170 | $info = [];
|
|
215 | 215 | $passthruOrFail("$COMPOSER require --no-update phpunit/phpunit-mock-objects \"~3.1.0\"");
|
216 | 216 | }
|
217 | 217 |
|
218 |
| - if (preg_match('{\^((\d++\.)\d++)[\d\.]*$}', $info['requires']['php'], $phpVersion) && version_compare($phpVersion[2].'99', PHP_VERSION, '<')) { |
| 218 | + if (preg_match('{\^((\d++\.)\d++)[\d\.]*$}', $info['requires']['php'], $phpVersion) && version_compare($phpVersion[2].'99', \PHP_VERSION, '<')) { |
219 | 219 | $passthruOrFail("$COMPOSER config platform.php \"$phpVersion[1].99\"");
|
220 | 220 | } else {
|
221 | 221 | $passthruOrFail("$COMPOSER config --unset platform.php");
|
222 | 222 | }
|
223 | 223 | if (file_exists($path = $root.'/vendor/symfony/phpunit-bridge')) {
|
224 | 224 | $passthruOrFail("$COMPOSER require --no-update symfony/phpunit-bridge \"*@dev\"");
|
225 |
| - $passthruOrFail("$COMPOSER config repositories.phpunit-bridge path ".escapeshellarg(str_replace('/', DIRECTORY_SEPARATOR, $path))); |
226 |
| - if ('\\' === DIRECTORY_SEPARATOR) { |
| 225 | + $passthruOrFail("$COMPOSER config repositories.phpunit-bridge path ".escapeshellarg(str_replace('/', \DIRECTORY_SEPARATOR, $path))); |
| 226 | + if ('\\' === \DIRECTORY_SEPARATOR) { |
227 | 227 | file_put_contents('composer.json', preg_replace('/^( {8})"phpunit-bridge": \{$/m', "$0\n$1 ".'"options": {"symlink": false},', file_get_contents('composer.json')));
|
228 | 228 | }
|
229 | 229 | } else {
|
230 | 230 | $passthruOrFail("$COMPOSER require --no-update symfony/phpunit-bridge \"*\"");
|
231 | 231 | }
|
232 | 232 | $prevRoot = getenv('COMPOSER_ROOT_VERSION');
|
233 | 233 | putenv("COMPOSER_ROOT_VERSION=$PHPUNIT_VERSION.99");
|
234 |
| - $q = '\\' === DIRECTORY_SEPARATOR ? '"' : ''; |
| 234 | + $q = '\\' === \DIRECTORY_SEPARATOR ? '"' : ''; |
235 | 235 | // --no-suggest is not in the list to keep compat with composer 1.0, which is shipped with Ubuntu 16.04LTS
|
236 | 236 | $exit = proc_close(proc_open("$q$COMPOSER install --no-dev --prefer-dist --no-progress $q", [], $p, getcwd()));
|
237 | 237 | putenv('COMPOSER_ROOT_VERSION'.(false !== $prevRoot ? '='.$prevRoot : ''));
|
|
244 | 244 | if ($PHPUNIT_REMOVE_RETURN_TYPEHINT) {
|
245 | 245 | $alteredCode = preg_replace('/^ ((?:protected|public)(?: static)? function \w+\(\)): void/m', ' $1', $alteredCode);
|
246 | 246 | }
|
247 |
| - $alteredCode = preg_replace('/abstract class (?:TestCase|PHPUnit_Framework_TestCase)[^\{]+\{/', '$0 '.PHP_EOL." use \Symfony\Bridge\PhpUnit\Legacy\PolyfillTestCaseTrait;", $alteredCode, 1); |
| 247 | + $alteredCode = preg_replace('/abstract class (?:TestCase|PHPUnit_Framework_TestCase)[^\{]+\{/', '$0 '.\PHP_EOL." use \Symfony\Bridge\PhpUnit\Legacy\PolyfillTestCaseTrait;", $alteredCode, 1); |
248 | 248 | file_put_contents($alteredFile, $alteredCode);
|
249 | 249 |
|
250 | 250 | // Mutate Assert code
|
251 | 251 | $alteredCode = file_get_contents($alteredFile = './src/Framework/Assert.php');
|
252 |
| - $alteredCode = preg_replace('/abstract class (?:Assert|PHPUnit_Framework_Assert)[^\{]+\{/', '$0 '.PHP_EOL." use \Symfony\Bridge\PhpUnit\Legacy\PolyfillAssertTrait;", $alteredCode, 1); |
| 252 | + $alteredCode = preg_replace('/abstract class (?:Assert|PHPUnit_Framework_Assert)[^\{]+\{/', '$0 '.\PHP_EOL." use \Symfony\Bridge\PhpUnit\Legacy\PolyfillAssertTrait;", $alteredCode, 1); |
253 | 253 | file_put_contents($alteredFile, $alteredCode);
|
254 | 254 |
|
255 | 255 | file_put_contents('phpunit', <<<'EOPHP'
|
@@ -302,7 +302,7 @@ class SymfonyExcludeListPhpunit {}
|
302 | 302 |
|
303 | 303 | return false;
|
304 | 304 | });
|
305 |
| -} elseif (filter_var(getenv('SYMFONY_PHPUNIT_DISABLE_RESULT_CACHE'), FILTER_VALIDATE_BOOLEAN)) { |
| 305 | +} elseif (filter_var(getenv('SYMFONY_PHPUNIT_DISABLE_RESULT_CACHE'), \FILTER_VALIDATE_BOOLEAN)) { |
306 | 306 | $argv[] = '--do-not-cache-result';
|
307 | 307 | ++$argc;
|
308 | 308 | }
|
@@ -334,7 +334,7 @@ class SymfonyExcludeListPhpunit {}
|
334 | 334 | $cmd[0] = sprintf('%s %s --colors=always', $PHP, escapeshellarg("$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR/phpunit"));
|
335 | 335 | $cmd = str_replace('%', '%%', implode(' ', $cmd)).' %1$s';
|
336 | 336 |
|
337 |
| -if ('\\' === DIRECTORY_SEPARATOR) { |
| 337 | +if ('\\' === \DIRECTORY_SEPARATOR) { |
338 | 338 | $cmd = 'cmd /v:on /d /c "('.$cmd.')%2$s"';
|
339 | 339 | } else {
|
340 | 340 | $cmd .= '%2$s';
|
@@ -384,7 +384,7 @@ class SymfonyExcludeListPhpunit {}
|
384 | 384 | // STATUS_STACK_BUFFER_OVERRUN (-1073740791/0xC0000409)
|
385 | 385 | // STATUS_ACCESS_VIOLATION (-1073741819/0xC0000005)
|
386 | 386 | // STATUS_HEAP_CORRUPTION (-1073740940/0xC0000374)
|
387 |
| - if ($procStatus && ('\\' !== DIRECTORY_SEPARATOR || !extension_loaded('apcu') || !filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN) || !in_array($procStatus, [-1073740791, -1073741819, -1073740940]))) { |
| 387 | + if ($procStatus && ('\\' !== \DIRECTORY_SEPARATOR || !extension_loaded('apcu') || !filter_var(ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN) || !in_array($procStatus, [-1073740791, -1073741819, -1073740940]))) { |
388 | 388 | $exit = $procStatus;
|
389 | 389 | echo "\033[41mKO\033[0m $component\n\n";
|
390 | 390 | } else {
|
|
0 commit comments