3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { private function foo() { echo "I R private::A called in class ".get_class()."\n"; } public function rebind(Closure $fn) { //$fn = $this->getClosure(); $fn2 = $fn->call($this); $fn2(); } public function getClosure() { $fn = function() { $this->foo();}; return $fn; } } class B extends A { private function foo() { echo "I R private::B called in class ".get_class()."\n"; } public function getClosure() { $fn = function() { $this->foo();}; return $fn; } } $b = new B(); $fn = $b->getClosure(); $a = new A(); $a->rebind($fn);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FVmY0
function name:  (null)
number of ops:  13
compiled vars:  !0 = $b, !1 = $fn, !2 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   43     0  E >   NEW                                              $3      'B'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   44     3        INIT_METHOD_CALL                                         !0, 'getClosure'
          4        DO_FCALL                                      0  $6      
          5        ASSIGN                                                   !1, $6
   46     6        NEW                                              $8      'A'
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !2, $8
   47     9        INIT_METHOD_CALL                                         !2, 'rebind'
         10        SEND_VAR_EX                                              !1
         11        DO_FCALL                                      0          
         12      > RETURN                                                   1

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

End of function %00%7Bclosure%7D%2Fin%2FFVmY0%3A20%240

Function %00%7Bclosure%7D%2Fin%2FFVmY0%3A36%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FVmY0
function name:  {closure}
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   FETCH_THIS                                       $0      
          1        INIT_METHOD_CALL                                         $0, 'foo'
          2        DO_FCALL                                      0          
          3      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FFVmY0%3A36%241

Class A:
Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FVmY0
function name:  foo
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   GET_CLASS                                        ~0      
          1        CONCAT                                           ~1      'I+R+private%3A%3AA+called+in+class+', ~0
          2        CONCAT                                           ~2      ~1, '%0A'
          3        ECHO                                                     ~2
    9     4      > RETURN                                                   null

End of function foo

Function rebind:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FVmY0
function name:  rebind
number of ops:  9
compiled vars:  !0 = $fn, !1 = $fn2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   14     1        INIT_METHOD_CALL                                         !0, 'call'
          2        FETCH_THIS                                       $2      
          3        SEND_VAR_EX                                              $2
          4        DO_FCALL                                      0  $3      
          5        ASSIGN                                                   !1, $3
   15     6        INIT_DYNAMIC_CALL                                        !1
          7        DO_FCALL                                      0          
   16     8      > RETURN                                                   null

End of function rebind

Function getclosure:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FVmY0
function name:  getClosure
number of ops:  4
compiled vars:  !0 = $fn
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FFVmY0%3A20%240'
          1        ASSIGN                                                   !0, ~1
   22     2      > RETURN                                                   !0
   23     3*     > RETURN                                                   null

End of function getclosure

End of class A.

Class B:
Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FVmY0
function name:  foo
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   GET_CLASS                                        ~0      
          1        CONCAT                                           ~1      'I+R+private%3A%3AB+called+in+class+', ~0
          2        CONCAT                                           ~2      ~1, '%0A'
          3        ECHO                                                     ~2
   32     4      > RETURN                                                   null

End of function foo

Function getclosure:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FVmY0
function name:  getClosure
number of ops:  4
compiled vars:  !0 = $fn
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FFVmY0%3A36%241'
          1        ASSIGN                                                   !0, ~1
   38     2      > RETURN                                                   !0
   39     3*     > RETURN                                                   null

End of function getclosure

Function rebind:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FVmY0
function name:  rebind
number of ops:  9
compiled vars:  !0 = $fn, !1 = $fn2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   14     1        INIT_METHOD_CALL                                         !0, 'call'
          2        FETCH_THIS                                       $2      
          3        SEND_VAR_EX                                              $2
          4        DO_FCALL                                      0  $3      
          5        ASSIGN                                                   !1, $3
   15     6        INIT_DYNAMIC_CALL                                        !1
          7        DO_FCALL                                      0          
   16     8      > RETURN                                                   null

End of function rebind

End of class B.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.54 ms | 1403 KiB | 13 Q