3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { function __construct($val) { $this->val = $val; } function getClosure() { //returns closure bound to this object and scope return function() { return $this->val; }; } } $ob1 = new A(1); $ob2 = new A(2); echo $ob1->getClosure()->call($obj1); echo $ob2->getClosure()->call($ob2);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4APXg
function name:  (null)
number of ops:  21
compiled vars:  !0 = $ob1, !1 = $ob2, !2 = $obj1
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   NEW                                              $3      'A'
          1        SEND_VAL_EX                                              1
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $3
   14     4        NEW                                              $6      'A'
          5        SEND_VAL_EX                                              2
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $6
   16     8        INIT_METHOD_CALL                                         !0, 'getClosure'
          9        DO_FCALL                                      0  $9      
         10        INIT_METHOD_CALL                                         $9, 'call'
         11        SEND_VAR_EX                                              !2
         12        DO_FCALL                                      0  $10     
         13        ECHO                                                     $10
   18    14        INIT_METHOD_CALL                                         !1, 'getClosure'
         15        DO_FCALL                                      0  $11     
         16        INIT_METHOD_CALL                                         $11, 'call'
         17        SEND_VAR_EX                                              !1
         18        DO_FCALL                                      0  $12     
         19        ECHO                                                     $12
         20      > RETURN                                                   1

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

End of function %00%7Bclosure%7D%2Fin%2F4APXg%3A9%240

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

End of function __construct

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

End of function getclosure

End of class A.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.79 ms | 1399 KiB | 13 Q