3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Collection implements Iterator { protected $array, $valid = false; public function __construct(array $a) { echo __METHOD__ . "\n"; $this->array = $a; } public function current() { echo __METHOD__ . "\n"; return current($this->array); } public function key() { echo __METHOD__ . "\n"; return key($this->array); } public function next() { echo __METHOD__ . "\n"; $this->valid = (false !== next($this->array)); } public function valid() { echo __METHOD__ . "\n"; return $this->valid; } public function rewind() { echo __METHOD__ . "\n"; $this->valid = (false !== reset($this->array)); } } class TestFilter extends FilterIterator { public function accept() { echo __METHOD__ . "\n"; throw new Exception("Failure in Accept"); } } $test = new TestFilter(new Collection(array(0))); try { foreach ($test as $item) { echo $item; } } catch (Exception $e) { var_dump($e->getMessage()); } ?> ===DONE===
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 12
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 12
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
Found catch point at position: 14
Branch analysis from position: 14
2 jumps found. (Code = 107) Position 1 = 15, Position 2 = -2
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jLMCn
function name:  (null)
number of ops:  22
compiled vars:  !0 = $test, !1 = $item, !2 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'collection'
   53     1        NEW                                              $3      'TestFilter'
          2        NEW                                              $4      'Collection'
          3        SEND_VAL_EX                                              <array>
          4        DO_FCALL                                      0          
          5        SEND_VAR_NO_REF_EX                                       $4
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !0, $3
   57     8      > FE_RESET_R                                       $8      !0, ->12
          9    > > FE_FETCH_R                                               $8, !1, ->12
   59    10    >   ECHO                                                     !1
   57    11      > JMP                                                      ->9
         12    >   FE_FREE                                                  $8
         13      > JMP                                                      ->20
   62    14  E > > CATCH                                       last         'Exception'
   64    15    >   INIT_FCALL                                               'var_dump'
         16        INIT_METHOD_CALL                                         !2, 'getMessage'
         17        DO_FCALL                                      0  $9      
         18        SEND_VAR                                                 $9
         19        DO_ICALL                                                 
   68    20    >   ECHO                                                     '%3D%3D%3DDONE%3D%3D%3D'
         21      > RETURN                                                   1

Class Collection:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jLMCn
function name:  __construct
number of ops:  5
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    9     1        ECHO                                                     'Collection%3A%3A__construct%0A'
   10     2        ASSIGN_OBJ                                               'array'
          3        OP_DATA                                                  !0
   11     4      > RETURN                                                   null

End of function __construct

Function current:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jLMCn
function name:  current
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   ECHO                                                     'Collection%3A%3Acurrent%0A'
   16     1        INIT_FCALL                                               'current'
          2        FETCH_OBJ_R                                      ~0      'array'
          3        SEND_VAL                                                 ~0
          4        DO_ICALL                                         $1      
          5      > RETURN                                                   $1
   17     6*     > 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/jLMCn
function name:  key
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   ECHO                                                     'Collection%3A%3Akey%0A'
   22     1        INIT_FCALL                                               'key'
          2        FETCH_OBJ_R                                      ~0      'array'
          3        SEND_VAL                                                 ~0
          4        DO_ICALL                                         $1      
          5      > RETURN                                                   $1
   23     6*     > 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/jLMCn
function name:  next
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   ECHO                                                     'Collection%3A%3Anext%0A'
   28     1        INIT_FCALL                                               'next'
          2        FETCH_OBJ_W                                      $1      'array'
          3        SEND_REF                                                 $1
          4        DO_ICALL                                         $2      
          5        TYPE_CHECK                                  1018  ~3      $2
          6        ASSIGN_OBJ                                               'valid'
          7        OP_DATA                                                  ~3
   29     8      > RETURN                                                   null

End of function next

Function valid:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jLMCn
function name:  valid
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   ECHO                                                     'Collection%3A%3Avalid%0A'
   34     1        FETCH_OBJ_R                                      ~0      'valid'
          2      > RETURN                                                   ~0
   35     3*     > RETURN                                                   null

End of function valid

Function rewind:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jLMCn
function name:  rewind
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   ECHO                                                     'Collection%3A%3Arewind%0A'
   40     1        INIT_FCALL                                               'reset'
          2        FETCH_OBJ_W                                      $1      'array'
          3        SEND_REF                                                 $1
          4        DO_ICALL                                         $2      
          5        TYPE_CHECK                                  1018  ~3      $2
          6        ASSIGN_OBJ                                               'valid'
          7        OP_DATA                                                  ~3
   41     8      > RETURN                                                   null

End of function rewind

End of class Collection.

Class TestFilter:
Function accept:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/jLMCn
function name:  accept
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   48     0  E >   ECHO                                                     'TestFilter%3A%3Aaccept%0A'
   49     1        NEW                                              $0      'Exception'
          2        SEND_VAL_EX                                              'Failure+in+Accept'
          3        DO_FCALL                                      0          
          4      > THROW                                         0          $0
   50     5*     > RETURN                                                   null

End of function accept

End of class TestFilter.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.55 ms | 1404 KiB | 23 Q