where does $data come from in hook_tokens? In a custom module i have hook_tokens() implemented in order to create some custom tokens. What i realized is that some data is being declared as null but i don't know where this is happening. These values are coming from user input in a submitted web form. input from traditional web form fields do appear but input added through payment method fields are the ones appearing as null.

this is a small snip of what var_dump($data) shows:

$data['webform-submission']-&gt;payments[34]-&gt;contextObj-&gt;submission-&gt;data[47][0]"August"
$data['webform-submission']-&gt;payments[34]-&gt;contextObj-&gt;submission-&gt;data[46]array[1]
$data['webform-submission']-&gt;payments[34]-&gt;contextObj-&gt;submission-&gt;data[46][0]"1"
$data['webform-submission']-&gt;payments[34]-&gt;contextObj-&gt;submission-&gt;data[16]array[1]
$data['webform-submission']-&gt;payments[34]-&gt;contextObj-&gt;submission-&gt;data[16][0]null
$data['webform-submission']-&gt;payments[34]-&gt;contextObj-&gt;submission-&gt;data[35]array[1]


EDIT:

Thanks for the clarification on where $data comes from. I also realized that the hook i created (hook_token_info) is not being utilized. When i create a token i do not see it listed under Browse available tokens when i edit emails templates under the web form tab. Oddly hook_tokens is being called when i pass token_alter('[submission:custom:card_type]', array('submission'=>$card_type)) however the token is empty.
The $data is whatever is originally passed to the token_replace function by the process that's doing the token replacement.

The var itself is:


  An array of keyed objects. For simple replacement scenarios 'node', 'user', and others are common keys, with an accompanying node or user object being the value. Some token types, like 'site', do not require any explicit information from $data and can be replaced even if it is empty.


It's essentially just an array that's used to pass extra context to the token replacement, and it can contain anything at all. 

For example if you were writing a module that introduced a custom entity type, you could use this feature to pass an instance of that type in to be used in your own tokens.

In your specific case, it's presumably the Webform module that prepares that data array, so that would be where to look if something's missing. Or it could be a submodule if that's what you've used to provide the payment fields themselves.