Skip to content

Commit 0689edb

Browse files
committed
fix: Remove deprecated hash key constants and update array iteration logic for PHPER 8.5 compatibility
1 parent daa9a7d commit 0689edb

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed

phper-sys/php_wrapper.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ phper_init_class_entry_handler(zend_class_entry *class_ce, void *argument);
5454
#define ZEND_CALL_MAY_HAVE_UNDEF (1 << 26)
5555
#endif
5656

57-
const int PHPER_HASH_KEY_IS_STRING = (int) HASH_KEY_IS_STRING;
58-
const int PHPER_HASH_KEY_IS_LONG = (int) HASH_KEY_IS_LONG;
59-
6057
// ==================================================
6158
// zval apis:
6259
// ==================================================

phper/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ unexpected_cfgs = { level = "warn", check-cfg = [
4444
'cfg(phper_minor_version, values("2"))',
4545
'cfg(phper_minor_version, values("3"))',
4646
'cfg(phper_minor_version, values("4"))',
47+
'cfg(phper_minor_version, values("5"))',
4748
'cfg(phper_zts)',
4849
'cfg(phper_enum_supported)',
4950
] }

phper/src/arrays.rs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//! Apis relate to [zend_array].
1212
1313
use crate::{alloc::EBox, strings::ZStr, sys::*, values::ZVal};
14+
use cfg_if::cfg_if;
1415
use derive_more::From;
1516
use phper_alloc::ToRefOwned;
1617
use std::{
@@ -463,16 +464,37 @@ impl<'a> Iterator for RawIter<'a> {
463464
&mut self.pos,
464465
) as u32;
465466

466-
let iter_key = if result == HASH_KEY_IS_STRING {
467+
const IS_STRING: u32 = {
468+
cfg_if! {
469+
if #[cfg(all(phper_major_version = "8", phper_minor_version = "5"))] {
470+
zend_hash_key_type_HASH_KEY_IS_STRING
471+
} else {
472+
HASH_KEY_IS_STRING
473+
}
474+
}
475+
};
476+
477+
const IS_LONG: u32 = {
478+
cfg_if! {
479+
if #[cfg(all(phper_major_version = "8", phper_minor_version = "5"))] {
480+
zend_hash_key_type_HASH_KEY_IS_LONG
481+
} else {
482+
HASH_KEY_IS_LONG
483+
}
484+
}
485+
};
486+
487+
let iter_key = if result == IS_STRING {
467488
IterKey::ZStr(ZStr::from_mut_ptr(str_index))
468-
} else if result == HASH_KEY_IS_LONG {
489+
} else if result == IS_LONG {
469490
#[allow(clippy::unnecessary_cast)]
470491
IterKey::Index(num_index as u64)
471492
} else {
472493
self.finished = true;
473494
return None;
474495
};
475496

497+
#[allow(clippy::unnecessary_mut_passed)]
476498
let val = zend_hash_get_current_data_ex(self.arr, &mut self.pos);
477499
if val.is_null() {
478500
self.finished = true;

phper/src/constants.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl Constant {
7575
module_number,
7676
)
7777
}
78-
}
78+
};
7979
}
8080
}
8181
}

0 commit comments

Comments
 (0)