X-Git-Url: https://yaffs.net/gitweb/?a=blobdiff_plain;f=vendor%2Fsymfony%2Frouting%2FRouteCollection.php;h=c42229af2878250fe5478eeb253d7c343a8052a2;hb=4e1bfbf98b844da83b18aca92ef00f11a4735806;hp=2ccb90f3b096696963487f9a726cf83d63341a48;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/vendor/symfony/routing/RouteCollection.php b/vendor/symfony/routing/RouteCollection.php index 2ccb90f3b..c42229af2 100644 --- a/vendor/symfony/routing/RouteCollection.php +++ b/vendor/symfony/routing/RouteCollection.php @@ -63,7 +63,7 @@ class RouteCollection implements \IteratorAggregate, \Countable */ public function count() { - return count($this->routes); + return \count($this->routes); } /** @@ -104,7 +104,7 @@ class RouteCollection implements \IteratorAggregate, \Countable /** * Removes a route or an array of routes by name from the collection. * - * @param string|array $name The route name or an array of route names + * @param string|string[] $name The route name or an array of route names */ public function remove($name) { @@ -116,10 +116,8 @@ class RouteCollection implements \IteratorAggregate, \Countable /** * Adds a route collection at the end of the current set by appending all * routes of the added collection. - * - * @param RouteCollection $collection A RouteCollection instance */ - public function addCollection(RouteCollection $collection) + public function addCollection(self $collection) { // we need to remove all routes with the same names first because just replacing them // would not place the new route at the end of the merged array @@ -128,7 +126,9 @@ class RouteCollection implements \IteratorAggregate, \Countable $this->routes[$name] = $route; } - $this->resources = array_merge($this->resources, $collection->getResources()); + foreach ($collection->getResources() as $resource) { + $this->addResource($resource); + } } /** @@ -234,7 +234,7 @@ class RouteCollection implements \IteratorAggregate, \Countable /** * Sets the schemes (e.g. 'https') all child routes are restricted to. * - * @param string|array $schemes The scheme or an array of schemes + * @param string|string[] $schemes The scheme or an array of schemes */ public function setSchemes($schemes) { @@ -246,7 +246,7 @@ class RouteCollection implements \IteratorAggregate, \Countable /** * Sets the HTTP methods (e.g. 'POST') all child routes are restricted to. * - * @param string|array $methods The method or an array of methods + * @param string|string[] $methods The method or an array of methods */ public function setMethods($methods) { @@ -262,16 +262,19 @@ class RouteCollection implements \IteratorAggregate, \Countable */ public function getResources() { - return array_unique($this->resources); + return array_values($this->resources); } /** - * Adds a resource for this collection. - * - * @param ResourceInterface $resource A resource instance + * Adds a resource for this collection. If the resource already exists + * it is not added. */ public function addResource(ResourceInterface $resource) { - $this->resources[] = $resource; + $key = (string) $resource; + + if (!isset($this->resources[$key])) { + $this->resources[$key] = $resource; + } } }