3v4l.org

run code in 300+ PHP versions simultaneously
<?php function iterate($current, $queue, $result = null) { if (!$current) { return $result; } return iterate(step($queue), $queue, $current); } function step(&$queue) { return next($queue); } function start($queue) { return current($queue); } function traverse($queue) { return iterate(start($queue), $queue); } $queue = ['foo', 'bar', 'baz']; $queue = unserialize(serialize($queue)); echo traverse($queue); //baz
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QmfJM
function name:  (null)
number of ops:  13
compiled vars:  !0 = $queue
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   ASSIGN                                                   !0, <array>
   29     1        INIT_FCALL                                               'unserialize'
          2        INIT_FCALL                                               'serialize'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                         $3      
          7        ASSIGN                                                   !0, $3
   31     8        INIT_FCALL                                               'traverse'
          9        SEND_VAR                                                 !0
         10        DO_FCALL                                      0  $5      
         11        ECHO                                                     $5
         12      > RETURN                                                   1

Function iterate:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 6
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QmfJM
function name:  iterate
number of ops:  16
compiled vars:  !0 = $current, !1 = $queue, !2 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      null
    5     3        BOOL_NOT                                         ~3      !0
          4      > JMPZ                                                     ~3, ->6
    6     5    > > RETURN                                                   !2
    9     6    >   INIT_FCALL_BY_NAME                                       'iterate'
          7        INIT_FCALL_BY_NAME                                       'step'
          8        SEND_VAR_EX                                              !1
          9        DO_FCALL                                      0  $4      
         10        SEND_VAR_NO_REF_EX                                       $4
         11        SEND_VAR_EX                                              !1
         12        SEND_VAR_EX                                              !0
         13        DO_FCALL                                      0  $5      
         14      > RETURN                                                   $5
   10    15*     > RETURN                                                   null

End of function iterate

Function step:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QmfJM
function name:  step
number of ops:  6
compiled vars:  !0 = $queue
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   14     1        INIT_FCALL                                               'next'
          2        SEND_REF                                                 !0
          3        DO_ICALL                                         $1      
          4      > RETURN                                                   $1
   15     5*     > RETURN                                                   null

End of function step

Function start:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QmfJM
function name:  start
number of ops:  6
compiled vars:  !0 = $queue
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
   19     1        INIT_FCALL                                               'current'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $1      
          4      > RETURN                                                   $1
   20     5*     > RETURN                                                   null

End of function start

Function traverse:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QmfJM
function name:  traverse
number of ops:  10
compiled vars:  !0 = $queue
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
   24     1        INIT_FCALL                                               'iterate'
          2        INIT_FCALL                                               'start'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $1      
          5        SEND_VAR                                                 $1
          6        SEND_VAR                                                 !0
          7        DO_FCALL                                      0  $2      
          8      > RETURN                                                   $2
   25     9*     > RETURN                                                   null

End of function traverse

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.96 ms | 1403 KiB | 24 Q