3v4l.org

run code in 300+ PHP versions simultaneously
<?php spl_autoload_register(function ($class) { if ('Foo' === $class) { class Foo implements Foointerface {} } elseif ('Foointerface' === $class) { throw new Exception(); } }); try { // First call triggers the autoloader new Foo(); } catch (Exception $e) {} // For the second call Foo is loaded var_dump(new Foo()); // Even though it’s missing the interface var_dump(new Foo() instanceof Foointerface); var_dump((new ReflectionClass('Foo'))->getInterfaces());
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 = 62) 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
filename:       /in/s8ti7
function name:  (null)
number of ops:  29
compiled vars:  !0 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'spl_autoload_register'
          1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fs8ti7%3A3%240'
    9     2        SEND_VAL                                                 ~1
          3        DO_ICALL                                                 
   13     4        NEW                                              $3      'Foo'
          5        DO_FCALL                                      0          
          6        FREE                                                     $3
          7      > JMP                                                      ->9
   14     8  E > > CATCH                                       last         'Exception'
   17     9    >   INIT_FCALL                                               'var_dump'
         10        NEW                                              $5      'Foo'
         11        DO_FCALL                                      0          
         12        SEND_VAR                                                 $5
         13        DO_ICALL                                                 
   20    14        INIT_FCALL                                               'var_dump'
         15        NEW                                              $8      'Foo'
         16        DO_FCALL                                      0          
         17        INSTANCEOF                                       ~10     $8, 'Foointerface'
         18        SEND_VAL                                                 ~10
         19        DO_ICALL                                                 
   21    20        INIT_FCALL                                               'var_dump'
         21        NEW                                              $12     'ReflectionClass'
         22        SEND_VAL_EX                                              'Foo'
         23        DO_FCALL                                      0          
         24        INIT_METHOD_CALL                                         $12, 'getInterfaces'
         25        DO_FCALL                                      0  $14     
         26        SEND_VAR                                                 $14
         27        DO_ICALL                                                 
         28      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2Fs8ti7%3A3%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 10
Branch analysis from position: 7
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 10
filename:       /in/s8ti7
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $class
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        IS_IDENTICAL                                             !0, 'Foo'
          2      > JMPZ                                                     ~1, ->5
    5     3    >   DECLARE_CLASS                                            'foo'
          4      > JMP                                                      ->10
    6     5    >   IS_IDENTICAL                                             !0, 'Foointerface'
          6      > JMPZ                                                     ~2, ->10
    7     7    >   NEW                                              $3      'Exception'
          8        DO_FCALL                                      0          
          9      > THROW                                         0          $3
    9    10    > > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fs8ti7%3A3%240

Class Foo: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.8 ms | 1400 KiB | 17 Q