pub trait RegisteredClass: Sized + 'static {
const CLASS_NAME: &'static str;
const BUILDER_MODIFIER: Option<fn(ClassBuilder) -> ClassBuilder>;
const EXTENDS: Option<ClassEntryInfo>;
const IMPLEMENTS: &'static [ClassEntryInfo];
const FLAGS: ClassFlags = _;
const DOC_COMMENTS: DocComments = _;
// Required methods
fn get_metadata() -> &'static ClassMetadata<Self>;
fn get_properties<'a>() -> HashMap<&'static str, PropertyInfo<'a, Self>>;
fn method_builders() -> Vec<(FunctionBuilder<'static>, MethodFlags)>;
fn constructor() -> Option<ConstructorMeta<Self>>;
fn constants( ) -> &'static [(&'static str, &'static dyn IntoZvalDyn, DocComments)];
}
Expand description
Implemented on Rust types which are exported to PHP. Allows users to get and set PHP properties on the object.
Required Associated Constants§
Sourceconst CLASS_NAME: &'static str
const CLASS_NAME: &'static str
PHP class name of the registered class.
Sourceconst BUILDER_MODIFIER: Option<fn(ClassBuilder) -> ClassBuilder>
const BUILDER_MODIFIER: Option<fn(ClassBuilder) -> ClassBuilder>
Function to be called when building the class. Allows user to modify the class at runtime (add runtime constants etc).
Sourceconst EXTENDS: Option<ClassEntryInfo>
const EXTENDS: Option<ClassEntryInfo>
Parent class entry. Optional.
Sourceconst IMPLEMENTS: &'static [ClassEntryInfo]
const IMPLEMENTS: &'static [ClassEntryInfo]
Interfaces implemented by the class.
Provided Associated Constants§
Sourceconst FLAGS: ClassFlags = _
const FLAGS: ClassFlags = _
PHP flags applied to the class.
Sourceconst DOC_COMMENTS: DocComments = _
const DOC_COMMENTS: DocComments = _
Doc comments for the class.
Required Methods§
Sourcefn get_metadata() -> &'static ClassMetadata<Self>
fn get_metadata() -> &'static ClassMetadata<Self>
Returns a reference to the class metadata, which stores the class entry and handlers.
This must be statically allocated, and is usually done through the
macro@php_class
macro.
Sourcefn get_properties<'a>() -> HashMap<&'static str, PropertyInfo<'a, Self>>
fn get_properties<'a>() -> HashMap<&'static str, PropertyInfo<'a, Self>>
Returns a hash table containing the properties of the class.
The key should be the name of the property and the value should be a
reference to the property with reference to self
. The value is a
[PropertyInfo
].
Instead of using this method directly, you should access the properties
through the ClassMetadata::get_properties
function, which builds the
hashmap one and stores it in memory.
Sourcefn method_builders() -> Vec<(FunctionBuilder<'static>, MethodFlags)>
fn method_builders() -> Vec<(FunctionBuilder<'static>, MethodFlags)>
Returns the method builders required to build the class.
Sourcefn constructor() -> Option<ConstructorMeta<Self>>
fn constructor() -> Option<ConstructorMeta<Self>>
Returns the class constructor (if any).
Sourcefn constants() -> &'static [(&'static str, &'static dyn IntoZvalDyn, DocComments)]
fn constants() -> &'static [(&'static str, &'static dyn IntoZvalDyn, DocComments)]
Returns the constants provided by the class.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementors§
Source§impl RegisteredClass for Closure
Available on crate feature closure
only.
impl RegisteredClass for Closure
closure
only.