3v4l.org

run code in 300+ PHP versions simultaneously
<?php class t { private static $configs = ["a" => ["b" => "c"]]; public static function set($name, $value) { $keyParts = explode(".", $name); $config =& self::$configs; while (!empty($keyParts)) { $key = array_shift($keyParts); if (!isset($config[$key])) { $config[$key] = []; } if (empty($keyParts)) { $config[$key] = $value; return; } $config =& $config[$key]; //unset($config); //$config = $tconfig; } } private static function getKey($parts, $config = null) { if (is_null($config)) { $config =& self::$configs; } return self::findKey($parts, $config, true); } private static function findKey($keyParts, &$array, $returnValue = false) { $key = array_shift($keyParts); if (!isset($array[$key])) { return false; } if (empty($keyParts)) { if ($returnValue) { return $array[$key]; } return true; } return self::findKey($keyParts, $array[$key], $returnValue); } public static function dump() { var_dump(self::$configs); } } t::set("a.b", "vittu"); t::set("c", "perse"); t::dump();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/A6Q5f
function name:  (null)
number of ops:  11
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   62     0  E >   INIT_STATIC_METHOD_CALL                                  't', 'set'
          1        SEND_VAL                                                 'a.b'
          2        SEND_VAL                                                 'vittu'
          3        DO_FCALL                                      0          
   63     4        INIT_STATIC_METHOD_CALL                                  't', 'set'
          5        SEND_VAL                                                 'c'
          6        SEND_VAL                                                 'perse'
          7        DO_FCALL                                      0          
   65     8        INIT_STATIC_METHOD_CALL                                  't', 'dump'
          9        DO_FCALL                                      0          
         10      > RETURN                                                   1

Class t:
Function set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 10
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 24
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 10
Branch analysis from position: 29
Branch analysis from position: 10
Branch analysis from position: 19
filename:       /in/A6Q5f
function name:  set
number of ops:  30
compiled vars:  !0 = $name, !1 = $value, !2 = $keyParts, !3 = $config, !4 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    7     2        INIT_FCALL                                               'explode'
          3        SEND_VAL                                                 '.'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $5      
          6        ASSIGN                                                   !2, $5
    9     7        FETCH_STATIC_PROP_W          unknown             $7      'configs'
          8        ASSIGN_REF                                               !3, $7
   11     9      > JMP                                                      ->26
   12    10    >   INIT_FCALL                                               'array_shift'
         11        SEND_REF                                                 !2
         12        DO_ICALL                                         $9      
         13        ASSIGN                                                   !4, $9
   14    14        ISSET_ISEMPTY_DIM_OBJ                         0  ~11     !3, !4
         15        BOOL_NOT                                         ~12     ~11
         16      > JMPZ                                                     ~12, ->19
   15    17    >   ASSIGN_DIM                                               !3, !4
         18        OP_DATA                                                  <array>
   18    19    >   ISSET_ISEMPTY_CV                                         !2
         20      > JMPZ                                                     ~14, ->24
   19    21    >   ASSIGN_DIM                                               !3, !4
         22        OP_DATA                                                  !1
   20    23      > RETURN                                                   null
   23    24    >   FETCH_DIM_W                                      $16     !3, !4
         25        ASSIGN_REF                                               !3, $16
   11    26    >   ISSET_ISEMPTY_CV                                 ~18     !2
         27        BOOL_NOT                                         ~19     ~18
         28      > JMPNZ                                                    ~19, ->10
   27    29    > > RETURN                                                   null

End of function set

Function getkey:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
filename:       /in/A6Q5f
function name:  getKey
number of ops:  13
compiled vars:  !0 = $parts, !1 = $config
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
   30     2        TYPE_CHECK                                    2          !1
          3      > JMPZ                                                     ~2, ->6
   31     4    >   FETCH_STATIC_PROP_W          unknown             $3      'configs'
          5        ASSIGN_REF                                               !1, $3
   34     6    >   INIT_STATIC_METHOD_CALL                                  'findKey'
          7        SEND_VAR_EX                                              !0
          8        SEND_VAR_EX                                              !1
          9        SEND_VAL_EX                                              <true>
         10        DO_FCALL                                      0  $5      
         11      > RETURN                                                   $5
   36    12*     > RETURN                                                   null

End of function getkey

Function findkey:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 11
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 17
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 16
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/A6Q5f
function name:  findKey
number of ops:  25
compiled vars:  !0 = $keyParts, !1 = $array, !2 = $returnValue, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      <false>
   40     3        INIT_FCALL                                               'array_shift'
          4        SEND_REF                                                 !0
          5        DO_ICALL                                         $4      
          6        ASSIGN                                                   !3, $4
   42     7        ISSET_ISEMPTY_DIM_OBJ                         0  ~6      !1, !3
          8        BOOL_NOT                                         ~7      ~6
          9      > JMPZ                                                     ~7, ->11
   43    10    > > RETURN                                                   <false>
   46    11    >   ISSET_ISEMPTY_CV                                         !0
         12      > JMPZ                                                     ~8, ->17
   47    13    > > JMPZ                                                     !2, ->16
   48    14    >   FETCH_DIM_R                                      ~9      !1, !3
         15      > RETURN                                                   ~9
   50    16    > > RETURN                                                   <true>
   53    17    >   INIT_STATIC_METHOD_CALL                                  'findKey'
         18        SEND_VAR                                                 !0
         19        FETCH_DIM_W                                      $10     !1, !3
         20        SEND_REF                                                 $10
         21        SEND_VAR                                                 !2
         22        DO_FCALL                                      0  $11     
         23      > RETURN                                                   $11
   54    24*     > RETURN                                                   null

End of function findkey

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

End of function dump

End of class t.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.33 ms | 1396 KiB | 19 Q