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

When using closure routing calling getController() on the route throws an error #49267

Closed
Orrison opened this issue Dec 6, 2023 · 2 comments · Fixed by #49269
Closed

When using closure routing calling getController() on the route throws an error #49267

Orrison opened this issue Dec 6, 2023 · 2 comments · Fixed by #49269
Labels

Comments

@Orrison
Copy link
Contributor

Orrison commented Dec 6, 2023

Laravel Version

10.34.2

PHP Version

8.2.8

Database Driver & Version

Postgres

Description

If a route is registered and provides a closure rather than a Controller, calling getController() on the \Illuminate\Routing\Route instance will result in an error.

This is because getControllerClass() returns null, which is then passed into $this->container->make() on the next lines.

The expected behavior here seems like it should return null instead of attempting the make() and throwing an error. That would prevent issues with calling this method and return an expected result of null for the return.

I can submit a PR if y'all consider this a viable fix.

Steps To Reproduce

  1. Register a route with a closure instead of a Controller.
  2. Call getController() on a \Illuminate\Routing\Route instance for that route.
@crynobone

This comment was marked as outdated.

@Orrison
Copy link
Contributor Author

Orrison commented Dec 7, 2023

Thank you for the consideration and the fix @crynobone!

taylorotwell pushed a commit that referenced this issue Dec 7, 2023
…ng (#49269)

closure based route

fixes #49267

Signed-off-by: Mior Muhammad Zaki <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants