3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Proxy extends Base { public function __construct($initializer) { // do proxy initializing stuff, NOT calling base object's (i.e. parent's) constructor } } class Base { public function __construct($data) { echo $data; } } $reflection = new ReflectionObject($proxy); $parentReflection = $reflection->getParentClass(); $parentConstructor = $parentReflection->getMethod('__construct'); $parentConstructor->invoke($proxy, 'Hello world!');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/U6XTj
function name:  (null)
number of ops:  17
compiled vars:  !0 = $reflection, !1 = $proxy, !2 = $parentReflection, !3 = $parentConstructor
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   DECLARE_CLASS                                            'proxy', 'base'
   15     1        NEW                                              $4      'ReflectionObject'
          2        SEND_VAR_EX                                              !1
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $4
   16     5        INIT_METHOD_CALL                                         !0, 'getParentClass'
          6        DO_FCALL                                      0  $7      
          7        ASSIGN                                                   !2, $7
   17     8        INIT_METHOD_CALL                                         !2, 'getMethod'
          9        SEND_VAL_EX                                              '__construct'
         10        DO_FCALL                                      0  $9      
         11        ASSIGN                                                   !3, $9
   18    12        INIT_METHOD_CALL                                         !3, 'invoke'
         13        SEND_VAR_EX                                              !1
         14        SEND_VAL_EX                                              'Hello+world%21'
         15        DO_FCALL                                      0          
         16      > RETURN                                                   1

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

End of function __construct

End of class Proxy.

Class Base:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/U6XTj
function name:  __construct
number of ops:  3
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   11     1        ECHO                                                     !0
   12     2      > RETURN                                                   null

End of function __construct

End of class Base.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.83 ms | 1395 KiB | 13 Q