Skip to content

Commit 5b3fc4d

Browse files
committed
Test
1 parent d7c9859 commit 5b3fc4d

File tree

2 files changed

+26
-13
lines changed

2 files changed

+26
-13
lines changed

allowed_bindings.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ bind! {
231231
_ZEND_TYPE_NULLABLE_BIT,
232232
ts_rsrc_id,
233233
_ZEND_TYPE_NAME_BIT,
234+
_ZEND_TYPE_NAME_LITERAL_BIT,
234235
ZEND_INTERNAL_FUNCTION,
235236
ZEND_USER_FUNCTION,
236237
ZEND_EVAL_CODE,

src/zend/_type.rs

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
use std::{
2-
ffi::{c_void, CString},
3-
ptr,
4-
};
1+
use std::{ffi::c_void, ptr};
52

63
use crate::{
74
ffi::{
@@ -81,16 +78,31 @@ impl ZendType {
8178
is_variadic: bool,
8279
allow_null: bool,
8380
) -> Option<Self> {
84-
Some(Self {
85-
ptr: CString::new(class_name).ok()?.into_raw() as *mut c_void,
86-
type_mask: _ZEND_TYPE_NAME_BIT
87-
| (if allow_null {
88-
_ZEND_TYPE_NULLABLE_BIT
89-
} else {
90-
0
81+
cfg_if::cfg_if! {
82+
if #[cfg(any(php80,php81,php82))] {
83+
Some(Self {
84+
ptr: crate::types::ZendStr::new(class_name, true).into_raw().as_ptr() as *mut c_void,
85+
type_mask: _ZEND_TYPE_NAME_BIT
86+
| (if allow_null {
87+
_ZEND_TYPE_NULLABLE_BIT
88+
} else {
89+
0
90+
})
91+
| Self::arg_info_flags(pass_by_ref, is_variadic),
92+
})
93+
} else {
94+
Some(Self {
95+
ptr: std::ffi::CString::new(class_name).ok()?.into_raw() as *mut c_void,
96+
type_mask: _ZEND_TYPE_NAME_BIT
97+
| (if allow_null {
98+
_ZEND_TYPE_NULLABLE_BIT
99+
} else {
100+
0
101+
})
102+
| Self::arg_info_flags(pass_by_ref, is_variadic),
91103
})
92-
| Self::arg_info_flags(pass_by_ref, is_variadic),
93-
})
104+
}
105+
}
94106
}
95107

96108
/// Attempts to create a zend type for a primitive PHP type.

0 commit comments

Comments
 (0)