Doc #53877 [Com]: SPL exception definitions are too ambiguous
| From: | nightstorm at tlen dot pl | Date: | Sat, 29 Jan 2011 14:31:34 +0000 |
| Subject: | Doc #53877 [Com]: SPL exception definitions are too ambiguous | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-5888@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=53877&edit=1
ID: 53877
Comment by: nightstorm at tlen dot pl
Reported by: nightstorm at tlen dot pl
Summary: SPL exception definitions are too ambiguous
Status: Assigned
Type: Documentation Problem
Package: Documentation problem
PHP Version: Irrelevant
Assigned To: salathe
Block user comment: N
Private report: N
New Comment:
Small update: the last point concerns LengthException, not
LogicException.
Previous Comments:
------------------------------------------------------------------------
[2011-01-29 09:54:28] nightstorm at tlen dot pl
Description:
------------
The SPL exception definitions in the official manual are too ambiguous.
As I talked to programmers, I noticed that many have problems with
understanding, how to use them properly. Furthermore, the older
documentation was more precise here and I think the authors should
seriously consider writing something more about them.
Here's, what should be added:
LogicException:
- Description: "Exception that represents error in the program logic.
This kind of exceptions should directly leed to a fix in your code."
- Source: copied from
http://www.php.net/~helly/php/ext/spl/classLogicException.html
OutOfRangeException:
- here, the description is completely wrong and makes no sense, if we
look at the class diagram. According to docs.php.net, this class should
extend RuntimeException, not LogicException.
- Valid description: "Exception thrown when an illegal index was
requested. This represents errors that should be detected at compile
time."
- Source: copied from
http://www.php.net/~helly/php/ext/spl/classOutOfRangeException.html
RangeException:
- identical case, as OutOfRangeException
- Valid description: "Exception thrown to indicate range errors during
program execution. Normally this means there was an arithmetic error
other than under/overflow. This is the runtime version of
DomainException."
- Source: copied from
http://www.php.net/~helly/php/ext/spl/classRangeException.html
OutOfBoundsException:
- "This represents errors that cannot be detected at compile time."
should be added, as it is in
http://docs.php.net/manual/en/class.outofboundsexception.php
UnexpectedValue:
- "Typically this happens when a function calls another function and
espects the return value to be of a certain type or value not including
arithmetic or buffer related errors." should be added, as it is in
http://docs.php.net/manual/en/class.unexpectedvalueexception.php
LogicException:
- The old documentation at http://www.php.net/~helly/php/ext/spl/ and
the official one say two completely different things about this
exception. Decide: does it mean that the specified length makes no sense
(i.e. because it is negative, and length cannot be negative), or that
some value has an invalid length, but then - why does it extend
LogicException in this case? If it extends, it should be clarified that
it should be only used on errors in the program logic, not to validate
user data.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=53877&edit=1