serialization_objects_015.phpt 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. --TEST--
  2. Object serialization / unserialization: properties reference containing object
  3. --INI--
  4. error_reporting = E_ALL & ~E_STRICT
  5. --FILE--
  6. <?php
  7. function check(&$obj) {
  8. var_dump($obj);
  9. $ser = serialize($obj);
  10. var_dump($ser);
  11. $uobj = unserialize($ser);
  12. var_dump($uobj);
  13. $uobj->a = "obj->a.changed";
  14. var_dump($uobj);
  15. $uobj->b = "obj->b.changed";
  16. var_dump($uobj);
  17. $uobj->c = "obj->c.changed";
  18. var_dump($uobj);
  19. }
  20. echo "\n\n--- a refs container:\n";
  21. $ext = 1;
  22. $obj = new stdClass;
  23. $obj->a = &$obj;
  24. $obj->b = 1;
  25. $obj->c = 1;
  26. check($obj);
  27. echo "\n\n--- a eqs container:\n";
  28. $ext = 1;
  29. $obj = new stdClass;
  30. $obj->a = $obj;
  31. $obj->b = 1;
  32. $obj->c = 1;
  33. check($obj);
  34. echo "\n\n--- a,b ref container:\n";
  35. $ext = 1;
  36. $obj = new stdClass;
  37. $obj->a = &$obj;
  38. $obj->b = &$obj;
  39. $obj->c = 1;
  40. check($obj);
  41. echo "\n\n--- a,b eq container:\n";
  42. $ext = 1;
  43. $obj = new stdClass;
  44. $obj->a = $obj;
  45. $obj->b = $obj;
  46. $obj->c = 1;
  47. check($obj);
  48. echo "\n\n--- a,b,c ref container:\n";
  49. $ext = 1;
  50. $obj = new stdClass;
  51. $obj->a = &$obj;
  52. $obj->b = &$obj;
  53. $obj->c = &$obj;
  54. check($obj);
  55. echo "\n\n--- a,b,c eq container:\n";
  56. $ext = 1;
  57. $obj = new stdClass;
  58. $obj->a = $obj;
  59. $obj->b = $obj;
  60. $obj->c = $obj;
  61. check($obj);
  62. echo "Done";
  63. ?>
  64. --EXPECTF--
  65. --- a refs container:
  66. object(stdClass)#%d (3) {
  67. ["a"]=>
  68. *RECURSION*
  69. ["b"]=>
  70. int(1)
  71. ["c"]=>
  72. int(1)
  73. }
  74. string(55) "O:8:"stdClass":3:{s:1:"a";R:1;s:1:"b";i:1;s:1:"c";i:1;}"
  75. object(stdClass)#%d (3) {
  76. ["a"]=>
  77. *RECURSION*
  78. ["b"]=>
  79. int(1)
  80. ["c"]=>
  81. int(1)
  82. }
  83. object(stdClass)#%d (3) {
  84. ["a"]=>
  85. string(14) "obj->a.changed"
  86. ["b"]=>
  87. int(1)
  88. ["c"]=>
  89. int(1)
  90. }
  91. object(stdClass)#%d (3) {
  92. ["a"]=>
  93. string(14) "obj->a.changed"
  94. ["b"]=>
  95. string(14) "obj->b.changed"
  96. ["c"]=>
  97. int(1)
  98. }
  99. object(stdClass)#%d (3) {
  100. ["a"]=>
  101. string(14) "obj->a.changed"
  102. ["b"]=>
  103. string(14) "obj->b.changed"
  104. ["c"]=>
  105. string(14) "obj->c.changed"
  106. }
  107. --- a eqs container:
  108. object(stdClass)#%d (3) {
  109. ["a"]=>
  110. *RECURSION*
  111. ["b"]=>
  112. int(1)
  113. ["c"]=>
  114. int(1)
  115. }
  116. string(55) "O:8:"stdClass":3:{s:1:"a";r:1;s:1:"b";i:1;s:1:"c";i:1;}"
  117. object(stdClass)#%d (3) {
  118. ["a"]=>
  119. *RECURSION*
  120. ["b"]=>
  121. int(1)
  122. ["c"]=>
  123. int(1)
  124. }
  125. object(stdClass)#%d (3) {
  126. ["a"]=>
  127. string(14) "obj->a.changed"
  128. ["b"]=>
  129. int(1)
  130. ["c"]=>
  131. int(1)
  132. }
  133. object(stdClass)#%d (3) {
  134. ["a"]=>
  135. string(14) "obj->a.changed"
  136. ["b"]=>
  137. string(14) "obj->b.changed"
  138. ["c"]=>
  139. int(1)
  140. }
  141. object(stdClass)#%d (3) {
  142. ["a"]=>
  143. string(14) "obj->a.changed"
  144. ["b"]=>
  145. string(14) "obj->b.changed"
  146. ["c"]=>
  147. string(14) "obj->c.changed"
  148. }
  149. --- a,b ref container:
  150. object(stdClass)#%d (3) {
  151. ["a"]=>
  152. *RECURSION*
  153. ["b"]=>
  154. *RECURSION*
  155. ["c"]=>
  156. int(1)
  157. }
  158. string(55) "O:8:"stdClass":3:{s:1:"a";R:1;s:1:"b";R:1;s:1:"c";i:1;}"
  159. object(stdClass)#%d (3) {
  160. ["a"]=>
  161. *RECURSION*
  162. ["b"]=>
  163. *RECURSION*
  164. ["c"]=>
  165. int(1)
  166. }
  167. object(stdClass)#%d (3) {
  168. ["a"]=>
  169. &string(14) "obj->a.changed"
  170. ["b"]=>
  171. &string(14) "obj->a.changed"
  172. ["c"]=>
  173. int(1)
  174. }
  175. object(stdClass)#%d (3) {
  176. ["a"]=>
  177. &string(14) "obj->b.changed"
  178. ["b"]=>
  179. &string(14) "obj->b.changed"
  180. ["c"]=>
  181. int(1)
  182. }
  183. object(stdClass)#%d (3) {
  184. ["a"]=>
  185. &string(14) "obj->b.changed"
  186. ["b"]=>
  187. &string(14) "obj->b.changed"
  188. ["c"]=>
  189. string(14) "obj->c.changed"
  190. }
  191. --- a,b eq container:
  192. object(stdClass)#%d (3) {
  193. ["a"]=>
  194. *RECURSION*
  195. ["b"]=>
  196. *RECURSION*
  197. ["c"]=>
  198. int(1)
  199. }
  200. string(55) "O:8:"stdClass":3:{s:1:"a";r:1;s:1:"b";r:1;s:1:"c";i:1;}"
  201. object(stdClass)#%d (3) {
  202. ["a"]=>
  203. *RECURSION*
  204. ["b"]=>
  205. *RECURSION*
  206. ["c"]=>
  207. int(1)
  208. }
  209. object(stdClass)#%d (3) {
  210. ["a"]=>
  211. string(14) "obj->a.changed"
  212. ["b"]=>
  213. *RECURSION*
  214. ["c"]=>
  215. int(1)
  216. }
  217. object(stdClass)#%d (3) {
  218. ["a"]=>
  219. string(14) "obj->a.changed"
  220. ["b"]=>
  221. string(14) "obj->b.changed"
  222. ["c"]=>
  223. int(1)
  224. }
  225. object(stdClass)#%d (3) {
  226. ["a"]=>
  227. string(14) "obj->a.changed"
  228. ["b"]=>
  229. string(14) "obj->b.changed"
  230. ["c"]=>
  231. string(14) "obj->c.changed"
  232. }
  233. --- a,b,c ref container:
  234. object(stdClass)#%d (3) {
  235. ["a"]=>
  236. *RECURSION*
  237. ["b"]=>
  238. *RECURSION*
  239. ["c"]=>
  240. *RECURSION*
  241. }
  242. string(55) "O:8:"stdClass":3:{s:1:"a";R:1;s:1:"b";R:1;s:1:"c";R:1;}"
  243. object(stdClass)#%d (3) {
  244. ["a"]=>
  245. *RECURSION*
  246. ["b"]=>
  247. *RECURSION*
  248. ["c"]=>
  249. *RECURSION*
  250. }
  251. object(stdClass)#%d (3) {
  252. ["a"]=>
  253. &string(14) "obj->a.changed"
  254. ["b"]=>
  255. &string(14) "obj->a.changed"
  256. ["c"]=>
  257. &string(14) "obj->a.changed"
  258. }
  259. object(stdClass)#%d (3) {
  260. ["a"]=>
  261. &string(14) "obj->b.changed"
  262. ["b"]=>
  263. &string(14) "obj->b.changed"
  264. ["c"]=>
  265. &string(14) "obj->b.changed"
  266. }
  267. object(stdClass)#%d (3) {
  268. ["a"]=>
  269. &string(14) "obj->c.changed"
  270. ["b"]=>
  271. &string(14) "obj->c.changed"
  272. ["c"]=>
  273. &string(14) "obj->c.changed"
  274. }
  275. --- a,b,c eq container:
  276. object(stdClass)#%d (3) {
  277. ["a"]=>
  278. *RECURSION*
  279. ["b"]=>
  280. *RECURSION*
  281. ["c"]=>
  282. *RECURSION*
  283. }
  284. string(55) "O:8:"stdClass":3:{s:1:"a";r:1;s:1:"b";r:1;s:1:"c";r:1;}"
  285. object(stdClass)#%d (3) {
  286. ["a"]=>
  287. *RECURSION*
  288. ["b"]=>
  289. *RECURSION*
  290. ["c"]=>
  291. *RECURSION*
  292. }
  293. object(stdClass)#%d (3) {
  294. ["a"]=>
  295. string(14) "obj->a.changed"
  296. ["b"]=>
  297. *RECURSION*
  298. ["c"]=>
  299. *RECURSION*
  300. }
  301. object(stdClass)#%d (3) {
  302. ["a"]=>
  303. string(14) "obj->a.changed"
  304. ["b"]=>
  305. string(14) "obj->b.changed"
  306. ["c"]=>
  307. *RECURSION*
  308. }
  309. object(stdClass)#%d (3) {
  310. ["a"]=>
  311. string(14) "obj->a.changed"
  312. ["b"]=>
  313. string(14) "obj->b.changed"
  314. ["c"]=>
  315. string(14) "obj->c.changed"
  316. }
  317. Done