Skip to content

Commit

Permalink
Fix Sudo static property manipulation in PHP 8.3.
Browse files Browse the repository at this point in the history
  • Loading branch information
bobthecow committed Oct 13, 2023
1 parent 8a11c39 commit 5927f39
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Sudo.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 5927f39

Please sign in to comment.