From 891fa4ad3d308e99fa9c013a7ae27f9c4f0b4080 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Mon, 4 Sep 2023 10:48:06 +0200 Subject: [PATCH] Cargo fmt --- src/lib.rs | 2 +- src/types/object.rs | 14 +++++++------- src/types/zval.rs | 4 +++- src/zend/class.rs | 8 +++++++- src/zend/function.rs | 22 +++++++++++++++------- src/zend/globals.rs | 3 +-- src/zend/mod.rs | 2 +- 7 files changed, 35 insertions(+), 20 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index bc20ada..ba4c956 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -35,7 +35,7 @@ pub mod zend; /// A module typically glob-imported containing the typically required macros /// and imports. pub mod prelude { - + pub use crate::builders::ModuleBuilder; #[cfg(any(docs, feature = "closure"))] #[cfg_attr(docs, doc(cfg(feature = "closure")))] diff --git a/src/types/object.rs b/src/types/object.rs index f48c205..ca8e526 100644 --- a/src/types/object.rs +++ b/src/types/object.rs @@ -9,8 +9,9 @@ use crate::{ convert::{FromZendObject, FromZval, FromZvalMut, IntoZval, IntoZvalDyn}, error::{Error, Result}, ffi::{ - ext_php_rs_zend_object_release, zend_call_known_function, zend_object, zend_objects_new, - HashTable, ZEND_ISEMPTY, ZEND_PROPERTY_EXISTS, ZEND_PROPERTY_ISSET, zend_hash_str_find_ptr_lc, zend_function, object_properties_init, + ext_php_rs_zend_object_release, object_properties_init, zend_call_known_function, + zend_function, zend_hash_str_find_ptr_lc, zend_object, zend_objects_new, HashTable, + ZEND_ISEMPTY, ZEND_PROPERTY_EXISTS, ZEND_PROPERTY_ISSET, }, flags::DataType, rc::PhpRc, @@ -49,8 +50,8 @@ impl ZendObject { } object_properties_init(ptr, ce as *const _ as *mut _); ptr - }, - Some(v) => v(ce as *const _ as *mut _) + } + Some(v) => v(ce as *const _ as *mut _), }; ZBox::from_raw( @@ -132,7 +133,6 @@ impl ZendObject { (self.ce as *const ClassEntry).eq(&(T::get_metadata().ce() as *const _)) } - #[inline(always)] pub fn try_call_method(&self, name: &str, params: Vec<&dyn IntoZvalDyn>) -> Result { let mut retval = Zval::new(); @@ -147,10 +147,10 @@ impl ZendObject { let res = zend_hash_str_find_ptr_lc( &(*self.ce).function_table, name.as_ptr() as *const i8, - name.len() + name.len(), ) as *mut zend_function; if res.is_null() { - return Err(Error::Callable) + return Err(Error::Callable); } zend_call_known_function( res, diff --git a/src/types/zval.rs b/src/types/zval.rs index 721f354..94b62aa 100644 --- a/src/types/zval.rs +++ b/src/types/zval.rs @@ -208,7 +208,9 @@ impl Zval { #[inline(always)] pub fn try_call_method(&self, name: &str, params: Vec<&dyn IntoZvalDyn>) -> Result { - self.object().ok_or(Error::Object)?.try_call_method(name, params) + self.object() + .ok_or(Error::Object)? + .try_call_method(name, params) } /// Returns the value of the zval if it is a reference. diff --git a/src/zend/class.rs b/src/zend/class.rs index 5cb6ec0..b54ad4c 100644 --- a/src/zend/class.rs +++ b/src/zend/class.rs @@ -1,6 +1,12 @@ //! Builder and objects for creating classes in the PHP world. -use crate::{ffi::{zend_class_entry}, flags::ClassFlags, types::{ZendStr, ZendObject}, zend::ExecutorGlobals, boxed::ZBox}; +use crate::{ + boxed::ZBox, + ffi::zend_class_entry, + flags::ClassFlags, + types::{ZendObject, ZendStr}, + zend::ExecutorGlobals, +}; use std::{convert::TryInto, fmt::Debug, ops::DerefMut}; /// A PHP class entry. diff --git a/src/zend/function.rs b/src/zend/function.rs index 93f1903..9321e1a 100644 --- a/src/zend/function.rs +++ b/src/zend/function.rs @@ -1,8 +1,16 @@ //! Builder for creating functions and methods in PHP. -use std::{fmt::Debug, os::raw::c_char, ptr::self}; +use std::{fmt::Debug, os::raw::c_char, ptr}; -use crate::{ffi::{zend_function_entry, zend_fetch_function_str, zend_function, zend_hash_str_find_ptr_lc, zend_call_known_function}, convert::IntoZvalDyn, types::Zval, error::Result}; +use crate::{ + convert::IntoZvalDyn, + error::Result, + ffi::{ + zend_call_known_function, zend_fetch_function_str, zend_function, zend_function_entry, + zend_hash_str_find_ptr_lc, + }, + types::Zval, +}; use super::ClassEntry; @@ -58,14 +66,14 @@ impl Function { let res = zend_hash_str_find_ptr_lc( &ce.function_table, name.as_ptr() as *const i8, - name.len() + name.len(), ) as *mut zend_function; if res.is_null() { - return None + return None; } - return Some(*res) - } - } + return Some(*res); + }, + }; } pub fn from_function(name: &str) -> Self { diff --git a/src/zend/globals.rs b/src/zend/globals.rs index 6843dfd..8b7a219 100644 --- a/src/zend/globals.rs +++ b/src/zend/globals.rs @@ -4,7 +4,6 @@ use std::ops::{Deref, DerefMut}; use parking_lot::{const_rwlock, RwLock, RwLockReadGuard, RwLockWriteGuard}; - use crate::boxed::ZBox; #[cfg(php82)] use crate::ffi::zend_atomic_bool_store; @@ -144,4 +143,4 @@ impl DerefMut for GlobalWriteGuard { fn deref_mut(&mut self) -> &mut Self::Target { self.globals } -} \ No newline at end of file +} diff --git a/src/zend/mod.rs b/src/zend/mod.rs index 89d1df5..872f65b 100644 --- a/src/zend/mod.rs +++ b/src/zend/mod.rs @@ -15,8 +15,8 @@ use std::ffi::CString; pub use _type::ZendType; pub use class::ClassEntry; pub use ex::ExecuteData; -pub use function::FunctionEntry; pub use function::Function; +pub use function::FunctionEntry; pub use globals::ExecutorGlobals; pub use handlers::ZendObjectHandlers; pub use module::ModuleEntry;