109109 $ PHPUNIT_VERSION = $ MAX_PHPUNIT_VERSION ;
110110}
111111
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+
112117$ PHPUNIT_REMOVE_RETURN_TYPEHINT = filter_var ($ getEnvVar ('SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT ' , '0 ' ), \FILTER_VALIDATE_BOOLEAN );
113118
114119$ COMPOSER_JSON = getenv ('COMPOSER ' ) ?: 'composer.json ' ;
143148 }
144149}
145150
146- if ('disabled ' === $ getEnvVar ('SYMFONY_DEPRECATIONS_HELPER ' )) {
151+ if ('disabled ' === $ getEnvVar ('SYMFONY_DEPRECATIONS_HELPER ' ) || version_compare ( $ PHPUNIT_VERSION , ' 11.0 ' , ' >= ' ) ) {
147152 putenv ('SYMFONY_DEPRECATIONS_HELPER=disabled ' );
148153}
149154
273278 }
274279
275280 // 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 );
282288
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 );
287293
288- file_put_contents ('phpunit ' , <<<'EOPHP'
294+ file_put_contents ('phpunit ' , <<<'EOPHP'
289295<?php
290296
291297define('PHPUNIT_COMPOSER_INSTALL', __DIR__.'/vendor/autoload.php');
@@ -310,7 +316,9 @@ class_exists(\SymfonyExcludeListSimplePhpunit::class, false) && PHPUnit\Util\Bla
310316Symfony\Bridge\PhpUnit\TextUI\Command::main();
311317
312318EOPHP
313- );
319+ );
320+ }
321+
314322 chdir ('.. ' );
315323 file_put_contents (". $ PHPUNIT_VERSION_DIR .md5 " , $ configurationHash );
316324 chdir ($ oldPwd );
0 commit comments