3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { private $items = ['a','b','c','d']; public function dup() { $dupes = 0; foreach ($this->items as $key => $item) { $this->addItem($item . '2', $key + 1 + $dupes); $dupes++; } } private function addItem($newItem, $position) { array_splice($this->items, $position, 0, array($newItem)); } public function dump() { var_dump($this->items); } } $test = new Test(); $test->dup(); $test->dump();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bCJN0
function name:  (null)
number of ops:  8
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   NEW                                              $1      'Test'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   29     3        INIT_METHOD_CALL                                         !0, 'dup'
          4        DO_FCALL                                      0          
   30     5        INIT_METHOD_CALL                                         !0, 'dump'
          6        DO_FCALL                                      0          
          7      > RETURN                                                   1

Class Test:
Function dup:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 14
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 14
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/bCJN0
function name:  dup
number of ops:  16
compiled vars:  !0 = $dupes, !1 = $item, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   ASSIGN                                                   !0, 0
   10     1        FETCH_OBJ_R                                      ~4      'items'
          2      > FE_RESET_R                                       $5      ~4, ->14
          3    > > FE_FETCH_R                                       ~6      $5, !1, ->14
          4    >   ASSIGN                                                   !2, ~6
   11     5        INIT_METHOD_CALL                                         'addItem'
          6        CONCAT                                           ~8      !1, '2'
          7        SEND_VAL_EX                                              ~8
          8        ADD                                              ~9      !2, 1
          9        ADD                                              ~10     ~9, !0
         10        SEND_VAL_EX                                              ~10
         11        DO_FCALL                                      0          
   12    12        PRE_INC                                                  !0
   10    13      > JMP                                                      ->3
         14    >   FE_FREE                                                  $5
   14    15      > RETURN                                                   null

End of function dup

Function additem:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bCJN0
function name:  addItem
number of ops:  11
compiled vars:  !0 = $newItem, !1 = $position
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   17     2        INIT_FCALL                                               'array_splice'
          3        FETCH_OBJ_W                                      $2      'items'
          4        SEND_REF                                                 $2
          5        SEND_VAR                                                 !1
          6        SEND_VAL                                                 0
          7        INIT_ARRAY                                       ~3      !0
          8        SEND_VAL                                                 ~3
          9        DO_ICALL                                                 
   18    10      > RETURN                                                   null

End of function additem

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

End of function dump

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.83 ms | 1004 KiB | 15 Q