pub struct ClassEntry { /* private fields */ }
Expand description
Wrapper of zend_class_entry.
Implementations§
Source§impl ClassEntry
impl ClassEntry
Sourcepub unsafe fn from_ptr<'a>(ptr: *const zend_class_entry) -> &'a Self
pub unsafe fn from_ptr<'a>(ptr: *const zend_class_entry) -> &'a Self
Sourcepub unsafe fn try_from_ptr<'a>(ptr: *const zend_class_entry) -> Option<&'a Self>
pub unsafe fn try_from_ptr<'a>(ptr: *const zend_class_entry) -> Option<&'a Self>
Sourcepub unsafe fn from_mut_ptr<'a>(ptr: *mut zend_class_entry) -> &'a mut Self
pub unsafe fn from_mut_ptr<'a>(ptr: *mut zend_class_entry) -> &'a mut Self
Sourcepub unsafe fn try_from_mut_ptr<'a>(
ptr: *mut zend_class_entry,
) -> Option<&'a mut Self>
pub unsafe fn try_from_mut_ptr<'a>( ptr: *mut zend_class_entry, ) -> Option<&'a mut Self>
Sourcepub const fn as_ptr(&self) -> *const zend_class_entry
pub const fn as_ptr(&self) -> *const zend_class_entry
Returns a raw pointer wrapped.
Sourcepub fn as_mut_ptr(&mut self) -> *mut zend_class_entry
pub fn as_mut_ptr(&mut self) -> *mut zend_class_entry
Returns a raw pointer wrapped.
Sourcepub fn from_globals(class_name: impl AsRef<str>) -> Result<&'static Self>
pub fn from_globals(class_name: impl AsRef<str>) -> Result<&'static Self>
Create reference from global class name.
§Examples
use phper::classes::ClassEntry;
let std_class = ClassEntry::from_globals("stdClass").unwrap();
let _obj = std_class.new_object([]).unwrap();
Sourcepub fn new_object(&self, arguments: impl AsMut<[ZVal]>) -> Result<ZObject>
pub fn new_object(&self, arguments: impl AsMut<[ZVal]>) -> Result<ZObject>
Create the object from class and call __construct
with arguments.
If the __construct
is private, or protected and the called scope isn’t
parent class, it will throw PHP Error.
Sourcepub fn init_object(&self) -> Result<ZObject>
pub fn init_object(&self) -> Result<ZObject>
Create the object from class, without calling __construct
.
Be careful when __construct
is necessary.
Sourcepub fn has_method(&self, method_name: &str) -> bool
pub fn has_method(&self, method_name: &str) -> bool
Detect if the method is exists in class.
Sourcepub fn is_instance_of(&self, parent: &ClassEntry) -> bool
pub fn is_instance_of(&self, parent: &ClassEntry) -> bool
Detect if the class is instance of parent class.
Sourcepub fn get_static_property(&self, name: impl AsRef<str>) -> Option<&ZVal>
pub fn get_static_property(&self, name: impl AsRef<str>) -> Option<&ZVal>
Get the static property by name of class.
Return None when static property hasn’t register by ClassEntity::add_static_property.
Sourcepub fn set_static_property(
&self,
name: impl AsRef<str>,
val: impl Into<ZVal>,
) -> Option<ZVal>
pub fn set_static_property( &self, name: impl AsRef<str>, val: impl Into<ZVal>, ) -> Option<ZVal>
Set the static property by name of class.
Return Some(x)
where x
is the previous value of static property, or
return None
when static property hasn’t register by
ClassEntity::add_static_property.
Trait Implementations§
Source§impl Clone for ClassEntry
impl Clone for ClassEntry
Source§fn clone(&self) -> ClassEntry
fn clone(&self) -> ClassEntry
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read more