3v4l.org

run code in 500+ PHP versions simultaneously
<?php class FooBar implements Iterator { function __construct() { echo "Constructing new FooBar\n"; } function __destruct() { echo "Destructing FooBar\n"; } function current () { throw new Exception; } function key () { return 0; } function next () {} function rewind () {} function valid () { return true; } } function foo() { yield 1; try { $f = new FooBar; yield from $f; } catch (Exception $e) { echo "[foo()] Caught Exception\n"; } } function bar() { echo "Starting bar()\n"; $x = foo(); $x->next(); try { var_dump($x->current()); } catch (Exception $e) { echo "[bar()] Caught Exception\n"; } echo "Unsetting \$x\n"; unset($x); echo "Finishing bar()\n"; } bar();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oMdRC
function name:  (null)
number of ops:  4
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                                'foobar'
   37     1        INIT_FCALL                                                   'bar'
          2        DO_FCALL                                          0          
          3      > RETURN                                                       1

Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
1 jumps found. (Code = 161) Position 1 = -2
Found catch point at position: 8
Branch analysis from position: 8
2 jumps found. (Code = 107) Position 1 = 9, Position 2 = -2
Branch analysis from position: 9
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/oMdRC
function name:  foo
number of ops:  11
compiled vars:  !0 = $f, !1 = $e
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   13     0  E >   GENERATOR_CREATE                                             
   14     1        YIELD                                                        1
   16     2        NEW                                                  $3      'FooBar'
          3        DO_FCALL                                          0          
          4        ASSIGN                                                       !0, $3
   17     5        YIELD_FROM                                           ~6      !0
          6        FREE                                                         ~6
          7      > JMP                                                          ->10
   18     8  E > > CATCH                                           last         'Exception'
   19     9    >   ECHO                                                         '%5Bfoo%28%29%5D+Caught+Exception%0A'
   21    10    > > GENERATOR_RETURN                                             

End of function foo

Function bar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 12
Branch analysis from position: 12
2 jumps found. (Code = 107) Position 1 = 13, Position 2 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oMdRC
function name:  bar
number of ops:  18
compiled vars:  !0 = $x, !1 = $e
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   24     0  E >   ECHO                                                         'Starting+bar%28%29%0A'
   25     1        INIT_FCALL                                                   'foo'
          2        DO_FCALL                                          0  $2      
          3        ASSIGN                                                       !0, $2
   26     4        INIT_METHOD_CALL                                             !0, 'next'
          5        DO_FCALL                                          0          
   28     6        INIT_FCALL                                                   'var_dump'
          7        INIT_METHOD_CALL                                             !0, 'current'
          8        DO_FCALL                                          0  $5      
          9        SEND_VAR                                                     $5
         10        DO_ICALL                                                     
         11      > JMP                                                          ->14
   29    12  E > > CATCH                                           last         'Exception'
   30    13    >   ECHO                                                         '%5Bbar%28%29%5D+Caught+Exception%0A'
   32    14    >   ECHO                                                         'Unsetting+%24x%0A'
   33    15        UNSET_CV                                                     !0
   34    16        ECHO                                                         'Finishing+bar%28%29%0A'
   35    17      > RETURN                                                       null

End of function bar

Class FooBar:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oMdRC
function name:  __construct
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    4     0  E >   ECHO                                                         'Constructing+new+FooBar%0A'
          1      > RETURN                                                       null

End of function __construct

Function __destruct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oMdRC
function name:  __destruct
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    5     0  E >   ECHO                                                         'Destructing+FooBar%0A'
          1      > RETURN                                                       null

End of function __destruct

Function current:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/oMdRC
function name:  current
number of ops:  4
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    6     0  E >   NEW                                                  $0      'Exception'
          1        DO_FCALL                                          0          
          2      > THROW                                             0          $0
          3*     > RETURN                                                       null

End of function current

Function key:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oMdRC
function name:  key
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E > > RETURN                                                       0
          1*     > RETURN                                                       null

End of function key

Function next:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oMdRC
function name:  next
number of ops:  1
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    8     0  E > > RETURN                                                       null

End of function next

Function rewind:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oMdRC
function name:  rewind
number of ops:  1
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    9     0  E > > RETURN                                                       null

End of function rewind

Function valid:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oMdRC
function name:  valid
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   10     0  E > > RETURN                                                       <true>
          1*     > RETURN                                                       null

End of function valid

End of class FooBar.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
236.97 ms | 3084 KiB | 16 Q