Skip to content

Commit 086b4c1

Browse files
committed
Make SplFixedArray::jsonSerialize() an implementation alias of SplFixedArray::toArray()
This reduces code duplication and can then use the optimized version.
1 parent 0733e45 commit 086b4c1

File tree

3 files changed

+5
-15
lines changed

3 files changed

+5
-15
lines changed

ext/spl/spl_fixedarray.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -872,18 +872,6 @@ PHP_METHOD(SplFixedArray, getIterator)
872872
zend_create_internal_iterator_zval(return_value, ZEND_THIS);
873873
}
874874

875-
PHP_METHOD(SplFixedArray, jsonSerialize)
876-
{
877-
ZEND_PARSE_PARAMETERS_NONE();
878-
879-
spl_fixedarray_object *intern = Z_SPLFIXEDARRAY_P(ZEND_THIS);
880-
array_init_size(return_value, intern->array.size);
881-
for (zend_long i = 0; i < intern->array.size; i++) {
882-
zend_hash_next_index_insert_new(Z_ARR_P(return_value), &intern->array.elements[i]);
883-
Z_TRY_ADDREF(intern->array.elements[i]);
884-
}
885-
}
886-
887875
static void spl_fixedarray_it_dtor(zend_object_iterator *iter)
888876
{
889877
zval_ptr_dtor(&iter->data);

ext/spl/spl_fixedarray.stub.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,8 @@ public function offsetUnset($index): void {}
5555

5656
public function getIterator(): Iterator {}
5757

58+
/**
59+
* @implementation-alias SplFixedArray::toArray
60+
*/
5861
public function jsonSerialize(): array {}
5962
}

ext/spl/spl_fixedarray_arginfo.h

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)