3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { private $a = 'Bob'; } class B extends A { function __construct() { $instance = new A(); $reflection = new \ReflectionClass($instance); $property = $reflection->getProperty('a'); $property->setAccessible(true); echo $property->getValue(new A()); } } (new B());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/X2TX6
function name:  (null)
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   NEW                                              $0      'B'
          1        DO_FCALL                                      0          
          2        FREE                                                     $0
          3      > RETURN                                                   1

Class A: [no user functions]
Class B:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/X2TX6
function name:  __construct
number of ops:  21
compiled vars:  !0 = $instance, !1 = $reflection, !2 = $property
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   NEW                                              $3      'A'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   13     3        NEW                                              $6      'ReflectionClass'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $6
   14     7        INIT_METHOD_CALL                                         !1, 'getProperty'
          8        SEND_VAL_EX                                              'a'
          9        DO_FCALL                                      0  $9      
         10        ASSIGN                                                   !2, $9
   15    11        INIT_METHOD_CALL                                         !2, 'setAccessible'
         12        SEND_VAL_EX                                              <true>
         13        DO_FCALL                                      0          
   16    14        INIT_METHOD_CALL                                         !2, 'getValue'
         15        NEW                                              $12     'A'
         16        DO_FCALL                                      0          
         17        SEND_VAR_NO_REF_EX                                       $12
         18        DO_FCALL                                      0  $14     
         19        ECHO                                                     $14
   17    20      > RETURN                                                   null

End of function __construct

End of class B.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
283.34 ms | 1007 KiB | 13 Q