pub struct ZendExtensionBuilder<'a> { /* private fields */ }observer only.Expand description
Builder for a zend_extension registration.
Returned by crate::builders::ModuleBuilder::zend_extension. Call
Self::finish to return to the outer
ModuleBuilder after selecting opt-in
hooks.
Each opt-in method enables one family of ZendExtensionHandler hooks.
Self::hook_statements and Self::hook_fcalls also flip the matching
ZEND_COMPILE_* flag so PHP emits the extra opcodes the hook depends on,
which costs every compiled script. Self::hook_op_array_compile has no
compile-time cost because its flag is already set by PHP’s defaults; it
only controls whether the dispatcher callback runs.
Implementations§
Source§impl<'a> ZendExtensionBuilder<'a>
impl<'a> ZendExtensionBuilder<'a>
Sourcepub fn hook_op_array_compile(self) -> Self
pub fn hook_op_array_compile(self) -> Self
Enable on_op_array_compiled, called after PHP finishes compiling
each function or method.
Unlike Self::hook_statements and Self::hook_fcalls, this
opt-in does not change the bytecode PHP emits: the matching flag
(ZEND_COMPILE_HANDLE_OP_ARRAY) is already part of PHP’s default
CG(compiler_options). The opt-in only controls whether the
dispatcher is registered, so the cost scales with the number of
compiled functions, not with every opcode.
Sourcepub fn hook_statements(self) -> Self
pub fn hook_statements(self) -> Self
Enable on_statement – called for every executed statement.
Flips ZEND_COMPILE_EXTENDED_STMT, which causes PHP to emit extra
ZEND_EXT_STMT opcodes in every compiled script. Opt in only if your
profiler actually needs per-statement granularity.
Sourcepub fn hook_fcalls(self) -> Self
pub fn hook_fcalls(self) -> Self
Enable on_fcall_begin / on_fcall_end – legacy per-call-site hooks.
Flips ZEND_COMPILE_EXTENDED_FCALL, which causes PHP to emit
ZEND_EXT_FCALL_BEGIN/END opcodes around every call site.
Sourcepub fn finish(self) -> ModuleBuilder<'a>
pub fn finish(self) -> ModuleBuilder<'a>
Consume the builder, register the extension, and return the outer
ModuleBuilder so further module
config can be chained.
§Panics
Panics if a ZendExtensionHandler has already been registered on this
module. Each extension may register at most one handler.