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

Migrate to edition 2024 #179

Merged
merged 4 commits into from
Feb 22, 2025
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
370 changes: 177 additions & 193 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ members = [
[workspace.package]
version = "0.14.1"
authors = ["PHPER Framework Team", "jmjoy <jmjoy@apache.org>"]
edition = "2021"
edition = "2024"
license = "MulanPSL-2.0"
repository = "https://github.com/phper-framework/phper"
rust-version = "1.79"
rust-version = "1.85"

[workspace.dependencies]
phper = { version = "0.14.1", path = "./phper" }
Expand Down
47 changes: 22 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,36 +18,33 @@ The framework that allows us to write PHP extensions using pure and safe Rust wh

### Necessary

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

### Tested Support

- **OS**
- [x] linux
- [x] macos
- [ ] ~~windows~~
- **PHP**
- **version**
- [x] 7.0
- [x] 7.1
- [x] 7.2
- [x] 7.3
- [x] 7.4
- [x] 8.0
- [x] 8.1
- [x] 8.2
- [x] 8.3
- **mode**
- [x] nts
- [ ] ~~zts~~
- **sapi**
- [x] cli
- [x] fpm
- **debug**
- [x] disable
- [ ] ~~enable~~
| **Category** | **Item** | **Status** |
| --------------- | -------- | ---------- |
| **OS** | Linux | ✅ |
| | macOS | ✅ |
| | Windows | ❌ |
| **PHP Version** | 7.0 | ✅ |
| | 7.1 | ✅ |
| | 7.2 | ✅ |
| | 7.3 | ✅ |
| | 7.4 | ✅ |
| | 8.0 | ✅ |
| | 8.1 | ✅ |
| | 8.2 | ✅ |
| | 8.3 | ✅ |
| | 8.4 | ✅ |
| **PHP Mode** | NTS | ✅ |
| | ZTS | ❌ |
| **SAPI** | CLI | ✅ |
| | FPM | ✅ |
| **Debug** | Disable | ✅ |
| | Enable | ❌ |

## Examples

Expand Down
2 changes: 1 addition & 1 deletion examples/complex/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use phper::{
arrays::ZArray,
classes::{ClassEntity, Visibility},
functions::Argument,
ini::{ini_get, Policy},
ini::{Policy, ini_get},
modules::Module,
objects::StateObj,
php_get_module,
Expand Down
4 changes: 2 additions & 2 deletions examples/http-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ crate-type = ["lib", "cdylib"]

[dependencies]
phper = { workspace = true }
reqwest = { version = "0.12.5", features = ["blocking", "cookies"] }
thiserror = "1.0.63"
reqwest = { version = "0.12.12", features = ["blocking", "cookies"] }
thiserror = "2.0.11"

[dev-dependencies]
phper-test = { workspace = true }
2 changes: 1 addition & 1 deletion examples/http-client/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use phper::{
classes::{ClassEntity, ClassEntry},
errors::{exception_class, Throwable},
errors::{Throwable, exception_class},
};

/// The exception class name of extension.
Expand Down
12 changes: 6 additions & 6 deletions examples/http-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ name = "http_server"
crate-type = ["lib", "cdylib"]

[dependencies]
hyper = { version = "1.4.1", features = ["http1", "server"] }
axum = "0.7.5"
hyper = { version = "1.6.0", features = ["http1", "server"] }
axum = "0.8.1"
phper = { workspace = true }
thiserror = "1.0.63"
tokio = { version = "1.39.2", features = ["full"] }
reqwest = { version = "0.12.5", features = ["blocking"] }
thiserror = "2.0.11"
tokio = { version = "1.43.0", features = ["full"] }
reqwest = { version = "0.12.12", features = ["blocking"] }

[dev-dependencies]
phper-test = { workspace = true }
reqwest = "0.12.5"
reqwest = "0.12.12"
2 changes: 1 addition & 1 deletion examples/http-server/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use phper::{
classes::{ClassEntity, ClassEntry},
errors::{exception_class, Throwable},
errors::{Throwable, exception_class},
};
use std::error::Error;

Expand Down
2 changes: 1 addition & 1 deletion examples/http-server/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

use crate::{errors::HttpServerError, request::RequestClass, response::ResponseClass};
use axum::{
Router,
body::{self, Body},
http::{Request, Response, StatusCode},
routing::any,
Router,
};
use phper::{
alloc::ToRefOwned,
Expand Down
2 changes: 1 addition & 1 deletion phper-alloc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ mod macros;
use phper_sys::*;
use std::{
borrow::Borrow,
mem::{size_of, ManuallyDrop},
mem::{ManuallyDrop, size_of},
ops::{Deref, DerefMut},
};

Expand Down
4 changes: 1 addition & 3 deletions phper-alloc/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,5 @@
/// ```
#[macro_export]
macro_rules! ebox {
($arg:tt) => {{
$crate::EBox::new($arg)
}};
($arg:tt) => {{ $crate::EBox::new($arg) }};
}
4 changes: 2 additions & 2 deletions phper-doc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ license = { workspace = true }
phper = { workspace = true }

[dev-dependencies]
thiserror = "1.0.63"
reqwest = { version = "0.12.5", features = ["blocking", "cookies"] }
thiserror = "2.0.11"
reqwest = { version = "0.12.12", features = ["blocking", "cookies"] }
3 changes: 1 addition & 2 deletions phper-doc/doc/_03_integrate_with_pecl/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ This chapter will guide you on how to integrate the phper project with `pecl` an

### Adapt to `phpize`

1. At first, imagine you have finished the hello project follow [write your first extension](_02_quick_start::_01_write_your_first_extension), can build the
php extension `.so` file successfully.
1. At first, imagine you have finished the hello project follow [write your first extension](_02_quick_start::_01_write_your_first_extension), can build the php extension `.so` file successfully.

1. And then, create the `config.m4` file using by `phpize` (In theory,
`config.w32` is also required for compatibility with Windows, but now phper
Expand Down
2 changes: 1 addition & 1 deletion phper-doc/doc/_05_internal_types/_01_z_str/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ use phper::sys;
use phper::strings::ZStr;
use phper::alloc::ToRefOwned;

extern "C" {
unsafe extern "C" {
fn something() -> *mut sys::zend_string;
}

Expand Down
2 changes: 1 addition & 1 deletion phper-doc/doc/_05_internal_types/_02_z_arr/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ use phper::sys;
use phper::arrays::ZArr;
use phper::alloc::ToRefOwned;

extern "C" {
unsafe extern "C" {
fn something() -> *mut sys::zend_array;
}

Expand Down
2 changes: 1 addition & 1 deletion phper-doc/doc/_05_internal_types/_03_z_obj/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use phper::sys;
use phper::objects::ZObj;
use phper::alloc::ToRefOwned;

extern "C" {
unsafe extern "C" {
fn something() -> *mut sys::zend_object;
}

Expand Down
8 changes: 4 additions & 4 deletions phper-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ license = { workspace = true }
proc-macro = true

[dependencies]
quote = "1.0.36"
syn = { version = "2.0.72", features = ["full"] }
proc-macro2 = "1.0.86"
quote = "1.0.38"
syn = { version = "2.0.98", features = ["full"] }
proc-macro2 = "1.0.93"

[dev-dependencies]
syn = { version = "2.0.72", features = ["full", "extra-traits"] }
syn = { version = "2.0.98", features = ["full", "extra-traits"] }
4 changes: 2 additions & 2 deletions phper-macros/src/inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use proc_macro::TokenStream;
use quote::quote;
use syn::{parse_macro_input, ItemFn, Visibility};
use syn::{ItemFn, Visibility, parse_macro_input};

pub(crate) fn php_get_module(_attr: TokenStream, input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as ItemFn);
Expand All @@ -31,7 +31,7 @@ pub(crate) fn php_get_module(_attr: TokenStream, input: TokenStream) -> TokenStr
}

let result = quote! {
#[no_mangle]
#[unsafe(no_mangle)]
#[doc(hidden)]
#(#attrs)*
#vis extern "C" fn #name() -> *const ::phper::sys::zend_module_entry {
Expand Down
7 changes: 3 additions & 4 deletions phper-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ repository = { workspace = true }
license = { workspace = true }

[build-dependencies]
bindgen = "0.69.4"
cc = "1.1.7"
home = "=0.5.9"
regex = "1.10.6"
bindgen = "0.71.1"
cc = "1.2.14"
regex = "1.11.1"
2 changes: 2 additions & 0 deletions phper-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
// TODO Because `bindgen` generates codes contains deref nullptr, temporary suppression.
#![allow(deref_nullptr)]
#![allow(clippy::all)]
// TODO unsafe_op_in_unsafe_fn warning in edition 2024, temporary suppression.
#![allow(unsafe_op_in_unsafe_fn)]
#![doc = include_str!("../README.md")]

include!(concat!(env!("OUT_DIR"), "/php_bindings.rs"));
8 changes: 4 additions & 4 deletions phper-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ license = { workspace = true }

[dependencies]
fastcgi-client = "0.9.0"
libc = "0.2.155"
once_cell = "1.19.0"
libc = "0.2.169"
once_cell = "1.20.3"
phper-macros = { workspace = true }
tempfile = "3.11.0"
tokio = { version = "1.39.2", features = ["full"] }
tempfile = "3.17.1"
tokio = { version = "1.43.0", features = ["full"] }

[package.metadata.docs.rs]
rustdoc-args = ["--cfg", "docsrs"]
Expand Down
6 changes: 3 additions & 3 deletions phper-test/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

use crate::context::Context;
use std::{
panic::{catch_unwind, resume_unwind, UnwindSafe},
panic::{UnwindSafe, catch_unwind, resume_unwind},
path::Path,
process::{Child, Output},
};
Expand Down Expand Up @@ -41,8 +41,7 @@ pub type ScriptCondition<'a> = (&'a dyn AsRef<Path>, &'a dyn Fn(Output) -> bool)
/// checkers are pass, than the test is pass.
///
/// - `exec_path` is the path of the make executable, which will be used to
/// detect the path of
/// extension lib.
/// detect the path of extension lib.
///
/// - `scripts` is the slice of the tuple, format is `(path of your php test
/// script, checker function or closure)`.
Expand Down Expand Up @@ -93,6 +92,7 @@ pub fn test_php_scripts_with_condition(

/// Check your extension by executing the long term php script such as http
/// server, if the all your specified checkers are pass, than the test is pass.
#[allow(clippy::zombie_processes)]
pub fn test_long_term_php_script_with_condition(
lib_path: impl AsRef<Path>, script: impl AsRef<Path>,
condition: impl FnOnce(&Child) + UnwindSafe,
Expand Down
2 changes: 1 addition & 1 deletion phper-test/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl Context {
.and_then(|name| {
let mut p = p.to_path_buf();
p.push("sbin");
p.push(&format!(
p.push(format!(
"php-fpm{}",
if name.starts_with("php") {
name.chars().skip(3).collect::<String>()
Expand Down
4 changes: 2 additions & 2 deletions phper-test/src/fpm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
//! Test tools for php fpm program.
use crate::{context::Context, utils::spawn_command};
use fastcgi_client::{Client, Params, Request};
use libc::{atexit, kill, pid_t, SIGTERM};
use libc::{SIGTERM, atexit, kill, pid_t};
use once_cell::sync::OnceCell;
use std::{
fs,
mem::{forget, ManuallyDrop},
mem::{ManuallyDrop, forget},
path::{Path, PathBuf},
process::Child,
sync::Mutex,
Expand Down
8 changes: 4 additions & 4 deletions phper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ license = { workspace = true }

[dependencies]
cfg-if = "1.0.0"
derive_more = "0.99.18"
indexmap = "2.3.0"
once_cell = "1.19.0"
derive_more = { version = "2.0.1", features = ["from", "constructor"] }
indexmap = "2.7.1"
once_cell = "1.20.3"
phper-alloc = { workspace = true }
phper-macros = { workspace = true }
phper-sys = { workspace = true }
thiserror = "1.0.63"
thiserror = "2.0.11"

[build-dependencies]
phper-build = { workspace = true }
Expand Down
Loading
Loading