mirror of
https://github.com/php/php-src.git
synced 2025-08-15 13:38:49 +02:00
[RFC] Deprecate ReflectionProperty::getDefaultValue() without default (#19457)
https://wiki.php.net/rfc/deprecations_php_8_5
This commit is contained in:
parent
ffdc1044c9
commit
57a88b216c
3 changed files with 22 additions and 3 deletions
|
@ -24,11 +24,13 @@ var_dump($r->hasDefaultValue());
|
||||||
var_dump($r->getDefaultValue());
|
var_dump($r->getDefaultValue());
|
||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECTF--
|
||||||
Pre-test
|
Pre-test
|
||||||
Setting
|
Setting
|
||||||
Constructor
|
Constructor
|
||||||
Getting
|
Getting
|
||||||
Setting
|
Setting
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Deprecated: ReflectionProperty::getDefaultValue() for a property without a default value is deprecated, use ReflectionProperty::hasDefaultValue() to check if the default value exists in %s on line %d
|
||||||
NULL
|
NULL
|
||||||
|
|
|
@ -6514,11 +6514,22 @@ ZEND_METHOD(ReflectionProperty, getDefaultValue)
|
||||||
prop_info = ref->prop;
|
prop_info = ref->prop;
|
||||||
|
|
||||||
if (prop_info == NULL) {
|
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);
|
prop = property_get_default(prop_info);
|
||||||
if (!prop || Z_ISUNDEF_P(prop)) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,15 +60,21 @@ $property = new ReflectionProperty($test, 'dynamic');
|
||||||
var_dump($property->getDefaultValue());
|
var_dump($property->getDefaultValue());
|
||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECTF--
|
||||||
NULL
|
NULL
|
||||||
string(3) "baz"
|
string(3) "baz"
|
||||||
NULL
|
NULL
|
||||||
int(1234)
|
int(1234)
|
||||||
|
|
||||||
|
Deprecated: ReflectionProperty::getDefaultValue() for a property without a default value is deprecated, use ReflectionProperty::hasDefaultValue() to check if the default value exists in %s on line %d
|
||||||
NULL
|
NULL
|
||||||
int(1234)
|
int(1234)
|
||||||
|
|
||||||
|
Deprecated: ReflectionProperty::getDefaultValue() for a property without a default value is deprecated, use ReflectionProperty::hasDefaultValue() to check if the default value exists in %s on line %d
|
||||||
NULL
|
NULL
|
||||||
NULL
|
NULL
|
||||||
int(4)
|
int(4)
|
||||||
int(42)
|
int(42)
|
||||||
|
|
||||||
|
Deprecated: ReflectionProperty::getDefaultValue() for a property without a default value is deprecated, use ReflectionProperty::hasDefaultValue() to check if the default value exists in %s on line %d
|
||||||
NULL
|
NULL
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue