3v4l.org

run code in 500+ PHP versions simultaneously
<?php class P { protected static $v = 1; public function output() { echo new ReflectionProperty($this, 'v')->getValue($this); } } class C extends P { public function test(P $i) { return $i->v; } } class C2 extends P { protected static $v = 2; } $c = new C; $c2 = new C2; $reflection = new ReflectionClass(P::class); $property = $reflection->getProperty('v'); echo $property->getValue($c2); echo new ReflectionProperty(P::class, 'v')->getValue($c2); $c2->output();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WKILh
function name:  (null)
number of ops:  29
compiled vars:  !0 = $c, !1 = $c2, !2 = $reflection, !3 = $property
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   20     0  E >   NEW                                                  $4      'C'
          1        DO_FCALL                                          0          
          2        ASSIGN                                                       !0, $4
   21     3        NEW                                                  $7      'C2'
          4        DO_FCALL                                          0          
          5        ASSIGN                                                       !1, $7
   23     6        NEW                                                  $10     'ReflectionClass'
          7        SEND_VAL_EX                                                  'P'
          8        DO_FCALL                                          0          
          9        ASSIGN                                                       !2, $10
   24    10        INIT_METHOD_CALL                                             !2, 'getProperty'
         11        SEND_VAL_EX                                                  'v'
         12        DO_FCALL                                          0  $13     
         13        ASSIGN                                                       !3, $13
   25    14        INIT_METHOD_CALL                                             !3, 'getValue'
         15        SEND_VAR_EX                                                  !1
         16        DO_FCALL                                          0  $15     
         17        ECHO                                                         $15
   27    18        NEW                                                  $16     'ReflectionProperty'
         19        SEND_VAL_EX                                                  'P'
         20        SEND_VAL_EX                                                  'v'
         21        DO_FCALL                                          0          
         22        INIT_METHOD_CALL                                             $16, 'getValue'
         23        SEND_VAR_EX                                                  !1
         24        DO_FCALL                                          0  $18     
         25        ECHO                                                         $18
   28    26        INIT_METHOD_CALL                                             !1, 'output'
         27        DO_FCALL                                          0          
         28      > RETURN                                                       1

Class P:
Function output:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WKILh
function name:  output
number of ops:  11
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    6     0  E >   NEW                                                  $0      'ReflectionProperty'
          1        FETCH_THIS                                           $1      
          2        SEND_VAR_EX                                                  $1
          3        SEND_VAL_EX                                                  'v'
          4        DO_FCALL                                          0          
          5        INIT_METHOD_CALL                                             $0, 'getValue'
          6        FETCH_THIS                                           $3      
          7        SEND_VAR_EX                                                  $3
          8        DO_FCALL                                          0  $4      
          9        ECHO                                                         $4
    7    10      > RETURN                                                       null

End of function output

End of class P.

Class C:
Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WKILh
function name:  test
number of ops:  4
compiled vars:  !0 = $i
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   RECV                                                 !0      
   12     1        FETCH_OBJ_R                                          ~1      !0, 'v'
          2      > RETURN                                                       ~1
   13     3*     > RETURN                                                       null

End of function test

Function output:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WKILh
function name:  output
number of ops:  11
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    6     0  E >   NEW                                                  $0      'ReflectionProperty'
          1        FETCH_THIS                                           $1      
          2        SEND_VAR_EX                                                  $1
          3        SEND_VAL_EX                                                  'v'
          4        DO_FCALL                                          0          
          5        INIT_METHOD_CALL                                             $0, 'getValue'
          6        FETCH_THIS                                           $3      
          7        SEND_VAR_EX                                                  $3
          8        DO_FCALL                                          0  $4      
          9        ECHO                                                         $4
    7    10      > RETURN                                                       null

End of function output

End of class C.

Class C2:
Function output:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WKILh
function name:  output
number of ops:  11
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    6     0  E >   NEW                                                  $0      'ReflectionProperty'
          1        FETCH_THIS                                           $1      
          2        SEND_VAR_EX                                                  $1
          3        SEND_VAL_EX                                                  'v'
          4        DO_FCALL                                          0          
          5        INIT_METHOD_CALL                                             $0, 'getValue'
          6        FETCH_THIS                                           $3      
          7        SEND_VAR_EX                                                  $3
          8        DO_FCALL                                          0  $4      
          9        ECHO                                                         $4
    7    10      > RETURN                                                       null

End of function output

End of class C2.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
158.96 ms | 1106 KiB | 13 Q