php-src/ext/reflection/tests/ReflectionObject___toString_basic2.phpt
Nikita Popov 902d64390e Deprecate implicit dynamic properties
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
2021-11-26 14:10:11 +01:00

41 lines
614 B
PHP

--TEST--
ReflectionObject::__toString() : very basic test with dynamic properties
--FILE--
<?php
#[AllowDynamicProperties]
class Foo {
public $bar = 1;
}
$f = new foo;
$f->dynProp = 'hello';
$f->dynProp2 = 'hello again';
echo new ReflectionObject($f);
?>
--EXPECTF--
Object of class [ <user> class Foo ] {
@@ %s
- Constants [0] {
}
- Static properties [0] {
}
- Static methods [0] {
}
- Properties [1] {
Property [ public $bar = 1 ]
}
- Dynamic properties [2] {
Property [ <dynamic> public $dynProp ]
Property [ <dynamic> public $dynProp2 ]
}
- Methods [0] {
}
}