3v4l.org

run code in 500+ PHP versions simultaneously
<?php function &drupal_static($name, $default_value = NULL, $reset = FALSE) { static $data = array(), $default = array(); // First check if dealing with a previously defined static variable. if (isset($data [$name]) || array_key_exists($name, $data)) { // Non-NULL $name and both $data[$name] and $default[$name] statics exist. if ($reset) { // Reset pre-existing static variable to its default value. $data [$name] = $default [$name]; } return $data [$name]; } // Neither $data[$name] nor $default[$name] static variables exist. if (isset($name)) { if ($reset) { // Reset was called before a default is set and yet a variable must be // returned. return $data; } // First call with new non-NULL $name. Initialize a new static variable. $default [$name] = $data [$name] = $default_value; return $data [$name]; } // Reset all: ($name == NULL). This needs to be done one at a time so that // references returned by earlier invocations of drupal_static() also get // reset. foreach ($default as $name => $value) { $data [$name] = $value; } // As the function returns a reference, the return should always be a // variable. return $data; } $drupal_static_fast = &drupal_static('foo'); $missing = &$drupal_static_fast['missing']; var_dump(!isset($missing)); $missing = array(); var_dump(!isset($missing));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/11S72
function name:  (null)
number of ops:  18
compiled vars:  !0 = $drupal_static_fast, !1 = $missing
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   36     0  E >   INIT_FCALL                                                   'drupal_static'
          1        SEND_VAL                                                     'foo'
          2        DO_FCALL                                          0  $2      
          3        ASSIGN_REF                                                   !0, $2
   37     4        FETCH_DIM_W                                          $4      !0, 'missing'
          5        ASSIGN_REF                                                   !1, $4
   39     6        INIT_FCALL                                                   'var_dump'
          7        ISSET_ISEMPTY_CV                                     ~6      !1
          8        BOOL_NOT                                             ~7      ~6
          9        SEND_VAL                                                     ~7
         10        DO_ICALL                                                     
   41    11        ASSIGN                                                       !1, <array>
   43    12        INIT_FCALL                                                   'var_dump'
         13        ISSET_ISEMPTY_CV                                     ~10     !1
         14        BOOL_NOT                                             ~11     ~10
         15        SEND_VAL                                                     ~11
         16        DO_ICALL                                                     
         17      > RETURN                                                       1

Function drupal_static:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 16
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 14
Branch analysis from position: 11
Return found
Branch analysis from position: 14
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 26
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 20
Branch analysis from position: 19
Return found
Branch analysis from position: 20
Return found
Branch analysis from position: 26
2 jumps found. (Code = 77) Position 1 = 27, Position 2 = 32
Branch analysis from position: 27
2 jumps found. (Code = 78) Position 1 = 28, Position 2 = 32
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
Branch analysis from position: 32
Return found
Branch analysis from position: 32
Branch analysis from position: 9
filename:       /in/11S72
function name:  drupal_static
number of ops:  35
compiled vars:  !0 = $name, !1 = $default_value, !2 = $reset, !3 = $data, !4 = $default, !5 = $value
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
          1        RECV_INIT                                            !1      null
          2        RECV_INIT                                            !2      <false>
    4     3        BIND_STATIC                                                  !3
          4        BIND_STATIC                                                  !4
    6     5        ISSET_ISEMPTY_DIM_OBJ                             0  ~6      !3, !0
          6      > JMPNZ_EX                                             ~6      ~6, ->9
          7    >   ARRAY_KEY_EXISTS                                     ~7      !0, !3
          8        BOOL                                                 ~6      ~7
          9    > > JMPZ                                                         ~6, ->16
    8    10    > > JMPZ                                                         !2, ->14
   10    11    >   FETCH_DIM_R                                          ~9      !4, !0
         12        ASSIGN_DIM                                                   !3, !0
         13        OP_DATA                                                      ~9
   12    14    >   FETCH_DIM_W                                          $10     !3, !0
         15      > RETURN_BY_REF                                                $10
   15    16    >   ISSET_ISEMPTY_CV                                             !0
         17      > JMPZ                                                         ~11, ->26
   16    18    > > JMPZ                                                         !2, ->20
   19    19    > > RETURN_BY_REF                                                !3
   22    20    >   ASSIGN_DIM                                           ~13     !3, !0
         21        OP_DATA                                                      !1
         22        ASSIGN_DIM                                                   !4, !0
         23        OP_DATA                                                      ~13
   23    24        FETCH_DIM_W                                          $14     !3, !0
         25      > RETURN_BY_REF                                                $14
   28    26    > > FE_RESET_R                                           $15     !4, ->32
         27    > > FE_FETCH_R                                           ~16     $15, !5, ->32
         28    >   ASSIGN                                                       !0, ~16
   29    29        ASSIGN_DIM                                                   !3, !0
         30        OP_DATA                                                      !5
   28    31      > JMP                                                          ->27
         32    >   FE_FREE                                                      $15
   33    33      > RETURN_BY_REF                                                !3
   34    34*     > RETURN_BY_REF                                                null

End of function drupal_static

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
212.95 ms | 2748 KiB | 15 Q