3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Intercept { protected $class = null; protected $callback = null; public function __construct($class, $callback = null) { $this->class = new $class(); $this->callback = $callback; } protected function run_callback() { $this->{$callback}(); } public function __get($name) { $this->run_callback(); return $this->class->$name; } public function __set($name, $value) { $this->run_callback(); return $this->class->$name = $value; } public function __isset($name) { $this->run_callback(); return isset($this->class->$name); } public function __unset($name) { $this->run_callback(); unset($this->class->$name); } public function __call($method, $args) { $this->run_callback(); return call_user_func_array(array($this->class, $method), $args); } public function __toString() { $this->run_callback(); return $this->class; } public function __invoke() { $this->run_callback(); return $this->class(); } } class test { public function hello() { return 'world'; } } $closure = function() { echo 123; }; $test=new Intercept('test', $closure); echo $test->hello();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dmnKc
function name:  (null)
number of ops:  12
compiled vars:  !0 = $closure, !1 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   DECLARE_CLASS                                            'intercept'
   67     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FdmnKc%3A67%241'
          2        ASSIGN                                                   !0, ~2
   71     3        NEW                                              $4      'Intercept'
          4        SEND_VAL_EX                                              'test'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $4
   72     8        INIT_METHOD_CALL                                         !1, 'hello'
          9        DO_FCALL                                      0  $7      
         10        ECHO                                                     $7
         11      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FdmnKc%3A67%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dmnKc
function name:  {closure}
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   68     0  E >   ECHO                                                     123
   69     1      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FdmnKc%3A67%241

Class Intercept:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dmnKc
function name:  __construct
number of ops:  10
compiled vars:  !0 = $class, !1 = $callback
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
    9     2        FETCH_CLASS                                   0  $3      !0
          3        NEW                                              $4      $3
          4        DO_FCALL                                      0          
          5        ASSIGN_OBJ                                               'class'
          6        OP_DATA                                                  $4
   10     7        ASSIGN_OBJ                                               'callback'
          8        OP_DATA                                                  !1
   11     9      > RETURN                                                   null

End of function __construct

Function run_callback:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dmnKc
function name:  run_callback
number of ops:  3
compiled vars:  !0 = $callback
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   INIT_METHOD_CALL                                         !0
          1        DO_FCALL                                      0          
   16     2      > RETURN                                                   null

End of function run_callback

Function __get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dmnKc
function name:  __get
number of ops:  7
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   20     1        INIT_METHOD_CALL                                         'run_callback'
          2        DO_FCALL                                      0          
   21     3        FETCH_OBJ_R                                      ~2      'class'
          4        FETCH_OBJ_R                                      ~3      ~2, !0
          5      > RETURN                                                   ~3
   22     6*     > RETURN                                                   null

End of function __get

Function __set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dmnKc
function name:  __set
number of ops:  9
compiled vars:  !0 = $name, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   26     2        INIT_METHOD_CALL                                         'run_callback'
          3        DO_FCALL                                      0          
   27     4        FETCH_OBJ_W                                      $3      'class'
          5        ASSIGN_OBJ                                       ~4      $3, !0
          6        OP_DATA                                                  !1
          7      > RETURN                                                   ~4
   28     8*     > RETURN                                                   null

End of function __set

Function __isset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dmnKc
function name:  __isset
number of ops:  7
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
   32     1        INIT_METHOD_CALL                                         'run_callback'
          2        DO_FCALL                                      0          
   33     3        FETCH_OBJ_IS                                     ~2      'class'
          4        ISSET_ISEMPTY_PROP_OBJ                           ~3      ~2, !0
          5      > RETURN                                                   ~3
   34     6*     > RETURN                                                   null

End of function __isset

Function __unset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dmnKc
function name:  __unset
number of ops:  6
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   RECV                                             !0      
   38     1        INIT_METHOD_CALL                                         'run_callback'
          2        DO_FCALL                                      0          
   39     3        FETCH_OBJ_UNSET                                  $2      'class'
          4        UNSET_OBJ                                                $2, !0
   40     5      > RETURN                                                   null

End of function __unset

Function __call:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dmnKc
function name:  __call
number of ops:  13
compiled vars:  !0 = $method, !1 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   44     2        INIT_METHOD_CALL                                         'run_callback'
          3        DO_FCALL                                      0          
   45     4        FETCH_OBJ_R                                      ~3      'class'
          5        INIT_ARRAY                                       ~4      ~3
          6        ADD_ARRAY_ELEMENT                                ~4      !0
          7        INIT_USER_CALL                                0          'call_user_func_array', ~4
          8        SEND_ARRAY                                               !1
          9        CHECK_UNDEF_ARGS                                         
         10        DO_FCALL                                      0  $5      
         11      > RETURN                                                   $5
   46    12*     > RETURN                                                   null

End of function __call

Function __tostring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dmnKc
function name:  __toString
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   50     0  E >   INIT_METHOD_CALL                                         'run_callback'
          1        DO_FCALL                                      0          
   51     2        FETCH_OBJ_R                                      ~1      'class'
          3        VERIFY_RETURN_TYPE                                       ~1
          4      > RETURN                                                   ~1
   52     5*       VERIFY_RETURN_TYPE                                       
          6*     > RETURN                                                   null

End of function __tostring

Function __invoke:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dmnKc
function name:  __invoke
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   56     0  E >   INIT_METHOD_CALL                                         'run_callback'
          1        DO_FCALL                                      0          
   57     2        INIT_METHOD_CALL                                         'class'
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
   58     5*     > RETURN                                                   null

End of function __invoke

End of class Intercept.

Class test:
Function hello:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dmnKc
function name:  hello
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   63     0  E > > RETURN                                                   'world'
   64     1*     > RETURN                                                   null

End of function hello

End of class test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
191.63 ms | 1403 KiB | 13 Q