]> granicus.if.org Git - php/commitdiff
fix #41692 (ArrayObject shows weird behaviour in respect to inheritance)
authorAntony Dovgal <tony2001@php.net>
Wed, 27 Jun 2007 12:17:30 +0000 (12:17 +0000)
committerAntony Dovgal <tony2001@php.net>
Wed, 27 Jun 2007 12:17:30 +0000 (12:17 +0000)
ext/spl/spl_array.c
ext/spl/tests/bug41692.phpt [new file with mode: 0644]

index 26ee8d53363d0e16fdc351ae9d67631a66ea8cc8..9212dace9fbdad608440b23219b5073f982e33cb 100755 (executable)
@@ -942,7 +942,7 @@ SPL_METHOD(Array, __construct)
 
        intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|lC", &array, &ar_flags, &ce_get_iterator) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z/|lC", &array, &ar_flags, &ce_get_iterator) == FAILURE) {
                php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
                return;
        }
diff --git a/ext/spl/tests/bug41692.phpt b/ext/spl/tests/bug41692.phpt
new file mode 100644 (file)
index 0000000..1729fd1
--- /dev/null
@@ -0,0 +1,106 @@
+--TEST--
+Bug #41692 (ArrayObject shows weird behaviour in respect to inheritance)
+--FILE--
+<?php
+
+class Bar extends ArrayObject {
+    private $foo = array( 1, 2, 3 );
+    function __construct()
+    {
+        parent::__construct($this->foo);
+    }
+}
+
+$foo = new Bar();
+var_dump($foo);
+$foo['foo'] = 23;
+
+$bar = new Bar();
+var_dump($bar);
+
+echo "Done\n";
+?>
+--EXPECTF--    
+object(Bar)#%d (2) {
+  ["foo":"Bar":private]=>
+  array(3) {
+    [0]=>
+    int(1)
+    [1]=>
+    int(2)
+    [2]=>
+    int(3)
+  }
+  ["storage":"ArrayObject":private]=>
+  array(3) {
+    [0]=>
+    int(1)
+    [1]=>
+    int(2)
+    [2]=>
+    int(3)
+  }
+}
+object(Bar)#%d (2) {
+  ["foo":"Bar":private]=>
+  array(3) {
+    [0]=>
+    int(1)
+    [1]=>
+    int(2)
+    [2]=>
+    int(3)
+  }
+  ["storage":"ArrayObject":private]=>
+  array(3) {
+    [0]=>
+    int(1)
+    [1]=>
+    int(2)
+    [2]=>
+    int(3)
+  }
+}
+Done
+--UEXPECTF--
+object(Bar)#%d (2) {
+  [u"foo":u"Bar":private]=>
+  array(3) {
+    [0]=>
+    int(1)
+    [1]=>
+    int(2)
+    [2]=>
+    int(3)
+  }
+  [u"storage":u"ArrayObject":private]=>
+  array(3) {
+    [0]=>
+    int(1)
+    [1]=>
+    int(2)
+    [2]=>
+    int(3)
+  }
+}
+object(Bar)#%d (2) {
+  [u"foo":u"Bar":private]=>
+  array(3) {
+    [0]=>
+    int(1)
+    [1]=>
+    int(2)
+    [2]=>
+    int(3)
+  }
+  [u"storage":u"ArrayObject":private]=>
+  array(3) {
+    [0]=>
+    int(1)
+    [1]=>
+    int(2)
+    [2]=>
+    int(3)
+  }
+}
+Done