3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait CanWhatever { public function doStuff() { return 'result!'; } } class X { use CanWhatever; public function doStuff() { return 'overridden!'; } } $x = new X(); echo $x->doStuff(); echo "\n\$x has "; echo (class_uses($x, 'CanWhatever')) ? 'the trait' : 'no trait';
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Vin2H
function name:  (null)
number of ops:  18
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   DECLARE_CLASS                                            'x'
   21     1        NEW                                              $1      'X'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   22     4        INIT_METHOD_CALL                                         !0, 'doStuff'
          5        DO_FCALL                                      0  $4      
          6        ECHO                                                     $4
   23     7        ECHO                                                     '%0A%24x+has+'
   24     8        INIT_FCALL                                               'class_uses'
          9        SEND_VAR                                                 !0
         10        SEND_VAL                                                 'CanWhatever'
         11        DO_ICALL                                         $5      
         12      > JMPZ                                                     $5, ->15
         13    >   QM_ASSIGN                                        ~6      'the+trait'
         14      > JMP                                                      ->16
         15    >   QM_ASSIGN                                        ~6      'no+trait'
         16    >   ECHO                                                     ~6
         17      > RETURN                                                   1

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

End of function dostuff

End of class CanWhatever.

Class X:
Function dostuff:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Vin2H
function name:  doStuff
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E > > RETURN                                                   'overridden%21'
   18     1*     > RETURN                                                   null

End of function dostuff

End of class X.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.52 ms | 999 KiB | 14 Q