...
I think the named and positional parameter options are confusing. I
like having a single point of entry. I'd vote for deprecating the
combination and at the same time keeping the parameters to a single
property name. I think it is simpler to keep one input parameters
name.
#Iterate over the function's defined parameter list
for($i = 0; $i < count($parametersForPrivateProcs[$privateProcName]); $i++){
$param = $parametersForPrivateProcs[$privateProcName][$i];
#Named request parameter matches
if(isset($requestParams[$param['name']])){
array_push($paramsToPass, $requestParams[$param['name']]);
unset($requestParams[$param['name']]);
}
#Numbered request parameter matches
else if(isset($requestParams[$i])){
array_push($paramsToPass, $requestParams[$i]);
unset($requestParams[$i]);
}
#Provide default for missing parameter if provided and if default values are preserved
# This ability is not specified by 1.1 WD as it requires that NULL be supplied as default
else if($this->defaultParametersPreserved && isset($param['default'])){
array_push($paramsToPass, $param['default']);
}
#Supply NULL for missing parameter
else {
array_push($paramsToPass, null);
}
}
I do not see much harm in requiring 1.1 servers *must* support named
params, as otherwise they are basically running a 1.0 server at that
point. But a point I won't bicker over in the slightest.
--
Matt (MPCM)
I like this idea. Objects with numeric keys look funny to me. If it
has a position, it should be in an array, and if it has a name, it
should be in a hash/object.
It introduces an inherent ambiguity - what if I have a named parameter
'2' in the third position. It becomes impossible to supply a value
for it! I admit its somewhat unusual to use numbers for names, but
should we actually restrict you from doing that by forcing a numeric
name to be a parameter? I say no.
> Do we need to have 2 names for the
> same concept of passing a structure of values to be applied as
> parameters?
Thats an interesting problem that complicates strongly typed
languages. That is, you'd have to have some kind of generic factory
or object for managing the retrieval of the parameters value as you
never know whether its going to be an object or an array. It bears
consideration, perhaps.
David
I also think we should drop using both and I'd go a step further...
How do people feel about multi purposing the params field be an array
(positional) or an object (named)? Do we need to have 2 names for the
same concept of passing a structure of values to be applied as
parameters?
--
Matt (MPCM)