From 14462ee65961de6a411d13d77cda435aa116daf1 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Fri, 13 Oct 2023 08:52:39 -0400 Subject: [PATCH] Fix Sudo static property manipulation in PHP 8.3. --- src/Sudo.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Sudo.php b/src/Sudo.php index 0015cbc7..a84f31da 100644 --- a/src/Sudo.php +++ b/src/Sudo.php @@ -95,7 +95,13 @@ public static function fetchStaticProperty($class, string $property) public static function assignStaticProperty($class, string $property, $value) { $prop = self::getProperty(new \ReflectionClass($class), $property); - $prop->setValue($value); + $refl = $prop->getDeclaringClass(); + + if (\method_exists($refl, 'setStaticPropertyValue')) { + $refl->setStaticPropertyValue($property, $value); + } else { + $prop->setValue($value); + } return $value; }