Skip to content
This repository has been archived by the owner on Dec 6, 2022. It is now read-only.

Controller method with custom params (ids parameters excluded) throw Too few arguments Exception #128

Open
brodalee opened this issue Aug 21, 2020 · 0 comments

Comments

@brodalee
Copy link

brodalee commented Aug 21, 2020

  • PHPRouter version: @Dev-Master
  • PHP version:
  • Exact steps to cause this issue
    1. Create abstraction of router.
    2. Create controllers with customs params and at first the id, and load routes.
    3. Sending request.
  • What you expected
    • e.g. I expected to get my custom params with the id.
  • What happened instead
    • e.g. Instead, I got Error : Too few arguments to function Controller::test(), 1 passed and exactly 2.

Hey ! just found an exception about controllers method params. I wanted to pass (with or without url dynamic param) some custom object like a RequestObject.

To fix it, in Router.php, match() function, just before call $routes->setParameters($params);, add

foreach ($routes->getParameters() as $parameter) {
           $params[] = $parameter;
}

Thanks you.

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

No branches or pull requests

1 participant