3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public function test() { return $this->getGenerator(range(0, 10)); } public function getGenerator(array $items) { foreach ($items as $item) { yield $item; } } } $f = new Foo; foreach ($f->test() as $item) { var_dump($item); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 11
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 11
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/Ckgt7
function name:  (null)
number of ops:  13
compiled vars:  !0 = $f, !1 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   NEW                                              $2      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   18     3        INIT_METHOD_CALL                                         !0, 'test'
          4        DO_FCALL                                      0  $5      
          5      > FE_RESET_R                                       $6      $5, ->11
          6    > > FE_FETCH_R                                               $6, !1, ->11
   19     7    >   INIT_FCALL                                               'var_dump'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                                 
   18    10      > JMP                                                      ->6
         11    >   FE_FREE                                                  $6
   20    12      > RETURN                                                   1

Class Foo:
Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ckgt7
function name:  test
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   INIT_METHOD_CALL                                         'getGenerator'
          1        INIT_FCALL                                               'range'
          2        SEND_VAL                                                 0
          3        SEND_VAL                                                 10
          4        DO_ICALL                                         $0      
          5        SEND_VAR_NO_REF_EX                                       $0
          6        DO_FCALL                                      0  $1      
          7      > RETURN                                                   $1
    7     8*     > RETURN                                                   null

End of function test

Function getgenerator:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 6
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 6
filename:       /in/Ckgt7
function name:  getGenerator
number of ops:  8
compiled vars:  !0 = $items, !1 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        GENERATOR_CREATE                                         
   10     2      > FE_RESET_R                                       $2      !0, ->6
          3    > > FE_FETCH_R                                               $2, !1, ->6
   11     4    >   YIELD                                                    !1
   10     5      > JMP                                                      ->3
          6    >   FE_FREE                                                  $2
   13     7      > GENERATOR_RETURN                                         

End of function getgenerator

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.67 ms | 1400 KiB | 17 Q