1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 16:22:37 +01:00
Files
archived-php-src/Zend/tests/bug79477.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

22 lines
298 B
PHP

--TEST--
Bug #79477: casting object into array creates references
--FILE--
<?php
#[AllowDynamicProperties]
class Test {
public $prop = 'default value';
}
$obj = new Test;
$obj->{1} = null;
$arr = (array) $obj;
$arr['prop'] = 'new value';
echo $obj->prop, "\n";
?>
--EXPECT--
default value