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() { try { $f = new FooBar; yield from $f; } catch (Exception $e) { echo "[foo()] Caught Exception\n"; } } function bar() { echo "Starting bar()\n"; $x = foo(); try { var_dump($x->current()); } catch (Exception $e) { var_dump($x->key()); echo "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/2c5Aq
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'
   36     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 = 9
Branch analysis from position: 9
1 jumps found. (Code = 161) Position 1 = -2
Found catch point at position: 7
Branch analysis from position: 7
2 jumps found. (Code = 107) Position 1 = 8, Position 2 = -2
Branch analysis from position: 8
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/2c5Aq
function name:  foo
number of ops:  10
compiled vars:  !0 = $f, !1 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   GENERATOR_CREATE                                         
   15     1        NEW                                              $2      'FooBar'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
   16     4        YIELD_FROM                                       ~5      !0
          5        FREE                                                     ~5
          6      > JMP                                                      ->9
   17     7  E > > CATCH                                       last         'Exception'
   18     8    >   ECHO                                                     '%5Bfoo%28%29%5D+Caught+Exception%0A'
   20     9    > > GENERATOR_RETURN                                         

End of function foo

Function bar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 10
Branch analysis from position: 10
2 jumps found. (Code = 107) Position 1 = 11, Position 2 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2c5Aq
function name:  bar
number of ops:  21
compiled vars:  !0 = $x, !1 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   ECHO                                                     'Starting+bar%28%29%0A'
   24     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                                                 
          9      > JMP                                                      ->17
   27    10  E > > CATCH                                       last         'Exception'
   28    11    >   INIT_FCALL                                               'var_dump'
         12        INIT_METHOD_CALL                                         !0, 'key'
         13        DO_FCALL                                      0  $6      
         14        SEND_VAR                                                 $6
         15        DO_ICALL                                                 
   29    16        ECHO                                                     'Caught+Exception%0A'
   31    17    >   ECHO                                                     'Unsetting+%24x%0A'
   32    18        UNSET_CV                                                 !0
   33    19        ECHO                                                     'Finishing+bar%28%29%0A'
   34    20      > 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/2c5Aq
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/2c5Aq
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/2c5Aq
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/2c5Aq
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/2c5Aq
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/2c5Aq
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/2c5Aq
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:
171.9 ms | 1398 KiB | 17 Q