Skip to content

Commit 968d04f

Browse files
Check before handling 404 routes (bramus#187)
* Add `isset` check to `Router::run` 404 handling * Change some indentation slightly * Nest the 404 handler `isset` check
1 parent 6df7b67 commit 968d04f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/Bramus/Router/Router.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -289,12 +289,12 @@ public function run($callback = null)
289289

290290
// If no route was handled, trigger the 404 (if any)
291291
if ($numHandled === 0) {
292-
$this->trigger404($this->afterRoutes[$this->requestedMethod]);
293-
} // If a route was handled, perform the finish callback (if any)
294-
else {
295-
if ($callback && is_callable($callback)) {
296-
$callback();
292+
if (isset($this->afterRoutes[$this->requestedMethod])) {
293+
$this->trigger404($this->afterRoutes[$this->requestedMethod]);
297294
}
295+
} // If a route was handled, perform the finish callback (if any)
296+
elseif ($callback && is_callable($callback)) {
297+
$callback();
298298
}
299299

300300
// If it originally was a HEAD request, clean up after ourselves by emptying the output buffer

0 commit comments

Comments
 (0)