|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-09-25 01:04 UTC] xianrenb at gmail dot com
Description: ------------ --- From manual page: http://www.php.net/class.errorexception --- I think doc bug #63125 (https://bugs.php.net/bug.php?id=63125) was closed as "Not a bug" without proper reasons, so I have to open a new bug. Please see the comments I made in the above bug report. I think the documentation should match the source code, as in https://github.com/php/php-src/blob/master/Zend/zend_exceptions.c (24 Sep, 2012), lines 221~228: /* {{{ 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: ---------------- Class synopsis documented as: ErrorException extends Exception { /* Properties */ protected int $severity ; /* Methods */ public __construct ([ string $message = "" [, int $code = 0 [, int $severity = E_ERROR [, string $filename = __FILE__ [, int $lineno = __LINE__ [, Exception $previous = NULL ]]]]]] ) final public int getSeverity ( void ) /* Inherited methods */ final public string Exception::getMessage ( void ) final public Exception Exception::getPrevious ( void ) final public mixed Exception::getCode ( void ) final public string Exception::getFile ( void ) final public int Exception::getLine ( void ) final public array Exception::getTrace ( void ) final public string Exception::getTraceAsString ( void ) public string Exception::__toString ( void ) final private void Exception::__clone ( void ) } Example documented as: <?php function exception_error_handler($errno, $errstr, $errfile, $errline ) { throw new ErrorException($errstr, 0, $errno, $errfile, $errline); } set_error_handler("exception_error_handler"); /* Trigger exception */ strpos(); ?> Actual result: -------------- Class synopsis documented as: ErrorException extends Exception { /* Properties */ protected int $severity ; /* Methods */ public __construct ([ string $message = "" [, int $code = 0 [, int $severity = 1 [, string $filename = __FILE__ [, int $lineno = __LINE__ [, Exception $previous = NULL ]]]]]] ) final public int getSeverity ( void ) /* Inherited methods */ final public string Exception::getMessage ( void ) final public Exception Exception::getPrevious ( void ) final public mixed Exception::getCode ( void ) final public string Exception::getFile ( void ) final public int Exception::getLine ( void ) final public array Exception::getTrace ( void ) final public string Exception::getTraceAsString ( void ) public string Exception::__toString ( void ) final private void Exception::__clone ( void ) } Example documented as: <?php function exception_error_handler($errno, $errstr, $errfile, $errline ) { throw new ErrorException($errstr, $errno, 0, $errfile, $errline); } set_error_handler("exception_error_handler"); /* Trigger exception */ strpos(); ?> PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 07:00:02 2025 UTC |
Hi, It is not clear what you are trying to report. Are you trying to say that the behaviour of the code is not good, or that the documentation does not reflect what the code does? Also 'Actual result' vs 'expected result' is only useful for code examples. If you think the documentation needs changing, please just specify the words that need changing. This code seems to be working fine and as expected for me: <?php try { throw new ErrorException("Exception message", 0, 75); } catch(ErrorException $e) { echo "This exception severity is: " . $e->getSeverity() . "\n"; } try { throw new ErrorException("Exception message", 0); } catch(ErrorException $e) { if ($e->getSeverity() == E_ERROR) { echo "Severity was same value as E_ERROR."; } } // Output // This exception severity is: 75 // Severity was same value as E_ERROR.