summaryrefslogtreecommitdiff
path: root/Zend/tests/bug78502.phpt
blob: 1f83e27644a330cf28ed4e0561d6b2e121e7cbb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
--TEST--
Bug #78502: Incorrect stack size calculation for indirectly recursive function call
--FILE--
<?php

$tree = [
    'name' => 'a',
    'quant' => 1,
    'children' => [
        ['name' => 'b', 'quant' => 1],
        ['name' => 'c', 'quant' => 1, 'children' => [
            ['name' => 'd', 'quant' => 1],
        ]],
    ],
];

function tree_map($tree, $recursive_attr, closure $callback){
    if(isset($tree[$recursive_attr])){
        $tree[$recursive_attr] = array_map(function($c) use($recursive_attr, $callback){
            return tree_map($c, $recursive_attr, $callback);
        }, $tree[$recursive_attr]);
    }
    return $callback($tree);
}

tree_map($tree, 'children', function ($node) {});

?>
===DONE===
--EXPECT--
===DONE===