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() { $closure = $this->callback; $closure(); } 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/F8GfM
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'
   68     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FF8GfM%3A68%241'
          2        ASSIGN                                                   !0, ~2
   72     3        NEW                                              $4      'Intercept'
          4        SEND_VAL_EX                                              'test'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $4
   73     8        INIT_METHOD_CALL                                         !1, 'hello'
          9        DO_FCALL                                      0  $7      
         10        ECHO                                                     $7
         11      > RETURN                                                   1

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

End of function %00%7Bclosure%7D%2Fin%2FF8GfM%3A68%241

Class Intercept:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/F8GfM
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/F8GfM
function name:  run_callback
number of ops:  5
compiled vars:  !0 = $closure
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   FETCH_OBJ_R                                      ~1      'callback'
          1        ASSIGN                                                   !0, ~1
   16     2        INIT_DYNAMIC_CALL                                        !0
          3        DO_FCALL                                      0          
   17     4      > 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/F8GfM
function name:  __get
number of ops:  7
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
   21     1        INIT_METHOD_CALL                                         'run_callback'
          2        DO_FCALL                                      0          
   22     3        FETCH_OBJ_R                                      ~2      'class'
          4        FETCH_OBJ_R                                      ~3      ~2, !0
          5      > RETURN                                                   ~3
   23     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/F8GfM
function name:  __set
number of ops:  9
compiled vars:  !0 = $name, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   27     2        INIT_METHOD_CALL                                         'run_callback'
          3        DO_FCALL                                      0          
   28     4        FETCH_OBJ_W                                      $3      'class'
          5        ASSIGN_OBJ                                       ~4      $3, !0
          6        OP_DATA                                                  !1
          7      > RETURN                                                   ~4
   29     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/F8GfM
function name:  __isset
number of ops:  7
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   RECV                                             !0      
   33     1        INIT_METHOD_CALL                                         'run_callback'
          2        DO_FCALL                                      0          
   34     3        FETCH_OBJ_IS                                     ~2      'class'
          4        ISSET_ISEMPTY_PROP_OBJ                           ~3      ~2, !0
          5      > RETURN                                                   ~3
   35     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/F8GfM
function name:  __unset
number of ops:  6
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   RECV                                             !0      
   39     1        INIT_METHOD_CALL                                         'run_callback'
          2        DO_FCALL                                      0          
   40     3        FETCH_OBJ_UNSET                                  $2      'class'
          4        UNSET_OBJ                                                $2, !0
   41     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/F8GfM
function name:  __call
number of ops:  13
compiled vars:  !0 = $method, !1 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   43     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   45     2        INIT_METHOD_CALL                                         'run_callback'
          3        DO_FCALL                                      0          
   46     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
   47    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/F8GfM
function name:  __toString
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   51     0  E >   INIT_METHOD_CALL                                         'run_callback'
          1        DO_FCALL                                      0          
   52     2        FETCH_OBJ_R                                      ~1      'class'
          3        VERIFY_RETURN_TYPE                                       ~1
          4      > RETURN                                                   ~1
   53     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/F8GfM
function name:  __invoke
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   57     0  E >   INIT_METHOD_CALL                                         'run_callback'
          1        DO_FCALL                                      0          
   58     2        INIT_METHOD_CALL                                         'class'
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
   59     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/F8GfM
function name:  hello
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   64     0  E > > RETURN                                                   'world'
   65     1*     > RETURN                                                   null

End of function hello

End of class test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.76 ms | 1403 KiB | 13 Q