summaryrefslogtreecommitdiff
path: root/ext/opcache/tests/jit/fetch_obj_001.phpt
blob: 49de772b66c9fd831ff5971ada6c34f9f1f0c5c5 (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
136
137
--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' on array
array(0) {
}
Attempt to modify property 'abc' on null
NULL
Attempt to modify property 'abc' on string
string(0) ""