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; } SampleClass::getSample(); 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/rqPeg
function name:  (null)
number of ops:  18
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'
   27     4        INIT_STATIC_METHOD_CALL                                  'SampleClass', 'getSample'
          5        DO_FCALL                                      0          
   28     6        INIT_STATIC_METHOD_CALL                                  'SampleTrait', 'getSample'
          7        DO_FCALL                                      0          
   29     8        NEW                                              $4      'SampleClass'
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !0, $4
   30    11        INIT_FCALL                                               'var_dump'
         12        FETCH_CLASS                                   0  $7      !0
         13        INIT_STATIC_METHOD_CALL                                  $7, 'getSample'
         14        DO_FCALL                                      0  $8      
         15        SEND_VAR                                                 $8
         16        DO_ICALL                                                 
         17      > RETURN                                                   1

Class SampleTrait:
Function setsample:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rqPeg
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/rqPeg
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:
163 ms | 1396 KiB | 15 Q