diff options
-rw-r--r-- | ext/spl/spl_fixedarray.c | 2 | ||||
-rw-r--r-- | ext/spl/tests/SplFixedArray_override_offsetGet_only.phpt | 22 |
2 files changed, 23 insertions, 1 deletions
diff --git a/ext/spl/spl_fixedarray.c b/ext/spl/spl_fixedarray.c index ab81d9e351..87c59261c0 100644 --- a/ext/spl/spl_fixedarray.c +++ b/ext/spl/spl_fixedarray.c @@ -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 index 0000000000..4ad03a4c34 --- /dev/null +++ b/ext/spl/tests/SplFixedArray_override_offsetGet_only.phpt @@ -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" |