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
+4
View File
@@ -77,7 +77,9 @@ final class InvalidTag implements Tag
private function flattenExceptionBacktrace(Throwable $exception): void
{
$traceProperty = (new ReflectionClass(Exception::class))->getProperty('trace');
if (PHP_VERSION_ID < 80100) {
$traceProperty->setAccessible(true);
}
do {
$trace = $exception->getTrace();
@@ -96,8 +98,10 @@ final class InvalidTag implements Tag
$exception = $exception->getPrevious();
} while ($exception !== null);
if (PHP_VERSION_ID < 80100) {
$traceProperty->setAccessible(false);
}
}
/**
* @param mixed $value