Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/builders/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ impl ClassBuilder {

let class = unsafe {
zend_register_internal_class_ex(
&mut self.ce,
&raw mut self.ce,
match self.extends {
Some((ptr, _)) => ptr::from_ref(ptr()).cast_mut(),
None => std::ptr::null_mut(),
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![warn(clippy::pedantic)]
#![cfg_attr(docs, feature(doc_cfg))]
#![cfg_attr(windows, feature(abi_vectorcall))]

Expand Down
10 changes: 5 additions & 5 deletions src/types/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ impl ZendHashTable {
V: IntoZval,
{
let mut val = val.into_zval(false)?;
unsafe { zend_hash_str_update(self, CString::new(key)?.as_ptr(), key.len(), &mut val) };
unsafe { zend_hash_str_update(self, CString::new(key)?.as_ptr(), key.len(), &raw mut val) };
val.release();
Ok(())
}
Expand Down Expand Up @@ -416,7 +416,7 @@ impl ZendHashTable {
V: IntoZval,
{
let mut val = val.into_zval(false)?;
unsafe { zend_hash_index_update(self, key, &mut val) };
unsafe { zend_hash_index_update(self, key, &raw mut val) };
val.release();
Ok(())
}
Expand Down Expand Up @@ -453,7 +453,7 @@ impl ZendHashTable {
V: IntoZval,
{
let mut val = val.into_zval(false)?;
unsafe { zend_hash_next_index_insert(self, &mut val) };
unsafe { zend_hash_next_index_insert(self, &raw mut val) };
val.release();

Ok(())
Expand Down Expand Up @@ -534,7 +534,7 @@ impl ZendHashTable {
/// }
#[inline]
#[must_use]
pub fn values(&self) -> Values {
pub fn values(&self) -> Values<'_> {
Values::new(self)
}

Expand All @@ -559,7 +559,7 @@ impl ZendHashTable {
/// }
#[inline]
#[must_use]
pub fn iter(&self) -> Iter {
pub fn iter(&self) -> Iter<'_> {
self.into_iter()
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/types/callable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,12 @@ impl<'a> ZendCallable<'a> {
let result = unsafe {
#[allow(clippy::used_underscore_items)]
_call_user_function_impl(
std::ptr::null_mut(),
ptr::null_mut(),
ptr::from_ref(self.0.as_ref()).cast_mut(),
&mut retval,
&raw mut retval,
len.try_into()?,
packed.as_ptr().cast_mut(),
std::ptr::null_mut(),
ptr::null_mut(),
)
};

Expand Down
10 changes: 5 additions & 5 deletions src/types/class_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,13 @@ impl<T: RegisteredClass> ZendClassObject<T> {
.as_mut()
.expect("Failed to allocate for new Zend object");

zend_object_std_init(&mut obj.std, ce);
object_properties_init(&mut obj.std, ce);
zend_object_std_init(&raw mut obj.std, ce);
object_properties_init(&raw mut obj.std, ce);

// SAFETY: `obj` is non-null and well aligned as it is a reference.
// As the data in `obj.obj` is uninitialized, we don't want to drop
// the data, but directly override it.
ptr::write(&mut obj.obj, val);
ptr::write(&raw mut obj.obj, val);

obj.std.handlers = meta.handlers();
ZBox::from_raw(obj)
Expand Down Expand Up @@ -239,7 +239,7 @@ unsafe impl<T: RegisteredClass> ZBoxable for ZendClassObject<T> {
// SAFETY: All constructors guarantee that `self` contains a valid pointer.
// Further, all constructors guarantee that the `std` field of
// `ZendClassObject` will be initialized.
unsafe { ext_php_rs_zend_object_release(&mut self.std) }
unsafe { ext_php_rs_zend_object_release(&raw mut self.std) }
}
}

Expand Down Expand Up @@ -276,7 +276,7 @@ impl<T: RegisteredClass + Clone> Clone for ZBox<ZendClassObject<T>> {
// therefore we can dereference both safely.
unsafe {
let mut new = ZendClassObject::new((***self).clone());
zend_objects_clone_members(&mut new.std, (&raw const self.std).cast_mut());
zend_objects_clone_members(&raw mut new.std, (&raw const self.std).cast_mut());
new
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/types/iterable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl Iterable<'_> {
/// May return None if a Traversable cannot be rewound.
// TODO: Check iter not returning iterator
#[allow(clippy::iter_not_returning_iterator)]
pub fn iter(&mut self) -> Option<Iter> {
pub fn iter(&mut self) -> Option<Iter<'_>> {
match self {
Iterable::Array(array) => Some(Iter::Array(array.iter())),
Iterable::Traversable(traversable) => Some(Iter::Traversable(traversable.iter()?)),
Expand Down
12 changes: 6 additions & 6 deletions src/types/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl ZendIterator {
/// iterator cannot be rewound.
// TODO: Check iter not returning iterator
#[allow(clippy::iter_not_returning_iterator)]
pub fn iter(&mut self) -> Option<Iter> {
pub fn iter(&mut self) -> Option<Iter<'_>> {
self.index = 0;

if self.rewind() {
Expand All @@ -39,7 +39,7 @@ impl ZendIterator {
/// `\Iterator` interface. see <https://www.php.net/manual/en/iterator.valid.php>
pub fn valid(&mut self) -> bool {
if let Some(valid) = unsafe { (*self.funcs).valid } {
let valid = unsafe { valid(&mut *self) == ZEND_RESULT_CODE_SUCCESS };
let valid = unsafe { valid(&raw mut *self) == ZEND_RESULT_CODE_SUCCESS };

if ExecutorGlobals::has_exception() {
return false;
Expand All @@ -63,7 +63,7 @@ impl ZendIterator {
pub fn rewind(&mut self) -> bool {
if let Some(rewind) = unsafe { (*self.funcs).rewind } {
unsafe {
rewind(&mut *self);
rewind(&raw mut *self);
}
}

Expand All @@ -82,7 +82,7 @@ impl ZendIterator {
pub fn move_forward(&mut self) -> bool {
if let Some(move_forward) = unsafe { (*self.funcs).move_forward } {
unsafe {
move_forward(&mut *self);
move_forward(&raw mut *self);
}
}

Expand All @@ -97,7 +97,7 @@ impl ZendIterator {
/// , [`None`] otherwise.
pub fn get_current_data<'a>(&mut self) -> Option<&'a Zval> {
let get_current_data = unsafe { (*self.funcs).get_current_data }?;
let value = unsafe { &*get_current_data(&mut *self) };
let value = unsafe { &*get_current_data(&raw mut *self) };

if ExecutorGlobals::has_exception() {
return None;
Expand All @@ -117,7 +117,7 @@ impl ZendIterator {
let mut key = Zval::new();

unsafe {
get_current_key(&mut *self, &mut key);
get_current_key(&raw mut *self, &raw mut key);
}

if ExecutorGlobals::has_exception() {
Expand Down
24 changes: 12 additions & 12 deletions src/types/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ impl ZendObject {

unsafe {
let res = zend_hash_str_find_ptr_lc(
&(*self.ce).function_table,
&raw const (*self.ce).function_table,
name.as_ptr().cast::<c_char>(),
name.len(),
)
Expand All @@ -193,7 +193,7 @@ impl ZendObject {
res,
ptr::from_ref(self).cast_mut(),
self.ce,
&mut retval,
&raw mut retval,
len.try_into()?,
packed.as_ptr().cast_mut(),
std::ptr::null_mut(),
Expand Down Expand Up @@ -230,10 +230,10 @@ impl ZendObject {
let zv = unsafe {
self.handlers()?.read_property.ok_or(Error::InvalidScope)?(
self.mut_ptr(),
&mut *name,
&raw mut *name,
1,
std::ptr::null_mut(),
&mut rv,
ptr::null_mut(),
&raw mut rv,
)
.as_ref()
}
Expand All @@ -260,9 +260,9 @@ impl ZendObject {
unsafe {
self.handlers()?.write_property.ok_or(Error::InvalidScope)?(
self,
&mut *name,
&mut value,
std::ptr::null_mut(),
&raw mut *name,
&raw mut value,
ptr::null_mut(),
)
.as_ref()
}
Expand All @@ -289,7 +289,7 @@ impl ZendObject {
Ok(unsafe {
self.handlers()?.has_property.ok_or(Error::InvalidScope)?(
self.mut_ptr(),
&mut *name,
&raw mut *name,
query as _,
std::ptr::null_mut(),
)
Expand Down Expand Up @@ -440,10 +440,10 @@ impl FromZendObject<'_> for String {
(*obj.ce).__tostring,
ptr::from_ref(obj).cast_mut(),
obj.ce,
&mut ret,
&raw mut ret,
0,
std::ptr::null_mut(),
std::ptr::null_mut(),
ptr::null_mut(),
ptr::null_mut(),
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/types/zval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ impl Zval {

/// Returns the value of the zval if it is callable.
#[must_use]
pub fn callable(&self) -> Option<ZendCallable> {
pub fn callable(&self) -> Option<ZendCallable<'_>> {
// The Zval is checked if it is callable in the `new` function.
ZendCallable::new(self).ok()
}
Expand All @@ -309,7 +309,7 @@ impl Zval {
/// Returns an iterable over the zval if it is an array or traversable. (is
/// iterable)
#[must_use]
pub fn iterable(&self) -> Option<Iterable> {
pub fn iterable(&self) -> Option<Iterable<'_>> {
if self.is_iterable() {
Iterable::from_zval(self)
} else {
Expand Down
4 changes: 3 additions & 1 deletion src/zend/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ impl ClassEntry {
ExecutorGlobals::get().class_table()?;
let mut name = ZendStr::new(name, false);

unsafe { crate::ffi::zend_lookup_class_ex(&mut *name, std::ptr::null_mut(), 0).as_ref() }
unsafe {
crate::ffi::zend_lookup_class_ex(&raw mut *name, std::ptr::null_mut(), 0).as_ref()
}
}

/// Creates a new [`ZendObject`], returned inside an [`ZBox<ZendObject>`]
Expand Down
10 changes: 5 additions & 5 deletions src/zend/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl Function {
None => None,
Some(ce) => unsafe {
let res = zend_hash_str_find_ptr_lc(
&ce.function_table,
&raw const ce.function_table,
name.as_ptr().cast::<c_char>(),
name.len(),
)
Expand Down Expand Up @@ -139,12 +139,12 @@ impl Function {
unsafe {
zend_call_known_function(
ptr::from_ref(self).cast_mut(),
std::ptr::null_mut(),
std::ptr::null_mut(),
&mut retval,
ptr::null_mut(),
ptr::null_mut(),
&raw mut retval,
len.try_into()?,
packed.as_ptr().cast_mut(),
std::ptr::null_mut(),
ptr::null_mut(),
);
};

Expand Down
Loading