3v4l.org

run code in 300+ PHP versions simultaneously
<?php class T1 { public static $data; public static function getDataBySelf() { return self::$data; } public static function getDataByStatic() { return static::$data; } } class T2 extends T1 {} $Prop1 = new ReflectionProperty(T1::class, 'data'); $Prop2 = new ReflectionProperty(T2::class, 'data'); // #1 // prints: hello, hello in PHP5, but world, hello in PHP7 - not OK $Prop1->setValue(\T1::class, "world"); $Prop2->setValue(\T2::class, 'hello'); // #2 // prints: hello, hello in both PHP5 and PHP7 - OK //T1::$data = "world"; //T2::$data = 'hello'; var_dump("T2::self = " . T2::getDataBySelf()); var_dump("T2::static = " . T2::getDataByStatic());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ioaEe
function name:  (null)
number of ops:  31
compiled vars:  !0 = $Prop1, !1 = $Prop2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   NEW                                              $2      'ReflectionProperty'
          1        SEND_VAL_EX                                              'T1'
          2        SEND_VAL_EX                                              'data'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $2
   19     5        NEW                                              $5      'ReflectionProperty'
          6        SEND_VAL_EX                                              'T2'
          7        SEND_VAL_EX                                              'data'
          8        DO_FCALL                                      0          
          9        ASSIGN                                                   !1, $5
   23    10        INIT_METHOD_CALL                                         !0, 'setValue'
         11        SEND_VAL_EX                                              'T1'
         12        SEND_VAL_EX                                              'world'
         13        DO_FCALL                                      0          
   24    14        INIT_METHOD_CALL                                         !1, 'setValue'
         15        SEND_VAL_EX                                              'T2'
         16        SEND_VAL_EX                                              'hello'
         17        DO_FCALL                                      0          
   31    18        INIT_FCALL                                               'var_dump'
         19        INIT_STATIC_METHOD_CALL                                  'T2', 'getDataBySelf'
         20        DO_FCALL                                      0  $10     
         21        CONCAT                                           ~11     'T2%3A%3Aself+%3D+', $10
         22        SEND_VAL                                                 ~11
         23        DO_ICALL                                                 
   32    24        INIT_FCALL                                               'var_dump'
         25        INIT_STATIC_METHOD_CALL                                  'T2', 'getDataByStatic'
         26        DO_FCALL                                      0  $13     
         27        CONCAT                                           ~14     'T2%3A%3Astatic+%3D+', $13
         28        SEND_VAL                                                 ~14
         29        DO_ICALL                                                 
         30      > RETURN                                                   1

Class T1:
Function getdatabyself:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ioaEe
function name:  getDataBySelf
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'data'
          1      > RETURN                                                   ~0
    8     2*     > RETURN                                                   null

End of function getdatabyself

Function getdatabystatic:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ioaEe
function name:  getDataByStatic
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'data'
          1      > RETURN                                                   ~0
   13     2*     > RETURN                                                   null

End of function getdatabystatic

End of class T1.

Class T2:
Function getdatabyself:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ioaEe
function name:  getDataBySelf
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'data'
          1      > RETURN                                                   ~0
    8     2*     > RETURN                                                   null

End of function getdatabyself

Function getdatabystatic:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ioaEe
function name:  getDataByStatic
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'data'
          1      > RETURN                                                   ~0
   13     2*     > RETURN                                                   null

End of function getdatabystatic

End of class T2.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.39 ms | 1400 KiB | 15 Q