summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2017-12-22 18:11:38 +0100
committerNikita Popov <nikita.ppv@gmail.com>2017-12-22 18:11:38 +0100
commitec142f2c86c28b970aef631a5750f6a02b954089 (patch)
tree1e3a3e2906b0ff3db1c61b2d34fffe38e3d76e3c
parentccb113c3e5964ef2d2e5b4ae3e67d61702db9bfc (diff)
downloadphp-git-ec142f2c86c28b970aef631a5750f6a02b954089.tar.gz
Fixed bug #75242
-rw-r--r--NEWS2
-rw-r--r--ext/spl/spl_array.c8
-rw-r--r--ext/spl/tests/bug75242.phpt36
3 files changed, 42 insertions, 4 deletions
diff --git a/NEWS b/NEWS
index c7d75f1503..d474e9fd08 100644
--- a/NEWS
+++ b/NEWS
@@ -20,6 +20,8 @@ PHP NEWS
- SPL:
. Fixed bug #75717 (RecursiveArrayIterator does not traverse arrays by
reference). (Nikita)
+ . Fixed bug #75242 (RecursiveArrayIterator doesn't have constants from parent
+ class). (Nikita)
04 Jan 2018, PHP 7.1.13
diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c
index 1be55d785b..105fb269d6 100644
--- a/ext/spl/spl_array.c
+++ b/ext/spl/spl_array.c
@@ -1999,16 +1999,16 @@ PHP_MINIT_FUNCTION(spl_array)
memcpy(&spl_handler_ArrayIterator, &spl_handler_ArrayObject, sizeof(zend_object_handlers));
spl_ce_ArrayIterator->get_iterator = spl_array_get_iterator;
- REGISTER_SPL_SUB_CLASS_EX(RecursiveArrayIterator, ArrayIterator, spl_array_object_new, spl_funcs_RecursiveArrayIterator);
- REGISTER_SPL_IMPLEMENTS(RecursiveArrayIterator, RecursiveIterator);
- spl_ce_RecursiveArrayIterator->get_iterator = spl_array_get_iterator;
-
REGISTER_SPL_CLASS_CONST_LONG(ArrayObject, "STD_PROP_LIST", SPL_ARRAY_STD_PROP_LIST);
REGISTER_SPL_CLASS_CONST_LONG(ArrayObject, "ARRAY_AS_PROPS", SPL_ARRAY_ARRAY_AS_PROPS);
REGISTER_SPL_CLASS_CONST_LONG(ArrayIterator, "STD_PROP_LIST", SPL_ARRAY_STD_PROP_LIST);
REGISTER_SPL_CLASS_CONST_LONG(ArrayIterator, "ARRAY_AS_PROPS", SPL_ARRAY_ARRAY_AS_PROPS);
+ REGISTER_SPL_SUB_CLASS_EX(RecursiveArrayIterator, ArrayIterator, spl_array_object_new, spl_funcs_RecursiveArrayIterator);
+ REGISTER_SPL_IMPLEMENTS(RecursiveArrayIterator, RecursiveIterator);
+ spl_ce_RecursiveArrayIterator->get_iterator = spl_array_get_iterator;
+
REGISTER_SPL_CLASS_CONST_LONG(RecursiveArrayIterator, "CHILD_ARRAYS_ONLY", SPL_ARRAY_CHILD_ARRAYS_ONLY);
return SUCCESS;
diff --git a/ext/spl/tests/bug75242.phpt b/ext/spl/tests/bug75242.phpt
new file mode 100644
index 0000000000..0ffd783e47
--- /dev/null
+++ b/ext/spl/tests/bug75242.phpt
@@ -0,0 +1,36 @@
+--TEST--
+Bug #75242: RecursiveArrayIterator doesn't have constants from parent class
+--FILE--
+<?php
+
+class Foo extends ArrayIterator { }
+
+$r = new ReflectionClass(Foo::class);
+var_dump($r->getConstants());
+$r = new ReflectionClass(ArrayIterator::class);
+var_dump($r->getConstants());
+$r = new ReflectionClass(RecursiveArrayIterator::class);
+var_dump($r->getConstants());
+
+?>
+--EXPECT--
+array(2) {
+ ["STD_PROP_LIST"]=>
+ int(1)
+ ["ARRAY_AS_PROPS"]=>
+ int(2)
+}
+array(2) {
+ ["STD_PROP_LIST"]=>
+ int(1)
+ ["ARRAY_AS_PROPS"]=>
+ int(2)
+}
+array(3) {
+ ["STD_PROP_LIST"]=>
+ int(1)
+ ["ARRAY_AS_PROPS"]=>
+ int(2)
+ ["CHILD_ARRAYS_ONLY"]=>
+ int(4)
+}