3v4l.org

run code in 300+ PHP versions simultaneously
<?php function foo() { yield 1; yield 2; yield 3; yield 4; } $fooG = foo(); var_dump($fooG instanceof Traversable); array_walk($fooG, function ($foo) { var_dump($foo); }); iterator_apply($fooG, function ($foo) { var_dump($foo); });
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/n70qm
function name:  (null)
number of ops:  18
compiled vars:  !0 = $fooG
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL                                               'foo'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN                                                   !0, $1
   14     3        INIT_FCALL                                               'var_dump'
          4        INSTANCEOF                                       ~3      !0, 'Traversable'
          5        SEND_VAL                                                 ~3
          6        DO_ICALL                                                 
   16     7        INIT_FCALL                                               'array_walk'
          8        SEND_REF                                                 !0
          9        DECLARE_LAMBDA_FUNCTION                          ~5      [0]
   18    10        SEND_VAL                                                 ~5
   16    11        DO_ICALL                                                 
   20    12        INIT_FCALL                                               'iterator_apply'
         13        SEND_VAR                                                 !0
         14        DECLARE_LAMBDA_FUNCTION                          ~7      [1]
   22    15        SEND_VAL                                                 ~7
   20    16        DO_ICALL                                                 
   22    17      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/n70qm
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
   17     1        INIT_FCALL                                               'var_dump'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                                 
   18     4      > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/n70qm
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   21     1        INIT_FCALL                                               'var_dump'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                                 
   22     4      > RETURN                                                   null

End of Dynamic Function 1

Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/n70qm
function name:  foo
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   GENERATOR_CREATE                                         
    5     1        YIELD                                                    1
    6     2        YIELD                                                    2
    7     3        YIELD                                                    3
    8     4        YIELD                                                    4
    9     5      > GENERATOR_RETURN                                         

End of function foo

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.21 ms | 1442 KiB | 17 Q