Multiple Aliases

<?php

trait t {
    function foo() {
        echo __METHOD__.PHP_EOL;
    }
}

class x {
    use t {
        foo as goo;
        foo as ioo;
    }
}

(new x)->foo(); // t::foo
(new x)->goo(); // t::foo
(new x)->ioo(); // t::foo

It is possible to rename an imported method from a trait, by using an alias name. It is also possible to import it several times, with different names.

And, unlike static/self, it is not possible for the called method to know how it was called.

See Also

PHP Features

Last updated: 14 July 2026