Skip to content

Commit d076aff

Browse files
committed
refactor(router): remove leftover allowDuplicate parameter
1 parent 313e8a4 commit d076aff

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

packages/router/src/Routing/Construction/RouteTreeNode.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,13 @@ public function findOrCreateNodeForSegment(string $routeSegment): self
5050
return $this->dynamicPaths[$regexRouteSegment] ??= self::createDynamicRouteNode($regexRouteSegment);
5151
}
5252

53-
public function setTargetRoute(MarkedRoute $markedRoute, bool $allowDuplicate = false): void
53+
public function setTargetRoute(MarkedRoute $markedRoute): void
5454
{
55-
if ($this->targetRoute !== null && ! $allowDuplicate) {
55+
if ($this->targetRoute !== null) {
5656
throw new DuplicateRouteException($markedRoute->route);
5757
}
5858

59-
if ($this->targetRoute === null) {
60-
$this->targetRoute = $markedRoute;
61-
}
59+
$this->targetRoute = $markedRoute;
6260
}
6361

6462
private static function convertDynamicSegmentToRegex(string $uriPart): string

packages/router/src/Routing/Construction/RoutingTree.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,20 @@ public function add(MarkedRoute $markedRoute): void
2828
$node = $this->roots[$method->value] ??= RouteTreeNode::createRootRoute();
2929

3030
$segments = $markedRoute->route->split();
31-
$hasOptionalParams = false;
3231

3332
// Traverse the tree and find the node for each route segment
3433
foreach ($segments as $index => $routeSegment) {
3534
$isOptional = $this->isOptionalSegment($routeSegment);
3635

3736
if ($isOptional) {
38-
$hasOptionalParams = true;
39-
$node->setTargetRoute($markedRoute, allowDuplicate: true);
37+
$node->setTargetRoute($markedRoute);
4038
$routeSegment = $this->stripOptionalMarker($routeSegment);
4139
}
4240

4341
$node = $node->findOrCreateNodeForSegment($routeSegment);
4442
}
4543

46-
$node->setTargetRoute($markedRoute, allowDuplicate: $hasOptionalParams);
44+
$node->setTargetRoute($markedRoute);
4745
}
4846

4947
private function isOptionalSegment(string $segment): bool

0 commit comments

Comments
 (0)