3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait first_trait { function first_function() { echo "From First Trait\n"; } } trait second_trait { use first_trait, second_trait { second_trait::first_function insteadof first_function; first_trait::first_function as second_function; } function first_function() { echo "From Second Trait\n"; } } class first_class { use second_trait; } $obj = new first_class(); // Output: From Second Trait $obj->first_function(); // Output: From First Trait $obj->second_function();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Z1WFr
function name:  (null)
number of ops:  10
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   DECLARE_CLASS                                            'second_trait'
   23     1        DECLARE_CLASS                                            'first_class'
   28     2        NEW                                              $1      'first_class'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $1
   30     5        INIT_METHOD_CALL                                         !0, 'first_function'
          6        DO_FCALL                                      0          
   33     7        INIT_METHOD_CALL                                         !0, 'second_function'
          8        DO_FCALL                                      0          
          9      > RETURN                                                   1

Class first_trait:
Function first_function:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Z1WFr
function name:  first_function
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   ECHO                                                     'From+First+Trait%0A'
    7     1      > RETURN                                                   null

End of function first_function

End of class first_trait.

Class second_trait:
Function first_function:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Z1WFr
function name:  first_function
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   ECHO                                                     'From+Second+Trait%0A'
   20     1      > RETURN                                                   null

End of function first_function

End of class second_trait.

Class first_class: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.73 ms | 1397 KiB | 14 Q