3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ColorGenerator { /** * Map of Material Design hex colors. * * @var array */ private static $map = [ 0xFF000000, // black 0xFFFFFFFF, // white 0xFFF44336, // red 0xFFE91E63, // pink 0xFF9C27B0, // purple 0xFF673AB7, // deep purple 0xFF3F51B5, // indigo 0xFF2196F3, // blue 0xFF03A9F4, // light blue 0xFF00BCD4, // cyan 0xFF009688, // teal 0xFF4CAF50, // green 0xFF8BC34A, // light green 0xFFCDDC39, // lime 0xFFFFEB3B, // yellow 0xFFFFC107, // amber 0xFFFF9800, // orange 0xFFFF5722, // deep orange 0xFF795548, // brown 0xFF9E9E9E, // grey 0xFF607D8B, // blue grey ]; public static function debug(): void { var_dump(self::$map); } /** * @return string */ public static function generate(): string { $size = count(self::$map); $random = mt_rand(0, ($size - 1)); $_color = self::$map[$random] ?? self::$map[0]; return dechex($_color); } } $color = ColorGenerator::generate(); ColorGenerator::debug(); var_dump($color);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IkSn2
function name:  (null)
number of ops:  9
compiled vars:  !0 = $color
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   50     0  E >   INIT_STATIC_METHOD_CALL                                  'ColorGenerator', 'generate'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN                                                   !0, $1
   51     3        INIT_STATIC_METHOD_CALL                                  'ColorGenerator', 'debug'
          4        DO_FCALL                                      0          
   52     5        INIT_FCALL                                               'var_dump'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                                 
          8      > RETURN                                                   1

Class ColorGenerator:
Function debug:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IkSn2
function name:  debug
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   INIT_FCALL                                               'var_dump'
          1        FETCH_STATIC_PROP_R          global lock         ~0      'map'
          2        SEND_VAL                                                 ~0
          3        DO_ICALL                                                 
   35     4      > RETURN                                                   null

End of function debug

Function generate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IkSn2
function name:  generate
number of ops:  23
compiled vars:  !0 = $size, !1 = $random, !2 = $_color
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   FETCH_STATIC_PROP_R          unknown             ~3      'map'
          1        COUNT                                            ~4      ~3
          2        ASSIGN                                                   !0, ~4
   42     3        INIT_FCALL                                               'mt_rand'
          4        SEND_VAL                                                 0
          5        SUB                                              ~6      !0, 1
          6        SEND_VAL                                                 ~6
          7        DO_ICALL                                         $7      
          8        ASSIGN                                                   !1, $7
   44     9        FETCH_STATIC_PROP_IS                             ~9      'map'
         10        FETCH_DIM_IS                                     ~10     ~9, !1
         11        COALESCE                                         ~11     ~10
         12        FETCH_STATIC_PROP_R          unknown             ~12     'map'
         13        FETCH_DIM_R                                      ~13     ~12, 0
         14        QM_ASSIGN                                        ~11     ~13
         15        ASSIGN                                                   !2, ~11
   46    16        INIT_FCALL                                               'dechex'
         17        SEND_VAR                                                 !2
         18        DO_ICALL                                         $15     
         19        VERIFY_RETURN_TYPE                                       $15
         20      > RETURN                                                   $15
   47    21*       VERIFY_RETURN_TYPE                                       
         22*     > RETURN                                                   null

End of function generate

End of class ColorGenerator.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.1 ms | 1017 KiB | 16 Q