mirror of
https://github.com/php/php-src.git
synced 2026-04-22 23:48:14 +02:00
a66c60cce3
This removes object auto-vivification support. This also means that we can remove the corresponding special handling for typed properites: We no longer need to check that a property is convertible to stdClass if such a conversion might take place indirectly due to a nested property write. Additionally OBJ_W style operations now no longer modify the object operand, and as such we no longer need to treat op1 as a def in SSA form. The next step would be to actually compile the whole LHS of OBJ_W operations in R rather than W mode, but that causes issues with SimpleXML, whose object handlers depend on the current compilation structure. Part of https://wiki.php.net/rfc/engine_warnings.
138 lines
1.9 KiB
PHP
138 lines
1.9 KiB
PHP
--TEST--
|
|
JIT: FETCH_OBJ
|
|
--INI--
|
|
opcache.enable=1
|
|
opcache.enable_cli=1
|
|
opcache.file_update_protection=0
|
|
opcache.jit_buffer_size=1M
|
|
--SKIPIF--
|
|
<?php require_once('skipif.inc'); ?>
|
|
--FILE--
|
|
<?php
|
|
function foo(&$a) {
|
|
$a = 2;
|
|
}
|
|
|
|
function foo2(&$a) {
|
|
$a = array();
|
|
}
|
|
|
|
function foo3(&$a, $var) {
|
|
$a = $var;
|
|
}
|
|
|
|
$obj = new stdClass;
|
|
foo($obj->a);
|
|
var_dump($obj);
|
|
foo2($obj->b);
|
|
var_dump($obj);
|
|
foo3($obj->a, "2" . "3");
|
|
foo3($obj->a, $obj->b);
|
|
var_dump($obj);
|
|
|
|
$a = &$obj->a;
|
|
$a = fopen(__FILE__, "r");
|
|
var_dump($obj);
|
|
|
|
function bar() {
|
|
$obj = new stdClass;
|
|
foo($obj->a);
|
|
var_dump($obj);
|
|
foo2($obj->b);
|
|
var_dump($obj);
|
|
foo3($obj->a, "2" . "3");
|
|
foo3($obj->a, $obj->b);
|
|
var_dump($obj);
|
|
|
|
$a = &$obj->a;
|
|
$a = fopen(__FILE__, "r");
|
|
var_dump($obj);
|
|
|
|
$d = array();
|
|
try {
|
|
foo($d->{"ab" ."c"});
|
|
} catch (Error $err) {
|
|
echo $err->getMessage(), "\n";
|
|
}
|
|
var_dump($d);
|
|
|
|
$e = NULL;
|
|
try {
|
|
foo($e->{"ab" ."c"});
|
|
} catch (Error $err) {
|
|
echo $err->getMessage(), "\n";
|
|
}
|
|
var_dump($e);
|
|
|
|
$f = "";
|
|
try {
|
|
foo($f->{"ab" ."c"});
|
|
} catch (Error $err) {
|
|
echo $err->getMessage(), "\n";
|
|
}
|
|
var_dump($f);
|
|
}
|
|
|
|
bar();
|
|
?>
|
|
--EXPECTF--
|
|
object(stdClass)#%d (1) {
|
|
["a"]=>
|
|
int(2)
|
|
}
|
|
object(stdClass)#%d (2) {
|
|
["a"]=>
|
|
int(2)
|
|
["b"]=>
|
|
array(0) {
|
|
}
|
|
}
|
|
object(stdClass)#%d (2) {
|
|
["a"]=>
|
|
array(0) {
|
|
}
|
|
["b"]=>
|
|
array(0) {
|
|
}
|
|
}
|
|
object(stdClass)#%d (2) {
|
|
["a"]=>
|
|
&resource(5) of type (stream)
|
|
["b"]=>
|
|
array(0) {
|
|
}
|
|
}
|
|
object(stdClass)#%d (1) {
|
|
["a"]=>
|
|
int(2)
|
|
}
|
|
object(stdClass)#%d (2) {
|
|
["a"]=>
|
|
int(2)
|
|
["b"]=>
|
|
array(0) {
|
|
}
|
|
}
|
|
object(stdClass)#%d (2) {
|
|
["a"]=>
|
|
array(0) {
|
|
}
|
|
["b"]=>
|
|
array(0) {
|
|
}
|
|
}
|
|
object(stdClass)#%d (2) {
|
|
["a"]=>
|
|
&resource(6) of type (stream)
|
|
["b"]=>
|
|
array(0) {
|
|
}
|
|
}
|
|
Attempt to modify property 'abc' of non-object
|
|
array(0) {
|
|
}
|
|
Attempt to modify property 'abc' of non-object
|
|
NULL
|
|
Attempt to modify property 'abc' of non-object
|
|
string(0) ""
|