109
109
$ PHPUNIT_VERSION = $ MAX_PHPUNIT_VERSION ;
110
110
}
111
111
112
+ if (version_compare ($ PHPUNIT_VERSION , '10.0 ' , '>= ' ) && version_compare ($ PHPUNIT_VERSION , '11.0 ' , '< ' )) {
113
+ fwrite (STDERR , 'This script does not work with PHPUnit 10. ' .\PHP_EOL );
114
+ exit (1 );
115
+ }
116
+
112
117
$ PHPUNIT_REMOVE_RETURN_TYPEHINT = filter_var ($ getEnvVar ('SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT ' , '0 ' ), \FILTER_VALIDATE_BOOLEAN );
113
118
114
119
$ COMPOSER_JSON = getenv ('COMPOSER ' ) ?: 'composer.json ' ;
143
148
}
144
149
}
145
150
146
- if ('disabled ' === $ getEnvVar ('SYMFONY_DEPRECATIONS_HELPER ' )) {
151
+ if ('disabled ' === $ getEnvVar ('SYMFONY_DEPRECATIONS_HELPER ' ) || version_compare ( $ PHPUNIT_VERSION , ' 11.0 ' , ' >= ' ) ) {
147
152
putenv ('SYMFONY_DEPRECATIONS_HELPER=disabled ' );
148
153
}
149
154
273
278
}
274
279
275
280
// Mutate TestCase code
276
- $ alteredCode = file_get_contents ($ alteredFile = './src/Framework/TestCase.php ' );
277
- if ($ PHPUNIT_REMOVE_RETURN_TYPEHINT ) {
278
- $ alteredCode = preg_replace ('/^ ((?:protected|public)(?: static)? function \w+\(\)): void/m ' , ' $1 ' , $ alteredCode );
279
- }
280
- $ alteredCode = preg_replace ('/abstract class TestCase[^\{]+\{/ ' , '$0 ' .\PHP_EOL ." use \Symfony\Bridge\PhpUnit\Legacy\PolyfillTestCaseTrait; " , $ alteredCode , 1 );
281
- file_put_contents ($ alteredFile , $ alteredCode );
281
+ if (version_compare ($ PHPUNIT_VERSION , '11.0 ' , '< ' )) {
282
+ $ alteredCode = file_get_contents ($ alteredFile = './src/Framework/TestCase.php ' );
283
+ if ($ PHPUNIT_REMOVE_RETURN_TYPEHINT ) {
284
+ $ alteredCode = preg_replace ('/^ ((?:protected|public)(?: static)? function \w+\(\)): void/m ' , ' $1 ' , $ alteredCode );
285
+ }
286
+ $ alteredCode = preg_replace ('/abstract class TestCase[^\{]+\{/ ' , '$0 ' .\PHP_EOL ." use \Symfony\Bridge\PhpUnit\Legacy\PolyfillTestCaseTrait; " , $ alteredCode , 1 );
287
+ file_put_contents ($ alteredFile , $ alteredCode );
282
288
283
- // Mutate Assert code
284
- $ alteredCode = file_get_contents ($ alteredFile = './src/Framework/Assert.php ' );
285
- $ alteredCode = preg_replace ('/abstract class Assert[^\{]+\{/ ' , '$0 ' .\PHP_EOL ." use \Symfony\Bridge\PhpUnit\Legacy\PolyfillAssertTrait; " , $ alteredCode , 1 );
286
- file_put_contents ($ alteredFile , $ alteredCode );
289
+ // Mutate Assert code
290
+ $ alteredCode = file_get_contents ($ alteredFile = './src/Framework/Assert.php ' );
291
+ $ alteredCode = preg_replace ('/abstract class Assert[^\{]+\{/ ' , '$0 ' .\PHP_EOL ." use \Symfony\Bridge\PhpUnit\Legacy\PolyfillAssertTrait; " , $ alteredCode , 1 );
292
+ file_put_contents ($ alteredFile , $ alteredCode );
287
293
288
- file_put_contents ('phpunit ' , <<<'EOPHP'
294
+ file_put_contents ('phpunit ' , <<<'EOPHP'
289
295
<?php
290
296
291
297
define('PHPUNIT_COMPOSER_INSTALL', __DIR__.'/vendor/autoload.php');
@@ -310,7 +316,9 @@ class_exists(\SymfonyExcludeListSimplePhpunit::class, false) && PHPUnit\Util\Bla
310
316
Symfony\Bridge\PhpUnit\TextUI\Command::main();
311
317
312
318
EOPHP
313
- );
319
+ );
320
+ }
321
+
314
322
chdir ('.. ' );
315
323
file_put_contents (". $ PHPUNIT_VERSION_DIR .md5 " , $ configurationHash );
316
324
chdir ($ oldPwd );
0 commit comments