From: Gunnar Wrobel Date: Thu, 11 Feb 2010 08:29:43 +0000 (+0100) Subject: Do not convert incorrect code types to integer automatically. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=be21276bd434285ab8900060f8a99353dad778b4;p=horde.git Do not convert incorrect code types to integer automatically. If $code is null it will be converted to 0 by the default Exception anyhow. If $code contains a string it will elicit a Fatal Error. But that is okay and should not be hidden. In nearly all cases where we provided a string as $code it was a simple coding error that needs to be fixed. There may be cases where the code is a value returned from another library. If it is uncertain that the library ensures that the return value is an integer then it can be cast into an integer before providing it to the exception. --- diff --git a/framework/Exception/lib/Horde/Exception.php b/framework/Exception/lib/Horde/Exception.php index 49f4a5cae..f849a7268 100644 --- a/framework/Exception/lib/Horde/Exception.php +++ b/framework/Exception/lib/Horde/Exception.php @@ -17,7 +17,7 @@ class Horde_Exception extends Exception * * @param mixed $message The exception message, a PEAR_Error * object, or an Exception object. - * @param mixed $code A numeric error code. + * @param int $code A numeric error code. */ public function __construct($message = null, $code = null) { @@ -30,12 +30,6 @@ class Horde_Exception extends Exception $message = $message->getMessage(); } - if (is_null($code)) { - $code = 0; - } else if (is_string($code)) { - $code = null; - } - parent::__construct($message, $code); } diff --git a/framework/Exception/lib/Horde/Exception/LastError.php b/framework/Exception/lib/Horde/Exception/LastError.php index cb30d6750..44c3a203e 100644 --- a/framework/Exception/lib/Horde/Exception/LastError.php +++ b/framework/Exception/lib/Horde/Exception/LastError.php @@ -23,7 +23,7 @@ class Horde_Exception_LastError extends Horde_Exception * * @param mixed $message The exception message, a PEAR_Error * object, or an Exception object. - * @param mixed $code_or_lasterror Either a numeric error code, or + * @param mixed $code_or_lasterror Either a numeric error code, or * an array from error_get_last(). */ public function __construct($message = null, $code_or_lasterror = null) diff --git a/framework/Exception/lib/Horde/Exception/NotFound.php b/framework/Exception/lib/Horde/Exception/NotFound.php index 8deeabffa..9b7dfa365 100644 --- a/framework/Exception/lib/Horde/Exception/NotFound.php +++ b/framework/Exception/lib/Horde/Exception/NotFound.php @@ -19,7 +19,7 @@ class Horde_Exception_NotFound extends Horde_Exception * * @param mixed $message The exception message, a PEAR_Error * object, or an Exception object. - * @param mixed $code A numeric error code. + * @param int $code A numeric error code. */ public function __construct($message = null, $code = null) { diff --git a/framework/Exception/lib/Horde/Exception/PermissionDenied.php b/framework/Exception/lib/Horde/Exception/PermissionDenied.php index 547f60662..31a53fa25 100644 --- a/framework/Exception/lib/Horde/Exception/PermissionDenied.php +++ b/framework/Exception/lib/Horde/Exception/PermissionDenied.php @@ -19,7 +19,7 @@ class Horde_Exception_PermissionDenied extends Horde_Exception * * @param mixed $message The exception message, a PEAR_Error * object, or an Exception object. - * @param mixed $code A numeric error code. + * @param int $code A numeric error code. */ public function __construct($message = null, $code = null) {