diff --git a/src/Symfony/Bridge/PhpUnit/CoverageListener.php b/src/Symfony/Bridge/PhpUnit/CoverageListener.php index 65d6aa9dc9dcc..f1a89ff8ee846 100644 --- a/src/Symfony/Bridge/PhpUnit/CoverageListener.php +++ b/src/Symfony/Bridge/PhpUnit/CoverageListener.php @@ -86,7 +86,9 @@ public function startTest(Test $test): void private function addCoversForClassToAnnotationCache(Test $test, array $covers): void { $r = new \ReflectionProperty(TestUtil::class, 'annotationCache'); - $r->setAccessible(true); + if (\PHP_VERSION_ID < 80100) { + $r->setAccessible(true); + } $cache = $r->getValue(); $cache = array_replace_recursive($cache, [ @@ -103,7 +105,9 @@ private function addCoversForDocBlockInsideRegistry(Test $test, array $covers): $docBlock = Registry::getInstance()->forClassName(\get_class($test)); $symbolAnnotations = new \ReflectionProperty($docBlock, 'symbolAnnotations'); - $symbolAnnotations->setAccessible(true); + if (\PHP_VERSION_ID < 80100) { + $symbolAnnotations->setAccessible(true); + } // Exclude internal classes; PHPUnit 9.1+ is picky about tests covering, say, a \RuntimeException $covers = array_filter($covers, function (string $class) { diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php index f7a57f5704dae..082509fd763d2 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php @@ -437,7 +437,9 @@ public function toString() { $exception = new \Exception($this->message); $reflection = new \ReflectionProperty($exception, 'trace'); - $reflection->setAccessible(true); + if (\PHP_VERSION_ID < 80100) { + $reflection->setAccessible(true); + } $reflection->setValue($exception, $this->trace); return ($this->originatesFromAnObject() ? 'deprecation triggered by '.$this->originatingClass().'::'.$this->originatingMethod().":\n" : '') diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php index 2b45051e83d74..13d9abc96a401 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php @@ -357,7 +357,9 @@ private function willBeIsolated(TestCase $test): bool } $r = new \ReflectionProperty($test, 'runTestInSeparateProcess'); - $r->setAccessible(true); + if (\PHP_VERSION_ID < 80100) { + $r->setAccessible(true); + } return $r->getValue($test) ?? false; } diff --git a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/DeprecationTest.php b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/DeprecationTest.php index 4c17a806b4281..2a7643a9d6d17 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/DeprecationTest.php +++ b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/DeprecationTest.php @@ -275,7 +275,9 @@ public static function setUpBeforeClass(): void $loader = require $v.'/autoload.php'; $reflection = new \ReflectionClass($loader); $prop = $reflection->getProperty('prefixDirsPsr4'); - $prop->setAccessible(true); + if (\PHP_VERSION_ID < 80100) { + $prop->setAccessible(true); + } $currentValue = $prop->getValue($loader); self::$prefixDirsPsr4[] = [$prop, $loader, $currentValue]; $currentValue['Symfony\\Bridge\\PhpUnit\\'] = [realpath(__DIR__.'/../..')];