3v4l.org

run code in 300+ PHP versions simultaneously
<?php function number_factory($num) { return function($operation=null) use ($num) { return $operation ? $operation($num) : $num; }; } function operation_factory($operation) { return function($b) use ($operation) { return function($a) use ($b, $operation) { return $operation($a, $b); }; }; } $plus = operation_factory(function($a, $b) { return $a+$b; }); $minus = operation_factory(function($a, $b) { return $a-$b; }); $times = operation_factory(function($a, $b) { return $a*$b; }); $dividedBy = operation_factory(function($a, $b) { return $a/$b; }); $zero = number_factory(0); $one = number_factory(1); $two = number_factory(2); $three = number_factory(3); $four = number_factory(4); $five = number_factory(5); $six = number_factory(6); $seven = number_factory(7); $eight = number_factory(8); $nine = number_factory(9); print($two($plus($three($minus($two())))));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gjiId
function name:  (null)
number of ops:  76
compiled vars:  !0 = $plus, !1 = $minus, !2 = $times, !3 = $dividedBy, !4 = $zero, !5 = $one, !6 = $two, !7 = $three, !8 = $four, !9 = $five, !10 = $six, !11 = $seven, !12 = $eight, !13 = $nine
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   INIT_FCALL                                               'operation_factory'
          1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FgjiId%3A17%243'
          2        SEND_VAL                                                 ~14
          3        DO_FCALL                                      0  $15     
          4        ASSIGN                                                   !0, $15
   18     5        INIT_FCALL                                               'operation_factory'
          6        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FgjiId%3A18%244'
          7        SEND_VAL                                                 ~17
          8        DO_FCALL                                      0  $18     
          9        ASSIGN                                                   !1, $18
   19    10        INIT_FCALL                                               'operation_factory'
         11        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FgjiId%3A19%245'
         12        SEND_VAL                                                 ~20
         13        DO_FCALL                                      0  $21     
         14        ASSIGN                                                   !2, $21
   20    15        INIT_FCALL                                               'operation_factory'
         16        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FgjiId%3A20%246'
         17        SEND_VAL                                                 ~23
         18        DO_FCALL                                      0  $24     
         19        ASSIGN                                                   !3, $24
   22    20        INIT_FCALL                                               'number_factory'
         21        SEND_VAL                                                 0
         22        DO_FCALL                                      0  $26     
         23        ASSIGN                                                   !4, $26
   23    24        INIT_FCALL                                               'number_factory'
         25        SEND_VAL                                                 1
         26        DO_FCALL                                      0  $28     
         27        ASSIGN                                                   !5, $28
   24    28        INIT_FCALL                                               'number_factory'
         29        SEND_VAL                                                 2
         30        DO_FCALL                                      0  $30     
         31        ASSIGN                                                   !6, $30
   25    32        INIT_FCALL                                               'number_factory'
         33        SEND_VAL                                                 3
         34        DO_FCALL                                      0  $32     
         35        ASSIGN                                                   !7, $32
   26    36        INIT_FCALL                                               'number_factory'
         37        SEND_VAL                                                 4
         38        DO_FCALL                                      0  $34     
         39        ASSIGN                                                   !8, $34
   27    40        INIT_FCALL                                               'number_factory'
         41        SEND_VAL                                                 5
         42        DO_FCALL                                      0  $36     
         43        ASSIGN                                                   !9, $36
   28    44        INIT_FCALL                                               'number_factory'
         45        SEND_VAL                                                 6
         46        DO_FCALL                                      0  $38     
         47        ASSIGN                                                   !10, $38
   29    48        INIT_FCALL                                               'number_factory'
         49        SEND_VAL                                                 7
         50        DO_FCALL                                      0  $40     
         51        ASSIGN                                                   !11, $40
   30    52        INIT_FCALL                                               'number_factory'
         53        SEND_VAL                                                 8
         54        DO_FCALL                                      0  $42     
         55        ASSIGN                                                   !12, $42
   31    56        INIT_FCALL                                               'number_factory'
         57        SEND_VAL                                                 9
         58        DO_FCALL                                      0  $44     
         59        ASSIGN                                                   !13, $44
   33    60        INIT_DYNAMIC_CALL                                        !6
         61        INIT_DYNAMIC_CALL                                        !0
         62        INIT_DYNAMIC_CALL                                        !7
         63        INIT_DYNAMIC_CALL                                        !1
         64        INIT_DYNAMIC_CALL                                        !6
         65        DO_FCALL                                      0  $46     
         66        SEND_VAR_NO_REF_EX                                       $46
         67        DO_FCALL                                      0  $47     
         68        SEND_VAR_NO_REF_EX                                       $47
         69        DO_FCALL                                      0  $48     
         70        SEND_VAR_NO_REF_EX                                       $48
         71        DO_FCALL                                      0  $49     
         72        SEND_VAR_NO_REF_EX                                       $49
         73        DO_FCALL                                      0  $50     
         74        ECHO                                                     $50
         75      > RETURN                                                   1

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

End of function number_factory

Function %00%7Bclosure%7D%2Fin%2FgjiId%3A4%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 8
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gjiId
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $operation, !1 = $num
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV_INIT                                        !0      null
          1        BIND_STATIC                                              !1
    5     2      > JMPZ                                                     !0, ->8
          3    >   INIT_DYNAMIC_CALL                                        !0
          4        SEND_VAR_EX                                              !1
          5        DO_FCALL                                      0  $2      
          6        QM_ASSIGN                                        ~3      $2
          7      > JMP                                                      ->9
          8    >   QM_ASSIGN                                        ~3      !1
          9    > > RETURN                                                   ~3
    6    10*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FgjiId%3A4%240

Function operation_factory:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gjiId
function name:  operation_factory
number of ops:  5
compiled vars:  !0 = $operation
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   10     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FgjiId%3A10%241'
          2        BIND_LEXICAL                                             ~1, !0
   14     3      > RETURN                                                   ~1
   15     4*     > RETURN                                                   null

End of function operation_factory

Function %00%7Bclosure%7D%2Fin%2FgjiId%3A10%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gjiId
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $b, !1 = $operation
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   11     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FgjiId%3A11%242'
          3        BIND_LEXICAL                                             ~2, !0
          4        BIND_LEXICAL                                             ~2, !1
   13     5      > RETURN                                                   ~2
   14     6*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FgjiId%3A10%241

Function %00%7Bclosure%7D%2Fin%2FgjiId%3A11%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gjiId
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $a, !1 = $b, !2 = $operation
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        BIND_STATIC                                              !2
   12     3        INIT_DYNAMIC_CALL                                        !2
          4        SEND_VAR_EX                                              !0
          5        SEND_VAR_EX                                              !1
          6        DO_FCALL                                      0  $3      
          7      > RETURN                                                   $3
   13     8*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FgjiId%3A11%242

Function %00%7Bclosure%7D%2Fin%2FgjiId%3A17%243:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gjiId
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        ADD                                              ~2      !0, !1
          3      > RETURN                                                   ~2
          4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FgjiId%3A17%243

Function %00%7Bclosure%7D%2Fin%2FgjiId%3A18%244:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gjiId
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        SUB                                              ~2      !0, !1
          3      > RETURN                                                   ~2
          4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FgjiId%3A18%244

Function %00%7Bclosure%7D%2Fin%2FgjiId%3A19%245:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gjiId
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        MUL                                              ~2      !0, !1
          3      > RETURN                                                   ~2
          4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FgjiId%3A19%245

Function %00%7Bclosure%7D%2Fin%2FgjiId%3A20%246:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gjiId
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        DIV                                              ~2      !0, !1
          3      > RETURN                                                   ~2
          4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FgjiId%3A20%246

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.08 ms | 1410 KiB | 27 Q