Skip to content

Commit 6261e04

Browse files
committed
fix(cfg): unified php version cfg
Refs: #331
1 parent fd385d8 commit 6261e04

File tree

4 files changed

+20
-17
lines changed

4 files changed

+20
-17
lines changed

build.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,16 @@ fn check_php_version(info: &PHPInfo) -> Result<()> {
231231
const PHP_83_API_VER: u32 = 20230831;
232232

233233
println!("cargo::rustc-check-cfg=cfg(php80, php81, php82, php83, php_zts, php_debug, docs)");
234-
println!("cargo:rustc-cfg=php80");
234+
235+
if version < PHP_81_API_VER {
236+
println!("cargo:rustc-cfg=php80");
237+
}
235238

236239
if (PHP_81_API_VER..PHP_82_API_VER).contains(&version) {
237240
println!("cargo:rustc-cfg=php81");
238241
}
239242

240-
if version >= PHP_82_API_VER {
243+
if (PHP_82_API_VER..PHP_83_API_VER).contains(&version) {
241244
println!("cargo:rustc-cfg=php82");
242245
}
243246

src/builders/class.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ impl ClassBuilder {
247247
// disable serialization if the class has an associated object
248248
if self.object_override.is_some() {
249249
cfg_if::cfg_if! {
250-
if #[cfg(any(php81, php82))] {
250+
if #[cfg(not(php80))] {
251251
class.ce_flags |= ClassFlags::NotSerializable.bits();
252252
} else {
253253
class.serialize = Some(crate::ffi::zend_class_serialize_deny);

src/flags.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use bitflags::bitflags;
44

5-
#[cfg(not(php82))]
5+
#[cfg(any(php80, php81))]
66
use crate::ffi::ZEND_ACC_REUSE_GET_ITERATOR;
77
use crate::ffi::{
88
CONST_CS, CONST_DEPRECATED, CONST_NO_FILE_CACHE, CONST_PERSISTENT, E_COMPILE_ERROR,
@@ -84,14 +84,14 @@ bitflags! {
8484
const ConstantsUpdated = ZEND_ACC_CONSTANTS_UPDATED;
8585
const NoDynamicProperties = ZEND_ACC_NO_DYNAMIC_PROPERTIES;
8686
const HasStaticInMethods = ZEND_HAS_STATIC_IN_METHODS;
87-
#[cfg(not(php82))]
87+
#[cfg(any(php80, php81))]
8888
const ReuseGetIterator = ZEND_ACC_REUSE_GET_ITERATOR;
8989
const ResolvedParent = ZEND_ACC_RESOLVED_PARENT;
9090
const ResolvedInterfaces = ZEND_ACC_RESOLVED_INTERFACES;
9191
const UnresolvedVariance = ZEND_ACC_UNRESOLVED_VARIANCE;
9292
const NearlyLinked = ZEND_ACC_NEARLY_LINKED;
9393

94-
#[cfg(any(php81,php82))]
94+
#[cfg(not(php80))]
9595
const NotSerializable = crate::ffi::ZEND_ACC_NOT_SERIALIZABLE;
9696
}
9797
}

src/zend/globals.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ use parking_lot::{const_rwlock, RwLock, RwLockReadGuard, RwLockWriteGuard};
1010

1111
use crate::boxed::ZBox;
1212
use crate::exception::PhpResult;
13-
#[cfg(php80)]
14-
use crate::ffi::_zend_hash_find_known_hash;
15-
#[cfg(php82)]
13+
#[cfg(not(any(php80, php81)))]
1614
use crate::ffi::zend_atomic_bool_store;
1715
use crate::ffi::{
18-
_sapi_module_struct, _zend_executor_globals, _zend_string, executor_globals,
19-
ext_php_rs_executor_globals, ext_php_rs_file_globals, ext_php_rs_process_globals,
20-
ext_php_rs_sapi_globals, ext_php_rs_sapi_module, php_core_globals, php_file_globals,
21-
sapi_globals_struct, sapi_header_struct, sapi_headers_struct, sapi_request_info,
22-
zend_ini_entry, zend_is_auto_global, TRACK_VARS_COOKIE, TRACK_VARS_ENV, TRACK_VARS_FILES,
23-
TRACK_VARS_GET, TRACK_VARS_POST, TRACK_VARS_SERVER,
16+
_sapi_module_struct, _zend_executor_globals, executor_globals, ext_php_rs_executor_globals,
17+
ext_php_rs_file_globals, ext_php_rs_process_globals, ext_php_rs_sapi_globals,
18+
ext_php_rs_sapi_module, php_core_globals, php_file_globals, sapi_globals_struct,
19+
sapi_header_struct, sapi_headers_struct, sapi_request_info, zend_ini_entry,
20+
zend_is_auto_global, TRACK_VARS_COOKIE, TRACK_VARS_ENV, TRACK_VARS_FILES, TRACK_VARS_GET,
21+
TRACK_VARS_POST, TRACK_VARS_SERVER,
2422
};
23+
#[cfg(php80)]
24+
use crate::ffi::{_zend_hash_find_known_hash, _zend_string};
2525
#[cfg(not(php80))]
2626
use crate::ffi::{
2727
_zend_known_string_id_ZEND_STR_AUTOGLOBAL_REQUEST, zend_hash_find_known_hash,
@@ -161,7 +161,7 @@ impl ExecutorGlobals {
161161
/// set with [`crate::ffi::zend_interrupt_function`].
162162
pub fn request_interrupt(&mut self) {
163163
cfg_if::cfg_if! {
164-
if #[cfg(php82)] {
164+
if #[cfg(not(any(php80, php81)))] {
165165
unsafe {
166166
zend_atomic_bool_store(&mut self.vm_interrupt, true);
167167
}
@@ -174,7 +174,7 @@ impl ExecutorGlobals {
174174
/// Cancel a requested an interrupt of the PHP VM.
175175
pub fn cancel_interrupt(&mut self) {
176176
cfg_if::cfg_if! {
177-
if #[cfg(php82)] {
177+
if #[cfg(not(any(php80, php81)))] {
178178
unsafe {
179179
zend_atomic_bool_store(&mut self.vm_interrupt, false);
180180
}

0 commit comments

Comments
 (0)