3v4l.org

run code in 300+ PHP versions simultaneously
<?php function compose(/* funs to compose */) { $fl = func_get_args(); return function($x) use($fl) { $val = $x; while (null !== $f = array_pop($fl)) { $val = $f($val); }; return $val; }; } $up = function($s) {return strtoupper($s);}; $y = function($s) {return $s.'!';}; $reverse = function($a) {return array_reverse($a);}; $head = function($a) {return array_shift(array_values($a));}; $data = ['jumpkick', 'roundhouse', 'uppercut']; $c = compose($y, $up, $head, $reverse); var_dump($c($data));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eqaWl
function name:  (null)
number of ops:  23
compiled vars:  !0 = $up, !1 = $y, !2 = $reverse, !3 = $head, !4 = $data, !5 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FeqaWl%3A14%241'
          1        ASSIGN                                                   !0, ~6
   15     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FeqaWl%3A15%242'
          3        ASSIGN                                                   !1, ~8
   16     4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FeqaWl%3A16%243'
          5        ASSIGN                                                   !2, ~10
   17     6        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FeqaWl%3A17%244'
          7        ASSIGN                                                   !3, ~12
   19     8        ASSIGN                                                   !4, <array>
   20     9        INIT_FCALL                                               'compose'
         10        SEND_VAR                                                 !1
         11        SEND_VAR                                                 !0
         12        SEND_VAR                                                 !3
         13        SEND_VAR                                                 !2
         14        DO_FCALL                                      0  $15     
         15        ASSIGN                                                   !5, $15
   22    16        INIT_FCALL                                               'var_dump'
         17        INIT_DYNAMIC_CALL                                        !5
         18        SEND_VAR_EX                                              !4
         19        DO_FCALL                                      0  $17     
         20        SEND_VAR                                                 $17
         21        DO_ICALL                                                 
         22      > RETURN                                                   1

Function compose:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eqaWl
function name:  compose
number of ops:  6
compiled vars:  !0 = $fl
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   FUNC_GET_ARGS                                    ~1      
          1        ASSIGN                                                   !0, ~1
    5     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FeqaWl%3A5%240'
          3        BIND_LEXICAL                                             ~3, !0
   11     4      > RETURN                                                   ~3
   12     5*     > RETURN                                                   null

End of function compose

Function %00%7Bclosure%7D%2Fin%2FeqaWl%3A5%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 4
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 4
Branch analysis from position: 14
Branch analysis from position: 4
filename:       /in/eqaWl
function name:  {closure}
number of ops:  16
compiled vars:  !0 = $x, !1 = $fl, !2 = $val, !3 = $f
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
    6     2        ASSIGN                                                   !2, !0
    7     3      > JMP                                                      ->8
    8     4    >   INIT_DYNAMIC_CALL                                        !3
          5        SEND_VAR_EX                                              !2
          6        DO_FCALL                                      0  $5      
          7        ASSIGN                                                   !2, $5
    7     8    >   INIT_FCALL                                               'array_pop'
          9        SEND_REF                                                 !1
         10        DO_ICALL                                         $7      
         11        ASSIGN                                           ~8      !3, $7
         12        TYPE_CHECK                                  1020          ~8
         13      > JMPNZ                                                    ~9, ->4
   10    14    > > RETURN                                                   !2
   11    15*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FeqaWl%3A5%240

Function %00%7Bclosure%7D%2Fin%2FeqaWl%3A14%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eqaWl
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $s
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        INIT_FCALL                                               'strtoupper'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $1      
          4      > RETURN                                                   $1
          5*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FeqaWl%3A14%241

Function %00%7Bclosure%7D%2Fin%2FeqaWl%3A15%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eqaWl
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $s
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
          1        CONCAT                                           ~1      !0, '%21'
          2      > RETURN                                                   ~1
          3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FeqaWl%3A15%242

Function %00%7Bclosure%7D%2Fin%2FeqaWl%3A16%243:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eqaWl
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        INIT_FCALL                                               'array_reverse'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $1      
          4      > RETURN                                                   $1
          5*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FeqaWl%3A16%243

Function %00%7Bclosure%7D%2Fin%2FeqaWl%3A17%244:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eqaWl
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
          1        INIT_FCALL                                               'array_shift'
          2        INIT_FCALL                                               'array_values'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $1      
          5        SEND_VAR_NO_REF                               0          $1
          6        DO_ICALL                                         $2      
          7      > RETURN                                                   $2
          8*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FeqaWl%3A17%244

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.61 ms | 1407 KiB | 26 Q