3v4l.org

run code in 300+ PHP versions simultaneously
<?php class FooNotUsingBarTrait { } 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 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/f77cn
function name:  (null)
number of ops:  19
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   INIT_FCALL                                               'trait_exists'
          1        SEND_VAL                                                 'BarTrait'
          2        DO_ICALL                                         $1      
          3      > JMPZ                                                     $1, ->6
    8     4    >   DECLARE_CLASS                                            'foo', 'foousingbartrait'
          5      > JMP                                                      ->7
   12     6    >   DECLARE_CLASS                                            'foo', 'foonotusingbartrait'
   17     7    >   NEW                                              $2      'Foo'
          8        DO_FCALL                                      0          
          9        ASSIGN                                                   !0, $2
   19    10        INIT_FCALL                                               'var_dump'
   20    11        GET_CLASS                                        ~5      !0
         12        SEND_VAL                                                 ~5
   21    13        INIT_FCALL                                               'class_parents'
         14        SEND_VAL                                                 'Foo'
         15        DO_ICALL                                         $6      
         16        SEND_VAR                                                 $6
         17        DO_ICALL                                                 
   22    18      > RETURN                                                   1

Class FooNotUsingBarTrait: [no user functions]
Class Foo: [no user functions]
Class Foo: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.6 ms | 1395 KiB | 19 Q