<?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();