Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark bind_class and bind_interface public #177

Merged
merged 1 commit into from
Feb 19, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions phper/src/classes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ fn find_global_class_entry_ptr(name: impl AsRef<str>) -> *mut zend_class_entry {
}

/// The [StateClass] holds [zend_class_entry] and inner state, created by
/// [Module::add_class](crate::modules::Module::add_class).
/// [Module::add_class](crate::modules::Module::add_class) or
/// [ClassEntity::bind_class].
///
/// When the class registered (module initialized), the [StateClass] will
/// be initialized, so you can use the [StateClass] to new stateful
Expand Down Expand Up @@ -690,8 +691,25 @@ impl<T: 'static> ClassEntity<T> {
.collect()
}

/// Get the bound class.
///
/// # Examples
///
/// ```
/// use phper::classes::{ClassEntity, Visibility};
///
/// pub fn make_foo_class() -> ClassEntity<()> {
/// let mut class = ClassEntity::<()>::new_with_default_state_constructor("Foo");
/// let foo_class = class.bind_class();
/// class.add_static_method("newInstance", Visibility::Public, move |_| {
/// let mut object = foo_class.init_object()?;
/// Ok::<_, phper::Error>(object)
/// });
/// class
/// }
/// ```
#[inline]
pub(crate) fn bind_class(&self) -> StateClass<T> {
pub fn bind_class(&self) -> StateClass<T> {
self.bind_class.clone()
}
}
Expand Down Expand Up @@ -798,8 +816,9 @@ impl InterfaceEntity {
Box::into_raw(methods.into_boxed_slice()).cast()
}

/// Get the bound interface.
#[inline]
pub(crate) fn bind_interface(&self) -> Interface {
pub fn bind_interface(&self) -> Interface {
self.bind_interface.clone()
}
}
Expand Down
Loading