3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class Model { protected static $__columns = []; protected static $cache = []; public function test() { $modelName = get_class($this); var_dump($modelName::$cache); static::$cache = $modelName::$__columns; var_dump($modelName::$cache); } } class A extends Model { protected static $__columns = ["aaa", "aa", "a"]; } class B extends Model { protected static $__columns = ["bbb", "bb", "b"]; } $a = new A(); $a->test(); $b = new B(); $b->test(); $a->test();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6juD2
function name:  (null)
number of ops:  13
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   NEW                                              $2      'A'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   26     3        INIT_METHOD_CALL                                         !0, 'test'
          4        DO_FCALL                                      0          
   28     5        NEW                                              $6      'B'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $6
   29     8        INIT_METHOD_CALL                                         !1, 'test'
          9        DO_FCALL                                      0          
   31    10        INIT_METHOD_CALL                                         !0, 'test'
         11        DO_FCALL                                      0          
         12      > RETURN                                                   1

Class Model:
Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6juD2
function name:  test
number of ops:  18
compiled vars:  !0 = $modelName
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   FETCH_THIS                                       ~1      
          1        GET_CLASS                                        ~2      ~1
          2        ASSIGN                                                   !0, ~2
   10     3        INIT_FCALL                                               'var_dump'
          4        FETCH_CLASS                                   0  $4      !0
          5        FETCH_STATIC_PROP_R          global lock         ~5      'cache'
          6        SEND_VAL                                                 ~5
          7        DO_ICALL                                                 
   11     8        FETCH_CLASS                                   0  $8      !0
          9        FETCH_STATIC_PROP_R          unknown             ~9      '__columns'
         10        ASSIGN_STATIC_PROP                                       'cache'
         11        OP_DATA                                                  ~9
   12    12        INIT_FCALL                                               'var_dump'
         13        FETCH_CLASS                                   0  $10     !0
         14        FETCH_STATIC_PROP_R          unknown             ~11     'cache'
         15        SEND_VAL                                                 ~11
         16        DO_ICALL                                                 
   13    17      > RETURN                                                   null

End of function test

End of class Model.

Class A:
Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6juD2
function name:  test
number of ops:  18
compiled vars:  !0 = $modelName
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   FETCH_THIS                                       ~1      
          1        GET_CLASS                                        ~2      ~1
          2        ASSIGN                                                   !0, ~2
   10     3        INIT_FCALL                                               'var_dump'
          4        FETCH_CLASS                                   0  $4      !0
          5        FETCH_STATIC_PROP_R          global lock         ~5      'cache'
          6        SEND_VAL                                                 ~5
          7        DO_ICALL                                                 
   11     8        FETCH_CLASS                                   0  $8      !0
          9        FETCH_STATIC_PROP_R          unknown             ~9      '__columns'
         10        ASSIGN_STATIC_PROP                                       'cache'
         11        OP_DATA                                                  ~9
   12    12        INIT_FCALL                                               'var_dump'
         13        FETCH_CLASS                                   0  $10     !0
         14        FETCH_STATIC_PROP_R          unknown             ~11     'cache'
         15        SEND_VAL                                                 ~11
         16        DO_ICALL                                                 
   13    17      > RETURN                                                   null

End of function test

End of class A.

Class B:
Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6juD2
function name:  test
number of ops:  18
compiled vars:  !0 = $modelName
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   FETCH_THIS                                       ~1      
          1        GET_CLASS                                        ~2      ~1
          2        ASSIGN                                                   !0, ~2
   10     3        INIT_FCALL                                               'var_dump'
          4        FETCH_CLASS                                   0  $4      !0
          5        FETCH_STATIC_PROP_R          global lock         ~5      'cache'
          6        SEND_VAL                                                 ~5
          7        DO_ICALL                                                 
   11     8        FETCH_CLASS                                   0  $8      !0
          9        FETCH_STATIC_PROP_R          unknown             ~9      '__columns'
         10        ASSIGN_STATIC_PROP                                       'cache'
         11        OP_DATA                                                  ~9
   12    12        INIT_FCALL                                               'var_dump'
         13        FETCH_CLASS                                   0  $10     !0
         14        FETCH_STATIC_PROP_R          unknown             ~11     'cache'
         15        SEND_VAL                                                 ~11
         16        DO_ICALL                                                 
   13    17      > RETURN                                                   null

End of function test

End of class B.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.27 ms | 1400 KiB | 15 Q