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
22 lines
298 B
PHP
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
|