xref: /php-src/Zend/zend_exceptions.stub.php (revision cd66fcc6)
1<?php
2
3/** @generate-class-entries */
4
5require "zend_constants.stub.php";
6
7interface Throwable extends Stringable
8{
9    public function getMessage(): string;
10
11    /** @return int */
12    public function getCode(); // TODO add proper type (i.e. int|string)
13
14    public function getFile(): string;
15
16    public function getLine(): int;
17
18    public function getTrace(): array;
19
20    public function getPrevious(): ?Throwable;
21
22    public function getTraceAsString(): string;
23}
24
25class Exception implements Throwable
26{
27    /**
28     * Intentionally left untyped for BC reasons
29     * @var string
30     */
31    protected $message = "";
32    private string $string = "";
33    /**
34     * Intentionally left untyped for BC reasons
35     * @var int
36     */
37    protected $code = 0;  // TODO add proper type (i.e. int|string)
38    protected string $file = "";
39    protected int $line = 0;
40    private array $trace = [];
41    private ?Throwable $previous = null;
42
43    private function __clone(): void {}
44
45    public function __construct(string $message = "", int $code = 0, ?Throwable $previous = null) {}
46
47    /** @tentative-return-type */
48    public function __wakeup(): void {}
49
50    final public function getMessage(): string {}
51
52    /** @return int */
53    final public function getCode() {} // TODO add proper type (i.e. int|string)
54
55    final public function getFile(): string {}
56
57    final public function getLine(): int {}
58
59    final public function getTrace(): array {}
60
61    final public function getPrevious(): ?Throwable {}
62
63    final public function getTraceAsString(): string {}
64
65    public function __toString(): string {}
66}
67
68class ErrorException extends Exception
69{
70    protected int $severity = E_ERROR;
71
72    public function __construct(
73        string $message = "",
74        int $code = 0,
75        int $severity = E_ERROR,
76        ?string $filename = null,
77        ?int $line = null,
78        ?Throwable $previous = null
79    ) {}
80
81    final public function getSeverity(): int {}
82}
83
84class Error implements Throwable
85{
86    /**
87     * Intentionally left untyped for BC reasons
88     * @var string
89     */
90    protected $message = "";
91    private string $string = "";
92    /**
93     * Intentionally left untyped for BC reasons
94     * @var int
95     */
96    protected $code = 0; // TODO add proper type (i.e. int|string)
97    protected string $file = "";
98    protected int $line;
99    private array $trace = [];
100    private ?Throwable $previous = null;
101
102    /** @implementation-alias Exception::__clone */
103    private function __clone(): void {}
104
105    /** @implementation-alias Exception::__construct */
106    public function __construct(string $message = "", int $code = 0, ?Throwable $previous = null) {}
107
108    /**
109     * @tentative-return-type
110     * @implementation-alias Exception::__wakeup
111     */
112    public function __wakeup(): void {}
113
114    /** @implementation-alias Exception::getMessage */
115    final public function getMessage(): string {}
116
117    /**
118     * @return int
119     * @implementation-alias Exception::getCode
120     */
121    final public function getCode() {}
122
123    /** @implementation-alias Exception::getFile */
124    final public function getFile(): string {}
125
126    /** @implementation-alias Exception::getLine */
127    final public function getLine(): int {}
128
129    /** @implementation-alias Exception::getTrace */
130    final public function getTrace(): array {}
131
132    /** @implementation-alias Exception::getPrevious */
133    final public function getPrevious(): ?Throwable {}
134
135    /** @implementation-alias Exception::getTraceAsString */
136    final public function getTraceAsString(): string {}
137
138    /** @implementation-alias Exception::__toString */
139    public function __toString(): string {}
140}
141
142class CompileError extends Error
143{
144}
145
146class ParseError extends CompileError
147{
148}
149
150class TypeError extends Error
151{
152}
153
154class ArgumentCountError extends TypeError
155{
156}
157
158class ValueError extends Error
159{
160}
161
162class ArithmeticError extends Error
163{
164}
165
166class DivisionByZeroError extends ArithmeticError
167{
168}
169
170class UnhandledMatchError extends Error
171{
172}
173
174class RequestParseBodyException extends Exception
175{
176}
177