diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 388b5a2727..4745be5220 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -64,27 +64,26 @@ jobs: - name: Cache LLVM and Clang id: cache-llvm uses: actions/cache@v3 - if: "!contains(matrix.os, 'windows')" + # Macos build doesn't work with clang < 18. As a build for version 18 is not available, we skip the setup + if: "!contains(matrix.os, 'windows') && !contains(matrix.os, 'macos')" with: path: ${{ runner.temp }}/llvm-${{ matrix.clang }} key: ${{ matrix.os }}-llvm-${{ matrix.clang }} - name: Setup LLVM & Clang id: clang - uses: KyleMayes/install-llvm-action@v1 - if: "!contains(matrix.os, 'windows')" + uses: KyleMayes/install-llvm-action@v2 + # Macos build doesn't work with clang < 18. As a build for version 18 is not available, we skip the setup + if: "!contains(matrix.os, 'windows') && !contains(matrix.os, 'macos')" with: version: ${{ matrix.clang }} directory: ${{ runner.temp }}/llvm-${{ matrix.clang }} - cached: ${{ steps.cache-llvm.outputs.cache-hit }} - name: Configure Clang - if: "!contains(matrix.os, 'windows')" + # Macos build doesn't work with clang < 18. As a build for version 18 is not available, we skip the setup + if: "!contains(matrix.os, 'windows') && !contains(matrix.os, 'macos')" run: | echo "LIBCLANG_PATH=${{ runner.temp }}/llvm-${{ matrix.clang }}/lib" >> $GITHUB_ENV echo "LLVM_VERSION=${{ steps.clang.outputs.version }}" >> $GITHUB_ENV echo "LLVM_CONFIG_PATH=${{ runner.temp }}/llvm-${{ matrix.clang }}/bin/llvm-config" >> $GITHUB_ENV - - name: Configure Clang (macOS only) - if: "contains(matrix.os, 'macos')" - run: echo "SDKROOT=$(xcrun --show-sdk-path)" >> $GITHUB_ENV # Build - name: Build env: diff --git a/build.rs b/build.rs index 5afef52e2d..bcaabb4161 100644 --- a/build.rs +++ b/build.rs @@ -230,6 +230,7 @@ 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)"); println!("cargo:rustc-cfg=php80"); if (PHP_81_API_VER..PHP_82_API_VER).contains(&version) { diff --git a/crates/cli/src/lib.rs b/crates/cli/src/lib.rs index 496e5ce9e6..86b8692544 100644 --- a/crates/cli/src/lib.rs +++ b/crates/cli/src/lib.rs @@ -329,6 +329,7 @@ impl Remove { .read(true) .write(true) .create(true) + .truncate(false) .open(php_ini) .with_context(|| "Failed to open `php.ini`")?; diff --git a/crates/macros/src/method.rs b/crates/macros/src/method.rs index 7eb8a34f1a..b5d7fad21e 100644 --- a/crates/macros/src/method.rs +++ b/crates/macros/src/method.rs @@ -18,13 +18,6 @@ pub enum Arg { Typed(function::Arg), } -#[derive(Debug)] -pub struct AttrArgs { - pub defaults: HashMap, - pub optional: Option, - pub visibility: Visibility, -} - #[derive(Debug, Clone)] pub struct Method { /// Method name @@ -51,7 +44,7 @@ pub struct ParsedMethod { #[derive(Debug, Clone, Copy)] pub enum MethodType { - Receiver { mutable: bool }, + Receiver, ReceiverClassObject, Static, } @@ -176,7 +169,7 @@ pub fn parser( } } else { let this = match method_type { - MethodType::Receiver { .. } => quote! { this. }, + MethodType::Receiver => quote! { this. }, MethodType::ReceiverClassObject | MethodType::Static => quote! { Self:: }, }; @@ -309,9 +302,7 @@ fn build_args( if receiver.reference.is_none() { bail!("`self` parameter must be a reference."); } - Ok(Arg::Receiver(MethodType::Receiver { - mutable: receiver.mutability.is_some(), - })) + Ok(Arg::Receiver(MethodType::Receiver)) } FnArg::Typed(ty) => { let mut this = false; diff --git a/src/builders/class.rs b/src/builders/class.rs index 28e8463841..9224536906 100644 --- a/src/builders/class.rs +++ b/src/builders/class.rs @@ -153,8 +153,8 @@ impl ClassBuilder { /// /// * `T` - The type which will override the Zend object. Must implement /// [`RegisteredClass`] - /// which can be derived using the [`php_class`](crate::php_class) attribute - /// macro. + /// which can be derived using the [`php_class`](crate::php_class) attribute + /// macro. /// /// # Panics /// diff --git a/src/class.rs b/src/class.rs index c02a53fa18..c24cdf912a 100644 --- a/src/class.rs +++ b/src/class.rs @@ -108,6 +108,12 @@ impl ClassMetadata { } } +impl Default for ClassMetadata { + fn default() -> Self { + Self::new() + } +} + impl ClassMetadata { /// Returns an immutable reference to the object handlers contained inside /// the class metadata. diff --git a/src/lib.rs b/src/lib.rs index ee1d68fc80..1f42a1d878 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -153,7 +153,7 @@ pub use ext_php_rs_derive::php_extern; /// /// - Most primitive integers ([`i8`], [`i16`], [`i32`], [`i64`], [`u8`], /// [`u16`], [`u32`], [`u64`], -/// [`usize`], [`isize`]) +/// [`usize`], [`isize`]) /// - Double-precision floating point numbers ([`f64`]) /// - [`bool`] /// - [`String`] @@ -164,9 +164,9 @@ pub use ext_php_rs_derive::php_extern; /// values. /// - [`Option`] where `T: FromZval`. When used as a parameter, the parameter /// will be -/// deemed nullable, and will contain [`None`] when `null` is passed. When used -/// as a return type, if [`None`] is returned the [`Zval`] will be set to null. -/// Optional parameters *must* be of the type [`Option`]. +/// deemed nullable, and will contain [`None`] when `null` is passed. When used +/// as a return type, if [`None`] is returned the [`Zval`] will be set to null. +/// Optional parameters *must* be of the type [`Option`]. /// /// Additionally, you are able to return a variant of [`Result`]. `T` must /// implement [`IntoZval`] and `E` must implement `Into`. If an @@ -324,14 +324,14 @@ pub use ext_php_rs_derive::php_function; /// /// - `#[defaults(key = value, ...)]` for setting defaults of method variables, /// similar to the -/// function macro. Arguments with defaults need to be optional. +/// function macro. Arguments with defaults need to be optional. /// - `#[optional(key)]` for setting `key` as an optional argument (and /// therefore the rest of the -/// arguments). +/// arguments). /// - `#[public]`, `#[protected]` and `#[private]` for setting the visibility of /// the method, -/// defaulting to public. The Rust visibility has no effect on the PHP -/// visibility. +/// defaulting to public. The Rust visibility has no effect on the PHP +/// visibility. /// /// Methods can take a immutable or a mutable reference to `self`, but cannot /// consume `self`. They can also take no reference to `self` which indicates a diff --git a/src/types/array.rs b/src/types/array.rs index 0b54f6ea66..bc82cec831 100644 --- a/src/types/array.rs +++ b/src/types/array.rs @@ -7,7 +7,6 @@ use std::{ ffi::CString, fmt::{Debug, Display}, iter::FromIterator, - u64, }; use crate::{ diff --git a/tests/src/lib.rs b/tests/src/lib.rs index ec5c49d620..237c08ef05 100644 --- a/tests/src/lib.rs +++ b/tests/src/lib.rs @@ -120,7 +120,7 @@ pub fn get_module(module: ModuleBuilder) -> ModuleBuilder { #[cfg(test)] mod integration { use std::env; - use std::path::PathBuf; + use std::process::Command; use std::sync::Once; @@ -139,7 +139,7 @@ mod integration { pub fn run_php(file: &str) -> bool { setup(); - let mut path = PathBuf::from(env::current_dir().expect("Could not get cwd")); + let mut path = env::current_dir().expect("Could not get cwd"); path.pop(); path.push("target"); path.push("debug");