3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Test { public $data = []; function __construct($data){ $this->data = $data; } function &getIterator() { foreach ($this->data as $key => &$value) { yield $key => $value; } } function printData() { foreach ($this->data as $key => $value) { echo($key . ':' . $value . PHP_EOL); } } } $data = array('one'=>'Curly', 'two'=>'Larry', 'three'=>'Moe'); $t = new Test($data); foreach ($t->getIterator() as $key => &$value) { $value = strtoupper($value); } $t->printData();
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 9, Position 2 = 16
Branch analysis from position: 9
2 jumps found. (Code = 126) Position 1 = 10, Position 2 = 16
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/oY8Iv
function name:  (null)
number of ops:  20
compiled vars:  !0 = $data, !1 = $t, !2 = $value, !3 = $key
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   25     0  E >   ASSIGN                                                       !0, <array>
   26     1        NEW                                                  $5      'Test'
          2        SEND_VAR_EX                                                  !0
          3        DO_FCALL                                          0          
          4        ASSIGN                                                       !1, $5
   28     5        INIT_METHOD_CALL                                             !1, 'getIterator'
          6        DO_FCALL                                          0  $8      
          7        SEPARATE                                             $8      $8
          8      > FE_RESET_RW                                          $9      $8, ->16
          9    > > FE_FETCH_RW                                          ~10     $9, !2, ->16
         10    >   ASSIGN                                                       !3, ~10
   29    11        INIT_FCALL                                                   'strtoupper'
         12        SEND_VAR                                                     !2
         13        DO_ICALL                                             $12     
         14        ASSIGN                                                       !2, $12
   28    15      > JMP                                                          ->9
         16    >   FE_FREE                                                      $9
   32    17        INIT_METHOD_CALL                                             !1, 'printData'
         18        DO_FCALL                                          0          
         19      > RETURN                                                       1

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

End of function __construct

Function getiterator:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
2 jumps found. (Code = 126) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 7
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 7
filename:       /in/oY8Iv
function name:  getIterator
number of ops:  9
compiled vars:  !0 = $value, !1 = $key
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   GENERATOR_CREATE                                             
   12     1        FETCH_OBJ_W                                          $2      'data'
          2      > FE_RESET_RW                                          $3      $2, ->7
          3    > > FE_FETCH_RW                                          ~4      $3, !0, ->7
          4    >   ASSIGN                                                       !1, ~4
   13     5        YIELD                                                        !0, !1
   12     6      > JMP                                                          ->3
          7    >   FE_FREE                                                      $3
   15     8      > GENERATOR_RETURN                                             

End of function getiterator

Function printdata:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 9
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 9
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/oY8Iv
function name:  printData
number of ops:  11
compiled vars:  !0 = $value, !1 = $key
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   19     0  E >   FETCH_OBJ_R                                          ~2      'data'
          1      > FE_RESET_R                                           $3      ~2, ->9
          2    > > FE_FETCH_R                                           ~4      $3, !0, ->9
          3    >   ASSIGN                                                       !1, ~4
   20     4        CONCAT                                               ~6      !1, '%3A'
          5        CONCAT                                               ~7      ~6, !0
          6        CONCAT                                               ~8      ~7, '%0A'
          7        ECHO                                                         ~8
   19     8      > JMP                                                          ->2
          9    >   FE_FREE                                                      $3
   22    10      > RETURN                                                       null

End of function printdata

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
150.77 ms | 1688 KiB | 9 Q