summaryrefslogtreecommitdiff
path: root/ext/opcache/tests/jit/fetch_obj_001.phpt
blob: 3c0370d720b833685afe489990c45cc5bd63a317 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
--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;
}

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() {
	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();
    foo($d->{"ab" ."c"});
	var_dump($d);

    $e = NULL;
    foo($e->{"ab" ."c"});
	var_dump($e);

    $f = "";
    foo($f->{"ab" ."c"});
	var_dump($f);
}

bar();
?>
--EXPECTF--
Warning: Creating default object from empty value in %s on line 14
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) {
  }
}

Warning: Creating default object from empty value in %s on line 27
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) {
  }
}

Warning: Attempt to modify property 'abc' of non-object in %sfetch_obj_001.php on line 40
array(0) {
}

Warning: Creating default object from empty value in %s on line 44
object(stdClass)#%d (1) {
  ["abc"]=>
  int(2)
}

Warning: Creating default object from empty value in %s on line 48
object(stdClass)#%d (1) {
  ["abc"]=>
  int(2)
}