Skip to content

Commit bd13f69

Browse files
committed
fix: guard setAccessible() call for PHP 8.5+
ReflectionProperty::setAccessible() is deprecated in PHP 8.5 and will be removed in PHP 9.0. Since PHP 8.1, all properties are accessible via Reflection by default, making this call unnecessary. This adds a version guard to only call setAccessible() on PHP < 8.5, matching the pattern used in Laravel Telescope and Horizon.
1 parent 0467a7a commit bd13f69

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Types/Generator.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ protected function getMethods($boot)
3030
try {
3131
$c = new ReflectionClass(Carbon::now());
3232
$macros = $c->getProperty('globalMacros');
33-
$macros->setAccessible(true);
33+
34+
if (PHP_VERSION_ID < 80500) {
35+
$macros->setAccessible(true);
36+
}
3437

3538
return $macros->getValue();
3639
} catch (ReflectionException $exception) {

0 commit comments

Comments
 (0)