summaryrefslogtreecommitdiff
path: root/ext/spl/tests
diff options
context:
space:
mode:
authorTjerk Meesters <datibbaw@php.net>2014-10-06 09:40:39 +0800
committerTjerk Meesters <datibbaw@php.net>2014-10-14 22:49:01 +0800
commit71ba533640a33bf6d034637ad68c145dec3180ba (patch)
tree9a995c6b0bdd6f6b326a315fc8d7aaecf7f01d61 /ext/spl/tests
parentb73ef0ee4a8276734f6df180148dce2f445950ed (diff)
downloadphp-git-71ba533640a33bf6d034637ad68c145dec3180ba.tar.gz
Fixed bug #68128
Three issues are addressed: - RecursiveRegexIterator::accept() should accept non-empty arrays without applying any regular expression and RegexIterator::accept() should not accept an array. - RegexIterator::accept() should not accept an atom that fails to match anything, even when PREG_PATTERN_ORDER is used (which would return an array of empty arrays). - RecursiveRegexIterator::getChildren() should pass all constructor arguments to its child iterator instead of just the regular expression.
Diffstat (limited to 'ext/spl/tests')
-rw-r--r--ext/spl/tests/bug68128.phpt91
-rw-r--r--ext/spl/tests/iterator_048.phpt5
-rw-r--r--ext/spl/tests/iterator_050.phpt4
-rw-r--r--ext/spl/tests/iterator_052.phpt146
-rw-r--r--ext/spl/tests/iterator_053.phpt125
-rw-r--r--ext/spl/tests/iterator_054.phpt2
6 files changed, 95 insertions, 278 deletions
diff --git a/ext/spl/tests/bug68128.phpt b/ext/spl/tests/bug68128.phpt
new file mode 100644
index 0000000000..ff41dd4931
--- /dev/null
+++ b/ext/spl/tests/bug68128.phpt
@@ -0,0 +1,91 @@
+--TEST--
+Bug #68128 - RecursiveRegexIterator raises "Array to string conversion" notice
+--FILE--
+<?php
+
+$array = new ArrayIterator(array('a', array('b', 'c')));
+$regex = new RegexIterator($array, '/Array/');
+
+foreach ($regex as $match) {
+ var_dump($match);
+}
+
+$rArrayIterator = new RecursiveArrayIterator(array('test1', array('tet3', 'test4', 'test5')));
+$rRegexIterator = new RecursiveRegexIterator($rArrayIterator, '/^(t)est(\d*)/',
+ RecursiveRegexIterator::ALL_MATCHES, 0, PREG_PATTERN_ORDER);
+
+foreach ($rRegexIterator as $key1 => $value1) {
+
+ if ($rRegexIterator->hasChildren()) {
+
+ // print all children
+ echo "Children: ";
+ foreach ($rRegexIterator->getChildren() as $key => $value) {
+ print_r($value);
+ }
+ echo "\n";
+ } else {
+ echo "No children ";
+ print_r($value1);
+ echo "\n";
+ }
+}
+
+?>
+--EXPECT--
+No children Array
+(
+ [0] => Array
+ (
+ [0] => test1
+ )
+
+ [1] => Array
+ (
+ [0] => t
+ )
+
+ [2] => Array
+ (
+ [0] => 1
+ )
+
+)
+
+Children: Array
+(
+ [0] => Array
+ (
+ [0] => test4
+ )
+
+ [1] => Array
+ (
+ [0] => t
+ )
+
+ [2] => Array
+ (
+ [0] => 4
+ )
+
+)
+Array
+(
+ [0] => Array
+ (
+ [0] => test5
+ )
+
+ [1] => Array
+ (
+ [0] => t
+ )
+
+ [2] => Array
+ (
+ [0] => 5
+ )
+
+)
+
diff --git a/ext/spl/tests/iterator_048.phpt b/ext/spl/tests/iterator_048.phpt
index bad4e7888a..64ca97f4d6 100644
--- a/ext/spl/tests/iterator_048.phpt
+++ b/ext/spl/tests/iterator_048.phpt
@@ -13,11 +13,6 @@ class MyRecursiveRegexIterator extends RecursiveRegexIterator
var_dump($v);
}
}
-
- function accept()
- {
- return $this->hasChildren() || parent::accept();
- }
}
$ar = new RecursiveArrayIterator(array('Foo', array('Bar'), 'FooBar', array('Baz'), 'Biz'));
diff --git a/ext/spl/tests/iterator_050.phpt b/ext/spl/tests/iterator_050.phpt
index fed4a3b2ee..63d8fbfa9a 100644
--- a/ext/spl/tests/iterator_050.phpt
+++ b/ext/spl/tests/iterator_050.phpt
@@ -46,8 +46,6 @@ array(3) {
[2]=>
%s(1) "2"
}
-
-Notice: Array to string conversion in %siterator_050.php on line %d
int(0)
array(2) {
[0]=>
@@ -69,8 +67,6 @@ array(2) {
[1]=>
%s(1) "1"
}
-
-Notice: Array to string conversion in %siterator_050.php on line %d
object(ArrayIterator)#%d (1) {
%s"storage"%s"ArrayIterator":private]=>
array(9) {
diff --git a/ext/spl/tests/iterator_052.phpt b/ext/spl/tests/iterator_052.phpt
index c68bd5234d..84b3eb993c 100644
--- a/ext/spl/tests/iterator_052.phpt
+++ b/ext/spl/tests/iterator_052.phpt
@@ -46,18 +46,6 @@ var_dump($ar);
<?php exit(0); ?>
--EXPECTF--
bool(true)
-int(0)
-array(3) {
- [0]=>
- array(0) {
- }
- [1]=>
- array(0) {
- }
- [2]=>
- array(0) {
- }
-}
bool(true)
int(1)
array(3) {
@@ -97,85 +85,11 @@ array(3) {
}
}
bool(true)
-int(3)
-array(3) {
- [0]=>
- array(0) {
- }
- [1]=>
- array(0) {
- }
- [2]=>
- array(0) {
- }
-}
bool(true)
-int(4)
-array(3) {
- [0]=>
- array(0) {
- }
- [1]=>
- array(0) {
- }
- [2]=>
- array(0) {
- }
-}
-
-Notice: Array to string conversion in %siterator_052.php on line %d
+bool(false)
bool(true)
-int(5)
-array(3) {
- [0]=>
- array(0) {
- }
- [1]=>
- array(0) {
- }
- [2]=>
- array(0) {
- }
-}
bool(true)
-int(6)
-array(3) {
- [0]=>
- array(0) {
- }
- [1]=>
- array(0) {
- }
- [2]=>
- array(0) {
- }
-}
bool(true)
-int(7)
-array(3) {
- [0]=>
- array(0) {
- }
- [1]=>
- array(0) {
- }
- [2]=>
- array(0) {
- }
-}
-bool(true)
-int(8)
-array(3) {
- [0]=>
- array(0) {
- }
- [1]=>
- array(0) {
- }
- [2]=>
- array(0) {
- }
-}
bool(true)
int(0)
array(2) {
@@ -231,67 +145,11 @@ array(2) {
}
}
bool(true)
-int(3)
-array(2) {
- [0]=>
- array(0) {
- }
- [1]=>
- array(0) {
- }
-}
-bool(true)
-int(4)
-array(2) {
- [0]=>
- array(0) {
- }
- [1]=>
- array(0) {
- }
-}
-
-Notice: Array to string conversion in %siterator_052.php on line %d
bool(true)
-int(5)
-array(2) {
- [0]=>
- array(0) {
- }
- [1]=>
- array(0) {
- }
-}
+bool(false)
bool(true)
-int(6)
-array(2) {
- [0]=>
- array(0) {
- }
- [1]=>
- array(0) {
- }
-}
bool(true)
-int(7)
-array(2) {
- [0]=>
- array(0) {
- }
- [1]=>
- array(0) {
- }
-}
bool(true)
-int(8)
-array(2) {
- [0]=>
- array(0) {
- }
- [1]=>
- array(0) {
- }
-}
object(ArrayIterator)#%d (1) {
["storage":"ArrayIterator":private]=>
array(9) {
diff --git a/ext/spl/tests/iterator_053.phpt b/ext/spl/tests/iterator_053.phpt
index 5d9c740c31..b472523ab6 100644
--- a/ext/spl/tests/iterator_053.phpt
+++ b/ext/spl/tests/iterator_053.phpt
@@ -46,122 +46,14 @@ var_dump($ar);
<?php exit(0); ?>
--EXPECTF--
bool(true)
-int(0)
-array(3) {
- [0]=>
- array(0) {
- }
- [1]=>
- array(0) {
- }
- [2]=>
- array(0) {
- }
-}
bool(true)
-int(1)
-array(3) {
- [0]=>
- array(0) {
- }
- [1]=>
- array(0) {
- }
- [2]=>
- array(0) {
- }
-}
bool(true)
-int(2)
-array(3) {
- [0]=>
- array(0) {
- }
- [1]=>
- array(0) {
- }
- [2]=>
- array(0) {
- }
-}
-bool(true)
-int(3)
-array(3) {
- [0]=>
- array(0) {
- }
- [1]=>
- array(0) {
- }
- [2]=>
- array(0) {
- }
-}
bool(true)
-int(4)
-array(3) {
- [0]=>
- array(0) {
- }
- [1]=>
- array(0) {
- }
- [2]=>
- array(0) {
- }
-}
bool(true)
-int(5)
-array(3) {
- [0]=>
- array(0) {
- }
- [1]=>
- array(0) {
- }
- [2]=>
- array(0) {
- }
-}
+bool(false)
bool(true)
-int(6)
-array(3) {
- [0]=>
- array(0) {
- }
- [1]=>
- array(0) {
- }
- [2]=>
- array(0) {
- }
-}
bool(true)
-int(7)
-array(3) {
- [0]=>
- array(0) {
- }
- [1]=>
- array(0) {
- }
- [2]=>
- array(0) {
- }
-}
bool(true)
-int(8)
-array(3) {
- [0]=>
- array(0) {
- }
- [1]=>
- array(0) {
- }
- [2]=>
- array(0) {
- }
-}
bool(true)
int(0)
array(2) {
@@ -232,20 +124,7 @@ array(2) {
string(1) "4"
}
}
-bool(true)
-int(5)
-array(2) {
- [0]=>
- array(1) {
- [0]=>
- string(1) "5"
- }
- [1]=>
- array(1) {
- [0]=>
- string(1) "5"
- }
-}
+bool(false)
bool(true)
int(6)
array(2) {
diff --git a/ext/spl/tests/iterator_054.phpt b/ext/spl/tests/iterator_054.phpt
index 1f1cd580c1..91266c9571 100644
--- a/ext/spl/tests/iterator_054.phpt
+++ b/ext/spl/tests/iterator_054.phpt
@@ -42,8 +42,6 @@ array(3) {
[2]=>
string(1) "3"
}
-
-Notice: Array to string conversion in %siterator_054.php on line %d
int(7)
array(2) {
[0]=>