3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Created by Code Cleanup Team * @author aldo.suwandi@aurea.com */ class GlobalConfig { private static $config; public static function setConfig($key, $value) { static::$config[$key] = $value; } public static function getConfig($key) { if (isset($GLOBALS[$key])) { return $GLOBALS[$key]; //temporary until refactoring finished //NOSONAR } else { if (!isset(static::$config[$key])) { return null; } else { return self::$config[$key]; } } } public static function unsetConfig($key) { unset(self::$config[$key]); } } $key = 'var1'; // for simple values $val = 456; GlobalConfig::setConfig($key, $val); $var1 = GlobalConfig::getConfig($key); var_dump($var1); // for objects $obj = new stdClass(); GlobalConfig::setConfig($key, $obj); $var2 = GlobalConfig::getConfig($key); var_dump($var2); // for array $arr = array('str 111222333','str 333444555'); GlobalConfig::setConfig($key, $arr); $var3 = GlobalConfig::getConfig($key); var_dump($var3);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CfbOH
function name:  (null)
number of ops:  40
compiled vars:  !0 = $key, !1 = $val, !2 = $var1, !3 = $obj, !4 = $var2, !5 = $arr, !6 = $var3
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   ASSIGN                                                   !0, 'var1'
   38     1        ASSIGN                                                   !1, 456
   39     2        INIT_STATIC_METHOD_CALL                                  'GlobalConfig', 'setConfig'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_FCALL                                      0          
   40     6        INIT_STATIC_METHOD_CALL                                  'GlobalConfig', 'getConfig'
          7        SEND_VAR                                                 !0
          8        DO_FCALL                                      0  $10     
          9        ASSIGN                                                   !2, $10
   41    10        INIT_FCALL                                               'var_dump'
         11        SEND_VAR                                                 !2
         12        DO_ICALL                                                 
   44    13        NEW                                              $13     'stdClass'
         14        DO_FCALL                                      0          
         15        ASSIGN                                                   !3, $13
   45    16        INIT_STATIC_METHOD_CALL                                  'GlobalConfig', 'setConfig'
         17        SEND_VAR                                                 !0
         18        SEND_VAR                                                 !3
         19        DO_FCALL                                      0          
   46    20        INIT_STATIC_METHOD_CALL                                  'GlobalConfig', 'getConfig'
         21        SEND_VAR                                                 !0
         22        DO_FCALL                                      0  $17     
         23        ASSIGN                                                   !4, $17
   47    24        INIT_FCALL                                               'var_dump'
         25        SEND_VAR                                                 !4
         26        DO_ICALL                                                 
   50    27        ASSIGN                                                   !5, <array>
   51    28        INIT_STATIC_METHOD_CALL                                  'GlobalConfig', 'setConfig'
         29        SEND_VAR                                                 !0
         30        SEND_VAR                                                 !5
         31        DO_FCALL                                      0          
   52    32        INIT_STATIC_METHOD_CALL                                  'GlobalConfig', 'getConfig'
         33        SEND_VAR                                                 !0
         34        DO_FCALL                                      0  $22     
         35        ASSIGN                                                   !6, $22
   53    36        INIT_FCALL                                               'var_dump'
         37        SEND_VAR                                                 !6
         38        DO_ICALL                                                 
         39      > RETURN                                                   1

Class GlobalConfig:
Function setconfig:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CfbOH
function name:  setConfig
number of ops:  6
compiled vars:  !0 = $key, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   13     2        FETCH_STATIC_PROP_W          global              $2      'config'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
   14     5      > RETURN                                                   null

End of function setconfig

Function getconfig:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 14
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CfbOH
function name:  getConfig
number of ops:  18
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
   18     1        FETCH_IS                                         ~1      'GLOBALS'
          2        ISSET_ISEMPTY_DIM_OBJ                         0          ~1, !0
          3      > JMPZ                                                     ~2, ->8
   19     4    >   FETCH_R                      global              ~3      'GLOBALS'
          5        FETCH_DIM_R                                      ~4      ~3, !0
          6      > RETURN                                                   ~4
          7*       JMP                                                      ->17
   21     8    >   FETCH_STATIC_PROP_IS                             ~5      'config'
          9        ISSET_ISEMPTY_DIM_OBJ                         0  ~6      ~5, !0
         10        BOOL_NOT                                         ~7      ~6
         11      > JMPZ                                                     ~7, ->14
   22    12    > > RETURN                                                   null
         13*       JMP                                                      ->17
   24    14    >   FETCH_STATIC_PROP_R          unknown             ~8      'config'
         15        FETCH_DIM_R                                      ~9      ~8, !0
         16      > RETURN                                                   ~9
   27    17*     > RETURN                                                   null

End of function getconfig

Function unsetconfig:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CfbOH
function name:  unsetConfig
number of ops:  4
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV                                             !0      
   31     1        FETCH_STATIC_PROP_UNSET                          $1      'config'
          2        UNSET_DIM                                                $1, !0
   32     3      > RETURN                                                   null

End of function unsetconfig

End of class GlobalConfig.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.66 ms | 1400 KiB | 15 Q