3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Item { private $i; public function __construct($i) { $this->i = $i; } } class Foo { // private $arr = [[new Item(1)], [new Item(2)], [new Item(3)]]; private $arr = array(array(1), array(2), array(3)); public function getItems() { return $this->arr; } } class Wrapper { private $i; public function __construct($i) { $this->i = $i; } } $obj = new Foo(); foreach ($obj->getItems() as &$item) { $item = new Wrapper($item[0]); } print_r($obj); print_r(php_version());
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 7, Position 2 = 15
Branch analysis from position: 7
2 jumps found. (Code = 126) Position 1 = 8, Position 2 = 15
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/gIgHm
function name:  (null)
number of ops:  25
compiled vars:  !0 = $obj, !1 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   NEW                                              $2      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   35     3        INIT_METHOD_CALL                                         !0, 'getItems'
          4        DO_FCALL                                      0  $5      
          5        SEPARATE                                         $5      $5
          6      > FE_RESET_RW                                      $6      $5, ->15
          7    > > FE_FETCH_RW                                              $6, !1, ->15
   36     8    >   NEW                                              $7      'Wrapper'
          9        CHECK_FUNC_ARG                                           
         10        FETCH_DIM_FUNC_ARG                               $8      !1, 0
         11        SEND_FUNC_ARG                                            $8
         12        DO_FCALL                                      0          
         13        ASSIGN                                                   !1, $7
   35    14      > JMP                                                      ->7
         15    >   FE_FREE                                                  $6
   38    16        INIT_FCALL                                               'print_r'
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                                 
   39    19        INIT_FCALL                                               'print_r'
         20        INIT_FCALL_BY_NAME                                       'php_version'
         21        DO_FCALL                                      0  $12     
         22        SEND_VAR                                                 $12
         23        DO_ICALL                                                 
         24      > RETURN                                                   1

Class Item:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gIgHm
function name:  __construct
number of ops:  4
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    8     1        ASSIGN_OBJ                                               'i'
          2        OP_DATA                                                  !0
    9     3      > RETURN                                                   null

End of function __construct

End of class Item.

Class Foo:
Function getitems:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gIgHm
function name:  getItems
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   FETCH_OBJ_R                                      ~0      'arr'
          1      > RETURN                                                   ~0
   20     2*     > RETURN                                                   null

End of function getitems

End of class Foo.

Class Wrapper:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gIgHm
function name:  __construct
number of ops:  4
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   RECV                                             !0      
   29     1        ASSIGN_OBJ                                               'i'
          2        OP_DATA                                                  !0
   30     3      > RETURN                                                   null

End of function __construct

End of class Wrapper.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.5 ms | 1400 KiB | 15 Q