Doc #63158 [NEW]: Misleading Example of ErrorException::getSeverity()
| From: | xianrenb at gmail dot com | Date: | Tue, 25 Sep 2012 01:26:14 +0000 |
| Subject: | Doc #63158 [NEW]: Misleading Example of ErrorException::getSeverity() | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-8902@lists.php.net to get a copy of this message | ||
From: xianrenb at gmail dot com
Operating system:
PHP version: Irrelevant
Package: Documentation problem
Bug Type: Documentation Problem
Bug description:Misleading Example of ErrorException::getSeverity()
Description:
------------
---
From manual page:
http://www.php.net/errorexception.getseverity#refsect1-
errorexception.getseverity-examples
---
According to
https://github.com/php/php-src/blob/master/Zend/zend_exceptions.c
(Sep
24, 2012), lines 221~258 and 327~335 (especially 221~228), the method
getSeverity() should return error level constants as described in
http://hk.php.net/manual/en/errorfunc.constants.php
, as the default
value of $severity is exactly E_ERROR:
/* {{{ proto ErrorException::__construct(string message, int code, int
severity [, string filename [, int lineno [, Exception previous]]])
ErrorException constructor */
ZEND_METHOD(error_exception, __construct)
{
char *message = NULL, *filename = NULL;
long code = 0, severity = E_ERROR, lineno;
zval *object, *previous = NULL;
int argc = ZEND_NUM_ARGS(), message_len, filename_len;
Expected result:
----------------
<?php
try {
throw new ErrorException("Exception message", 0, E_USER_NOTICE);
} catch(ErrorException $e) {
echo "This exception severity is: " . $e->getSeverity();
}
?>
Actual result:
--------------
<?php
try {
throw new ErrorException("Exception message", 0, 75);
} catch(ErrorException $e) {
echo "This exception severity is: " . $e->getSeverity();
}
?>
--
Edit bug report at https://bugs.php.net/bug.php?id=63158&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=63158&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=63158&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=63158&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=63158&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=63158&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=63158&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=63158&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=63158&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=63158&r=support
Expected behavior: https://bugs.php.net/fix.php?id=63158&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=63158&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=63158&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=63158&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63158&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=63158&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=63158&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=63158&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=63158&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=63158&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=63158&r=mysqlcfg