Hacker News new | ask | show | jobs
by chrisohara 5093 days ago
It's pretty negligible in the scheme of things. I was abusing PHP reflection a while back to add decorator support (https://github.com/chriso/Request) and used this pattern to reduce the cost:

    switch (count($args)) {
        case 0: $method(); break;
        case 1: $method($args[0]); break;
        case 2: $method($args[0], $args[1]); break;
        //etc
        default: call_user_func_array($method, $args); break;
    }