3v4l.org

run code in 500+ PHP versions simultaneously
<?php trait TraitA{ public function sayHello(){ echo 'Hello world!'; } } class ClassA{ use TraitA{ sayHello as protected;} } class ClassB{ use TraitA{ sayHello as private;} } $objA = new ClassA(); // $objA->sayHello(); // Fatal error: Call to protected method ClassA::sayHello() from context $objB = new ClassB(); // $objB->sayHello(); Fatal error: Call to private method ClassB::sayHello
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HiYns
function name:  (null)
number of ops:  9
compiled vars:  !0 = $objA, !1 = $objB
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    9     0  E >   DECLARE_CLASS                                                'classa'
   13     1        DECLARE_CLASS                                                'classb'
   17     2        NEW                                                  $2      'ClassA'
          3        DO_FCALL                                          0          
          4        ASSIGN                                                       !0, $2
   20     5        NEW                                                  $5      'ClassB'
          6        DO_FCALL                                          0          
          7        ASSIGN                                                       !1, $5
   21     8      > RETURN                                                       1

Class TraitA:
Function sayhello:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HiYns
function name:  sayHello
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    5     0  E >   ECHO                                                         'Hello+world%21'
    6     1      > RETURN                                                       null

End of function sayhello

End of class TraitA.

Class ClassA: [no user functions]
Class ClassB: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
166.54 ms | 2171 KiB | 13 Q