It seems to me that if I am trying to retrieve a value that does not
exist in the url, the default action/controller should return NULL
instead of FALSE. False implies that the value was set to false, rather
than null which is it.
Using this return value in code will break the following logic:
-- snip snip --
http://localhost/controller/some/public function someAction()
{
$id = $this->_getParam("id");
if (isset($id))
die("I am set");
}
-- snip --
will produce "I am set"
Is this a bug or by design?
My proposed change is below. And I do not know if this carries through
the rest of the framework, but unless the function is checking for a
boolean response, the default response for some value that has the
absence of existence should be NULL.
as per:
http://us3.php.net/manual/en/types.comparisons.php-ralph
/**
* Gets a parameter that was passed to this controller. If the
* parameter does not exist, FALSE will be return.
*
* If the parameter does not exist and $default is set, then
* $default will be returned instead of FALSE.
*
* @param string $paramName
* @param string $default
* @return boolean
*/
final protected function _getParam($paramName, $default=null)
{
if (array_key_exists($paramName, $this->_params)) {
return $this->_params[$paramName];
}
if ($default===null) {
return false; // <-- THIS SHOULD RETURN NULL
} else {
return $default;
}
}