Skip to content

Commit ce5d2f6

Browse files
authored
Make SplFixedArray::jsonSerialize() an implementation alias of SplFixedArray::toArray() (#18191)
This reduces code duplication and can then use the optimized version.
1 parent d13d9b3 commit ce5d2f6

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
@@ -881,18 +881,6 @@ PHP_METHOD(SplFixedArray, getIterator)
881881
zend_create_internal_iterator_zval(return_value, ZEND_THIS);
882882
}
883883

884-
PHP_METHOD(SplFixedArray, jsonSerialize)
885-
{
886-
ZEND_PARSE_PARAMETERS_NONE();
887-
888-
spl_fixedarray_object *intern = Z_SPLFIXEDARRAY_P(ZEND_THIS);
889-
array_init_size(return_value, intern->array.size);
890-
for (zend_long i = 0; i < intern->array.size; i++) {
891-
zend_hash_next_index_insert_new(Z_ARR_P(return_value), &intern->array.elements[i]);
892-
Z_TRY_ADDREF(intern->array.elements[i]);
893-
}
894-
}
895-
896884
static void spl_fixedarray_it_dtor(zend_object_iterator *iter)
897885
{
898886
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)