fix: deprecated code in PHP 8.3

Calling ReflectionProperty::setValue() with a 1st argument which is not null or an object is deprecated
This commit is contained in:
kenjis 2023-09-08 10:17:23 +09:00
parent ec8ba91c69
commit 436457338c
No known key found for this signature in database
GPG Key ID: BD254878922AF198

View File

@ -74,7 +74,12 @@ trait ReflectionHelper
public static function setPrivateProperty($obj, $property, $value)
{
$refProperty = self::getAccessibleRefProperty($obj, $property);
$refProperty->setValue($obj, $value);
if (is_object($obj)) {
$refProperty->setValue($obj, $value);
} else {
$refProperty->setValue(null, $value);
}
}
/**