3v4l.org

run code in 300+ 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(); var_dump($x->current()); $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/YsrV3
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'
   38     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/YsrV3
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 = 19
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 17
Branch analysis from position: 17
2 jumps found. (Code = 107) Position 1 = 18, Position 2 = -2
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YsrV3
function name:  bar
number of ops:  23
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_FCALL                                               'var_dump'
          5        INIT_METHOD_CALL                                         !0, 'current'
          6        DO_FCALL                                      0  $4      
          7        SEND_VAR                                                 $4
          8        DO_ICALL                                                 
   27     9        INIT_METHOD_CALL                                         !0, 'next'
         10        DO_FCALL                                      0          
   29    11        INIT_FCALL                                               'var_dump'
         12        INIT_METHOD_CALL                                         !0, 'current'
         13        DO_FCALL                                      0  $7      
         14        SEND_VAR                                                 $7
         15        DO_ICALL                                                 
         16      > JMP                                                      ->19
   30    17  E > > CATCH                                       last         'Exception'
   31    18    >   ECHO                                                     '%5Bbar%28%29%5D+Caught+Exception%0A'
   33    19    >   ECHO                                                     'Unsetting+%24x%0A'
   34    20        UNSET_CV                                                 !0
   35    21        ECHO                                                     'Finishing+bar%28%29%0A'
   36    22      > 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/YsrV3
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/YsrV3
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/YsrV3
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/YsrV3
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/YsrV3
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/YsrV3
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/YsrV3
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.0.0


preferences:
169.52 ms | 1407 KiB | 17 Q