3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface SerializableInterface {} interface SomeResizableInterface {} interface IterableInterface {} trait SomeSerializableTrait {function t2() {} } trait SomeOtherSerializableTrait { function t() {} } class SomeContainer implements SerializableInterface, IterableInterface { use SomeSerializableTrait; } class SomeOtherContainer extends SomeContainer implements SomeResizableInterface { use SomeOtherSerializableTrait; } $someContainer = new SomeContainer; testInterface($someOtherContainer); $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) {} testInterface($someOtherContainer); testOtherTrait($someOtherContainer); testTrait($someOtherContainer);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0SOSA
function name:  (null)
number of ops:  37
compiled vars:  !0 = $someContainer, !1 = $someOtherContainer
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   DECLARE_CLASS                                            'somecontainer'
   13     1        DECLARE_CLASS                                            'someothercontainer', 'somecontainer'
   17     2        NEW                                              $2      'SomeContainer'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $2
   18     5        INIT_FCALL_BY_NAME                                       'testInterface'
          6        SEND_VAR_EX                                              !1
          7        DO_FCALL                                      0          
   19     8        NEW                                              $6      'SomeOtherContainer'
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !1, $6
   21    11        INIT_FCALL                                               'var_dump'
         12        INSTANCEOF                                       ~9      !0, 'SerializableInterface'
         13        SEND_VAL                                                 ~9
         14        DO_ICALL                                                 
   22    15        INIT_FCALL                                               'var_dump'
         16        INSTANCEOF                                       ~11     !1, 'SerializableInterface'
         17        SEND_VAL                                                 ~11
         18        DO_ICALL                                                 
   24    19        INIT_FCALL                                               'var_dump'
         20        INSTANCEOF                                       ~13     !1, 'SomeSerializableTrait'
         21        SEND_VAL                                                 ~13
         22        DO_ICALL                                                 
   25    23        INIT_FCALL                                               'var_dump'
         24        INSTANCEOF                                       ~15     !1, 'SomeOtherSerializableTrait'
         25        SEND_VAL                                                 ~15
         26        DO_ICALL                                                 
   32    27        INIT_FCALL                                               'testinterface'
         28        SEND_VAR                                                 !1
         29        DO_FCALL                                      0          
   33    30        INIT_FCALL                                               'testothertrait'
         31        SEND_VAR                                                 !1
         32        DO_FCALL                                      0          
   34    33        INIT_FCALL                                               'testtrait'
         34        SEND_VAR                                                 !1
         35        DO_FCALL                                      0          
         36      > RETURN                                                   1

Function testtrait:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0SOSA
function name:  testTrait
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 testtrait

Function testothertrait:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0SOSA
function name:  testOtherTrait
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 testothertrait

Function testinterface:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0SOSA
function name:  testInterface
number of ops:  2
compiled vars:  !0 = $container
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     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:
Function t2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0SOSA
function name:  t2
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E > > RETURN                                                   null

End of function t2

End of class SomeSerializableTrait.

Class SomeOtherSerializableTrait:
Function t:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0SOSA
function name:  t
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E > > RETURN                                                   null

End of function t

End of class SomeOtherSerializableTrait.

Class SomeContainer: [no user functions]
Class SomeOtherContainer: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.95 ms | 1394 KiB | 18 Q