Skip to content

Commit fed1f2d

Browse files
committed
Fixed bug RecursiveArrayIterator does not implement Countable
ArrayIterator implemented Countable only after it was already inherited by RecursiveArrayIterator. Thus the interface was missing in RAI.
1 parent e793539 commit fed1f2d

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

‎ext/spl/spl_array.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2005,6 +2005,7 @@ PHP_MINIT_FUNCTION(spl_array)
20052005
REGISTER_SPL_IMPLEMENTS(ArrayObject, Aggregate);
20062006
REGISTER_SPL_IMPLEMENTS(ArrayObject, ArrayAccess);
20072007
REGISTER_SPL_IMPLEMENTS(ArrayObject, Serializable);
2008+
REGISTER_SPL_IMPLEMENTS(ArrayObject, Countable);
20082009
spl_ce_ArrayObject->serialize = spl_array_serialize;
20092010
spl_ce_ArrayObject->unserialize = spl_array_unserialize;
20102011
memcpy(&spl_handler_ArrayObject, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
@@ -2031,6 +2032,7 @@ PHP_MINIT_FUNCTION(spl_array)
20312032
REGISTER_SPL_IMPLEMENTS(ArrayIterator, ArrayAccess);
20322033
REGISTER_SPL_IMPLEMENTS(ArrayIterator, SeekableIterator);
20332034
REGISTER_SPL_IMPLEMENTS(ArrayIterator, Serializable);
2035+
REGISTER_SPL_IMPLEMENTS(ArrayIterator, Countable);
20342036
spl_ce_ArrayIterator->serialize = spl_array_serialize;
20352037
spl_ce_ArrayIterator->unserialize = spl_array_unserialize;
20362038
memcpy(&spl_handler_ArrayIterator, &spl_handler_ArrayObject, sizeof(zend_object_handlers));
@@ -2040,9 +2042,6 @@ PHP_MINIT_FUNCTION(spl_array)
20402042
REGISTER_SPL_IMPLEMENTS(RecursiveArrayIterator, RecursiveIterator);
20412043
spl_ce_RecursiveArrayIterator->get_iterator = spl_array_get_iterator;
20422044

2043-
REGISTER_SPL_IMPLEMENTS(ArrayObject, Countable);
2044-
REGISTER_SPL_IMPLEMENTS(ArrayIterator, Countable);
2045-
20462045
REGISTER_SPL_CLASS_CONST_LONG(ArrayObject, "STD_PROP_LIST", SPL_ARRAY_STD_PROP_LIST);
20472046
REGISTER_SPL_CLASS_CONST_LONG(ArrayObject, "ARRAY_AS_PROPS", SPL_ARRAY_ARRAY_AS_PROPS);
20482047

‎ext/spl/tests/bug62262.phpt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--TEST--
2+
Bug #62262: RecursiveArrayIterator does not implement Countable
3+
--FILE--
4+
<?php
5+
6+
var_dump(new RecursiveArrayIterator(array()) instanceof Countable);
7+
8+
?>
9+
--EXPECT--
10+
bool(true)

0 commit comments

Comments
 (0)