3v4l.org

run code in 500+ PHP versions simultaneously
<?php trait BarTrait { } class FooUsingBarTrait { use BarTrait; } if (trait_exists(BarTrait::class)) { class Foo extends FooUsingBarTrait { } } else { class Foo extends FooNotUsingBarTrait { } } $foo = new Foo(); var_dump( get_class($foo), class_parents(Foo::class) );
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 7
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fCLkt
function name:  (null)
number of ops:  20
compiled vars:  !0 = $foo
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   DECLARE_CLASS                                                'foousingbartrait'
   12     1        INIT_FCALL                                                   'trait_exists'
          2        SEND_VAL                                                     'BarTrait'
          3        DO_ICALL                                             $1      
          4      > JMPZ                                                         $1, ->7
   13     5    >   DECLARE_CLASS                                                'foo', 'foousingbartrait'
   12     6      > JMP                                                          ->8
   17     7    >   DECLARE_CLASS                                                'foo', 'foonotusingbartrait'
   22     8    >   NEW                                                  $2      'Foo'
          9        DO_FCALL                                          0          
         10        ASSIGN                                                       !0, $2
   24    11        INIT_FCALL                                                   'var_dump'
   25    12        GET_CLASS                                            ~5      !0
         13        SEND_VAL                                                     ~5
   26    14        INIT_FCALL                                                   'class_parents'
         15        SEND_VAL                                                     'Foo'
         16        DO_ICALL                                             $6      
         17        SEND_VAR                                                     $6
   24    18        DO_ICALL                                                     
   27    19      > RETURN                                                       1

Class BarTrait: [no user functions]
Class FooUsingBarTrait: [no user functions]
Class Foo: [no user functions]
Class Foo: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
158.72 ms | 2212 KiB | 15 Q