3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface SerializableInterface {} interface SomeResizableInterface {} interface IterableInterface {} trait SomeSerializableTrait {} trait SomeOtherSerializableTrait {} class SomeContainer implements SerializableInterface, IterableInterface { use SomeSerializableTrait; } class SomeOtherContainer extends SomeContainer implements SomeResizableInterface { use SomeOtherSerializableTrait; } $someContainer = new SomeContainer; $someOtherContainer = new SomeOtherContainer; var_dump($someContainer instanceof SerializableInterface); var_dump($someOtherContainer instanceof SerializableInterface); var_dump($someOtherContainer instanceof SomeSerializableTrait); var_dump($someOtherContainer instanceof SomeOtherSerializableTrait); // type hint it function testTrait(SomeSerializableTrait $container) {} function testOtherTrait(SomeOtherSerializableTrait $container) {} function testInterface(SomeResizableInterface $container) {} try {testInterface($someOtherContainer);} catch(Exception $e) {var_dump($e);} try {testOtherTrait($someOtherContainer);} catch(Exception $e) {var_dump($e);} try {testTrait($someOtherContainer);} catch(Exception $e) {var_dump($e);}
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 48
Branch analysis from position: 48
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 28
Branch analysis from position: 28
2 jumps found. (Code = 107) Position 1 = 29, Position 2 = -2
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
Found catch point at position: 36
Branch analysis from position: 36
2 jumps found. (Code = 107) Position 1 = 37, Position 2 = -2
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 48
Branch analysis from position: 48
Found catch point at position: 44
Branch analysis from position: 44
2 jumps found. (Code = 107) Position 1 = 45, Position 2 = -2
Branch analysis from position: 45
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/u0Bjs
function name:  (null)
number of ops:  49
compiled vars:  !0 = $someContainer, !1 = $someOtherContainer, !2 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   DECLARE_CLASS                                            'somecontainer'
   13     1        DECLARE_CLASS                                            'someothercontainer', 'somecontainer'
   17     2        NEW                                              $3      'SomeContainer'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $3
   18     5        NEW                                              $6      'SomeOtherContainer'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $6
   20     8        INIT_FCALL                                               'var_dump'
          9        INSTANCEOF                                       ~9      !0, 'SerializableInterface'
         10        SEND_VAL                                                 ~9
         11        DO_ICALL                                                 
   21    12        INIT_FCALL                                               'var_dump'
         13        INSTANCEOF                                       ~11     !1, 'SerializableInterface'
         14        SEND_VAL                                                 ~11
         15        DO_ICALL                                                 
   23    16        INIT_FCALL                                               'var_dump'
         17        INSTANCEOF                                       ~13     !1, 'SomeSerializableTrait'
         18        SEND_VAL                                                 ~13
         19        DO_ICALL                                                 
   24    20        INIT_FCALL                                               'var_dump'
         21        INSTANCEOF                                       ~15     !1, 'SomeOtherSerializableTrait'
         22        SEND_VAL                                                 ~15
         23        DO_ICALL                                                 
   31    24        INIT_FCALL                                               'testinterface'
         25        SEND_VAR                                                 !1
         26        DO_FCALL                                      0          
         27      > JMP                                                      ->32
         28  E > > CATCH                                       last         'Exception'
         29    >   INIT_FCALL                                               'var_dump'
         30        SEND_VAR                                                 !2
         31        DO_ICALL                                                 
   32    32    >   INIT_FCALL                                               'testothertrait'
         33        SEND_VAR                                                 !1
         34        DO_FCALL                                      0          
         35      > JMP                                                      ->40
         36  E > > CATCH                                       last         'Exception'
         37    >   INIT_FCALL                                               'var_dump'
         38        SEND_VAR                                                 !2
         39        DO_ICALL                                                 
   33    40    >   INIT_FCALL                                               'testtrait'
         41        SEND_VAR                                                 !1
         42        DO_FCALL                                      0          
         43      > JMP                                                      ->48
         44  E > > CATCH                                       last         'Exception'
         45    >   INIT_FCALL                                               'var_dump'
         46        SEND_VAR                                                 !2
         47        DO_ICALL                                                 
         48    > > RETURN                                                   1

Function testtrait:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/u0Bjs
function name:  testTrait
number of ops:  2
compiled vars:  !0 = $container
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   RECV                                             !0      
          1      > RETURN                                                   null

End of function testtrait

Function testothertrait:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/u0Bjs
function name:  testOtherTrait
number of ops:  2
compiled vars:  !0 = $container
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
          1      > RETURN                                                   null

End of function testothertrait

Function testinterface:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/u0Bjs
function name:  testInterface
number of ops:  2
compiled vars:  !0 = $container
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV                                             !0      
          1      > RETURN                                                   null

End of function testinterface

Class SerializableInterface: [no user functions]
Class SomeResizableInterface: [no user functions]
Class IterableInterface: [no user functions]
Class SomeSerializableTrait: [no user functions]
Class SomeOtherSerializableTrait: [no user functions]
Class SomeContainer: [no user functions]
Class SomeOtherContainer: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.54 ms | 1394 KiB | 18 Q