Skip to content

Commit

Permalink
Merge pull request #338 from davidcole1340/php-8.4
Browse files Browse the repository at this point in the history
PHP 8.4
  • Loading branch information
joehoyle authored Nov 26, 2024
2 parents c91fbac + cc2e462 commit bf9decd
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
php: ["8.0", "8.1", "8.2", "8.3"]
php: ["8.0", "8.1", "8.2", "8.3", "8.4"]
rust: [stable, nightly]
clang: ["15", "17"]
phpts: [ts, nts]
Expand Down
12 changes: 10 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use bindgen::RustTarget;
use impl_::Provider;

const MIN_PHP_API_VER: u32 = 20200930;
const MAX_PHP_API_VER: u32 = 20230831;
const MAX_PHP_API_VER: u32 = 20240924;

pub trait PHPProvider<'a>: Sized {
/// Create a new PHP provider.
Expand Down Expand Up @@ -230,7 +230,11 @@ fn check_php_version(info: &PHPInfo) -> Result<()> {

const PHP_83_API_VER: u32 = 20230831;

println!("cargo::rustc-check-cfg=cfg(php80, php81, php82, php83, php_zts, php_debug, docs)");
const PHP_84_API_VER: u32 = 20240924;

println!(
"cargo::rustc-check-cfg=cfg(php80, php81, php82, php83, php84, php_zts, php_debug, docs)"
);
println!("cargo:rustc-cfg=php80");

if (PHP_81_API_VER..PHP_82_API_VER).contains(&version) {
Expand All @@ -245,6 +249,10 @@ fn check_php_version(info: &PHPInfo) -> Result<()> {
println!("cargo:rustc-cfg=php83");
}

if version >= PHP_84_API_VER {
println!("cargo:rustc-cfg=php84");
}

Ok(())
}

Expand Down
8 changes: 8 additions & 0 deletions src/builders/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ impl<'a> FunctionBuilder<'a> {
arg_info: ptr::null(),
num_args: 0,
flags: 0, // TBD?
#[cfg(php84)]
doc_comment: ptr::null(),
#[cfg(php84)]
frameless_function_infos: ptr::null(),
},
args: vec![],
n_req: None,
Expand All @@ -79,6 +83,10 @@ impl<'a> FunctionBuilder<'a> {
arg_info: ptr::null(),
num_args: 0,
flags: MethodFlags::Abstract.bits(),
#[cfg(php84)]
doc_comment: ptr::null(),
#[cfg(php84)]
frameless_function_infos: ptr::null(),
},
args: vec![],
n_req: None,
Expand Down
4 changes: 4 additions & 0 deletions src/zend/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ impl FunctionEntry {
arg_info: ptr::null(),
num_args: 0,
flags: 0,
#[cfg(php84)]
doc_comment: ptr::null(),
#[cfg(php84)]
frameless_function_infos: ptr::null(),
}
}

Expand Down
15 changes: 12 additions & 3 deletions src/zend/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,18 @@ impl ZendObjectHandlers {
let mut zv = Zval::new();
val.get(self_, &mut zv)?;

#[allow(clippy::unnecessary_mut_passed)]
if zend_is_true(&mut zv) == 1 {
return Ok(1);
cfg_if::cfg_if! {
if #[cfg(php84)] {
#[allow(clippy::unnecessary_mut_passed)]
if zend_is_true(&mut zv) == true {
return Ok(1);
}
} else {
#[allow(clippy::unnecessary_mut_passed)]
if zend_is_true(&mut zv) == 1 {
return Ok(1);
}
}
}
}
}
Expand Down
23 changes: 20 additions & 3 deletions windows_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,27 @@ impl DevelPack {
/// Downloads a new PHP development pack, unzips it in the build script
/// temporary directory.
fn new(version: &str, is_zts: bool, arch: Arch) -> Result<DevelPack> {
// If the PHP version is more than 8.4.1, use VS17 instead of VS16.
let version_float = version
.split('.')
.take(2)
.collect::<Vec<_>>()
.join(".")
.parse::<f32>()
.context("Failed to parse PHP version as float")?;

// PHP builds switched to VS17 in PHP 8.4.1.
let visual_studio_version = if version_float >= 8.4f32 {
"vs17"
} else {
"vs16"
};

let zip_name = format!(
"php-devel-pack-{}{}-Win32-{}-{}.zip",
version,
if is_zts { "" } else { "-nts" },
"vs16", /* TODO(david): At the moment all PHPs supported by ext-php-rs use VS16 so
* this is constant. */
visual_studio_version,
arch
);

Expand Down Expand Up @@ -207,8 +222,10 @@ impl DevelPack {
Ok(devpack_path)
}

let is_archive = if version == "8.4.1" { false } else { true };

download(&zip_name, false)
.or_else(|_| download(&zip_name, true))
.or_else(|_| download(&zip_name, is_archive))
.map(DevelPack)
}

Expand Down

0 comments on commit bf9decd

Please sign in to comment.