ZF-2464: Add return values to Zend_Controller_Router_* for method chaining

Description

The current implementation of Zend_Controller_Router objects does not specify a return value for many of the single-use methods, ie:


    public function addRoutes($routes) {
        foreach ($routes as $name => $route) {
            $this->addRoute($name, $route);
        }
    }

For the sake of method chaining, these functions should return the object ( return $this; ), permitting calls like the following:


Zend_Controller_Front::getInstance()->getRouter()
    ->addRoute('newRoute', new Zend_Controller_Router_Route(':module/:controller/:action'))
    ->addRoute('newRoute', new Zend_Controller_Router_Route(':controller/:action'))
    ->dispatch();

This currently throws a fatal error: Call to method "addRoute()" on a non-object.

Comments

RewrteRouter already allows method chaining:

http://framework.zend.com/svn/framework/…

Not to nit-pick, but addDefaultRoutes() still doesn't...

David, do you actually use this method? It's an internal method which generally should be protected.

Actually, no... My overridden version of the class did to imitate the functionality of the parent, but no worries. Is this fixed in a release version?