Skip to content

Adds PHP 8.4 #163

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

Merged
merged 7 commits into from
Nov 28, 2024
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
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ jobs:
- "8.1"
- "8.2"
- "8.3"
- "8.4"

runs-on: ${{ matrix.os }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The framework that allows us to write PHP extensions using pure and safe Rust wh

### Necessary

- **rust** 1.65 or later
- **rust** 1.79 or later
- **libclang** 9.0 or later
- **php** 7.0 or later

Expand Down
4 changes: 4 additions & 0 deletions phper-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ fn main() {
.allowlist_file("php_wrapper\\.c")
// Block the `zend_ini_parse_quantity` because it's document causes the doc test to fail.
.blocklist_function("zend_ini_parse_quantity")
// Block the `zend_startup` because it fails checks.
.blocklist_function("zend_startup")
// Block the `zend_random_bytes_insecure` because it fails checks.
.blocklist_item("zend_random_bytes_insecure")
.clang_args(&includes)
.derive_default(true);

Expand Down
1 change: 1 addition & 0 deletions phper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ repository = { workspace = true }
license = { workspace = true }

[dependencies]
cfg-if = "1.0.0"
derive_more = "0.99.18"
indexmap = "2.3.0"
once_cell = "1.19.0"
Expand Down
20 changes: 19 additions & 1 deletion phper/src/classes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,25 @@ unsafe extern "C" fn create_object(ce: *mut zend_class_entry) -> *mut zend_objec
let object = state_object.as_mut_object().as_mut_ptr();
zend_object_std_init(object, ce);
object_properties_init(object, ce);
rebuild_object_properties(object);

cfg_if::cfg_if! {
if #[cfg(any(
phper_major_version = "7",
all(
phper_major_version = "8",
any(
phper_minor_version = "0",
phper_minor_version = "1",
phper_minor_version = "2",
phper_minor_version = "3",
),
)
))] {
rebuild_object_properties(object);
} else {
rebuild_object_properties_internal(object);
}
}

// Set handlers
let mut handlers = Box::new(std_object_handlers);
Expand Down
1 change: 1 addition & 0 deletions phper/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ thread_local! {
impl Default for ExceptionGuard {
fn default() -> Self {
EXCEPTION_STACK.with(|stack| unsafe {
#[allow(static_mut_refs)]
stack
.borrow_mut()
.push(replace(&mut eg!(exception), null_mut()));
Expand Down
3 changes: 3 additions & 0 deletions phper/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,14 @@ impl FunctionEntry {

let flags = visibility.unwrap_or(Visibility::default() as u32);

#[allow(clippy::needless_update)]
zend_function_entry {
fname: name.as_ptr().cast(),
handler: raw_handler,
arg_info: Box::into_raw(infos.into_boxed_slice()).cast(),
num_args: arguments.len() as u32,
flags,
..Default::default()
}
}

Expand Down Expand Up @@ -657,6 +659,7 @@ pub(crate) fn call_raw_common(call_fn: impl FnOnce(&mut ZVal)) -> crate::Result<

unsafe {
if !eg!(exception).is_null() {
#[allow(static_mut_refs)]
let e = ptr::replace(&mut eg!(exception), null_mut());
let obj = ZObject::from_raw(e);
match ThrowObject::new(obj) {
Expand Down
Loading