#[repr(C)]
pub struct _zend_execute_data { pub opline: *const zend_op, pub call: *mut zend_execute_data, pub return_value: *mut zval, pub func: *mut zend_function, pub This: zval, pub prev_execute_data: *mut zend_execute_data, pub symbol_table: *mut zend_array, pub run_time_cache: *mut *mut c_void, pub extra_named_params: *mut zend_array, }

Fields§

§opline: *const zend_op§call: *mut zend_execute_data§return_value: *mut zval§func: *mut zend_function§This: zval§prev_execute_data: *mut zend_execute_data§symbol_table: *mut zend_array§run_time_cache: *mut *mut c_void§extra_named_params: *mut zend_array

Implementations§

source§

impl _zend_execute_data

source

pub fn parser(&mut self) -> ArgParser<'_, '_>

Returns an ArgParser pre-loaded with the arguments contained inside self.

§Example
use ext_php_rs::{types::Zval, zend::ExecuteData, args::Arg, flags::DataType};

#[no_mangle]
pub extern "C" fn example_fn(ex: &mut ExecuteData, retval: &mut Zval) {
    let mut a = Arg::new("a", DataType::Long);

    // The `parse_args!()` macro can be used for this.
    let parser = ex.parser()
        .arg(&mut a)
        .parse();

    if parser.is_err() {
        return;
    }

    dbg!(a);
}
source

pub fn parser_object(&mut self) -> (ArgParser<'_, '_>, Option<&mut ZendObject>)

Returns an ArgParser pre-loaded with the arguments contained inside self.

A reference to $this is also returned in an Option, which resolves to None if this function is not called inside a method.

§Example
use ext_php_rs::{types::Zval, zend::ExecuteData, args::Arg, flags::DataType};

#[no_mangle]
pub extern "C" fn example_fn(ex: &mut ExecuteData, retval: &mut Zval) {
    let mut a = Arg::new("a", DataType::Long);

    let (parser, this) = ex.parser_object();
    let parser = parser
        .arg(&mut a)
        .parse();

    if parser.is_err() {
        return;
    }

    dbg!(a, this);
}
source

pub fn parser_method<T: RegisteredClass>( &mut self ) -> (ArgParser<'_, '_>, Option<&mut ZendClassObject<T>>)

Returns an ArgParser pre-loaded with the arguments contained inside self.

A reference to $this is also returned in an Option, which resolves to None if this function is not called inside a method.

This function differs from parse_object in the fact that it returns a reference to a ZendClassObject, which is an object that contains an arbitrary Rust type at the start of the object. The object will also resolve to None if the function is called inside a method that does not belong to an object with type T.

§Example
use ext_php_rs::{types::Zval, zend::ExecuteData, args::Arg, flags::DataType, prelude::*};

#[php_class]
#[derive(Debug)]
struct Example;

#[no_mangle]
pub extern "C" fn example_fn(ex: &mut ExecuteData, retval: &mut Zval) {
    let mut a = Arg::new("a", DataType::Long);

    let (parser, this) = ex.parser_method::<Example>();
    let parser = parser
        .arg(&mut a)
        .parse();

    if parser.is_err() {
        return;
    }

    dbg!(a, this);
}

#[php_module]
pub fn module(module: ModuleBuilder) -> ModuleBuilder {
    module
}
source

pub fn get_object<T: RegisteredClass>( &mut self ) -> Option<&mut ZendClassObject<T>>

Attempts to retrieve a reference to the underlying class object of the Zend object.

Returns a ZendClassObject if the execution data contained a valid object of type T, otherwise returns None.

§Example
use ext_php_rs::{types::Zval, zend::ExecuteData, prelude::*};

#[php_class]
#[derive(Debug)]
struct Example;

#[no_mangle]
pub extern "C" fn example_fn(ex: &mut ExecuteData, retval: &mut Zval) {
    let this = ex.get_object::<Example>();
    dbg!(this);
}

#[php_module]
pub fn module(module: ModuleBuilder) -> ModuleBuilder {
    module
}
source

pub fn get_self(&mut self) -> Option<&mut ZendObject>

Attempts to retrieve the ‘this’ object, which can be used in class methods to retrieve the underlying Zend object.

§Example
use ext_php_rs::{types::Zval, zend::ExecuteData};

#[no_mangle]
pub extern "C" fn example_fn(ex: &mut ExecuteData, retval: &mut Zval) {
    let this = ex.get_self();
    dbg!(this);
}
source

pub fn function(&self) -> Option<&Function>

Attempt to retrieve the function that is being called.

source

pub fn previous(&self) -> Option<&Self>

Attempt to retrieve the previous execute data on the call stack.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.