Kinda late static binding in PHP 5.2

In the process of porting the wp-routing package to PHP 5.2 (to be able to use it in compliance with WordPress minimum requirements) I’ve found myself missing PHP 5.3 late static binding capabilities.

PHP 5.3 code

Previous version of a class, leveraging late static binding, read

// static method in the parent class    
public static function staticMethod()
{
    ...

    // class hook to allow for extending classes to act on the route
    static::actOnRoute($routeId, $args);

    ...
}

that would have called the latest static implementation of the actOnRoute method.
In PHP 5.2 replacing the static keyword with self would, instead, call the own class implementation of the actOnRoute method.

Who’s extending whom

I’ve updated the tdd-helpers package adding the tad_Static to allow for a workaround to the problem like

// static method in the parent class    
public static function staticMethod()
{
    ...

    /**
     * Allow for extending classes to act on the route and circumvent PHP 5.2
     * lack of late static binding.
     * Extending classes should:
     *  - register as classes extending the WP_Routing_Route one using the tad_Static::setClassExtending method
     *  - implement the `actOnRoute` method
     */
    $class = tad_Static::getClassExtending(__CLASS__);
    if ($class and $class != __CLASS__) {
        if (method_exists($class, 'actOnRoute')) {
            call_user_func(array($class, 'actOnRoute'), $routeId, $args);
        }
    }

    ...
}

while that’s not at all as streamlined as the possibility offered by PHP 5.3 and limited it’s a good enough solution to the problem.

Probably related

I appreciate your input