mirror of
https://github.com/php/php-src.git
synced 2025-08-18 06:58:55 +02:00
Merge branch 'PHP-5.6'
This commit is contained in:
commit
6acfaa982b
2 changed files with 42 additions and 1 deletions
|
@ -2055,7 +2055,7 @@ SPL_METHOD(RegexIterator, accept)
|
|||
}
|
||||
|
||||
if (intern->u.regex.flags & REGIT_INVERTED) {
|
||||
RETVAL_BOOL(Z_LVAL_P(return_value));
|
||||
RETVAL_BOOL(! Z_LVAL_P(return_value));
|
||||
}
|
||||
|
||||
if (use_copy) {
|
||||
|
@ -3692,6 +3692,7 @@ PHP_MINIT_FUNCTION(spl_iterators)
|
|||
#if HAVE_PCRE || HAVE_BUNDLED_PCRE
|
||||
REGISTER_SPL_SUB_CLASS_EX(RegexIterator, FilterIterator, spl_dual_it_new, spl_funcs_RegexIterator);
|
||||
REGISTER_SPL_CLASS_CONST_LONG(RegexIterator, "USE_KEY", REGIT_USE_KEY);
|
||||
REGISTER_SPL_CLASS_CONST_LONG(RegexIterator, "INVERT_MATCH",REGIT_INVERTED);
|
||||
REGISTER_SPL_CLASS_CONST_LONG(RegexIterator, "MATCH", REGIT_MODE_MATCH);
|
||||
REGISTER_SPL_CLASS_CONST_LONG(RegexIterator, "GET_MATCH", REGIT_MODE_GET_MATCH);
|
||||
REGISTER_SPL_CLASS_CONST_LONG(RegexIterator, "ALL_MATCHES", REGIT_MODE_ALL_MATCHES);
|
||||
|
|
40
ext/spl/tests/bug66702.phpt
Normal file
40
ext/spl/tests/bug66702.phpt
Normal file
|
@ -0,0 +1,40 @@
|
|||
--TEST--
|
||||
Bug #66702 (RegexIterator inverted result works as expected)
|
||||
--FILE--
|
||||
<?php
|
||||
/**
|
||||
* @author Joshua Thijssen <jthijssen+php@noxlogic.nl>
|
||||
*/
|
||||
|
||||
$it = new \ArrayIterator(array("foo", "bar", "baz"));
|
||||
$it2 = new \RegexIterator($it, "/^ba/", \RegexIterator::MATCH);
|
||||
print_r(iterator_to_array($it2));
|
||||
$it2 = new \RegexIterator($it, "/^ba/", \RegexIterator::MATCH, \RegexIterator::INVERT_MATCH);
|
||||
print_r(iterator_to_array($it2));
|
||||
|
||||
$it = new \ArrayIterator(array("foo" => 1, "bar" => 2, "baz" => 3));
|
||||
$it2 = new \RegexIterator($it, "/^ba/", \RegexIterator::MATCH, \RegexIterator::USE_KEY);
|
||||
print_r(iterator_to_array($it2));
|
||||
$it2 = new \RegexIterator($it, "/^ba/", \RegexIterator::MATCH, \RegexIterator::USE_KEY | \RegexIterator::INVERT_MATCH);
|
||||
print_r(iterator_to_array($it2));
|
||||
|
||||
--EXPECTF--
|
||||
Array
|
||||
(
|
||||
[1] => bar
|
||||
[2] => baz
|
||||
)
|
||||
Array
|
||||
(
|
||||
[0] => foo
|
||||
)
|
||||
Array
|
||||
(
|
||||
[bar] => 2
|
||||
[baz] => 3
|
||||
)
|
||||
Array
|
||||
(
|
||||
[foo] => 1
|
||||
)
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue