Bug #66703 [NEW]: RegexIterator's ALL_MATCH does not filter

From: Date: Wed, 12 Feb 2014 20:49:07 +0000
Subject: Bug #66703 [NEW]: RegexIterator's ALL_MATCH does not filter
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-184275@lists.php.net to get a copy of this message
From:             jthijssen+php at noxlogic dot nl
Operating system: 
PHP version:      master-Git-2014-02-12 (Git)
Package:          SPL related
Bug Type:         Bug
Bug description:RegexIterator's ALL_MATCH does not filter

Description:
------------
When filtering with the RegexIterator and using the ALL_MATCH mode,
every element is returned, even if it does not have any matches. This
functionality differs from the GET_MATCH, which does filter out
empty/non-matching elements

Test script:
---------------
$it = new \ArrayIterator(array("tmp", "foo", "bar",
"bazbar"));
$it = new \RegexIterator($it, "/ba(.)/", \RegexIterator::ALL_MATCHES);
print_r(iterator_to_array($it));

Expected result:
----------------
Array
(
    [0] => Array
        (
            [0] => Array
                (
                )

            [1] => Array
                (
                )

        )

    [1] => Array
        (
            [0] => Array
                (
                )

            [1] => Array
                (
                )

        )

    [2] => Array
        (
            [0] => Array
                (
                    [0] => bar
                )

            [1] => Array
                (
                    [0] => r
                )

        )

    [3] => Array
        (
            [0] => Array
                (
                    [0] => baz
                    [1] => bar
                )

            [1] => Array
                (
                    [0] => z
                    [1] => r
                )

        )

)

Actual result:
--------------
Array
(
   
    [2] => Array
        (
            [0] => Array
                (
                    [0] => bar
                )

            [1] => Array
                (
                    [0] => r
                )

        )

    [3] => Array
        (
            [0] => Array
                (
                    [0] => baz
                    [1] => bar
                )

            [1] => Array
                (
                    [0] => z
                    [1] => r
                )

        )

)

-- 
Edit bug report at https://bugs.php.net/bug.php?id=66703&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=66703&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=66703&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=66703&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=66703&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=66703&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=66703&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=66703&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=66703&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=66703&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=66703&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=66703&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=66703&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=66703&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66703&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=66703&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=66703&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=66703&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=66703&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=66703&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=66703&r=mysqlcfg



Thread (3 messages)

« previous php.bugs (#184275) next »