Skip to content

Commit 08545da

Browse files
loks0nclaude
andcommitted
Drop Http::setRoute()
The matched route is owned by the routing pipeline and lives in the per-request context. setRoute let arbitrary code overwrite it post-match without invalidating any other state — a footgun under coroutines and not used in production. Drop it; getRoute() remains as a read-only view. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 0fe0807 commit 08545da

2 files changed

Lines changed: 2 additions & 20 deletions

File tree

src/Http/Http.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,8 @@ public static function getRoutes(): array
405405
}
406406

407407
/**
408-
* Get the current route
408+
* Get the route matched for the current request, or null if none matched
409+
* yet (or no match was found). Populated by {@see Http::match()}.
409410
*/
410411
public function getRoute(): ?Route
411412
{
@@ -418,16 +419,6 @@ public function getRoute(): ?Route
418419
return $route instanceof Route ? $route : null;
419420
}
420421

421-
/**
422-
* Set the current route
423-
*/
424-
public function setRoute(Route $route): self
425-
{
426-
$this->context()->set('route', fn() => $route, []);
427-
428-
return $this;
429-
}
430-
431422
/**
432423
* Add Route
433424
*

tests/HttpTest.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -576,15 +576,6 @@ public function testCanHookThrowExceptions(): void
576576
$this->assertSame('(init)-y-def-x-def-(shutdown)', $result);
577577
}
578578

579-
public function testCanSetRoute(): void
580-
{
581-
$route = Http::get('/path');
582-
583-
$this->assertNull($this->http->getRoute());
584-
$this->http->setRoute($route);
585-
$this->assertSame($route, $this->http->getRoute());
586-
}
587-
588579
/**
589580
* @return \Iterator<string, array<int, string>>
590581
*/

0 commit comments

Comments
 (0)