Skip to main content

ext_php_rs/
flags.rs

1//! Flags and enums used in PHP and the Zend engine.
2
3use bitflags::bitflags;
4
5#[cfg(php81)]
6use crate::ffi::ZEND_ACC_ENUM;
7#[cfg(not(php82))]
8use crate::ffi::ZEND_ACC_REUSE_GET_ITERATOR;
9use crate::ffi::{
10    _IS_BOOL, CONST_CS, CONST_DEPRECATED, CONST_NO_FILE_CACHE, CONST_PERSISTENT, E_COMPILE_ERROR,
11    E_COMPILE_WARNING, E_CORE_ERROR, E_CORE_WARNING, E_DEPRECATED, E_ERROR, E_NOTICE, E_PARSE,
12    E_RECOVERABLE_ERROR, E_STRICT, E_USER_DEPRECATED, E_USER_ERROR, E_USER_NOTICE, E_USER_WARNING,
13    E_WARNING, GC_IMMUTABLE, IS_ARRAY, IS_CALLABLE, IS_CONSTANT_AST, IS_DOUBLE, IS_FALSE,
14    IS_INDIRECT, IS_ITERABLE, IS_LONG, IS_MIXED, IS_NULL, IS_OBJECT, IS_PTR, IS_REFERENCE,
15    IS_RESOURCE, IS_STRING, IS_TRUE, IS_TYPE_COLLECTABLE, IS_TYPE_REFCOUNTED, IS_UNDEF, IS_VOID,
16    PHP_INI_ALL, PHP_INI_PERDIR, PHP_INI_SYSTEM, PHP_INI_USER, Z_TYPE_FLAGS_SHIFT,
17    ZEND_ACC_ABSTRACT, ZEND_ACC_ANON_CLASS, ZEND_ACC_CALL_VIA_TRAMPOLINE, ZEND_ACC_CHANGED,
18    ZEND_ACC_CLOSURE, ZEND_ACC_CONSTANTS_UPDATED, ZEND_ACC_CTOR, ZEND_ACC_DEPRECATED,
19    ZEND_ACC_DONE_PASS_TWO, ZEND_ACC_EARLY_BINDING, ZEND_ACC_FAKE_CLOSURE, ZEND_ACC_FINAL,
20    ZEND_ACC_GENERATOR, ZEND_ACC_HAS_FINALLY_BLOCK, ZEND_ACC_HAS_RETURN_TYPE,
21    ZEND_ACC_HAS_TYPE_HINTS, ZEND_ACC_HEAP_RT_CACHE, ZEND_ACC_IMMUTABLE,
22    ZEND_ACC_IMPLICIT_ABSTRACT_CLASS, ZEND_ACC_INTERFACE, ZEND_ACC_LINKED, ZEND_ACC_NEARLY_LINKED,
23    ZEND_ACC_NEVER_CACHE, ZEND_ACC_NO_DYNAMIC_PROPERTIES, ZEND_ACC_PRELOADED, ZEND_ACC_PRIVATE,
24    ZEND_ACC_PROMOTED, ZEND_ACC_PROTECTED, ZEND_ACC_PUBLIC, ZEND_ACC_RESOLVED_INTERFACES,
25    ZEND_ACC_RESOLVED_PARENT, ZEND_ACC_RETURN_REFERENCE, ZEND_ACC_STATIC, ZEND_ACC_STRICT_TYPES,
26    ZEND_ACC_TOP_LEVEL, ZEND_ACC_TRAIT, ZEND_ACC_TRAIT_CLONE, ZEND_ACC_UNRESOLVED_VARIANCE,
27    ZEND_ACC_USE_GUARDS, ZEND_ACC_USES_THIS, ZEND_ACC_VARIADIC, ZEND_EVAL_CODE,
28    ZEND_HAS_STATIC_IN_METHODS, ZEND_INTERNAL_FUNCTION, ZEND_USER_FUNCTION,
29};
30
31use std::{convert::TryFrom, fmt::Display};
32
33use crate::error::{Error, Result};
34
35bitflags! {
36    /// Flags used for setting the type of Zval.
37    #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)]
38    pub struct ZvalTypeFlags: u32 {
39        /// Undefined
40        const Undef = IS_UNDEF;
41        /// Null
42        const Null = IS_NULL;
43        /// `false`
44        const False = IS_FALSE;
45        /// `true`
46        const True = IS_TRUE;
47        /// Integer
48        const Long = IS_LONG;
49        /// Floating point number
50        const Double = IS_DOUBLE;
51        /// String
52        const String = IS_STRING;
53        /// Array
54        const Array = IS_ARRAY;
55        /// Object
56        const Object = IS_OBJECT;
57        /// Resource
58        const Resource = IS_RESOURCE;
59        /// Reference
60        const Reference = IS_REFERENCE;
61        /// Callable
62        const Callable = IS_CALLABLE;
63        /// Constant expression
64        const ConstantExpression = IS_CONSTANT_AST;
65        /// Void
66        const Void = IS_VOID;
67        /// Pointer
68        const Ptr = IS_PTR;
69        /// Iterable
70        const Iterable = IS_ITERABLE;
71
72        /// Interned string extended
73        const InternedStringEx = Self::String.bits();
74        /// String extended
75        const StringEx = Self::String.bits() | Self::RefCounted.bits();
76        /// Array extended
77        const ArrayEx = Self::Array.bits() | Self::RefCounted.bits() | Self::Collectable.bits();
78        /// Object extended
79        const ObjectEx = Self::Object.bits() | Self::RefCounted.bits() | Self::Collectable.bits();
80        /// Resource extended
81        const ResourceEx = Self::Resource.bits() | Self::RefCounted.bits();
82        /// Reference extended
83        const ReferenceEx = Self::Reference.bits() | Self::RefCounted.bits();
84        /// Constant ast extended
85        const ConstantAstEx = Self::ConstantExpression.bits() | Self::RefCounted.bits();
86
87        /// Reference counted
88        const RefCounted = (IS_TYPE_REFCOUNTED << Z_TYPE_FLAGS_SHIFT);
89        /// Collectable
90        const Collectable = (IS_TYPE_COLLECTABLE << Z_TYPE_FLAGS_SHIFT);
91
92        /// Immutable (used for the shared empty array)
93        const Immutable = GC_IMMUTABLE;
94    }
95}
96
97bitflags! {
98    /// Flags for building classes.
99    #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)]
100    pub struct ClassFlags: u32 {
101        /// Final class or method
102        const Final = ZEND_ACC_FINAL;
103        /// Abstract method
104        const Abstract = ZEND_ACC_ABSTRACT;
105        /// Immutable `op_array` and class_entries
106        /// (implemented only for lazy loading of `op_array`s)
107        const Immutable = ZEND_ACC_IMMUTABLE;
108        /// Function has typed arguments / class has typed props
109        const HasTypeHints = ZEND_ACC_HAS_TYPE_HINTS;
110        /// Top-level class or function declaration
111        const TopLevel = ZEND_ACC_TOP_LEVEL;
112        /// op_array or class is preloaded
113        const Preloaded = ZEND_ACC_PRELOADED;
114
115        /// Class entry is an interface
116        const Interface = ZEND_ACC_INTERFACE;
117        /// Class entry is a trait
118        const Trait = ZEND_ACC_TRAIT;
119        /// Anonymous class
120        const AnonymousClass = ZEND_ACC_ANON_CLASS;
121        /// Class is an Enum
122        #[cfg(php81)]
123        const Enum = ZEND_ACC_ENUM;
124        /// Class linked with parent, interfaces and traits
125        const Linked = ZEND_ACC_LINKED;
126        /// Class is abstract, since it is set by any abstract method
127        const ImplicitAbstractClass = ZEND_ACC_IMPLICIT_ABSTRACT_CLASS;
128        /// Class has magic methods `__get`/`__set`/`__unset`/`__isset` that use guards
129        const UseGuards = ZEND_ACC_USE_GUARDS;
130
131        /// Class constants updated
132        const ConstantsUpdated = ZEND_ACC_CONSTANTS_UPDATED;
133        /// Objects of this class may not have dynamic properties
134        const NoDynamicProperties = ZEND_ACC_NO_DYNAMIC_PROPERTIES;
135        /// User class has methods with static variables
136        const HasStaticInMethods = ZEND_HAS_STATIC_IN_METHODS;
137        /// Children must reuse parent `get_iterator()`
138        #[cfg(not(php82))]
139        const ReuseGetIterator = ZEND_ACC_REUSE_GET_ITERATOR;
140        /// Parent class is resolved (CE)
141        const ResolvedParent = ZEND_ACC_RESOLVED_PARENT;
142        /// Interfaces are resolved (CE)
143        const ResolvedInterfaces = ZEND_ACC_RESOLVED_INTERFACES;
144        /// Class has unresolved variance obligations
145        const UnresolvedVariance = ZEND_ACC_UNRESOLVED_VARIANCE;
146        /// Class is linked apart from variance obligations
147        const NearlyLinked = ZEND_ACC_NEARLY_LINKED;
148
149        /// Class cannot be serialized or unserialized
150        #[cfg(php81)]
151        const NotSerializable = crate::ffi::ZEND_ACC_NOT_SERIALIZABLE;
152
153        /// Readonly class (PHP 8.2+)
154        /// All properties are implicitly readonly
155        #[cfg(php82)]
156        const ReadonlyClass = crate::ffi::ZEND_ACC_READONLY_CLASS;
157    }
158}
159
160bitflags! {
161    /// Flags for building methods.
162    #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)]
163    pub struct MethodFlags: u32 {
164        /// Visibility public
165        const Public = ZEND_ACC_PUBLIC;
166        /// Visibility protected
167        const Protected = ZEND_ACC_PROTECTED;
168        /// Visibility private
169        const Private = ZEND_ACC_PRIVATE;
170        /// Method or property overrides private one
171        const Changed = ZEND_ACC_CHANGED;
172        /// Static method
173        const Static = ZEND_ACC_STATIC;
174        /// Final method
175        const Final = ZEND_ACC_FINAL;
176        /// Abstract method
177        const Abstract = ZEND_ACC_ABSTRACT;
178        /// Immutable `op_array` and class_entries
179        /// (implemented only for lazy loading of op_arrays)
180        const Immutable = ZEND_ACC_IMMUTABLE;
181        /// Function has typed arguments / class has typed props
182        const HasTypeHints = ZEND_ACC_HAS_TYPE_HINTS;
183        /// Top-level class or function declaration
184        const TopLevel = ZEND_ACC_TOP_LEVEL;
185        /// `op_array` or class is preloaded
186        const Preloaded = ZEND_ACC_PRELOADED;
187
188        /// Deprecation flag
189        const Deprecated = ZEND_ACC_DEPRECATED;
190        /// Function returning by reference
191        const ReturnReference = ZEND_ACC_RETURN_REFERENCE;
192        /// Function has a return type
193        const HasReturnType = ZEND_ACC_HAS_RETURN_TYPE;
194        /// Function with variable number of arguments
195        const Variadic = ZEND_ACC_VARIADIC;
196        /// `op_array` has finally blocks (user only)
197        const HasFinallyBlock = ZEND_ACC_HAS_FINALLY_BLOCK;
198        /// "main" `op_array` with `ZEND_DECLARE_CLASS_DELAYED` opcodes
199        const EarlyBinding = ZEND_ACC_EARLY_BINDING;
200        /// Closure uses `$this`
201        const UsesThis = ZEND_ACC_USES_THIS;
202        /// Call through user function trampoline
203        ///
204        /// # Example
205        /// - `__call`
206        /// - `__callStatic`
207        const CallViaTrampoline = ZEND_ACC_CALL_VIA_TRAMPOLINE;
208        /// Disable inline caching
209        const NeverCache = ZEND_ACC_NEVER_CACHE;
210        /// `op_array` is a clone of trait method
211        const TraitClone = ZEND_ACC_TRAIT_CLONE;
212        /// Function is a constructor
213        const IsConstructor = ZEND_ACC_CTOR;
214        /// Function is a closure
215        const Closure = ZEND_ACC_CLOSURE;
216        /// Function is a fake closure
217        const FakeClosure = ZEND_ACC_FAKE_CLOSURE;
218        /// Function is a generator
219        const Generator = ZEND_ACC_GENERATOR;
220        /// Function was processed by pass two (user only)
221        const DonePassTwo = ZEND_ACC_DONE_PASS_TWO;
222        /// `run_time_cache` allocated on heap (user only)
223        const HeapRTCache = ZEND_ACC_HEAP_RT_CACHE;
224        /// `op_array` uses strict mode types
225        const StrictTypes = ZEND_ACC_STRICT_TYPES;
226    }
227}
228
229bitflags! {
230    /// Flags for building properties.
231    #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)]
232    pub struct PropertyFlags: u32 {
233        /// Visibility public
234        const Public = ZEND_ACC_PUBLIC;
235        /// Visibility protected
236        const Protected = ZEND_ACC_PROTECTED;
237        /// Visibility private
238        const Private = ZEND_ACC_PRIVATE;
239        /// Property or method overrides private one
240        const Changed = ZEND_ACC_CHANGED;
241        /// Static property
242        const Static = ZEND_ACC_STATIC;
243        /// Promoted property
244        const Promoted = ZEND_ACC_PROMOTED;
245    }
246}
247
248bitflags! {
249    /// Flags for building constants.
250    #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)]
251    pub struct ConstantFlags: u32 {
252        /// Visibility public
253        const Public = ZEND_ACC_PUBLIC;
254        /// Visibility protected
255        const Protected = ZEND_ACC_PROTECTED;
256        /// Visibility private
257        const Private = ZEND_ACC_PRIVATE;
258        /// Promoted constant
259        const Promoted = ZEND_ACC_PROMOTED;
260    }
261}
262
263bitflags! {
264    /// Flags for building module global constants.
265    #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)]
266    pub struct GlobalConstantFlags: u32 {
267        /// No longer used -- always case-sensitive
268        #[deprecated(note = "No longer used -- always case-sensitive")]
269        const CaseSensitive = CONST_CS;
270        /// Persistent
271        const Persistent = CONST_PERSISTENT;
272        /// Can't be saved in file cache
273        const NoFileCache = CONST_NO_FILE_CACHE;
274        /// Deprecated (this flag is not deprecated, it literally means the constant is deprecated)
275        const Deprecated = CONST_DEPRECATED;
276    }
277}
278
279bitflags! {
280    /// Represents the result of a function.
281    #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)]
282    pub struct ZendResult: i32 {
283        /// Function call was successful.
284        const Success = 0;
285        /// Function call failed.
286        const Failure = -1;
287    }
288}
289
290bitflags! {
291    /// Represents permissions for where a configuration setting may be set.
292    pub struct IniEntryPermission: u32 {
293        /// User
294        const User = PHP_INI_USER;
295        /// Per directory
296        const PerDir = PHP_INI_PERDIR;
297        /// System
298        const System = PHP_INI_SYSTEM;
299        /// All
300        const All = PHP_INI_ALL;
301    }
302}
303
304bitflags! {
305    /// Represents error types when used via php_error_docref for example.
306    pub struct ErrorType: u32 {
307        /// Error
308        const Error = E_ERROR;
309        /// Warning
310        const Warning = E_WARNING;
311        /// Parse
312        const Parse = E_PARSE;
313        /// Notice
314        const Notice = E_NOTICE;
315        /// Core error
316        const CoreError = E_CORE_ERROR;
317        /// Core warning
318        const CoreWarning = E_CORE_WARNING;
319        /// Compile error
320        const CompileError = E_COMPILE_ERROR;
321        /// Compile warning
322        const CompileWarning = E_COMPILE_WARNING;
323        /// User error
324        #[cfg_attr(php84, deprecated = "`E_USER_ERROR` is deprecated since PHP 8.4. Throw an exception instead.")]
325        const UserError = E_USER_ERROR;
326        /// User warning
327        const UserWarning = E_USER_WARNING;
328        /// User notice
329        const UserNotice = E_USER_NOTICE;
330        /// Strict
331        const Strict = E_STRICT;
332        /// Recoverable error
333        const RecoverableError = E_RECOVERABLE_ERROR;
334        /// Deprecated
335        const Deprecated = E_DEPRECATED;
336        /// User deprecated
337        const UserDeprecated = E_USER_DEPRECATED;
338    }
339}
340
341/// Represents the type of a function.
342#[derive(PartialEq, Eq, Hash, Debug, Clone, Copy)]
343pub enum FunctionType {
344    /// Internal function
345    Internal,
346    /// User function
347    User,
348    /// Eval code
349    Eval,
350}
351
352impl From<u8> for FunctionType {
353    #[allow(clippy::bad_bit_mask)]
354    fn from(value: u8) -> Self {
355        match value.into() {
356            ZEND_INTERNAL_FUNCTION => Self::Internal,
357            ZEND_USER_FUNCTION => Self::User,
358            ZEND_EVAL_CODE => Self::Eval,
359            _ => panic!("Unknown function type: {value}"),
360        }
361    }
362}
363
364/// Valid data types for PHP.
365#[repr(C, u8)]
366#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Default)]
367pub enum DataType {
368    /// Undefined
369    Undef,
370    /// `null`
371    Null,
372    /// `false`
373    False,
374    /// `true`
375    True,
376    /// Integer (the irony)
377    Long,
378    /// Floating point number
379    Double,
380    /// String
381    String,
382    /// Array
383    Array,
384    /// Iterable
385    Iterable,
386    /// Object
387    Object(Option<&'static str>),
388    /// Resource
389    Resource,
390    /// Reference
391    Reference,
392    /// Callable
393    Callable,
394    /// Constant expression
395    ConstantExpression,
396    /// Void
397    #[default]
398    Void,
399    /// Mixed
400    Mixed,
401    /// Boolean
402    Bool,
403    /// Pointer
404    Ptr,
405    /// Indirect (internal)
406    Indirect,
407}
408
409impl DataType {
410    /// Returns the integer representation of the data type.
411    #[must_use]
412    pub const fn as_u32(&self) -> u32 {
413        match self {
414            DataType::Undef => IS_UNDEF,
415            DataType::Null => IS_NULL,
416            DataType::False => IS_FALSE,
417            DataType::True => IS_TRUE,
418            DataType::Long => IS_LONG,
419            DataType::Double => IS_DOUBLE,
420            DataType::String => IS_STRING,
421            DataType::Array => IS_ARRAY,
422            DataType::Object(_) => IS_OBJECT,
423            DataType::Resource | DataType::Reference => IS_RESOURCE,
424            DataType::Indirect => IS_INDIRECT,
425            DataType::Callable => IS_CALLABLE,
426            DataType::ConstantExpression => IS_CONSTANT_AST,
427            DataType::Void => IS_VOID,
428            DataType::Mixed => IS_MIXED,
429            DataType::Bool => _IS_BOOL,
430            DataType::Ptr => IS_PTR,
431            DataType::Iterable => IS_ITERABLE,
432        }
433    }
434}
435
436// TODO: Ideally want something like this
437// pub struct Type {
438//     data_type: DataType,
439//     is_refcounted: bool,
440//     is_collectable: bool,
441//     is_immutable: bool,
442//     is_persistent: bool,
443// }
444//
445// impl From<u32> for Type { ... }
446
447impl TryFrom<ZvalTypeFlags> for DataType {
448    type Error = Error;
449
450    fn try_from(value: ZvalTypeFlags) -> Result<Self> {
451        macro_rules! contains {
452            ($t: ident) => {
453                if value.contains(ZvalTypeFlags::$t) {
454                    return Ok(DataType::$t);
455                }
456            };
457        }
458
459        contains!(Undef);
460        contains!(Null);
461        contains!(False);
462        contains!(True);
463        contains!(False);
464        contains!(Long);
465        contains!(Double);
466        contains!(String);
467        contains!(Array);
468        contains!(Resource);
469        contains!(Callable);
470        contains!(ConstantExpression);
471        contains!(Void);
472
473        if value.contains(ZvalTypeFlags::Object) {
474            return Ok(DataType::Object(None));
475        }
476
477        Err(Error::UnknownDatatype(0))
478    }
479}
480
481impl From<u32> for DataType {
482    #[allow(clippy::bad_bit_mask)]
483    fn from(value: u32) -> Self {
484        macro_rules! contains {
485            ($c: ident, $t: ident) => {
486                if (value & $c) == $c {
487                    return DataType::$t;
488                }
489            };
490        }
491
492        contains!(IS_VOID, Void);
493        contains!(IS_PTR, Ptr);
494        contains!(IS_INDIRECT, Indirect);
495        contains!(IS_CALLABLE, Callable);
496        contains!(IS_CONSTANT_AST, ConstantExpression);
497        contains!(IS_REFERENCE, Reference);
498        contains!(IS_RESOURCE, Resource);
499        contains!(IS_ARRAY, Array);
500        contains!(IS_STRING, String);
501        contains!(IS_DOUBLE, Double);
502        contains!(IS_LONG, Long);
503        contains!(IS_TRUE, True);
504        contains!(IS_FALSE, False);
505        contains!(IS_NULL, Null);
506
507        if (value & IS_OBJECT) == IS_OBJECT {
508            return DataType::Object(None);
509        }
510
511        contains!(IS_UNDEF, Undef);
512
513        DataType::Mixed
514    }
515}
516
517impl Display for DataType {
518    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
519        match self {
520            DataType::Undef => write!(f, "Undefined"),
521            DataType::Null => write!(f, "Null"),
522            DataType::False => write!(f, "False"),
523            DataType::True => write!(f, "True"),
524            DataType::Long => write!(f, "Long"),
525            DataType::Double => write!(f, "Double"),
526            DataType::String => write!(f, "String"),
527            DataType::Array => write!(f, "Array"),
528            DataType::Object(obj) => write!(f, "{}", obj.as_deref().unwrap_or("Object")),
529            DataType::Resource => write!(f, "Resource"),
530            DataType::Reference => write!(f, "Reference"),
531            DataType::Callable => write!(f, "Callable"),
532            DataType::ConstantExpression => write!(f, "Constant Expression"),
533            DataType::Void => write!(f, "Void"),
534            DataType::Bool => write!(f, "Bool"),
535            DataType::Mixed => write!(f, "Mixed"),
536            DataType::Ptr => write!(f, "Pointer"),
537            DataType::Indirect => write!(f, "Indirect"),
538            DataType::Iterable => write!(f, "Iterable"),
539        }
540    }
541}
542
543#[cfg(test)]
544mod tests {
545    #![allow(clippy::unnecessary_fallible_conversions)]
546    use super::DataType;
547    use crate::ffi::{
548        IS_ARRAY, IS_ARRAY_EX, IS_CONSTANT_AST, IS_CONSTANT_AST_EX, IS_DOUBLE, IS_FALSE,
549        IS_INDIRECT, IS_INTERNED_STRING_EX, IS_LONG, IS_NULL, IS_OBJECT, IS_OBJECT_EX, IS_PTR,
550        IS_REFERENCE, IS_REFERENCE_EX, IS_RESOURCE, IS_RESOURCE_EX, IS_STRING, IS_STRING_EX,
551        IS_TRUE, IS_UNDEF, IS_VOID,
552    };
553    use std::convert::TryFrom;
554
555    #[test]
556    fn test_datatype() {
557        macro_rules! test {
558            ($c: ident, $t: ident) => {
559                assert_eq!(DataType::try_from($c), Ok(DataType::$t));
560            };
561        }
562
563        test!(IS_UNDEF, Undef);
564        test!(IS_NULL, Null);
565        test!(IS_FALSE, False);
566        test!(IS_TRUE, True);
567        test!(IS_LONG, Long);
568        test!(IS_DOUBLE, Double);
569        test!(IS_STRING, String);
570        test!(IS_ARRAY, Array);
571        assert_eq!(DataType::try_from(IS_OBJECT), Ok(DataType::Object(None)));
572        test!(IS_RESOURCE, Resource);
573        test!(IS_REFERENCE, Reference);
574        test!(IS_CONSTANT_AST, ConstantExpression);
575        test!(IS_INDIRECT, Indirect);
576        test!(IS_VOID, Void);
577        test!(IS_PTR, Ptr);
578
579        test!(IS_INTERNED_STRING_EX, String);
580        test!(IS_STRING_EX, String);
581        test!(IS_ARRAY_EX, Array);
582        assert_eq!(DataType::try_from(IS_OBJECT_EX), Ok(DataType::Object(None)));
583        test!(IS_RESOURCE_EX, Resource);
584        test!(IS_REFERENCE_EX, Reference);
585        test!(IS_CONSTANT_AST_EX, ConstantExpression);
586    }
587}