3v4l.org

run code in 300+ PHP versions simultaneously
<?php class TestParentClass { public function method() { print_r('Parent method'); print "\n"; } } trait TestTrait { public function method() { print_r('Trait method'); print "\n"; } } class TestChildClass extends TestParentClass { use TestTrait { TestTrait::method as methodAlias; TestParentClass::method insteadof TestTrait; } } $r = new ReflectionClass('TestChildClass'); var_dump($r->getTraitNames()); (new TestChildClass)->method(); (new TestChildClass)->methodAlias();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WSEvM
function name:  (null)
number of ops:  19
compiled vars:  !0 = $r
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   DECLARE_CLASS                                            'testchildclass', 'testparentclass'
   30     1        NEW                                              $1      'ReflectionClass'
          2        SEND_VAL_EX                                              'TestChildClass'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $1
   31     5        INIT_FCALL                                               'var_dump'
          6        INIT_METHOD_CALL                                         !0, 'getTraitNames'
          7        DO_FCALL                                      0  $4      
          8        SEND_VAR                                                 $4
          9        DO_ICALL                                                 
   34    10        NEW                                              $6      'TestChildClass'
         11        DO_FCALL                                      0          
         12        INIT_METHOD_CALL                                         $6, 'method'
         13        DO_FCALL                                      0          
   35    14        NEW                                              $9      'TestChildClass'
         15        DO_FCALL                                      0          
         16        INIT_METHOD_CALL                                         $9, 'methodAlias'
         17        DO_FCALL                                      0          
         18      > RETURN                                                   1

Class TestParentClass:
Function method:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WSEvM
function name:  method
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   INIT_FCALL                                               'print_r'
          1        SEND_VAL                                                 'Parent+method'
          2        DO_ICALL                                                 
    8     3        ECHO                                                     '%0A'
    9     4      > RETURN                                                   null

End of function method

End of class TestParentClass.

Class TestTrait:
Function method:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WSEvM
function name:  method
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   INIT_FCALL                                               'print_r'
          1        SEND_VAL                                                 'Trait+method'
          2        DO_ICALL                                                 
   17     3        ECHO                                                     '%0A'
   18     4      > RETURN                                                   null

End of function method

End of class TestTrait.

Class TestChildClass: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.44 ms | 1388 KiB | 17 Q