Maybe I'm misinterpreting things, but there is a portion of the API.txt file that is confusing.

The section labeled "Altering the Replacement Values", last line of the last paragraph, says

"The return value will be an array with tokens as keys to their own replacement values."

When I first read this, I expected something like...

array(
  token1 => value1,
  token2 => value2,
  etc.
);

Instead, the array (or more accurately, object) looks like...

stdClass Object {
  [tokens] => array(
    [0] => mytoken1,
    [1] => mytoken2
  ),
  [values] => array(
    [0] => value1,
    [1] => value2,
  )
}

Perhaps the simplest way to handle this would be to add an example to the documentation.

Comments

greggles’s picture

Status: Active » Fixed

Quite confusing indeed! Thanks for noticing, submitting an issue, and providing an idea for how to fix it.

I do wonder if we should be returning an object or an array of arrays, though that's a question for a different issue.

Fixed - new text below.

"The return value will be an object containing one array of tokens
and one array of values as in this example:

stdClass Object {
[tokens] => array(
[0] => mytoken1,
[1] => mytoken2
),
[values] => array(
[0] => value1,
[1] => value2,
)
}"

Anonymous’s picture

Status: Fixed » Closed (fixed)