mirror of
https://github.com/php/php-src.git
synced 2026-03-24 16:22:37 +01:00
Writing to a proprety that hasn't been declared is deprecated, unless the class uses the #[AllowDynamicProperties] attribute or defines __get()/__set(). RFC: https://wiki.php.net/rfc/deprecate_dynamic_properties
27 lines
472 B
PHP
27 lines
472 B
PHP
--TEST--
|
|
Bug #53366 (Reflection doesn't get dynamic property value from getProperty())
|
|
--FILE--
|
|
<?php
|
|
|
|
#[AllowDynamicProperties]
|
|
class UserClass {
|
|
}
|
|
|
|
$myClass = new UserClass;
|
|
$myClass->id = 1000;
|
|
|
|
$reflect = new ReflectionObject($myClass);
|
|
|
|
var_dump($reflect->getProperty('id'));
|
|
var_dump($reflect->getProperty('id')->getValue($myClass));
|
|
|
|
?>
|
|
--EXPECTF--
|
|
object(ReflectionProperty)#%d (2) {
|
|
["name"]=>
|
|
string(2) "id"
|
|
["class"]=>
|
|
string(9) "UserClass"
|
|
}
|
|
int(1000)
|