Skip to content

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

@mariacha

Description

@mariacha

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions