1
0
mirror of https://github.com/php/php-src.git synced 2026-04-20 22:41:20 +02:00
Files
archived-php-src/ext/opcache/tests/jit/fetch_obj_004.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

45 lines
568 B
PHP

--TEST--
JIT: FETCH_OBJ 004
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.file_update_protection=0
opcache.jit_buffer_size=1M
--EXTENSIONS--
opcache
--FILE--
<?php
#[AllowDynamicProperties]
class C {
var $a = 0;
}
function foo() {
$x = new C;
$x->a = 1;
unset($x->a);
$x->a = 3;
var_dump($x);
}
function bar() {
$x = new C;
$x->a = 1;
$x->b = 2;
unset($x->a);
$x->a = 3;
var_dump($x);
}
foo();
bar();
?>
--EXPECT--
object(C)#1 (1) {
["a"]=>
int(3)
}
object(C)#1 (2) {
["a"]=>
int(3)
["b"]=>
int(2)
}