Doc #63157 [Fbk->Dup]: Wrong Documentation of Class ErrorException
| From: | salathe@php.net | Date: | Fri, 16 Jan 2015 20:18:39 +0000 |
| Subject: | Doc #63157 [Fbk->Dup]: Wrong Documentation of Class ErrorException | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-11860@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=63157&edit=1
ID: 63157
Updated by: salathe@php.net
Reported by: xianrenb at gmail dot com
Summary: Wrong Documentation of Class ErrorException
-Status: Feedback
+Status: Duplicate
Type: Documentation Problem
Package: Documentation problem
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Marking as duplicate of the closed bug #66362
The history goes as follows:
- 2008-04-14 Example added [1] using $errno for ErrorException::$severity property
- 2012-07-19 Example changed to use $errno for for ErrorException::$code
- 2012-09-21 Bug #63125 raised, requesting the example be changed back
- 2012-09-21 Bug #63125 closed as "not a bug" by author of change from July
- 2012-09-25 Bug #63157 (this bug!) raised instead of re-opening #63125
- 2013-12-27 Bug #66362 raised addressing the same issue
- 2013-12-29 Change from 2012-07-19 was reverted and #66362 closed
- 2015-01-16 Bug #63157 (this bug!) closed as dupe of #66362 :)
[1] http://svn.php.net/viewvc?view=revision&revision=257500
Previous Comments:
------------------------------------------------------------------------
[2015-01-16 20:18:39] salathe@php.net
Related To: Bug #63157
------------------------------------------------------------------------
[2015-01-16 20:18:39] salathe@php.net
Related To: Bug #63157
------------------------------------------------------------------------
[2015-01-16 18:12:47] danack@php.net
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.
------------------------------------------------------------------------
[2013-01-20 01:10:35] xianrenb at gmail dot com
I think a related doc bug #63158 (https://bugs.php.net/bug.php?id=63158) was
closed as "Not a bug" without a proper reason.
------------------------------------------------------------------------
[2012-09-26 02:42:46] xianrenb at gmail dot com
One may believe an instance of class ErrorException with $severity
being 20 is more severe than another instance with $severity being 10,
and argue that $severity of class ErrorException has nothing to do
with those error level constants, but I think this happens just
because the class is documented in a way that is not matching the
source code.
Please consider the case of using set_error_handler() without using
class ErrorException. How could one determine the severity of an
error? The only solution is to compare the $errno with error level
constants, i.e. E_* values. These error level constants are built-in
constants provided by the PHP system. If one wants to use his own
system of determining the severity of an error, he has to define those
constants somewhere. It is very clear that those are custom things,
and it is very strange to do so.
ErrorException is not a custom class. Anything dealing with it should
use what the PHP system provides. In other words, it only makes sense
to use $severity of class ErrorException by comparing it with error
level constants provided by the PHP system. And the source code says
the default value of $severity is E_ERROR.
It should be noted that larger value of $severity does not mean the
error is more severe. The same thinking should apply to error level
constants. However, $severity should represent the severity level of
an error, which could be determined by comparing $severity with error
level constants.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=63157
--
Edit this bug report at https://bugs.php.net/bug.php?id=63157&edit=1