3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ConstructorException extends Exception {} class Foo extends ArrayObject { public function __construct( $arr = array(), $flags = 0, $iterator = 'FooIterator' ) { parent::__construct( $arr, $flags, $iterator ); } /** * @return ArrayIterator */ public function getIterator() { $class = $this->getIteratorClass(); return new $class($this); } } class FooIterator extends ArrayIterator { function __construct( $array = array(), $flags = 0 ) { throw new ConstructorException( 'HELLO WORLD' ); // I AM NEVER CALLED. parent::__construct( $array, $flags ); } } try { $f = new Foo( array( 1, 2, 3 ) ); $it = $f->getIterator(); if ( get_class( $it ) !== 'FooIterator' ) { throw new Exception( 'Expected iterator to be FooIterator.' ); } die( "FAIL\n" ); } catch ( ConstructorException $e ) { die( "PASS\n" ); } catch ( \Exception $e ) { die( sprintf( "ERROR: %s\n", $e->getMessage() ) ); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 14
Branch analysis from position: 10
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 14
1 jumps found. (Code = 79) Position 1 = -2
Found catch point at position: 16
Branch analysis from position: 16
2 jumps found. (Code = 107) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 19
2 jumps found. (Code = 107) Position 1 = 20, Position 2 = -2
Branch analysis from position: 20
1 jumps found. (Code = 79) Position 1 = -2
Found catch point at position: 19
Branch analysis from position: 19
filename:       /in/HnFQm
function name:  (null)
number of ops:  28
compiled vars:  !0 = $f, !1 = $it, !2 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   NEW                                              $3      'Foo'
          1        SEND_VAL_EX                                              <array>
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $3
   30     4        INIT_METHOD_CALL                                         !0, 'getIterator'
          5        DO_FCALL                                      0  $6      
          6        ASSIGN                                                   !1, $6
   31     7        GET_CLASS                                        ~8      !1
          8        IS_NOT_IDENTICAL                                         ~8, 'FooIterator'
          9      > JMPZ                                                     ~9, ->14
   32    10    >   NEW                                              $10     'Exception'
         11        SEND_VAL_EX                                              'Expected+iterator+to+be+FooIterator.'
         12        DO_FCALL                                      0          
         13      > THROW                                         0          $10
   34    14    > > EXIT                                                     'FAIL%0A'
         15*       JMP                                                      ->27
   35    16  E > > CATCH                                                    'ConstructorException', ->19
   36    17    > > EXIT                                                     'PASS%0A'
         18*       JMP                                                      ->27
   37    19  E > > CATCH                                       last         'Exception'
   38    20    >   INIT_FCALL                                               'sprintf'
         21        SEND_VAL                                                 'ERROR%3A+%25s%0A'
         22        INIT_METHOD_CALL                                         !2, 'getMessage'
         23        DO_FCALL                                      0  $12     
         24        SEND_VAR                                                 $12
         25        DO_ICALL                                         $13     
         26      > EXIT                                                     $13
   39    27*     > RETURN                                                   1

Class ConstructorException: [no user functions]
Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HnFQm
function name:  __construct
number of ops:  9
compiled vars:  !0 = $arr, !1 = $flags, !2 = $iterator
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV_INIT                                        !0      <array>
          1        RECV_INIT                                        !1      0
          2        RECV_INIT                                        !2      'FooIterator'
    8     3        INIT_STATIC_METHOD_CALL                                  
          4        SEND_VAR_EX                                              !0
          5        SEND_VAR_EX                                              !1
          6        SEND_VAR_EX                                              !2
          7        DO_FCALL                                      0          
    9     8      > RETURN                                                   null

End of function __construct

Function getiterator:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HnFQm
function name:  getIterator
number of ops:  10
compiled vars:  !0 = $class
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   INIT_METHOD_CALL                                         'getIteratorClass'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN                                                   !0, $1
   17     3        FETCH_CLASS                                   0  $3      !0
          4        NEW                                              $4      $3
          5        FETCH_THIS                                       $5      
          6        SEND_VAR_EX                                              $5
          7        DO_FCALL                                      0          
          8      > RETURN                                                   $4
   18     9*     > RETURN                                                   null

End of function getiterator

End of class Foo.

Class FooIterator:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/HnFQm
function name:  __construct
number of ops:  11
compiled vars:  !0 = $array, !1 = $flags
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV_INIT                                        !0      <array>
          1        RECV_INIT                                        !1      0
   23     2        NEW                                              $2      'ConstructorException'
          3        SEND_VAL_EX                                              'HELLO+WORLD'
          4        DO_FCALL                                      0          
          5      > THROW                                         0          $2
   24     6*       INIT_STATIC_METHOD_CALL                                  
          7*       SEND_VAR_EX                                              !0
          8*       SEND_VAR_EX                                              !1
          9*       DO_FCALL                                      0          
   25    10*     > RETURN                                                   null

End of function __construct

End of class FooIterator.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.78 ms | 1400 KiB | 15 Q