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