You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
1.4 KiB

  1. --TEST--
  2. SPL: ArrayObject/Iterator and reference to self
  3. --SKIPIF--
  4. <?php if (!extension_loaded("spl")) print "skip"; ?>
  5. --FILE--
  6. ==ArrayObject===
  7. <?php
  8. class MyArrayObject extends ArrayObject
  9. {
  10. public function __construct()
  11. {
  12. parent::__construct($this);
  13. $this['bar'] = 'baz';
  14. }
  15. }
  16. $a = new MyArrayObject;
  17. $b = clone $a;
  18. $b['baz'] = 'Foo';
  19. var_dump($a);
  20. var_dump($b);
  21. ?>
  22. ==ArrayIterator===
  23. <?php
  24. class MyArrayIterator extends ArrayIterator
  25. {
  26. public function __construct()
  27. {
  28. parent::__construct($this);
  29. $this['bar'] = 'baz';
  30. }
  31. }
  32. $a = new MyArrayIterator;
  33. $b = clone $a;
  34. $b['baz'] = 'Foo';
  35. var_dump($a);
  36. var_dump($b);
  37. ?>
  38. ===DONE===
  39. --EXPECTF--
  40. ==ArrayObject===
  41. object(MyArrayObject)#%d (1) {
  42. ["bar"]=>
  43. string(3) "baz"
  44. }
  45. object(MyArrayObject)#%d (2) {
  46. ["bar"]=>
  47. string(3) "baz"
  48. ["baz"]=>
  49. string(3) "Foo"
  50. }
  51. ==ArrayIterator===
  52. object(MyArrayIterator)#%d (1) {
  53. ["bar"]=>
  54. string(3) "baz"
  55. }
  56. object(MyArrayIterator)#%d (2) {
  57. ["bar"]=>
  58. string(3) "baz"
  59. ["baz"]=>
  60. string(3) "Foo"
  61. }
  62. ===DONE===
  63. --UEXPECTF--
  64. ==ArrayObject===
  65. object(MyArrayObject)#%d (1) {
  66. [u"bar"]=>
  67. unicode(3) "baz"
  68. }
  69. object(MyArrayObject)#%d (2) {
  70. [u"bar"]=>
  71. unicode(3) "baz"
  72. [u"baz"]=>
  73. unicode(3) "Foo"
  74. }
  75. ==ArrayIterator===
  76. object(MyArrayIterator)#%d (1) {
  77. [u"bar"]=>
  78. unicode(3) "baz"
  79. }
  80. object(MyArrayIterator)#%d (2) {
  81. [u"bar"]=>
  82. unicode(3) "baz"
  83. [u"baz"]=>
  84. unicode(3) "Foo"
  85. }
  86. ===DONE===