3v4l.org

run code in 300+ PHP versions simultaneously
<?php class foo { private $x = 1; } function & getProp(foo $x) { $prop = new ReflectionProperty($x, 'x'); $prop->setAccessible(true); $p = &$x->x; // $prop->setAccessible(false); return $p; } $x = new foo; $y = getProp($x); var_dump($x); $y = 2; var_dump($x);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bHvIk
function name:  (null)
number of ops:  15
compiled vars:  !0 = $x, !1 = $y
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   NEW                                              $2      'foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   22     3        INIT_FCALL                                               'getprop'
          4        SEND_VAR                                                 !0
          5        DO_FCALL                                      0  $5      
          6        ASSIGN                                                   !1, $5
   24     7        INIT_FCALL                                               'var_dump'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                                 
   26    10        ASSIGN                                                   !1, 2
   28    11        INIT_FCALL                                               'var_dump'
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                                 
         14      > RETURN                                                   1

Function getprop:
Finding entry points
Branch analysis from position: 0
Return found
filename:       /in/bHvIk
function name:  getProp
number of ops:  13
compiled vars:  !0 = $x, !1 = $prop, !2 = $p
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
   10     1        NEW                                              $3      'ReflectionProperty'
          2        SEND_VAR_EX                                              !0
          3        SEND_VAL_EX                                              'x'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $3
   12     6        INIT_METHOD_CALL                                         !1, 'setAccessible'
          7        SEND_VAL_EX                                              <true>
          8        DO_FCALL                                      0          
   14     9        FETCH_OBJ_W                                      $7      !0, 'x'
         10        ASSIGN_REF                                               !2, $7
   18    11      > RETURN_BY_REF                                            !2
   19    12*     > RETURN_BY_REF                                            null

End of function getprop

Class foo: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
183.28 ms | 1399 KiB | 16 Q