Skip to content

Commit bf9decd

Browse files
authored
Merge pull request #338 from davidcole1340/php-8.4
PHP 8.4
2 parents c91fbac + cc2e462 commit bf9decd

File tree

6 files changed

+55
-9
lines changed

6 files changed

+55
-9
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
matrix:
1717
os: [ubuntu-latest, macos-latest, windows-latest]
18-
php: ["8.0", "8.1", "8.2", "8.3"]
18+
php: ["8.0", "8.1", "8.2", "8.3", "8.4"]
1919
rust: [stable, nightly]
2020
clang: ["15", "17"]
2121
phpts: [ts, nts]

build.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use bindgen::RustTarget;
1616
use impl_::Provider;
1717

1818
const MIN_PHP_API_VER: u32 = 20200930;
19-
const MAX_PHP_API_VER: u32 = 20230831;
19+
const MAX_PHP_API_VER: u32 = 20240924;
2020

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

231231
const PHP_83_API_VER: u32 = 20230831;
232232

233-
println!("cargo::rustc-check-cfg=cfg(php80, php81, php82, php83, php_zts, php_debug, docs)");
233+
const PHP_84_API_VER: u32 = 20240924;
234+
235+
println!(
236+
"cargo::rustc-check-cfg=cfg(php80, php81, php82, php83, php84, php_zts, php_debug, docs)"
237+
);
234238
println!("cargo:rustc-cfg=php80");
235239

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

252+
if version >= PHP_84_API_VER {
253+
println!("cargo:rustc-cfg=php84");
254+
}
255+
248256
Ok(())
249257
}
250258

src/builders/function.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ impl<'a> FunctionBuilder<'a> {
5555
arg_info: ptr::null(),
5656
num_args: 0,
5757
flags: 0, // TBD?
58+
#[cfg(php84)]
59+
doc_comment: ptr::null(),
60+
#[cfg(php84)]
61+
frameless_function_infos: ptr::null(),
5862
},
5963
args: vec![],
6064
n_req: None,
@@ -79,6 +83,10 @@ impl<'a> FunctionBuilder<'a> {
7983
arg_info: ptr::null(),
8084
num_args: 0,
8185
flags: MethodFlags::Abstract.bits(),
86+
#[cfg(php84)]
87+
doc_comment: ptr::null(),
88+
#[cfg(php84)]
89+
frameless_function_infos: ptr::null(),
8290
},
8391
args: vec![],
8492
n_req: None,

src/zend/function.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ impl FunctionEntry {
3838
arg_info: ptr::null(),
3939
num_args: 0,
4040
flags: 0,
41+
#[cfg(php84)]
42+
doc_comment: ptr::null(),
43+
#[cfg(php84)]
44+
frameless_function_infos: ptr::null(),
4145
}
4246
}
4347

src/zend/handlers.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,18 @@ impl ZendObjectHandlers {
238238
let mut zv = Zval::new();
239239
val.get(self_, &mut zv)?;
240240

241-
#[allow(clippy::unnecessary_mut_passed)]
242-
if zend_is_true(&mut zv) == 1 {
243-
return Ok(1);
241+
cfg_if::cfg_if! {
242+
if #[cfg(php84)] {
243+
#[allow(clippy::unnecessary_mut_passed)]
244+
if zend_is_true(&mut zv) == true {
245+
return Ok(1);
246+
}
247+
} else {
248+
#[allow(clippy::unnecessary_mut_passed)]
249+
if zend_is_true(&mut zv) == 1 {
250+
return Ok(1);
251+
}
252+
}
244253
}
245254
}
246255
}

windows_build.rs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,27 @@ impl DevelPack {
163163
/// Downloads a new PHP development pack, unzips it in the build script
164164
/// temporary directory.
165165
fn new(version: &str, is_zts: bool, arch: Arch) -> Result<DevelPack> {
166+
// If the PHP version is more than 8.4.1, use VS17 instead of VS16.
167+
let version_float = version
168+
.split('.')
169+
.take(2)
170+
.collect::<Vec<_>>()
171+
.join(".")
172+
.parse::<f32>()
173+
.context("Failed to parse PHP version as float")?;
174+
175+
// PHP builds switched to VS17 in PHP 8.4.1.
176+
let visual_studio_version = if version_float >= 8.4f32 {
177+
"vs17"
178+
} else {
179+
"vs16"
180+
};
181+
166182
let zip_name = format!(
167183
"php-devel-pack-{}{}-Win32-{}-{}.zip",
168184
version,
169185
if is_zts { "" } else { "-nts" },
170-
"vs16", /* TODO(david): At the moment all PHPs supported by ext-php-rs use VS16 so
171-
* this is constant. */
186+
visual_studio_version,
172187
arch
173188
);
174189

@@ -207,8 +222,10 @@ impl DevelPack {
207222
Ok(devpack_path)
208223
}
209224

225+
let is_archive = if version == "8.4.1" { false } else { true };
226+
210227
download(&zip_name, false)
211-
.or_else(|_| download(&zip_name, true))
228+
.or_else(|_| download(&zip_name, is_archive))
212229
.map(DevelPack)
213230
}
214231

0 commit comments

Comments
 (0)