setAccessible() does not have any effect as of PHP 8.1

This commit is contained in:
Worma
2025-08-01 06:16:17 +02:00
parent 65a4d3e9dd
commit a508a8b1de
+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);
}
}
/**