diff --git a/phper-build/src/lib.rs b/phper-build/src/lib.rs index e9cfd81d..18637784 100644 --- a/phper-build/src/lib.rs +++ b/phper-build/src/lib.rs @@ -28,10 +28,6 @@ pub fn register_configures() { "cargo:rustc-cfg=phper_release_version=\"{}\"", PHP_RELEASE_VERSION ); - println!( - "cargo:rustc-cfg=phper_php_version=\"{}.{}\"", - PHP_MAJOR_VERSION, PHP_MINOR_VERSION, - ); if PHP_DEBUG != 0 { println!("cargo:rustc-cfg=phper_debug"); diff --git a/phper/build.rs b/phper/build.rs index 56392ad0..2975236d 100644 --- a/phper/build.rs +++ b/phper/build.rs @@ -24,12 +24,4 @@ fn main() { "PHPER not support ZTS mode now (php built with `--enable-maintainer-zts` or \ `--enable-zts`)." ); - - register_version_flags(); -} - -fn register_version_flags() { - if PHP_VERSION_ID >= 70100 { - println!("cargo:rustc-cfg=phper_version_id_gte_70100",); - } } diff --git a/phper/src/errors.rs b/phper/src/errors.rs index 4608ee00..c8b193e5 100644 --- a/phper/src/errors.rs +++ b/phper/src/errors.rs @@ -55,7 +55,7 @@ pub fn type_error_class<'a>() -> &'a ClassEntry { } /// Predefined class `ArgumentCountError` (>= PHP 7.1.0). -#[cfg(phper_version_id_gte_70100)] +#[cfg(not(all(phper_major_version = "7", phper_minor_version = "0")))] #[inline] pub fn argument_count_error_class<'a>() -> &'a ClassEntry { unsafe { ClassEntry::from_ptr(zend_ce_argument_count_error) } @@ -434,12 +434,12 @@ pub struct ArgumentCountError { impl Throwable for ArgumentCountError { fn get_class(&self) -> &ClassEntry { - #[cfg(phper_version_id_gte_70100)] + #[cfg(not(all(phper_major_version = "7", phper_minor_version = "0")))] { argument_count_error_class() } - #[cfg(not(phper_version_id_gte_70100))] + #[cfg(all(phper_major_version = "7", phper_minor_version = "0"))] { type_error_class() } @@ -503,7 +503,7 @@ impl Throwable for NotImplementThrowableError { } } -pub struct ExceptionGuard(PhantomData<()>); +pub struct ExceptionGuard(PhantomData<*mut ()>); impl Default for ExceptionGuard { fn default() -> Self { diff --git a/phper/src/functions.rs b/phper/src/functions.rs index 1de6cd68..790b2fd8 100644 --- a/phper/src/functions.rs +++ b/phper/src/functions.rs @@ -381,9 +381,9 @@ impl ZendFunction { #[cfg(all( phper_major_version = "7", any( - phper_minor_version = "0", - phper_minor_version = "1", phper_minor_version = "2", + phper_minor_version = "1", + phper_minor_version = "0", ) ))] initialized: 1, @@ -449,7 +449,7 @@ unsafe extern "C" fn invoke(execute_data: *mut zend_execute_data, return_value: pub(crate) const fn create_zend_arg_info( name: *const c_char, _pass_by_ref: bool, ) -> zend_internal_arg_info { - #[cfg(any(phper_php_version = "8.1", phper_php_version = "8.0"))] + #[cfg(phper_major_version = "8")] { zend_internal_arg_info { name, @@ -461,10 +461,13 @@ pub(crate) const fn create_zend_arg_info( } } - #[cfg(any( - phper_php_version = "7.4", - phper_php_version = "7.3", - phper_php_version = "7.2" + #[cfg(all( + phper_major_version = "7", + any( + phper_minor_version = "4", + phper_minor_version = "3", + phper_minor_version = "2", + ) ))] { #[allow(clippy::unnecessary_cast)] @@ -476,7 +479,10 @@ pub(crate) const fn create_zend_arg_info( } } - #[cfg(any(phper_php_version = "7.1", phper_php_version = "7.0"))] + #[cfg(all( + phper_major_version = "7", + any(phper_minor_version = "1", phper_minor_version = "0") + ))] { zend_internal_arg_info { name, diff --git a/phper/src/ini.rs b/phper/src/ini.rs index 4171a475..b069eabc 100644 --- a/phper/src/ini.rs +++ b/phper/src/ini.rs @@ -141,16 +141,21 @@ impl IniEntity { fn create_ini_entry_ex(name: &str, default_value: &str, modifiable: u32) -> zend_ini_entry_def { #[cfg(any( - phper_php_version = "8.1", - phper_php_version = "8.0", - phper_php_version = "7.4", - phper_php_version = "7.3", + phper_major_version = "8", + all( + phper_major_version = "7", + any(phper_minor_version = "4", phper_minor_version = "3") + ) ))] let (modifiable, name_length) = (modifiable as std::os::raw::c_uchar, name.len() as u16); - #[cfg(any( - phper_php_version = "7.2", - phper_php_version = "7.1", - phper_php_version = "7.0", + + #[cfg(all( + phper_major_version = "7", + any( + phper_minor_version = "2", + phper_minor_version = "1", + phper_minor_version = "0", + ) ))] let (modifiable, name_length) = (modifiable as std::os::raw::c_int, name.len() as u32);