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 Exception; } function key () { return 0; } function next () {} function rewind () {} function valid () { return true; } } function foo() { $f = new FooBar; yield from $f; } function bar() { echo "Starting bar()\n"; $x = foo(); var_dump($x->current()); try { $x->next(); } catch (Exception $e) {} var_dump($x->current()); try { $x->next(); } catch (Exception $e) {} var_dump($x->current()); try { $x->next(); } catch (Exception $e) {} 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/WM1ok
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'
   32     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 = 161) Position 1 = -2
filename:       /in/WM1ok
function name:  foo
number of ops:  7
compiled vars:  !0 = $f
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   GENERATOR_CREATE                                         
   14     1        NEW                                              $1      'FooBar'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   15     4        YIELD_FROM                                       ~4      !0
          5        FREE                                                     ~4
   16     6      > GENERATOR_RETURN                                         

End of function foo

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