com php-langspec: Merge branch 'pull-request/135': spec/14-classes.md
[email protected] (Stanislav Malyshev) Fri, 01 Jan 2016 22:25:52 +0000
| Newsgroups | php.standards.cvs |
|---|---|
| Message-ID | <[email protected]> |
Commit: 0c77bc82fa41384f99110a18f4b6be1c9aa8e2df Author: Stanislav Malyshev <[email protected]> Fri, 1 Jan 2016 14:19:56 -0800 Parents: 2b64e7aa0d0907413f6abd0b23d450b8d1725e66 a9241b28db549639df01097e9fad69ad80cc3d78 Branches: master Link: http://git.php.net/?p=php-langspec.git;a=commitdiff;h=0c77bc82fa41384f99110a18f4b6be1c9aa8e2df Log: Merge branch 'pull-request/135' Changed paths: MM spec/14-classes.md Diff: diff --cc spec/14-classes.md index 7334f96,eebda61..788ffe6 --- a/spec/14-classes.md +++ b/spec/14-classes.md @@@ -2004,4 -2064,22 +2004,100 @@@ base class. An instance of this type i non-object is [converted to an object](08-conversions.md#converting-to-object-type), or the [member selection operator](10-expressions.md#member-selection-operator) is applied to `NULL`, `FALSE`, or an empty string. -###Class `TypeError` ++###Predefined Error Classes + ++PHP has a number of predefined classes that are used for error reporting. All these classes extend the base Error class. ++ ++####Class `Error` ++ ++This class is the base class for all internal PHP error exceptions. It is defined, as follows: ++ ++```PHP ++class Error implements Throwable ++{ ++} ++``` ++ ++**Defined elsewhere** ++ ++* [`Throwable`](15-interfaces.md#interface-throwable) ++ ++For information about the base interface, see [Throwable](15-interfaces.md#interface-Throwable). ++Note that the methods from Throwable are implemented as `final` in the Error class, which means ++the extending class can not override them. ++ ++####Class `ArithmeticError` ++ ++An instance of this class is thrown when an error occurs during certain mathematical operations. It is defined, as follows: ++ ++```PHP ++class ArithmeticError extends Error ++{ ++} ++``` ++ ++**Defined elsewhere** ++ ++* [`Error`](14-classes.md#class-error) ++ ++####Class `AssertionError` ++ ++An instance of this class is thrown when an assertion made via the intrinsic `assert` fails. The class type is defined, as follows: ++ ++```PHP ++class AssertionError extends Error ++{ ++} ++``` ++ ++**Defined elsewhere** ++ ++* [`Error`](14-classes.md#class-error) ++ ++####Class `DivisionByZeroError` ++ ++An instance of this class is thrown when an attempt is made to divide a number by zero using the remainder operators ([`%`](10-expressions.md#multiplicative-operators) and [`%=`](10-expressions.md#compound-assignment)). The class type is defined, as follows: ++ ++```PHP ++class DivisionByZeroError extends Error ++{ ++} ++``` ++ ++**Defined elsewhere** ++ ++* [`Error`](14-classes.md#class-error) ++ ++####Class `ParseError` ++ ++An instance of this class is thrown when an error occurs while parsing PHP code (such as when calling the intrinsic [`eval`](10-expressions.md#eval)). It is defined, as follows: ++ ++```PHP ++class ParseError extends Error ++{ ++} ++``` ++ ++**Defined elsewhere** ++ ++* [`Error`](14-classes.md#class-error) ++ ++####Class `TypeError` + + An instance of this class is thrown when any of the following occurs: + + * The type of an argument being passed to a function does not match its corresponding parameter’s declared type. + * The type of the value being returned from a function does not match the function’s declared return type. + * In [strict mode](13-functions.md#type-check-modes), an invalid number of arguments are passed to a library function. + + The class is defined, as follows: + + ```PHP + class TypeError extends Error + { + } + ``` + + **Defined elsewhere** + + * [`Error`](14-classes.md#class-error)