[RFC] Deprecate ReflectionProperty::getDefaultValue() without default (#19457)

https://wiki.php.net/rfc/deprecations_php_8_5
This commit is contained in:
Daniel Scherzer 2025-08-12 05:50:27 -07:00 committed by GitHub
parent ffdc1044c9
commit 57a88b216c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 22 additions and 3 deletions

View file

@ -6514,11 +6514,22 @@ ZEND_METHOD(ReflectionProperty, getDefaultValue)
prop_info = ref->prop;
if (prop_info == NULL) {
return; // throw exception?
// Dynamic property
zend_error(
E_DEPRECATED,
"ReflectionProperty::getDefaultValue() for a property without a default value is deprecated, "
"use ReflectionProperty::hasDefaultValue() to check if the default value exists"
);
return;
}
prop = property_get_default(prop_info);
if (!prop || Z_ISUNDEF_P(prop)) {
zend_error(
E_DEPRECATED,
"ReflectionProperty::getDefaultValue() for a property without a default value is deprecated, "
"use ReflectionProperty::hasDefaultValue() to check if the default value exists"
);
return;
}