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

Optionals parameters shifted if missing in request #10

Open
vtexier opened this issue Aug 8, 2014 · 1 comment
Open

Optionals parameters shifted if missing in request #10

vtexier opened this issue Aug 8, 2014 · 1 comment

Comments

@vtexier
Copy link

vtexier commented Aug 8, 2014

Parameters are ordered by name, but optional parameters not present in request are not handled and the parameters are shifted.

With the function :

updateUser($password = null, $email = null, $receiveEmail = null)

request :

"params":{"receiveEmail":false, "email":"[email protected]"}

bad call :

updateUser("[email protected]", false)

The server ordered well the parameters, but miss the first optional one and call the function with the list receive.

Anyway, thanks for this great bundle,
Vincent.

@vtexier
Copy link
Author

vtexier commented Aug 8, 2014

I've solved the problem by modifying function checkMethod in Server.php.

foreach ($refParams as $arg)
        {

          $argName = $arg->getName();

          if (array_key_exists($argName, $named))
          {
            $params[] = $named[$argName];
            unset($named[$argName]);
          }
          else
          {
            if (!$arg->isOptional())
            {
                $res = false;
                break;
            } else {
                $params[] = $arg->getDefaultValue();
            }
          }

        }

Hope it helps!

@vtexier vtexier closed this as completed Aug 8, 2014
@vtexier vtexier reopened this Aug 8, 2014
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

1 participant