Annotation of embedaddon/php/ext/spl/tests/spl_004.phpt, revision 1.1.1.3

1.1       misho       1: --TEST--
                      2: SPL: iterator_apply()
                      3: --FILE--
                      4: <?php
                      5: 
                      6: function my_error_handler($errno, $errstr, $errfile, $errline) {
                      7:        echo "Error: $errstr\n";
                      8: }
                      9: 
                     10: set_error_handler('my_error_handler');
                     11: 
                     12: function test_arg($arg)
                     13: {
                     14:        if ($arg instanceof Iterator)
                     15:        {
                     16:                var_dump($arg->key());
                     17:                var_dump($arg->current());
                     18:        }
                     19:        else
                     20:        {
                     21:                var_dump($arg);
                     22:        }
                     23:        return true;
                     24: }
                     25: 
                     26: function test()
                     27: {
                     28:        static $arg = 0;
                     29:        var_dump($arg++);
                     30:        return true;
                     31: }
                     32: 
                     33: $it = new RecursiveArrayIterator(array(1, array(21, 22), 3));
                     34: 
                     35: var_dump(iterator_apply($it, 'test', NULL));
                     36: 
                     37: echo "===ARGS===\n";
                     38: var_dump(iterator_apply($it, 'test_arg', array($it)));
                     39: 
                     40: echo "===RECURSIVE===\n";
                     41: $it = new RecursiveIteratorIterator($it);
                     42: var_dump(iterator_apply($it, 'test'));
                     43: 
                     44: echo "===ERRORS===\n";
                     45: var_dump(iterator_apply($it, 'test', 1));
1.1.1.3 ! misho      46: var_dump(iterator_apply($it, 'non_existing_function'));
        !            47: var_dump(iterator_apply($it, 'non_existing_function', NULL, 2));
1.1       misho      48: 
                     49: ?>
                     50: ===DONE===
                     51: <?php exit(0); ?>
                     52: --EXPECT--
                     53: int(0)
                     54: int(1)
                     55: int(2)
                     56: int(3)
                     57: ===ARGS===
                     58: int(0)
                     59: int(1)
                     60: int(1)
                     61: array(2) {
                     62:   [0]=>
                     63:   int(21)
                     64:   [1]=>
                     65:   int(22)
                     66: }
                     67: int(2)
                     68: int(3)
                     69: int(3)
                     70: ===RECURSIVE===
                     71: int(3)
                     72: int(4)
                     73: int(5)
                     74: int(6)
                     75: int(4)
                     76: ===ERRORS===
1.1.1.2   misho      77: Error: Argument 3 passed to iterator_apply() must be of the type array, integer given
1.1       misho      78: Error: iterator_apply() expects parameter 3 to be array, integer given
                     79: NULL
1.1.1.3 ! misho      80: Error: iterator_apply() expects parameter 2 to be a valid callback, function 'non_existing_function' not found or invalid function name
1.1       misho      81: NULL
                     82: Error: iterator_apply() expects at most 3 parameters, 4 given
                     83: NULL
                     84: ===DONE===

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>