in src/ClientResolver.php [400:460]
public function resolve(array $args, HandlerList $list)
{
$args['config'] = [];
foreach ($this->argDefinitions as $key => $a) {
// Add defaults, validate required values, and skip if not set.
if (!isset($args[$key])) {
if (isset($a['default'])) {
// Merge defaults in when not present.
if (is_callable($a['default'])
&& (
is_array($a['default'])
|| $a['default'] instanceof \Closure
)
) {
if ($a['default'] === self::DEFAULT_FROM_ENV_INI) {
$args[$key] = $a['default'](
$key,
$a['valid'][0] ?? 'string',
$args
);
} else {
$args[$key] = $a['default']($args);
}
} else {
$args[$key] = $a['default'];
}
} elseif (empty($a['required'])) {
continue;
} else {
$this->throwRequired($args);
}
}
// Validate the types against the provided value.
foreach ($a['valid'] as $check) {
if (isset(self::$typeMap[$check])) {
$fn = self::$typeMap[$check];
if ($fn($args[$key])) {
goto is_valid;
}
} elseif ($args[$key] instanceof $check) {
goto is_valid;
}
}
$this->invalidType($key, $args[$key]);
// Apply the value
is_valid:
if (isset($a['fn'])) {
$a['fn']($args[$key], $args, $list);
}
if ($a['type'] === 'config') {
$args['config'][$key] = $args[$key];
}
}
$this->_apply_client_context_params($args);
return $args;
}