davidcole1340 / ext-php-rs

Bindings for the Zend API to build PHP extensions natively in Rust.
Apache License 2.0
598 stars 64 forks source link

Support for variadic functions #300

Closed joehoyle closed 11 months ago

joehoyle commented 11 months ago

When a function is created with #[php_function], if the last param of the Rust function is &[&Zval], it will be treated as the variadic argument in PHP.

#[php_function]
fn my_func( name: &str, args: &[&Zval] ) {
    dbg!(args);
}

Called from PHP:

my_funct( 'joe', 1, 2, 3, 4, 5 );
danog commented 11 months ago

Thanks, could you also update the docs pls?

Also, do you think you could find some time to take a look at https://github.com/davidcole1340/ext-php-rs/pull/294? I don't have a mac machine so debugging that issue would be kinda tricky.