pub struct ClassMetadata<T: 'static> { /* private fields */ }Expand description
Stores the class entry, handlers, and property descriptors for a Rust type which has been exported to PHP. Usually allocated statically.
Implementations§
Source§impl<T: 'static> ClassMetadata<T>
impl<T: 'static> ClassMetadata<T>
Source§impl<T: RegisteredClass> ClassMetadata<T>
impl<T: RegisteredClass> ClassMetadata<T>
Sourcepub fn handlers(&self) -> &ZendObjectHandlers
pub fn handlers(&self) -> &ZendObjectHandlers
Returns an immutable reference to the object handlers contained inside the class metadata.
Sourcepub fn ce(&self) -> &'static ClassEntry
pub fn ce(&self) -> &'static ClassEntry
Retrieves a reference to the stored class entry.
The class entry lives until the module shuts down. A SAPI that starts
the module again in the same process (FrankenPHP worker restarts)
registers a new one, so do not keep the reference across a restart:
call this again instead.
§Panics
Panics if there is no class entry stored inside the class metadata.
Sourcepub fn set_ce(&self, ce: &'static mut ClassEntry)
pub fn set_ce(&self, ce: &'static mut ClassEntry)
Stores a reference to a class entry inside the class metadata.
Called during MINIT, before any concurrent access. A SAPI can shut the
module down and start it again in the same process (FrankenPHP does on
a worker restart or opcache_reset()): MINIT then registers the class
again, and the new entry replaces the one freed with the old module.
Sourcepub fn set_arg_info(&self, arg_info: OwnedArgInfo)
pub fn set_arg_info(&self, arg_info: OwnedArgInfo)
Takes ownership of the argument info tables of this class’s methods.
zend_register_functions keeps zend_internal_function.arg_info
pointing into these until the module shuts down, so they must outlive
registration. Called from ClassBuilder::register, once per MINIT: when
the SAPI starts the module again in the same process, the new tables
replace those of the class freed with the old module.
Sourcepub fn find_property(&self, name: &str) -> Option<&PropertyDescriptor<T>>
pub fn find_property(&self, name: &str) -> Option<&PropertyDescriptor<T>>
Finds a property descriptor by name.
Checks field properties first, then method properties. Linear scan is used since typical PHP classes have few properties and cache locality beats hashing at small N.
Sourcepub fn field_properties(&self) -> &'static [PropertyDescriptor<T>]
pub fn field_properties(&self) -> &'static [PropertyDescriptor<T>]
Returns the field properties (from #[php(prop)] struct fields).
Sourcepub fn method_properties(&self) -> &'static [PropertyDescriptor<T>]
pub fn method_properties(&self) -> &'static [PropertyDescriptor<T>]
Returns the method properties (from #[php(getter)]/#[php(setter)]).
Lazily initialized on first access from RegisteredClass::method_properties().
Sourcepub fn all_properties(&self) -> impl Iterator<Item = &PropertyDescriptor<T>>
pub fn all_properties(&self) -> impl Iterator<Item = &PropertyDescriptor<T>>
Iterates over all properties (field + method).
Sourcepub fn mangled_names(&self) -> &[Box<str>]
pub fn mangled_names(&self) -> &[Box<str>]
Returns the PHP-convention mangled names of every property, in
all_properties order.
Private properties mangle to "\0Class\0name", protected ones to
"\0*\0name", public ones keep their name. Computed once per class on
first access, one allocation for the process lifetime.