3v4l.org

run code in 300+ PHP versions simultaneously
<?php $items = [ 'total' => '5', '_embedded' => [ 'articles' => function() { yield "Article 1"; } ], 'more' => [ 'nested' => [ 'news' => function() { yield "Article 2"; } ], ], ]; $generators = []; $count = 0; array_walk_recursive($items, function (&$item, $key) use (&$count, &$generators) { if (is_callable($item)) { $placeholder = '__placeholder_' . $count . '__'; $generators[$placeholder] = $item; $item = $placeholder; ++$count; } }); var_dump($items); var_dump($generators);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tndhO
function name:  (null)
number of ops:  25
compiled vars:  !0 = $items, !1 = $generators, !2 = $count
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   INIT_ARRAY                                       ~3      '5', 'total'
    7     1        DECLARE_LAMBDA_FUNCTION                          ~4      [0]
          2        INIT_ARRAY                                       ~5      ~4, 'articles'
          3        ADD_ARRAY_ELEMENT                                ~3      ~5, '_embedded'
   11     4        DECLARE_LAMBDA_FUNCTION                          ~6      [1]
          5        INIT_ARRAY                                       ~7      ~6, 'news'
          6        INIT_ARRAY                                       ~8      ~7, 'nested'
          7        ADD_ARRAY_ELEMENT                                ~3      ~8, 'more'
    4     8        ASSIGN                                                   !0, ~3
   16     9        ASSIGN                                                   !1, <array>
   17    10        ASSIGN                                                   !2, 0
   19    11        INIT_FCALL                                               'array_walk_recursive'
         12        SEND_REF                                                 !0
         13        DECLARE_LAMBDA_FUNCTION                          ~12     [2]
         14        BIND_LEXICAL                                             ~12, !2
         15        BIND_LEXICAL                                             ~12, !1
   28    16        SEND_VAL                                                 ~12
   19    17        DO_ICALL                                                 
   30    18        INIT_FCALL                                               'var_dump'
         19        SEND_VAR                                                 !0
         20        DO_ICALL                                                 
   31    21        INIT_FCALL                                               'var_dump'
         22        SEND_VAR                                                 !1
         23        DO_ICALL                                                 
         24      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/tndhO
function name:  {closure}
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   GENERATOR_CREATE                                         
          1        YIELD                                                    'Article+1'
          2      > GENERATOR_RETURN                                         

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/tndhO
function name:  {closure}
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   GENERATOR_CREATE                                         
          1        YIELD                                                    'Article+2'
          2      > GENERATOR_RETURN                                         

End of Dynamic Function 1

Dynamic Function 2
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 15
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/tndhO
function name:  {closure}
number of ops:  16
compiled vars:  !0 = $item, !1 = $key, !2 = $count, !3 = $generators, !4 = $placeholder
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
          3        BIND_STATIC                                              !3
   21     4        INIT_FCALL                                               'is_callable'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $5      
          7      > JMPZ                                                     $5, ->15
   22     8    >   CONCAT                                           ~6      '__placeholder_', !2
          9        CONCAT                                           ~7      ~6, '__'
         10        ASSIGN                                                   !4, ~7
   23    11        ASSIGN_DIM                                               !3, !4
         12        OP_DATA                                                  !0
   25    13        ASSIGN                                                   !0, !4
   26    14        PRE_INC                                                  !2
   28    15    > > RETURN                                                   null

End of Dynamic Function 2

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.48 ms | 1005 KiB | 16 Q