]> granicus.if.org Git - php/commitdiff
Fix typo in SplFixedArray has_dimension implementation
authorNikita Popov <nikita.ppv@gmail.com>
Mon, 1 May 2017 10:14:53 +0000 (12:14 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Mon, 1 May 2017 10:15:26 +0000 (12:15 +0200)
ext/spl/spl_fixedarray.c
ext/spl/tests/SplFixedArray_override_offsetGet_only.phpt [new file with mode: 0644]

index ab81d9e35150da31bf1c83c4b88d7dc2d27edb67..87c59261c0589337e5aff386a981c960abea9b76 100644 (file)
@@ -507,7 +507,7 @@ static int spl_fixedarray_object_has_dimension(zval *object, zval *offset, int c
 
        intern = Z_SPLFIXEDARRAY_P(object);
 
-       if (intern->fptr_offset_get) {
+       if (intern->fptr_offset_has) {
                zval rv;
                SEPARATE_ARG_IF_REF(offset);
                zend_call_method_with_1_params(object, intern->std.ce, &intern->fptr_offset_has, "offsetExists", &rv, offset);
diff --git a/ext/spl/tests/SplFixedArray_override_offsetGet_only.phpt b/ext/spl/tests/SplFixedArray_override_offsetGet_only.phpt
new file mode 100644 (file)
index 0000000..4ad03a4
--- /dev/null
@@ -0,0 +1,22 @@
+--TEST--
+Overriding SplFixedArray::offsetGet() only
+--FILE--
+<?php
+
+class MyArray extends SplFixedArray {
+    public function offsetGet($key) {
+        return "prefix_" . parent::offsetGet($key);
+    }
+}
+
+$arr = new MyArray(1);
+var_dump(isset($arr[0]));
+$arr[0] = "abc";
+var_dump(isset($arr[0]));
+var_dump($arr[0]);
+
+?>
+--EXPECT--
+bool(false)
+bool(true)
+string(10) "prefix_abc"