3v4l.org

run code in 300+ PHP versions simultaneously
<?php class FooManager { public function test($foos) { foreach ($foos as $item) { yield from $item->test(); } } } class Foo { public function test() { return $this->getGenerator(range(0, 10)); } public function getGenerator(array $items) { foreach ($items as $item) { yield $item; } } } $f = new FooManager; $foos = [new Foo,new Foo,new Foo,new Foo]; foreach ($f->test($foos) as $int) { var_dump($int); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 20, Position 2 = 25
Branch analysis from position: 20
2 jumps found. (Code = 78) Position 1 = 21, Position 2 = 25
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/30Ep8
function name:  (null)
number of ops:  27
compiled vars:  !0 = $f, !1 = $foos, !2 = $int
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   NEW                                              $3      'FooManager'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   29     3        NEW                                              $6      'Foo'
          4        DO_FCALL                                      0          
          5        INIT_ARRAY                                       ~8      $6
          6        NEW                                              $9      'Foo'
          7        DO_FCALL                                      0          
          8        ADD_ARRAY_ELEMENT                                ~8      $9
          9        NEW                                              $11     'Foo'
         10        DO_FCALL                                      0          
         11        ADD_ARRAY_ELEMENT                                ~8      $11
         12        NEW                                              $13     'Foo'
         13        DO_FCALL                                      0          
         14        ADD_ARRAY_ELEMENT                                ~8      $13
         15        ASSIGN                                                   !1, ~8
   31    16        INIT_METHOD_CALL                                         !0, 'test'
         17        SEND_VAR_EX                                              !1
         18        DO_FCALL                                      0  $16     
         19      > FE_RESET_R                                       $17     $16, ->25
         20    > > FE_FETCH_R                                               $17, !2, ->25
   32    21    >   INIT_FCALL                                               'var_dump'
         22        SEND_VAR                                                 !2
         23        DO_ICALL                                                 
   31    24      > JMP                                                      ->20
         25    >   FE_FREE                                                  $17
   33    26      > RETURN                                                   1

Class FooManager:
Function test:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 9
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 9
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 9
filename:       /in/30Ep8
function name:  test
number of ops:  11
compiled vars:  !0 = $foos, !1 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        GENERATOR_CREATE                                         
    6     2      > FE_RESET_R                                       $2      !0, ->9
          3    > > FE_FETCH_R                                               $2, !1, ->9
    7     4    >   INIT_METHOD_CALL                                         !1, 'test'
          5        DO_FCALL                                      0  $3      
          6        YIELD_FROM                                       ~4      $3
          7        FREE                                                     ~4
    6     8      > JMP                                                      ->3
          9    >   FE_FREE                                                  $2
    9    10      > GENERATOR_RETURN                                         

End of function test

End of class FooManager.

Class Foo:
Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/30Ep8
function name:  test
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     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
   18     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/30Ep8
function name:  getGenerator
number of ops:  8
compiled vars:  !0 = $items, !1 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
          1        GENERATOR_CREATE                                         
   21     2      > FE_RESET_R                                       $2      !0, ->6
          3    > > FE_FETCH_R                                               $2, !1, ->6
   22     4    >   YIELD                                                    !1
   21     5      > JMP                                                      ->3
          6    >   FE_FREE                                                  $2
   24     7      > GENERATOR_RETURN                                         

End of function getgenerator

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.75 ms | 1400 KiB | 17 Q