1#![allow(clippy::unwrap_used)]
4
5use crate::ffi::{
6 zend_ce_aggregate, zend_ce_argument_count_error, zend_ce_arithmetic_error, zend_ce_arrayaccess,
7 zend_ce_compile_error, zend_ce_countable, zend_ce_division_by_zero_error, zend_ce_error,
8 zend_ce_error_exception, zend_ce_exception, zend_ce_iterator, zend_ce_parse_error,
9 zend_ce_serializable, zend_ce_stringable, zend_ce_throwable, zend_ce_traversable,
10 zend_ce_type_error, zend_ce_unhandled_match_error, zend_ce_value_error,
11 zend_standard_class_def,
12};
13
14use super::ClassEntry;
15
16pub fn stdclass() -> &'static ClassEntry {
22 unsafe { zend_standard_class_def.as_ref() }.unwrap()
23}
24
25pub fn throwable() -> &'static ClassEntry {
31 unsafe { zend_ce_throwable.as_ref() }.unwrap()
32}
33
34pub fn exception() -> &'static ClassEntry {
40 unsafe { zend_ce_exception.as_ref() }.unwrap()
41}
42
43pub fn error() -> &'static ClassEntry {
49 unsafe { zend_ce_error.as_ref() }.unwrap()
50}
51
52pub fn error_exception() -> &'static ClassEntry {
58 unsafe { zend_ce_error_exception.as_ref() }.unwrap()
59}
60
61pub fn compile_error() -> &'static ClassEntry {
67 unsafe { zend_ce_compile_error.as_ref() }.unwrap()
68}
69
70pub fn parse_error() -> &'static ClassEntry {
76 unsafe { zend_ce_parse_error.as_ref() }.unwrap()
77}
78
79pub fn type_error() -> &'static ClassEntry {
85 unsafe { zend_ce_type_error.as_ref() }.unwrap()
86}
87
88pub fn argument_count_error() -> &'static ClassEntry {
94 unsafe { zend_ce_argument_count_error.as_ref() }.unwrap()
95}
96
97pub fn value_error() -> &'static ClassEntry {
103 unsafe { zend_ce_value_error.as_ref() }.unwrap()
104}
105
106pub fn arithmetic_error() -> &'static ClassEntry {
112 unsafe { zend_ce_arithmetic_error.as_ref() }.unwrap()
113}
114
115pub fn division_by_zero_error() -> &'static ClassEntry {
121 unsafe { zend_ce_division_by_zero_error.as_ref() }.unwrap()
122}
123
124pub fn unhandled_match_error() -> &'static ClassEntry {
130 unsafe { zend_ce_unhandled_match_error.as_ref() }.unwrap()
131}
132
133pub fn traversable() -> &'static ClassEntry {
139 unsafe { zend_ce_traversable.as_ref() }.unwrap()
140}
141
142pub fn aggregate() -> &'static ClassEntry {
148 unsafe { zend_ce_aggregate.as_ref() }.unwrap()
149}
150
151pub fn iterator() -> &'static ClassEntry {
157 unsafe { zend_ce_iterator.as_ref() }.unwrap()
158}
159
160pub fn arrayaccess() -> &'static ClassEntry {
166 unsafe { zend_ce_arrayaccess.as_ref() }.unwrap()
167}
168
169pub fn serializable() -> &'static ClassEntry {
175 unsafe { zend_ce_serializable.as_ref() }.unwrap()
176}
177
178pub fn countable() -> &'static ClassEntry {
184 unsafe { zend_ce_countable.as_ref() }.unwrap()
185}
186
187pub fn stringable() -> &'static ClassEntry {
193 unsafe { zend_ce_stringable.as_ref() }.unwrap()
194}
195
196#[cfg(test)]
197#[cfg(feature = "embed")]
198mod tests {
199 use super::*;
200 use crate::embed::Embed;
201
202 #[test]
203 fn test_stdclass() {
204 Embed::run(|| {
205 let stdclass = stdclass();
206 assert_eq!(stdclass.name(), Some("stdClass"));
207 });
208 }
209
210 #[test]
211 fn test_throwable() {
212 Embed::run(|| {
213 let throwable = throwable();
214 assert_eq!(throwable.name(), Some("Throwable"));
215 });
216 }
217
218 #[test]
219 fn test_exception() {
220 Embed::run(|| {
221 let exception = exception();
222 assert_eq!(exception.name(), Some("Exception"));
223 });
224 }
225
226 #[test]
227 fn test_error_exception() {
228 Embed::run(|| {
229 let error_exception = error_exception();
230 assert_eq!(error_exception.name(), Some("ErrorException"));
231 });
232 }
233
234 #[test]
235 fn test_compile_error() {
236 Embed::run(|| {
237 let compile_error = compile_error();
238 assert_eq!(compile_error.name(), Some("CompileError"));
239 });
240 }
241
242 #[test]
243 fn test_parse_error() {
244 Embed::run(|| {
245 let parse_error = parse_error();
246 assert_eq!(parse_error.name(), Some("ParseError"));
247 });
248 }
249
250 #[test]
251 fn test_type_error() {
252 Embed::run(|| {
253 let type_error = type_error();
254 assert_eq!(type_error.name(), Some("TypeError"));
255 });
256 }
257
258 #[test]
259 fn test_argument_count_error() {
260 Embed::run(|| {
261 let argument_count_error = argument_count_error();
262 assert_eq!(argument_count_error.name(), Some("ArgumentCountError"));
263 });
264 }
265
266 #[test]
267 fn test_value_error() {
268 Embed::run(|| {
269 let value_error = value_error();
270 assert_eq!(value_error.name(), Some("ValueError"));
271 });
272 }
273
274 #[test]
275 fn test_arithmetic_error() {
276 Embed::run(|| {
277 let arithmetic_error = arithmetic_error();
278 assert_eq!(arithmetic_error.name(), Some("ArithmeticError"));
279 });
280 }
281
282 #[test]
283 fn test_division_by_zero_error() {
284 Embed::run(|| {
285 let division_by_zero_error = division_by_zero_error();
286 assert_eq!(division_by_zero_error.name(), Some("DivisionByZeroError"));
287 });
288 }
289
290 #[test]
291 fn test_unhandled_match_error() {
292 Embed::run(|| {
293 let unhandled_match_error = unhandled_match_error();
294 assert_eq!(unhandled_match_error.name(), Some("UnhandledMatchError"));
295 });
296 }
297
298 #[test]
299 fn test_traversable() {
300 Embed::run(|| {
301 let traversable = traversable();
302 assert_eq!(traversable.name(), Some("Traversable"));
303 });
304 }
305
306 #[test]
307 fn test_aggregate() {
308 Embed::run(|| {
309 let aggregate = aggregate();
310 assert_eq!(aggregate.name(), Some("IteratorAggregate"));
311 });
312 }
313
314 #[test]
315 fn test_iterator() {
316 Embed::run(|| {
317 let iterator = iterator();
318 assert_eq!(iterator.name(), Some("Iterator"));
319 });
320 }
321
322 #[test]
323 fn test_arrayaccess() {
324 Embed::run(|| {
325 let arrayaccess = arrayaccess();
326 assert_eq!(arrayaccess.name(), Some("ArrayAccess"));
327 });
328 }
329
330 #[test]
331 fn test_serializable() {
332 Embed::run(|| {
333 let serializable = serializable();
334 assert_eq!(serializable.name(), Some("Serializable"));
335 });
336 }
337
338 #[test]
339 fn test_countable() {
340 Embed::run(|| {
341 let countable = countable();
342 assert_eq!(countable.name(), Some("Countable"));
343 });
344 }
345
346 #[test]
347 fn test_stringable() {
348 Embed::run(|| {
349 let stringable = stringable();
350 assert_eq!(stringable.name(), Some("Stringable"));
351 });
352 }
353}