3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $bar; public function getBar() { return $this->bar; } } class FooProxy extends Foo { public function getBar() { $this->init(); return parent::getBar(); } private function init() { \Closure::bind(function (Foo $foo, $value) { $foo->bar = $value; }, null, \get_parent_class($this))($this, 'bar42'); } } $foo = new FooProxy(); var_dump($foo->getBar());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pOkj4
function name:  (null)
number of ops:  9
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   NEW                                              $1      'FooProxy'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   30     3        INIT_FCALL                                               'var_dump'
          4        INIT_METHOD_CALL                                         !0, 'getBar'
          5        DO_FCALL                                      0  $4      
          6        SEND_VAR                                                 $4
          7        DO_ICALL                                                 
          8      > RETURN                                                   1

Class Foo:
Function getbar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pOkj4
function name:  getBar
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   FETCH_OBJ_R                                      ~0      'bar'
          1      > RETURN                                                   ~0
   10     2*     > RETURN                                                   null

End of function getbar

End of class Foo.

Class FooProxy:
Function getbar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pOkj4
function name:  getBar
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   INIT_METHOD_CALL                                         'init'
          1        DO_FCALL                                      0          
   18     2        INIT_STATIC_METHOD_CALL                                  'getBar'
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
   19     5*     > RETURN                                                   null

End of function getbar

Function init:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pOkj4
function name:  init
number of ops:  16
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   INIT_STATIC_METHOD_CALL                                  'Closure', 'bind'
          1        DECLARE_LAMBDA_FUNCTION                          ~0      [0]
   25     2        SEND_VAL                                                 ~0
          3        SEND_VAL                                                 null
          4        INIT_FCALL                                               'get_parent_class'
          5        FETCH_THIS                                       ~1      
          6        SEND_VAL                                                 ~1
          7        DO_ICALL                                         $2      
          8        SEND_VAR                                                 $2
   23     9        DO_FCALL                                      0  $3      
   25    10        INIT_DYNAMIC_CALL                                        $3
         11        FETCH_THIS                                       $4      
         12        SEND_VAR_EX                                              $4
         13        SEND_VAL_EX                                              'bar42'
         14        DO_FCALL                                      0          
   26    15      > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pOkj4
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $foo, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   24     2        ASSIGN_OBJ                                               !0, 'bar'
          3        OP_DATA                                                  !1
   25     4      > RETURN                                                   null

End of Dynamic Function 0

End of function init

End of class FooProxy.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.56 ms | 1432 KiB | 15 Q