3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ConfigManager { var $config = array(); function ConfigManager() { echo "Created\n"; } function load() { $this->config = array('foo' => 'bar'); } function get($key) { return isset($this->config[$key]) ? $this->config[$key] : null; } function set($key, $value) { $this->config[$key] = $value; } } function &config_get_manager() { static $configManager = null; if (!isset($configManager)) { $configManager = new ConfigManager; $configManager->load(); } return $configManager; } function config_get($key) { static $configManager = null; if (!isset($configManager)) { $configManager = &config_get_manager(); } return $configManager->get($key); } function config_set($key, $value) { static $configManager = null; if (!isset($configManager)) { $configManager = &config_get_manager(); } $configManager->set($key, $value); } echo config_get('foo') . "\n"; config_set('foo', 'baz'); echo config_get('foo') . "\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sWsq5
function name:  (null)
number of ops:  15
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   62     0  E >   INIT_FCALL                                               'config_get'
          1        SEND_VAL                                                 'foo'
          2        DO_FCALL                                      0  $0      
          3        CONCAT                                           ~1      $0, '%0A'
          4        ECHO                                                     ~1
   63     5        INIT_FCALL                                               'config_set'
          6        SEND_VAL                                                 'foo'
          7        SEND_VAL                                                 'baz'
          8        DO_FCALL                                      0          
   64     9        INIT_FCALL                                               'config_get'
         10        SEND_VAL                                                 'foo'
         11        DO_FCALL                                      0  $3      
         12        CONCAT                                           ~4      $3, '%0A'
         13        ECHO                                                     ~4
         14      > RETURN                                                   1

Function config_get_manager:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
Return found
Branch analysis from position: 9
filename:       /in/sWsq5
function name:  config_get_manager
number of ops:  11
compiled vars:  !0 = $configManager
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   BIND_STATIC                                              !0
   32     1        ISSET_ISEMPTY_CV                                 ~1      !0
          2        BOOL_NOT                                         ~2      ~1
          3      > JMPZ                                                     ~2, ->9
   33     4    >   NEW                                              $3      'ConfigManager'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !0, $3
   34     7        INIT_METHOD_CALL                                         !0, 'load'
          8        DO_FCALL                                      0          
   37     9    > > RETURN_BY_REF                                            !0
   38    10*     > RETURN_BY_REF                                            null

End of function config_get_manager

Function config_get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/sWsq5
function name:  config_get
number of ops:  13
compiled vars:  !0 = $key, !1 = $configManager
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   RECV                                             !0      
   42     1        BIND_STATIC                                              !1
   44     2        ISSET_ISEMPTY_CV                                 ~2      !1
          3        BOOL_NOT                                         ~3      ~2
          4      > JMPZ                                                     ~3, ->8
   45     5    >   INIT_FCALL                                               'config_get_manager'
          6        DO_FCALL                                      0  $4      
          7        ASSIGN_REF                                               !1, $4
   48     8    >   INIT_METHOD_CALL                                         !1, 'get'
          9        SEND_VAR_EX                                              !0
         10        DO_FCALL                                      0  $6      
         11      > RETURN                                                   $6
   49    12*     > RETURN                                                   null

End of function config_get

Function config_set:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 9
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/sWsq5
function name:  config_set
number of ops:  14
compiled vars:  !0 = $key, !1 = $value, !2 = $configManager
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   51     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   53     2        BIND_STATIC                                              !2
   55     3        ISSET_ISEMPTY_CV                                 ~3      !2
          4        BOOL_NOT                                         ~4      ~3
          5      > JMPZ                                                     ~4, ->9
   56     6    >   INIT_FCALL                                               'config_get_manager'
          7        DO_FCALL                                      0  $5      
          8        ASSIGN_REF                                               !2, $5
   59     9    >   INIT_METHOD_CALL                                         !2, 'set'
         10        SEND_VAR_EX                                              !0
         11        SEND_VAR_EX                                              !1
         12        DO_FCALL                                      0          
   60    13      > RETURN                                                   null

End of function config_set

Class ConfigManager:
Function configmanager:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sWsq5
function name:  ConfigManager
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   ECHO                                                     'Created%0A'
   10     1      > RETURN                                                   null

End of function configmanager

Function load:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sWsq5
function name:  load
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   ASSIGN_OBJ                                               'config'
          1        OP_DATA                                                  <array>
   15     2      > RETURN                                                   null

End of function load

Function get:
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 = 42) Position 1 = 9
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sWsq5
function name:  get
number of ops:  11
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
   19     1        FETCH_OBJ_IS                                     ~1      'config'
          2        ISSET_ISEMPTY_DIM_OBJ                         0          ~1, !0
          3      > JMPZ                                                     ~2, ->8
          4    >   FETCH_OBJ_R                                      ~3      'config'
          5        FETCH_DIM_R                                      ~4      ~3, !0
          6        QM_ASSIGN                                        ~5      ~4
          7      > JMP                                                      ->9
          8    >   QM_ASSIGN                                        ~5      null
          9    > > RETURN                                                   ~5
   20    10*     > RETURN                                                   null

End of function get

Function set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sWsq5
function name:  set
number of ops:  6
compiled vars:  !0 = $key, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   24     2        FETCH_OBJ_W                                      $2      'config'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
   25     5      > RETURN                                                   null

End of function set

End of class ConfigManager.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.14 ms | 1407 KiB | 18 Q