<?php

trait T
{
    public function m1()
    {
        return 42;
    }
}
class C
{
    public function m2()
    {
        return new class
        {
        };
    }
    use T;
}
$c = new C();
var_dump($c->m1());
示例#2
0
function f($str)
{
    $obj = new C();
    $obj->m1();
    return TRUE;
}