1--TEST--
2Check behaviour of incomplete class
3--FILE--
4<?php
5/* Prototype  : proto string serialize(mixed variable)
6 * Description: Returns a string representation of variable (which can later be unserialized)
7 * Source code: ext/standard/var.c
8 * Alias to functions:
9 */
10/* Prototype  : proto mixed unserialize(string variable_representation)
11 * Description: Takes a string representation of variable and recreates it
12 * Source code: ext/standard/var.c
13 * Alias to functions:
14 */
15
16$serialized = 'O:1:"C":1:{s:1:"p";i:1;}';
17
18$incomplete = unserialize($serialized);
19eval('Class C {}');
20$complete   = unserialize($serialized);
21
22
23echo "\n\n---> Various types of access on complete class:\n" ;
24var_dump($complete);
25var_dump(is_object($complete));
26var_dump($complete->p);
27
28$ref1 = "ref1.original";
29$complete->p = &$ref1;
30var_dump($complete->p);
31$ref1 = "ref1.changed";
32var_dump($complete->p);
33$complete->p = "p.changed";
34var_dump($ref1);
35
36var_dump(isset($complete->x));
37$complete->x = "x.new";
38var_dump(isset($complete->x));
39unset($complete->x);
40var_dump($complete->x);
41
42
43echo "\n\n---> Same types of access on incomplete class:\n" ;
44var_dump($incomplete);
45var_dump(is_object($incomplete));
46var_dump($incomplete->p);
47
48$ref2 = "ref1.original";
49$incomplete->p = &$ref2;
50var_dump($incomplete->p);
51$ref2 = "ref1.changed";
52var_dump($incomplete->p);
53$incomplete->p = "p.changed";
54var_dump($ref1);
55
56var_dump(isset($incomplete->x));
57$incomplete->x = "x.new";
58var_dump(isset($incomplete->x));
59unset($incomplete->x);
60var_dump($incomplete->x);
61
62$incomplete->f();
63
64echo "Done";
65?>
66--EXPECTF--
67---> Various types of access on complete class:
68object(C)#%d (1) {
69  ["p"]=>
70  int(1)
71}
72bool(true)
73int(1)
74string(13) "ref1.original"
75string(12) "ref1.changed"
76string(9) "p.changed"
77bool(false)
78bool(true)
79
80Notice: Undefined property: C::$x in %s on line 37
81NULL
82
83
84---> Same types of access on incomplete class:
85object(__PHP_Incomplete_Class)#%d (2) {
86  ["__PHP_Incomplete_Class_Name"]=>
87  string(1) "C"
88  ["p"]=>
89  int(1)
90}
91bool(true)
92
93Notice: main(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "C" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide an autoloader to load the class definition in %s on line %d
94NULL
95
96Notice: main(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "C" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide an autoloader to load the class definition in %s on line %d
97
98Notice: main(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "C" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide an autoloader to load the class definition in %s on line %d
99NULL
100
101Notice: main(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "C" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide an autoloader to load the class definition in %s on line %d
102NULL
103
104Notice: main(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "C" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide an autoloader to load the class definition in %s on line %d
105string(9) "p.changed"
106
107Notice: main(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "C" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide an autoloader to load the class definition in %s on line %d
108bool(false)
109
110Notice: main(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "C" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide an autoloader to load the class definition in %s on line %d
111
112Notice: main(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "C" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide an autoloader to load the class definition in %s on line %d
113bool(false)
114
115Notice: main(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "C" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide an autoloader to load the class definition in %s on line %d
116
117Notice: main(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "C" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide an autoloader to load the class definition in %s on line %d
118NULL
119
120Fatal error: main(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "C" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide an autoloader to load the class definition in %s on line %d
121