php8.5
Home/ Manual/ reflection / reflectionclass/ ReflectionClass::setStaticPropertyValue

ReflectionClass::setStaticPropertyValue

PHP function Edit on GitHub ✎

(PHP 5 >= 5.1.2, PHP 7, PHP 8)

Sets static property value

Description

ReflectionClass::setStaticPropertyValue(string $name, mixed $value): void

Sets the value of a static property on this class, regardless of the property's visibility.

ReflectionProperty::setValue can also be used to set the value of static properties.

Parameters

name

Property name.

value

New property value.

Return Values

Void

Changelog

VersionDescription
7.4.9, 8.0.0ReflectionClass::setStaticPropertyValue can now set private and protected static properties. Previously, a ReflectionException was thrown.

See Also

  • ReflectionClass::getStaticPropertyValue
  • ReflectionProperty::setValue

Source: reference/reflection/reflectionclass/setstaticpropertyvalue.xml · from the official PHP manual (php/doc-en)