Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled notice exception instead of 404 handling #190

Open
idashevskii opened this issue Aug 26, 2022 · 4 comments
Open

Unhandled notice exception instead of 404 handling #190

idashevskii opened this issue Aug 26, 2022 · 4 comments

Comments

@idashevskii
Copy link

Notice: this issue is applicable for any HTTP method. Lets use PUT for example.
The Router throws 'Undefined index: PUT' PHP notice when there is attempt to call PUT method, and no PUT routers were registered.
Snipet to reproduce:

$router = new \Bramus\Router\Router();
$router->set404(function(){
    echo 'Not found';
});
$router->run();

Expected: 404 handler triggered without PHP notices.
Actual: PHP notice

@idashevskii
Copy link
Author

Already fixed in 968d04f but not yet released

@idashevskii idashevskii reopened this Aug 26, 2022
@idashevskii
Copy link
Author

Tested with 968d04f and it still not works.
There is no PHP notice, but 404 handler was not triggered.
Here is my observation

  1. $match argument is unused:
public function trigger404($match = null)
  1. Since 1-arg is unused, no need to pass it. So no needs in isset check, which is root reasoe of the issue.
if (isset($this->afterRoutes[$this->requestedMethod])) {
  $this->trigger404($this->afterRoutes[$this->requestedMethod]);
}

My suggestion is to revert/adjust 968d04f and just to remove transferred but unused argument to trigger404.

@bramus
Copy link
Owner

bramus commented Aug 26, 2022

I’m open to a PR that would fix this.

@liviocmachado
Copy link

Sorry for the question but do you know when the fix will be available?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants