diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2017-12-22 18:22:30 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2017-12-22 18:22:47 +0100 |
commit | 12e991f5bd88068ee09deb0711ab5aa92a99cb26 (patch) | |
tree | 28b92b9c3ab4ef94f18f959558fe0e2d47ce2ac5 /ext | |
parent | 2c880037f57d1ed72a14bc0c25a56d9a272e5c9a (diff) | |
parent | f14b6f49209b360018224aec38e8ea94fcf3dbf4 (diff) | |
download | php-git-12e991f5bd88068ee09deb0711ab5aa92a99cb26.tar.gz |
Merge branch 'PHP-7.1' into PHP-7.2
Diffstat (limited to 'ext')
-rw-r--r-- | ext/spl/spl_array.c | 9 | ||||
-rw-r--r-- | ext/spl/tests/bug73209.phpt | 28 |
2 files changed, 37 insertions, 0 deletions
diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index 21c30cfc74..4f432b61d8 100644 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -1666,6 +1666,10 @@ SPL_METHOD(Array, hasChildren) RETURN_FALSE; } + if (Z_TYPE_P(entry) == IS_INDIRECT) { + entry = Z_INDIRECT_P(entry); + } + ZVAL_DEREF(entry); RETURN_BOOL(Z_TYPE_P(entry) == IS_ARRAY || (Z_TYPE_P(entry) == IS_OBJECT && (intern->ar_flags & SPL_ARRAY_CHILD_ARRAYS_ONLY) == 0)); } @@ -1691,6 +1695,11 @@ SPL_METHOD(Array, getChildren) return; } + if (Z_TYPE_P(entry) == IS_INDIRECT) { + entry = Z_INDIRECT_P(entry); + } + + ZVAL_DEREF(entry); if (Z_TYPE_P(entry) == IS_OBJECT) { if ((intern->ar_flags & SPL_ARRAY_CHILD_ARRAYS_ONLY) != 0) { return; diff --git a/ext/spl/tests/bug73209.phpt b/ext/spl/tests/bug73209.phpt new file mode 100644 index 0000000000..7383940936 --- /dev/null +++ b/ext/spl/tests/bug73209.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #73209: RecursiveArrayIterator does not iterate object properties +--FILE-- +<?php + +class hello { + public $props = array(); + function __construct() { + $this->props = ['hello' => 5, 'props' => ['keyme' => ['test' => 5]]]; + } +} +$data = new hello(); + +$iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($data), RecursiveIteratorIterator::SELF_FIRST); +echo "Expect to see all keys in ->props here: \n"; + +foreach($iterator as $k=>$v) { + echo $k . "\n"; +} + +?> +--EXPECT-- +Expect to see all keys in ->props here: +props +hello +props +keyme +test |