ext_php_rs/zend/
ce.rs

1//! Stock class entries registered with PHP, primarily exceptions.
2
3#![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,
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
16/// Returns the base [`stdClass`](https://www.php.net/manual/en/class.stdclass.php) class.
17pub fn stdclass() -> &'static ClassEntry {
18    unsafe { zend_standard_class_def.as_ref() }.unwrap()
19}
20
21/// Returns the base [`Throwable`](https://www.php.net/manual/en/class.throwable.php) class.
22pub fn throwable() -> &'static ClassEntry {
23    unsafe { zend_ce_throwable.as_ref() }.unwrap()
24}
25
26/// Returns the base [`Exception`](https://www.php.net/manual/en/class.exception.php) class.
27pub fn exception() -> &'static ClassEntry {
28    unsafe { zend_ce_exception.as_ref() }.unwrap()
29}
30
31/// Returns the base [`ErrorException`](https://www.php.net/manual/en/class.errorexception.php) class.
32pub fn error_exception() -> &'static ClassEntry {
33    unsafe { zend_ce_error_exception.as_ref() }.unwrap()
34}
35
36/// Returns the base [`CompileError`](https://www.php.net/manual/en/class.compileerror.php) class.
37pub fn compile_error() -> &'static ClassEntry {
38    unsafe { zend_ce_compile_error.as_ref() }.unwrap()
39}
40
41/// Returns the base [`ParseError`](https://www.php.net/manual/en/class.parseerror.php) class.
42pub fn parse_error() -> &'static ClassEntry {
43    unsafe { zend_ce_parse_error.as_ref() }.unwrap()
44}
45
46/// Returns the base [`TypeError`](https://www.php.net/manual/en/class.typeerror.php) class.
47pub fn type_error() -> &'static ClassEntry {
48    unsafe { zend_ce_type_error.as_ref() }.unwrap()
49}
50
51/// Returns the base [`ArgumentCountError`](https://www.php.net/manual/en/class.argumentcounterror.php) class.
52pub fn argument_count_error() -> &'static ClassEntry {
53    unsafe { zend_ce_argument_count_error.as_ref() }.unwrap()
54}
55
56/// Returns the base [`ValueError`](https://www.php.net/manual/en/class.valueerror.php) class.
57pub fn value_error() -> &'static ClassEntry {
58    unsafe { zend_ce_value_error.as_ref() }.unwrap()
59}
60
61/// Returns the base [`ArithmeticError`](https://www.php.net/manual/en/class.arithmeticerror.php) class.
62pub fn arithmetic_error() -> &'static ClassEntry {
63    unsafe { zend_ce_arithmetic_error.as_ref() }.unwrap()
64}
65
66/// Returns the base [`DivisionByZeroError`](https://www.php.net/manual/en/class.divisionbyzeroerror.php) class.
67pub fn division_by_zero_error() -> &'static ClassEntry {
68    unsafe { zend_ce_division_by_zero_error.as_ref() }.unwrap()
69}
70
71/// Returns the base [`UnhandledMatchError`](https://www.php.net/manual/en/class.unhandledmatcherror.php) class.
72pub fn unhandled_match_error() -> &'static ClassEntry {
73    unsafe { zend_ce_unhandled_match_error.as_ref() }.unwrap()
74}
75
76/// Returns the [`Traversable`](https://www.php.net/manual/en/class.traversable.php) interface.
77pub fn traversable() -> &'static ClassEntry {
78    unsafe { zend_ce_traversable.as_ref() }.unwrap()
79}
80
81/// Returns the [`IteratorAggregate`](https://www.php.net/manual/en/class.iteratoraggregate.php) interface.
82pub fn aggregate() -> &'static ClassEntry {
83    unsafe { zend_ce_aggregate.as_ref() }.unwrap()
84}
85
86/// Returns the [`Iterator`](https://www.php.net/manual/en/class.iterator.php) interface.
87pub fn iterator() -> &'static ClassEntry {
88    unsafe { zend_ce_iterator.as_ref() }.unwrap()
89}
90
91/// Returns the [`ArrayAccess`](https://www.php.net/manual/en/class.arrayaccess.php) interface.
92pub fn arrayaccess() -> &'static ClassEntry {
93    unsafe { zend_ce_arrayaccess.as_ref() }.unwrap()
94}
95
96/// Returns the [`Serializable`](https://www.php.net/manual/en/class.serializable.php) interface.
97pub fn serializable() -> &'static ClassEntry {
98    unsafe { zend_ce_serializable.as_ref() }.unwrap()
99}
100
101/// Returns the [`Countable`](https://www.php.net/manual/en/class.countable.php) interface.
102pub fn countable() -> &'static ClassEntry {
103    unsafe { zend_ce_countable.as_ref() }.unwrap()
104}
105
106/// Returns the [`Stringable`](https://www.php.net/manual/en/class.stringable.php) interface.
107pub fn stringable() -> &'static ClassEntry {
108    unsafe { zend_ce_stringable.as_ref() }.unwrap()
109}