diff --git a/src/zend/ex.rs b/src/zend/ex.rs index dada00e0c..cb389cb2e 100644 --- a/src/zend/ex.rs +++ b/src/zend/ex.rs @@ -6,6 +6,8 @@ use crate::{ types::{ZendClassObject, ZendObject, Zval}, }; +use super::function::Function; + /// Execute data passed when a function is called from PHP. /// /// This generally contains things related to the call, including but not @@ -194,6 +196,16 @@ impl ExecuteData { self.This.object_mut() } + /// Attempt to retrieve the function that is being called. + pub fn function(&self) -> Option<&Function> { + unsafe { self.func.as_ref() } + } + + /// Attempt to retrieve the previous execute data on the call stack. + pub fn previous(&self) -> Option<&Self> { + unsafe { self.prev_execute_data.as_ref() } + } + /// Translation of macro `ZEND_CALL_ARG(call, n)` /// zend_compile.h:578 /// diff --git a/src/zend/function.rs b/src/zend/function.rs index fb5c4d4bd..6e6dd1a39 100644 --- a/src/zend/function.rs +++ b/src/zend/function.rs @@ -9,6 +9,7 @@ use crate::{ zend_call_known_function, zend_fetch_function_str, zend_function, zend_function_entry, zend_hash_str_find_ptr_lc, }, + flags::FunctionType, types::Zval, }; @@ -50,6 +51,10 @@ impl FunctionEntry { pub type Function = zend_function; impl Function { + pub fn function_type(&self) -> FunctionType { + FunctionType::from(unsafe { self.type_ }) + } + pub fn try_from_function(name: &str) -> Option { unsafe { let res = zend_fetch_function_str(name.as_ptr() as *const c_char, name.len());