Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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: 10 September 2026