Gavin Vess wrote:
- return null (as currently done)
- return an global NULL object (languages with both a NULL object and a
built-in type of null avoid the difficulty Gerrit highlighted)
- return false
- return an empty string (similar to a DB query)
- return a 2-tuple, where the second value denotes the type of the first
(e.g. [null, false], where false indicates the absence of a value)
- throw an error (j/k)
- don't distinguish between null values and the absence of a value (i.e.
rely on an additional isNull() method)
- ?
null is appropriate as its implementation in php seems to be correct. I
would strongly advise against false b/c false could be a valid value.
consider:
$logged_in = $this->getParam('userLoggedIn');
returning false answers the question that the user is not logged in
instead suggesting through the absense of a value that the user never
went through the login process. Semantics yes I know, but there are
other cases where false would be a valid response.
setParam($name, null) would clear a single value, though the array key
would still exist; I'll modify the code to unset if a null value is
passed.
For the sake of clarity, what you do above is the english language
equivalent of a double negative; this reads: set my param $name to not set.
Why not just have an unsetParam() & hasParam() method and complete the
accessor paradigm?
-ralph