3v4l.org

run code in 300+ PHP versions simultaneously
<?php class SomeHelperClass { public $_arr = []; public function addValue($value, $key = null): void { if ($key !== null) { $this->_arr[$key] = $value; } elseif (!$this->_arr) { $this->_arr[] = $value; } else { $this->_arr[max(array_keys($this->_arr)) + 1] = $value; } } } $test = new SomeHelperClass; var_export($test->_arr); echo "\n"; $test->addValue(1); var_export($test->_arr); echo "\n"; $test->addValue(2); var_export($test->_arr); echo "\n"; $test->addValue(3, 4); var_export($test->_arr); echo "\n"; $test->addValue(4, 3); var_export($test->_arr); echo "\n"; $test->addValue(5); var_export($test->_arr);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LP3Qe
function name:  (null)
number of ops:  50
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   NEW                                              $1      'SomeHelperClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   19     3        INIT_FCALL                                               'var_export'
          4        FETCH_OBJ_R                                      ~4      !0, '_arr'
          5        SEND_VAL                                                 ~4
          6        DO_ICALL                                                 
   20     7        ECHO                                                     '%0A'
   22     8        INIT_METHOD_CALL                                         !0, 'addValue'
          9        SEND_VAL_EX                                              1
         10        DO_FCALL                                      0          
   23    11        INIT_FCALL                                               'var_export'
         12        FETCH_OBJ_R                                      ~7      !0, '_arr'
         13        SEND_VAL                                                 ~7
         14        DO_ICALL                                                 
   24    15        ECHO                                                     '%0A'
   26    16        INIT_METHOD_CALL                                         !0, 'addValue'
         17        SEND_VAL_EX                                              2
         18        DO_FCALL                                      0          
   27    19        INIT_FCALL                                               'var_export'
         20        FETCH_OBJ_R                                      ~10     !0, '_arr'
         21        SEND_VAL                                                 ~10
         22        DO_ICALL                                                 
   28    23        ECHO                                                     '%0A'
   30    24        INIT_METHOD_CALL                                         !0, 'addValue'
         25        SEND_VAL_EX                                              3
         26        SEND_VAL_EX                                              4
         27        DO_FCALL                                      0          
   31    28        INIT_FCALL                                               'var_export'
         29        FETCH_OBJ_R                                      ~13     !0, '_arr'
         30        SEND_VAL                                                 ~13
         31        DO_ICALL                                                 
   32    32        ECHO                                                     '%0A'
   34    33        INIT_METHOD_CALL                                         !0, 'addValue'
         34        SEND_VAL_EX                                              4
         35        SEND_VAL_EX                                              3
         36        DO_FCALL                                      0          
   35    37        INIT_FCALL                                               'var_export'
         38        FETCH_OBJ_R                                      ~16     !0, '_arr'
         39        SEND_VAL                                                 ~16
         40        DO_ICALL                                                 
   37    41        ECHO                                                     '%0A'
   39    42        INIT_METHOD_CALL                                         !0, 'addValue'
         43        SEND_VAL_EX                                              5
         44        DO_FCALL                                      0          
   40    45        INIT_FCALL                                               'var_export'
         46        FETCH_OBJ_R                                      ~19     !0, '_arr'
         47        SEND_VAL                                                 ~19
         48        DO_ICALL                                                 
         49      > RETURN                                                   1

Class SomeHelperClass:
Function addvalue:
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 = 26
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 15
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LP3Qe
function name:  addValue
number of ops:  27
compiled vars:  !0 = $value, !1 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
    8     2        TYPE_CHECK                                  1020          !1
          3      > JMPZ                                                     ~2, ->8
    9     4    >   FETCH_OBJ_W                                      $3      '_arr'
          5        ASSIGN_DIM                                               $3, !1
          6        OP_DATA                                                  !0
    8     7      > JMP                                                      ->26
   10     8    >   FETCH_OBJ_R                                      ~5      '_arr'
          9        BOOL_NOT                                         ~6      ~5
         10      > JMPZ                                                     ~6, ->15
   11    11    >   FETCH_OBJ_W                                      $7      '_arr'
         12        ASSIGN_DIM                                               $7
         13        OP_DATA                                                  !0
   10    14      > JMP                                                      ->26
   13    15    >   INIT_FCALL                                               'max'
         16        INIT_FCALL                                               'array_keys'
         17        FETCH_OBJ_R                                      ~10     '_arr'
         18        SEND_VAL                                                 ~10
         19        DO_ICALL                                         $11     
         20        SEND_VAR                                                 $11
         21        DO_ICALL                                         $12     
         22        ADD                                              ~13     $12, 1
         23        FETCH_OBJ_W                                      $9      '_arr'
         24        ASSIGN_DIM                                               $9, ~13
         25        OP_DATA                                                  !0
   15    26    > > RETURN                                                   null

End of function addvalue

End of class SomeHelperClass.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.39 ms | 1005 KiB | 16 Q