symfony/symfony — pull request #3754 by Tobion (2012-04-01 11:15:39+00:00)
Title: [WIP] [Routing] fix bugs and improvements in RouteCollection

I found several bugs in RouteCollection and need @fabpot to review it.

1. The RouteCollection states

> it overrides existing routes with the same name defined in the instance or its children and parents.

But this is not true for `->addCollection()` but only for `->add()`. addCollection does not remove routes with the same name in its parents (only in its children). I don't think this is on purpose.
So I fixed it by making sure there can only be one route per name in all connected collections. This way we can also simplify `->get()` and `->remove()` and improve performance since
we can stop iterating recursively when we found the first and only route with a given name.
See `testSingleRouteWithGivenName` that fails in the old code but works now. The problem is that there is now a failing test case for `PhpMatcherDumperTest::testDump` after my change.
I haven't found out why this happens yet. Maybe you have a clue.

2. There was an bug with `$collection->addPrefix('0');` that didn't apply the starting slash. Fixed and test case added.

3. There is an issue with `->get()` that I also think is not intended. Currently it allows to access a sub-RouteCollection by specifing $name as array integer index.
But according to the PHPdoc you should only be allowed to receive a Route instance and not a RouteCollection.
See `testGet` that has a failing test case. I din't fix this behavior yet and need your opinion first.