Struct ext_php_rs::builders::ClassBuilder
source · pub struct ClassBuilder { /* private fields */ }
Expand description
Builder for registering a class in PHP.
Implementations§
source§impl ClassBuilder
impl ClassBuilder
sourcepub fn new<T: Into<String>>(name: T) -> Self
pub fn new<T: Into<String>>(name: T) -> Self
Creates a new class builder, used to build classes to be exported to PHP.
§Parameters
name
- The name of the class.
sourcepub fn extends(self, parent: &'static ClassEntry) -> Self
pub fn extends(self, parent: &'static ClassEntry) -> Self
sourcepub fn implements(self, interface: &'static ClassEntry) -> Self
pub fn implements(self, interface: &'static ClassEntry) -> Self
sourcepub fn method(self, func: FunctionEntry, flags: MethodFlags) -> Self
pub fn method(self, func: FunctionEntry, flags: MethodFlags) -> Self
Adds a method to the class.
§Parameters
func
- The function entry to add to the class.flags
- Flags relating to the function. SeeMethodFlags
.
sourcepub fn property<T: Into<String>>(
self,
name: T,
default: impl IntoZval,
flags: PropertyFlags
) -> Self
pub fn property<T: Into<String>>( self, name: T, default: impl IntoZval, flags: PropertyFlags ) -> Self
Adds a property to the class. The initial type of the property is given by the type of the given default. Note that the user can change the type.
§Parameters
name
- The name of the property to add to the class.default
- The default value of the property.flags
- Flags relating to the property. SeePropertyFlags
.
§Panics
Function will panic if the given default
cannot be converted into a
Zval
.
sourcepub fn constant<T: Into<String>>(
self,
name: T,
value: impl IntoZval
) -> Result<Self>
pub fn constant<T: Into<String>>( self, name: T, value: impl IntoZval ) -> Result<Self>
Adds a constant to the class. The type of the constant is defined by the type of the given default.
Returns a result containing the class builder if the constant was successfully added.
§Parameters
name
- The name of the constant to add to the class.value
- The value of the constant.
sourcepub fn flags(self, flags: ClassFlags) -> Self
pub fn flags(self, flags: ClassFlags) -> Self
sourcepub fn object_override<T: RegisteredClass>(self) -> Self
pub fn object_override<T: RegisteredClass>(self) -> Self
Overrides the creation of the Zend object which will represent an instance of this class.
§Parameters
T
- The type which will override the Zend object. Must implementRegisteredClass
which can be derived using thephp_class
attribute macro.
§Panics
Panics if the class name associated with T
is not the same as the
class name specified when creating the builder.
Auto Trait Implementations§
impl RefUnwindSafe for ClassBuilder
impl !Send for ClassBuilder
impl !Sync for ClassBuilder
impl Unpin for ClassBuilder
impl UnwindSafe for ClassBuilder
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more