Skip to content

Instantly share code, notes, and snippets.

@hkulekci
Last active May 15, 2019
Embed
What would you like to do?
Name Trait Method to Override
<?php
trait A {
public static function dispatch()
{
var_dump(func_get_args());
return new static(...func_get_args());
}
}
class B {
use A {
dispatch as traitDispatch;
}
public static function dispatch()
{
return self::traitDispatch(...func_get_args());
}
}
B::dispatch('A', 'B');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment