Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/zend/ex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
///
Expand Down
5 changes: 5 additions & 0 deletions src/zend/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down Expand Up @@ -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<Self> {
unsafe {
let res = zend_fetch_function_str(name.as_ptr() as *const c_char, name.len());
Expand Down