|
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 |
|
|
148 | 148 | }
|
149 | 149 |
|
150 | 150 | $COMPOSER = file_exists($COMPOSER = $oldPwd.'/composer.phar')
|
151 |
| - || ($COMPOSER = rtrim('\\' === DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer.phar`) : `which composer.phar 2> /dev/null`)) |
152 |
| - || ($COMPOSER = rtrim('\\' === DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer`) : `which composer 2> /dev/null`)) |
153 |
| - || 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') |
| 151 | + || ($COMPOSER = rtrim('\\' === \DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer.phar`) : `which composer.phar 2> /dev/null`)) |
| 152 | + || ($COMPOSER = rtrim('\\' === \DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer`) : `which composer 2> /dev/null`)) |
| 153 | + || 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') |
154 | 154 | ? ('#!/usr/bin/env php' === file_get_contents($COMPOSER, false, null, 0, 18) ? $PHP : '').' '.escapeshellarg($COMPOSER) // detect shell wrappers by looking at the shebang
|
155 | 155 | : 'composer';
|
156 | 156 |
|
157 | 157 | $SYMFONY_PHPUNIT_REMOVE = $getEnvVar('SYMFONY_PHPUNIT_REMOVE', 'phpspec/prophecy'.($PHPUNIT_VERSION < 6.0 ? ' symfony/yaml' : ''));
|
158 |
| -$configurationHash = md5(implode(PHP_EOL, [md5_file(__FILE__), $SYMFONY_PHPUNIT_REMOVE, (int) $PHPUNIT_REMOVE_RETURN_TYPEHINT])); |
| 158 | +$configurationHash = md5(implode(\PHP_EOL, [md5_file(__FILE__), $SYMFONY_PHPUNIT_REMOVE, (int) $PHPUNIT_REMOVE_RETURN_TYPEHINT])); |
159 | 159 | $PHPUNIT_VERSION_DIR = sprintf('phpunit-%s-%d', $PHPUNIT_VERSION, $PHPUNIT_REMOVE_RETURN_TYPEHINT);
|
160 | 160 | if (!file_exists("$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR/phpunit") || $configurationHash !== @file_get_contents("$PHPUNIT_DIR/.$PHPUNIT_VERSION_DIR.md5")) {
|
161 | 161 | // Build a standalone phpunit without symfony/yaml nor prophecy by default
|
162 | 162 |
|
163 | 163 | @mkdir($PHPUNIT_DIR, 0777, true);
|
164 | 164 | chdir($PHPUNIT_DIR);
|
165 | 165 | if (file_exists("$PHPUNIT_VERSION_DIR")) {
|
166 |
| - passthru(sprintf('\\' === DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s > NUL' : 'rm -rf %s', "$PHPUNIT_VERSION_DIR.old")); |
| 166 | + passthru(sprintf('\\' === \DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s > NUL' : 'rm -rf %s', "$PHPUNIT_VERSION_DIR.old")); |
167 | 167 | rename("$PHPUNIT_VERSION_DIR", "$PHPUNIT_VERSION_DIR.old");
|
168 |
| - passthru(sprintf('\\' === DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s' : 'rm -rf %s', "$PHPUNIT_VERSION_DIR.old")); |
| 168 | + passthru(sprintf('\\' === \DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s' : 'rm -rf %s', "$PHPUNIT_VERSION_DIR.old")); |
169 | 169 | }
|
170 | 170 |
|
171 | 171 | $info = [];
|
|
216 | 216 | $passthruOrFail("$COMPOSER require --no-update phpunit/phpunit-mock-objects \"~3.1.0\"");
|
217 | 217 | }
|
218 | 218 |
|
219 |
| - if (preg_match('{\^((\d++\.)\d++)[\d\.]*$}', $info['requires']['php'], $phpVersion) && version_compare($phpVersion[2].'99', PHP_VERSION, '<')) { |
| 219 | + if (preg_match('{\^((\d++\.)\d++)[\d\.]*$}', $info['requires']['php'], $phpVersion) && version_compare($phpVersion[2].'99', \PHP_VERSION, '<')) { |
220 | 220 | $passthruOrFail("$COMPOSER config platform.php \"$phpVersion[1].99\"");
|
221 | 221 | } else {
|
222 | 222 | $passthruOrFail("$COMPOSER config --unset platform.php");
|
223 | 223 | }
|
224 | 224 | if (file_exists($path = $root.'/vendor/symfony/phpunit-bridge')) {
|
225 | 225 | $passthruOrFail("$COMPOSER require --no-update symfony/phpunit-bridge \"*@dev\"");
|
226 |
| - $passthruOrFail("$COMPOSER config repositories.phpunit-bridge path ".escapeshellarg(str_replace('/', DIRECTORY_SEPARATOR, $path))); |
227 |
| - if ('\\' === DIRECTORY_SEPARATOR) { |
| 226 | + $passthruOrFail("$COMPOSER config repositories.phpunit-bridge path ".escapeshellarg(str_replace('/', \DIRECTORY_SEPARATOR, $path))); |
| 227 | + if ('\\' === \DIRECTORY_SEPARATOR) { |
228 | 228 | file_put_contents('composer.json', preg_replace('/^( {8})"phpunit-bridge": \{$/m', "$0\n$1 ".'"options": {"symlink": false},', file_get_contents('composer.json')));
|
229 | 229 | }
|
230 | 230 | } else {
|
231 | 231 | $passthruOrFail("$COMPOSER require --no-update symfony/phpunit-bridge \"*\"");
|
232 | 232 | }
|
233 | 233 | $prevRoot = getenv('COMPOSER_ROOT_VERSION');
|
234 | 234 | putenv("COMPOSER_ROOT_VERSION=$PHPUNIT_VERSION.99");
|
235 |
| - $q = '\\' === DIRECTORY_SEPARATOR ? '"' : ''; |
| 235 | + $q = '\\' === \DIRECTORY_SEPARATOR ? '"' : ''; |
236 | 236 | // --no-suggest is not in the list to keep compat with composer 1.0, which is shipped with Ubuntu 16.04LTS
|
237 | 237 | $exit = proc_close(proc_open("$q$COMPOSER install --no-dev --prefer-dist --no-progress $q", [], $p, getcwd()));
|
238 | 238 | putenv('COMPOSER_ROOT_VERSION'.(false !== $prevRoot ? '='.$prevRoot : ''));
|
|
245 | 245 | if ($PHPUNIT_REMOVE_RETURN_TYPEHINT) {
|
246 | 246 | $alteredCode = preg_replace('/^ ((?:protected|public)(?: static)? function \w+\(\)): void/m', ' $1', $alteredCode);
|
247 | 247 | }
|
248 |
| - $alteredCode = preg_replace('/abstract class (?:TestCase|PHPUnit_Framework_TestCase)[^\{]+\{/', '$0 '.PHP_EOL." use \Symfony\Bridge\PhpUnit\Legacy\PolyfillTestCaseTrait;", $alteredCode, 1); |
| 248 | + $alteredCode = preg_replace('/abstract class (?:TestCase|PHPUnit_Framework_TestCase)[^\{]+\{/', '$0 '.\PHP_EOL." use \Symfony\Bridge\PhpUnit\Legacy\PolyfillTestCaseTrait;", $alteredCode, 1); |
249 | 249 | file_put_contents($alteredFile, $alteredCode);
|
250 | 250 |
|
251 | 251 | // Mutate Assert code
|
252 | 252 | $alteredCode = file_get_contents($alteredFile = './src/Framework/Assert.php');
|
253 |
| - $alteredCode = preg_replace('/abstract class (?:Assert|PHPUnit_Framework_Assert)[^\{]+\{/', '$0 '.PHP_EOL." use \Symfony\Bridge\PhpUnit\Legacy\PolyfillAssertTrait;", $alteredCode, 1); |
| 253 | + $alteredCode = preg_replace('/abstract class (?:Assert|PHPUnit_Framework_Assert)[^\{]+\{/', '$0 '.\PHP_EOL." use \Symfony\Bridge\PhpUnit\Legacy\PolyfillAssertTrait;", $alteredCode, 1); |
254 | 254 | file_put_contents($alteredFile, $alteredCode);
|
255 | 255 |
|
256 | 256 | file_put_contents('phpunit', <<<'EOPHP'
|
@@ -303,7 +303,7 @@ class SymfonyExcludeListPhpunit {}
|
303 | 303 |
|
304 | 304 | return false;
|
305 | 305 | });
|
306 |
| -} elseif (filter_var(getenv('SYMFONY_PHPUNIT_DISABLE_RESULT_CACHE'), FILTER_VALIDATE_BOOLEAN)) { |
| 306 | +} elseif (filter_var(getenv('SYMFONY_PHPUNIT_DISABLE_RESULT_CACHE'), \FILTER_VALIDATE_BOOLEAN)) { |
307 | 307 | $argv[] = '--do-not-cache-result';
|
308 | 308 | ++$argc;
|
309 | 309 | }
|
@@ -335,7 +335,7 @@ class SymfonyExcludeListPhpunit {}
|
335 | 335 | $cmd[0] = sprintf('%s %s --colors=always', $PHP, escapeshellarg("$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR/phpunit"));
|
336 | 336 | $cmd = str_replace('%', '%%', implode(' ', $cmd)).' %1$s';
|
337 | 337 |
|
338 |
| -if ('\\' === DIRECTORY_SEPARATOR) { |
| 338 | +if ('\\' === \DIRECTORY_SEPARATOR) { |
339 | 339 | $cmd = 'cmd /v:on /d /c "('.$cmd.')%2$s"';
|
340 | 340 | } else {
|
341 | 341 | $cmd .= '%2$s';
|
@@ -385,7 +385,7 @@ class SymfonyExcludeListPhpunit {}
|
385 | 385 | // STATUS_STACK_BUFFER_OVERRUN (-1073740791/0xC0000409)
|
386 | 386 | // STATUS_ACCESS_VIOLATION (-1073741819/0xC0000005)
|
387 | 387 | // STATUS_HEAP_CORRUPTION (-1073740940/0xC0000374)
|
388 |
| - if ($procStatus && ('\\' !== DIRECTORY_SEPARATOR || !extension_loaded('apcu') || !filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN) || !in_array($procStatus, [-1073740791, -1073741819, -1073740940]))) { |
| 388 | + if ($procStatus && ('\\' !== \DIRECTORY_SEPARATOR || !extension_loaded('apcu') || !filter_var(ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN) || !in_array($procStatus, [-1073740791, -1073741819, -1073740940]))) { |
389 | 389 | $exit = $procStatus;
|
390 | 390 | echo "\033[41mKO\033[0m $component\n\n";
|
391 | 391 | } else {
|
|
0 commit comments