3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait SampleTrait { /** * @var string */ private static $sample; final public static function setSample($sample) { self::$sample = $sample; } final public static function getSample() { return self::$sample; } } SampleTrait::setSample('test'); class SampleClass { use SampleTrait; } var_dump(SampleClass::getSample()); var_dump(SampleTrait::getSample()); $sample = new SampleClass(); var_dump($sample::getSample());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EShiW
function name:  (null)
number of ops:  24
compiled vars:  !0 = $sample
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   INIT_STATIC_METHOD_CALL                                  'SampleTrait', 'setSample'
          1        SEND_VAL                                                 'test'
          2        DO_FCALL                                      0          
   23     3        DECLARE_CLASS                                            'sampleclass'
   28     4        INIT_FCALL                                               'var_dump'
          5        INIT_STATIC_METHOD_CALL                                  'SampleClass', 'getSample'
          6        DO_FCALL                                      0  $2      
          7        SEND_VAR                                                 $2
          8        DO_ICALL                                                 
   29     9        INIT_FCALL                                               'var_dump'
         10        INIT_STATIC_METHOD_CALL                                  'SampleTrait', 'getSample'
         11        DO_FCALL                                      0  $4      
         12        SEND_VAR                                                 $4
         13        DO_ICALL                                                 
   30    14        NEW                                              $6      'SampleClass'
         15        DO_FCALL                                      0          
         16        ASSIGN                                                   !0, $6
   31    17        INIT_FCALL                                               'var_dump'
         18        FETCH_CLASS                                   0  $9      !0
         19        INIT_STATIC_METHOD_CALL                                  $9, 'getSample'
         20        DO_FCALL                                      0  $10     
         21        SEND_VAR                                                 $10
         22        DO_ICALL                                                 
         23      > RETURN                                                   1

Class SampleTrait:
Function setsample:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EShiW
function name:  setSample
number of ops:  4
compiled vars:  !0 = $sample
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   12     1        ASSIGN_STATIC_PROP                                       'sample'
          2        OP_DATA                                                  !0
   13     3      > RETURN                                                   null

End of function setsample

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

End of function getsample

End of class SampleTrait.

Class SampleClass: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.97 ms | 1396 KiB | 15 Q