3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Number { private $v = 0; public function __construct($v) { $this->v = $v; } public function mul() { return function ($x) { return $this->v * $x; }; } } $one = new Number(1); $two = new Number(2); $double = $two->mul()->bindTo($one); echo $double(5);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BNrE1
function name:  (null)
number of ops:  19
compiled vars:  !0 = $one, !1 = $two, !2 = $double
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   NEW                                              $3      'Number'
          1        SEND_VAL_EX                                              1
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $3
   10     4        NEW                                              $6      'Number'
          5        SEND_VAL_EX                                              2
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $6
   11     8        INIT_METHOD_CALL                                         !1, 'mul'
          9        DO_FCALL                                      0  $9      
         10        INIT_METHOD_CALL                                         $9, 'bindTo'
         11        SEND_VAR_EX                                              !0
         12        DO_FCALL                                      0  $10     
         13        ASSIGN                                                   !2, $10
   12    14        INIT_DYNAMIC_CALL                                        !2
         15        SEND_VAL_EX                                              5
         16        DO_FCALL                                      0  $12     
         17        ECHO                                                     $12
         18      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FBNrE1%3A6%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BNrE1
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        FETCH_THIS                                       $1      
          2        FETCH_OBJ_R                                      ~2      $1, 'v'
          3        MUL                                              ~3      !0, ~2
          4      > RETURN                                                   ~3
          5*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FBNrE1%3A6%240

Class Number:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BNrE1
function name:  __construct
number of ops:  4
compiled vars:  !0 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        ASSIGN_OBJ                                               'v'
          2        OP_DATA                                                  !0
          3      > RETURN                                                   null

End of function __construct

Function mul:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BNrE1
function name:  mul
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FBNrE1%3A6%240'
          1      > RETURN                                                   ~0
    7     2*     > RETURN                                                   null

End of function mul

End of class Number.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.19 ms | 1399 KiB | 13 Q