diff --git a/src/Sudo.php b/src/Sudo.php index 0015cbc7..a769727c 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 (\version_compare(\PHP_VERSION, '7.4', '>=') && \method_exists($refl, 'setStaticPropertyValue')) { + $refl->setStaticPropertyValue($property, $value); + } else { + $prop->setValue($value); + } return $value; }