Skip to content

Commit fc5c3df

Browse files
committed
Compat php 8 for zend_read_property.
1 parent b50cbfe commit fc5c3df

File tree

2 files changed

+29
-12
lines changed

2 files changed

+29
-12
lines changed

phper/src/classes.rs

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -175,17 +175,34 @@ impl This {
175175

176176
pub fn get_property(&self, name: impl AsRef<str>) -> &mut Val {
177177
let name = name.as_ref();
178-
unsafe {
179-
let prop = zend_read_property(
180-
self.class as *mut _,
181-
self.val as *mut _,
182-
name.as_ptr().cast(),
183-
name.len(),
184-
false.into(),
185-
null_mut(),
186-
);
187-
Val::from_mut(prop)
188-
}
178+
179+
let prop = unsafe {
180+
#[cfg(phper_major_version = "8")]
181+
{
182+
zend_read_property(
183+
self.class as *mut _,
184+
(*self.val).inner.value.obj,
185+
name.as_ptr().cast(),
186+
name.len(),
187+
false.into(),
188+
null_mut(),
189+
)
190+
}
191+
192+
#[cfg(phper_major_version = "7")]
193+
{
194+
zend_read_property(
195+
self.class as *mut _,
196+
self.val as *mut _,
197+
name.as_ptr().cast(),
198+
name.len(),
199+
false.into(),
200+
null_mut(),
201+
)
202+
}
203+
};
204+
205+
unsafe { Val::from_mut(prop) }
189206
}
190207
}
191208

phper/src/values.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl ExecuteData {
5555

5656
#[repr(transparent)]
5757
pub struct Val {
58-
inner: zval,
58+
pub(crate) inner: zval,
5959
}
6060

6161
impl Val {

0 commit comments

Comments
 (0)