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

Set default value of token to [] in \Mailchimp\Mailchimp::request #103

Open
mariacha opened this issue Aug 5, 2021 · 0 comments
Open

Set default value of token to [] in \Mailchimp\Mailchimp::request #103

mariacha opened this issue Aug 5, 2021 · 0 comments

Comments

@mariacha
Copy link
Contributor

mariacha commented Aug 5, 2021

Right now the documentation says it should be an array, but it's set as NULL.

/**
   * Makes a request to the Mailchimp API.
   *
   * @param string $method
   *   The REST method to use when making the request.
   * @param string $path
   *   The API path to request.
   * **@param array $tokens**
   *   Associative array of tokens and values to replace in the path.
   * @param array $parameters
   *   Associative array of parameters to send in the request body.
   * @param bool $batch
   *   TRUE if this request should be added to pending batch operations.
   * @param bool $returnAssoc
   *   TRUE to return Mailchimp API response as an associative array.
   *
   * @return mixed
   *   Object or Array if $returnAssoc is TRUE.
   *
   * @throws MailchimpAPIException
   */
  public function request($method, $path, **$tokens = NULL**, $parameters = [], $batch = FALSE, $returnAssoc = FALSE) {
    if (!empty($tokens)) {
      foreach ($tokens as $key => $value) {
        $path = str_replace('{' . $key . '}', $value, $path);
      }
    }

If the parameter is changed to an empty array, the if (!empty($tokens)) { part can come off.

This would involve updating many of the calls to the request function as well, since they currently pass "NULL" instead of an empty array.

Alternatively, I suppose we could update the docs to say @param array|NULL $tokens maybe?

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