3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Base { public static $prop = 'BASE'; public function getProp() { return static::$prop; } } class Mock extends Base { } $obj = new Mock; $excepted = 'REFLECTED'; $property = new ReflectionProperty('Base', 'prop'); $property->setAccessible(true); $property->setValue($excepted); $actual = $obj->getProp(); echo "Schould be `{$excepted}` and is `{$actual}`\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dClFS
function name:  (null)
number of ops:  25
compiled vars:  !0 = $obj, !1 = $excepted, !2 = $property, !3 = $actual
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   NEW                                              $4      'Mock'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $4
   11     3        ASSIGN                                                   !1, 'REFLECTED'
   13     4        NEW                                              $8      'ReflectionProperty'
          5        SEND_VAL_EX                                              'Base'
          6        SEND_VAL_EX                                              'prop'
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !2, $8
   14     9        INIT_METHOD_CALL                                         !2, 'setAccessible'
         10        SEND_VAL_EX                                              <true>
         11        DO_FCALL                                      0          
   15    12        INIT_METHOD_CALL                                         !2, 'setValue'
         13        SEND_VAR_EX                                              !1
         14        DO_FCALL                                      0          
   17    15        INIT_METHOD_CALL                                         !0, 'getProp'
         16        DO_FCALL                                      0  $13     
         17        ASSIGN                                                   !3, $13
   18    18        ROPE_INIT                                     5  ~16     'Schould+be+%60'
         19        ROPE_ADD                                      1  ~16     ~16, !1
         20        ROPE_ADD                                      2  ~16     ~16, '%60+and+is+%60'
         21        ROPE_ADD                                      3  ~16     ~16, !3
         22        ROPE_END                                      4  ~15     ~16, '%60%0A'
         23        ECHO                                                     ~15
         24      > RETURN                                                   1

Class Base:
Function getprop:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dClFS
function name:  getProp
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'prop'
          1      > RETURN                                                   ~0
    6     2*     > RETURN                                                   null

End of function getprop

End of class Base.

Class Mock:
Function getprop:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dClFS
function name:  getProp
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'prop'
          1      > RETURN                                                   ~0
    6     2*     > RETURN                                                   null

End of function getprop

End of class Mock.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.21 ms | 1395 KiB | 13 Q