Merge pull request #414 from W0rma/reflection-set-accessible

Do not call Reflection*::setAccessible() in PHP >= 8.1
This commit is contained in:
Jaap van Otterdijk
2025-08-01 21:43:32 +02:00
committed by GitHub
+6 -2
View File
@@ -77,7 +77,9 @@ final class InvalidTag implements Tag
private function flattenExceptionBacktrace(Throwable $exception): void
{
$traceProperty = (new ReflectionClass(Exception::class))->getProperty('trace');
$traceProperty->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$traceProperty->setAccessible(true);
}
do {
$trace = $exception->getTrace();
@@ -96,7 +98,9 @@ final class InvalidTag implements Tag
$exception = $exception->getPrevious();
} while ($exception !== null);
$traceProperty->setAccessible(false);
if (PHP_VERSION_ID < 80100) {
$traceProperty->setAccessible(false);
}
}
/**