3v4l.org

run code in 500+ PHP versions simultaneously
<?php class It implements \IteratorAggregate { public $gen; public function getIterator(): \Generator { yield 'foo'; $this->gen->throw(new Exception()); var_dump("not executed"); } public function __destruct() { var_dump(__METHOD__); } } function f($it) { try { var_dump(new stdClass, yield from $it); } finally { var_dump(__FUNCTION__); } } $it = new It(); $gen = f($it); $it->gen = $gen; var_dump($gen->current()); $gen->next(); gc_collect_cycles(); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5pi53
function name:  (null)
number of ops:  20
compiled vars:  !0 = $it, !1 = $gen
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                                'it'
   28     1        NEW                                                  $2      'It'
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !0, $2
   29     4        INIT_FCALL                                                   'f'
          5        SEND_VAR                                                     !0
          6        DO_FCALL                                          0  $5      
          7        ASSIGN                                                       !1, $5
   30     8        ASSIGN_OBJ                                                   !0, 'gen'
          9        OP_DATA                                                      !1
   32    10        INIT_FCALL                                                   'var_dump'
         11        INIT_METHOD_CALL                                             !1, 'current'
         12        DO_FCALL                                          0  $8      
         13        SEND_VAR                                                     $8
         14        DO_ICALL                                                     
   33    15        INIT_METHOD_CALL                                             !1, 'next'
         16        DO_FCALL                                          0          
   35    17        INIT_FCALL                                                   'gc_collect_cycles'
         18        DO_ICALL                                                     
   37    19      > RETURN                                                       1

Function f:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 162) Position 1 = 11, Position 2 = 10
Branch analysis from position: 11
1 jumps found. (Code = 163) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/5pi53
function name:  f
number of ops:  16
compiled vars:  !0 = $it
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   20     0  E >   RECV                                                 !0      
          1        GENERATOR_CREATE                                             
   22     2        INIT_FCALL                                                   'var_dump'
          3        NEW                                                  $2      'stdClass'
          4        DO_FCALL                                          0          
          5        SEND_VAR                                                     $2
          6        YIELD_FROM                                           ~4      !0
          7        SEND_VAL                                                     ~4
          8        DO_ICALL                                                     
   23     9      > FAST_CALL                                                    ->11
         10    > > JMP                                                          ->15
   24    11    >   INIT_FCALL                                                   'var_dump'
         12        SEND_VAL                                                     'f'
         13        DO_ICALL                                                     
         14      > FAST_RET                                                     
   26    15    > > GENERATOR_RETURN                                             

End of function f

Class It:
Function getiterator:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/5pi53
function name:  getIterator
number of ops:  12
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   GENERATOR_CREATE                                             
    9     1        YIELD                                                        'foo'
   10     2        FETCH_OBJ_R                                          ~1      'gen'
          3        INIT_METHOD_CALL                                             ~1, 'throw'
          4        NEW                                                  $2      'Exception'
          5        DO_FCALL                                          0          
          6        SEND_VAR_NO_REF_EX                                           $2
          7        DO_FCALL                                          0          
   11     8        INIT_FCALL                                                   'var_dump'
          9        SEND_VAL                                                     'not+executed'
         10        DO_ICALL                                                     
   12    11      > GENERATOR_RETURN                                             

End of function getiterator

Function __destruct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5pi53
function name:  __destruct
number of ops:  4
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   16     0  E >   INIT_FCALL                                                   'var_dump'
          1        SEND_VAL                                                     'It%3A%3A__destruct'
          2        DO_ICALL                                                     
   17     3      > RETURN                                                       null

End of function __destruct

End of class It.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
158.27 ms | 1610 KiB | 16 Q