3v4l.org

run code in 300+ PHP versions simultaneously
<?php $generator = function (bool $return): Generator { if ($return) { return 1; } yield 2; return 3; }; $gen1 = $generator(false); $gen2 = $generator(true); var_dump($gen1->valid()); var_dump($gen2->valid()); var_dump($gen2->getReturn());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WUSJQ
function name:  (null)
number of ops:  26
compiled vars:  !0 = $generator, !1 = $gen1, !2 = $gen2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_LAMBDA_FUNCTION                          ~3      [0]
          1        ASSIGN                                                   !0, ~3
   11     2        INIT_DYNAMIC_CALL                                        !0
          3        SEND_VAL_EX                                              <false>
          4        DO_FCALL                                      0  $5      
          5        ASSIGN                                                   !1, $5
   12     6        INIT_DYNAMIC_CALL                                        !0
          7        SEND_VAL_EX                                              <true>
          8        DO_FCALL                                      0  $7      
          9        ASSIGN                                                   !2, $7
   14    10        INIT_FCALL                                               'var_dump'
         11        INIT_METHOD_CALL                                         !1, 'valid'
         12        DO_FCALL                                      0  $9      
         13        SEND_VAR                                                 $9
         14        DO_ICALL                                                 
   15    15        INIT_FCALL                                               'var_dump'
         16        INIT_METHOD_CALL                                         !2, 'valid'
         17        DO_FCALL                                      0  $11     
         18        SEND_VAR                                                 $11
         19        DO_ICALL                                                 
   17    20        INIT_FCALL                                               'var_dump'
         21        INIT_METHOD_CALL                                         !2, 'getReturn'
         22        DO_FCALL                                      0  $13     
         23        SEND_VAR                                                 $13
         24        DO_ICALL                                                 
         25      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 4
Branch analysis from position: 3
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 4
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/WUSJQ
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $return
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        GENERATOR_CREATE                                         
    4     2      > JMPZ                                                     !0, ->4
    5     3    > > GENERATOR_RETURN                                         
    7     4    >   YIELD                                                    2
    8     5      > GENERATOR_RETURN                                         
    9     6*     > GENERATOR_RETURN                                         

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.86 ms | 1001 KiB | 14 Q