Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions .github/workflows/release-plz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,24 @@ jobs:
if: ${{ github.repository_owner == 'phper-framework' }}
permissions:
contents: write
pull-requests: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- &checkout
name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Install Rust toolchain
persist-credentials: false
- &install-rust
name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable

- name: Install libclang
run: sudo apt-get install -y llvm-18-dev libclang-18-dev

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
tools: php-config

- name: Run release-plz
uses: release-plz/action@v0.5
with:
Expand All @@ -68,12 +69,8 @@ jobs:
group: release-plz-${{ github.ref }}
cancel-in-progress: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- *checkout
- *install-rust
- name: Run release-plz
uses: release-plz/action@v0.5
with:
Expand Down
4 changes: 0 additions & 4 deletions phper-sys/php_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,10 +463,6 @@ uint32_t phper_zend_call_num_args(const zend_execute_data *execute_data) {
return ZEND_CALL_NUM_ARGS(execute_data);
}

void phper_zend_set_call_num_args(zend_execute_data *execute_data, uint32_t num) {
ZEND_CALL_NUM_ARGS(execute_data) = num;
}

uint32_t phper_zend_call_info(zend_execute_data *execute_data) {
return ZEND_CALL_INFO(execute_data);
}
Expand Down
23 changes: 0 additions & 23 deletions phper/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ macro_rules! throwable_delegate {
Self::InitializeObject(e) => Throwable::$method(e),
Self::ExpectType(e) => Throwable::$method(e),
Self::NotImplementThrowable(e) => Throwable::$method(e),
Self::CallArg(e) => Throwable::$method(e),
}
};
// For `&mut self` methods (to_object).
Expand All @@ -62,7 +61,6 @@ macro_rules! throwable_delegate {
Self::InitializeObject(e) => Throwable::$method(e),
Self::ExpectType(e) => Throwable::$method(e),
Self::NotImplementThrowable(e) => Throwable::$method(e),
Self::CallArg(e) => Throwable::$method(e),
}
};
}
Expand Down Expand Up @@ -249,10 +247,6 @@ pub enum Error {
/// Failed when the object isn't implement PHP `Throwable`.
#[error(transparent)]
NotImplementThrowable(#[from] NotImplementThrowableError),

/// Call argument index out of bounds.
#[error(transparent)]
CallArg(#[from] CallArgError),
}

impl Error {
Expand Down Expand Up @@ -388,23 +382,6 @@ impl Throwable for ThrowObject {
}
}

/// Call argument index out of bounds.
#[derive(Debug, thiserror::Error, Constructor)]
#[error(
"call arg index {index} out of bounds: must be in [0, {declared_len}) (declared_len = \
{declared_len})"
)]
pub struct CallArgError {
index: usize,
declared_len: usize,
}

impl Throwable for CallArgError {
fn get_class(&self) -> &ClassEntry {
type_error_class()
}
}

/// Expect type is not the actual type.
#[derive(Debug, thiserror::Error, Constructor)]
#[error("type error: must be of type {expect_type}, {actual_type} given")]
Expand Down
3 changes: 1 addition & 2 deletions phper/src/modules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,7 @@ impl Module {
/// access.
///
/// Unlike [`add_function`], the handler receives `&mut ExecuteData`
/// alongside `&mut [ZVal]`, enabling methods like
/// [`materialize_missing`](crate::values::ExecuteData::materialize_missing).
/// alongside `&mut [ZVal]`.
pub fn add_function_with_execute_data<F, Z, E>(
&mut self, name: impl Into<String>, handler: F,
) -> &mut FunctionEntity
Expand Down
53 changes: 1 addition & 52 deletions phper/src/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use crate::{
arrays::{ZArr, ZArray},
classes::ClassEntry,
errors::{CallArgError, ExpectTypeError},
errors::ExpectTypeError,
functions::{ZFunc, call_internal},
objects::{StateObject, ZObj, ZObject},
references::ZRef,
Expand Down Expand Up @@ -241,57 +241,6 @@ impl ExecuteData {
ZVal::from_mut_ptr(val)
}
}

/// Fills missing optional parameters with their default values.
///
/// `defaults` is the full list of default values for **all** optional
/// parameters of the function. Already-provided optional arguments are
/// skipped automatically.
///
/// `num_args` is updated to reflect the new count.
///
/// # Errors
///
/// Returns [`CallArgError`] if the total after filling would not match
/// `common_num_args()`.
pub fn materialize_missing(
&mut self, defaults: impl IntoIterator<Item = ZVal>,
) -> crate::Result<()> {
let declared_len = self.common_num_args() as usize;
let required_len = self.common_required_num_args();
let passed_len = self.num_args();

if passed_len >= declared_len {
return Ok(());
}

let execute_data_ptr = self.as_mut_ptr();

let provided_optionals = passed_len.saturating_sub(required_len);
let mut i = passed_len;

for mut default in defaults.into_iter().skip(provided_optionals) {
if i >= declared_len {
return Err(CallArgError::new(i, declared_len).into());
}
unsafe {
phper_zend_init_call_arg(
execute_data_ptr,
i.try_into().unwrap(),
default.as_mut_ptr(),
);
}
i += 1;
}

if i != declared_len {
return Err(CallArgError::new(i, declared_len).into());
}
unsafe {
phper_zend_set_call_num_args(execute_data_ptr, i.try_into().unwrap());
}
Ok(())
}
}

/// Wrapper of [zval].
Expand Down
77 changes: 0 additions & 77 deletions tests/integration/src/execute_data.rs

This file was deleted.

2 changes: 0 additions & 2 deletions tests/integration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ mod classes;
mod constants;
mod enums;
mod errors;
mod execute_data;
mod functions;
mod ini;
mod macros;
Expand Down Expand Up @@ -47,7 +46,6 @@ pub fn get_module() -> Module {
ini::integrate(&mut module);
macros::integrate(&mut module);
errors::integrate(&mut module);
execute_data::integrate(&mut module);
references::integrate(&mut module);
typehints::integrate(&mut module);
#[cfg(all(phper_major_version = "8", not(phper_minor_version = "0")))]
Expand Down
5 changes: 0 additions & 5 deletions tests/integration/tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,3 @@ fn test_typehints() {
fn test_enums() {
test_php_script(&*DYLIB_PATH, TESTS_PHP_DIR.join("enums.php"));
}

#[test]
fn test_execute_data() {
test_php_script(&*DYLIB_PATH, TESTS_PHP_DIR.join("execute_data.php"));
}
42 changes: 0 additions & 42 deletions tests/integration/tests/php/execute_data.php

This file was deleted.

Loading