Skip to content

Commit fb9721b

Browse files
committed
Revert materialize_missing feature, refactor CI workflow
1 parent 904ba7f commit fb9721b

8 files changed

Lines changed: 11 additions & 210 deletions

File tree

.github/workflows/release-plz.yml

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,24 @@ jobs:
3131
if: ${{ github.repository_owner == 'phper-framework' }}
3232
permissions:
3333
contents: write
34+
pull-requests: read
3435
steps:
35-
- name: Checkout repository
36-
uses: actions/checkout@v4
36+
- &checkout
37+
name: Checkout repository
38+
uses: actions/checkout@v6
3739
with:
3840
fetch-depth: 0
39-
- name: Install Rust toolchain
41+
persist-credentials: false
42+
- &install-rust
43+
name: Install Rust toolchain
4044
uses: dtolnay/rust-toolchain@stable
41-
4245
- name: Install libclang
4346
run: sudo apt-get install -y llvm-18-dev libclang-18-dev
44-
4547
- name: Setup PHP
4648
uses: shivammathur/setup-php@v2
4749
with:
4850
php-version: 7.4
4951
tools: php-config
50-
5152
- name: Run release-plz
5253
uses: release-plz/action@v0.5
5354
with:
@@ -68,12 +69,8 @@ jobs:
6869
group: release-plz-${{ github.ref }}
6970
cancel-in-progress: false
7071
steps:
71-
- name: Checkout repository
72-
uses: actions/checkout@v4
73-
with:
74-
fetch-depth: 0
75-
- name: Install Rust toolchain
76-
uses: dtolnay/rust-toolchain@stable
72+
- *checkout
73+
- *install-rust
7774
- name: Run release-plz
7875
uses: release-plz/action@v0.5
7976
with:

phper-sys/php_wrapper.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -463,10 +463,6 @@ uint32_t phper_zend_call_num_args(const zend_execute_data *execute_data) {
463463
return ZEND_CALL_NUM_ARGS(execute_data);
464464
}
465465

466-
void phper_zend_set_call_num_args(zend_execute_data *execute_data, uint32_t num) {
467-
ZEND_CALL_NUM_ARGS(execute_data) = num;
468-
}
469-
470466
uint32_t phper_zend_call_info(zend_execute_data *execute_data) {
471467
return ZEND_CALL_INFO(execute_data);
472468
}

phper/src/errors.rs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ macro_rules! throwable_delegate {
4646
Self::InitializeObject(e) => Throwable::$method(e),
4747
Self::ExpectType(e) => Throwable::$method(e),
4848
Self::NotImplementThrowable(e) => Throwable::$method(e),
49-
Self::CallArg(e) => Throwable::$method(e),
5049
}
5150
};
5251
// For `&mut self` methods (to_object).
@@ -62,7 +61,6 @@ macro_rules! throwable_delegate {
6261
Self::InitializeObject(e) => Throwable::$method(e),
6362
Self::ExpectType(e) => Throwable::$method(e),
6463
Self::NotImplementThrowable(e) => Throwable::$method(e),
65-
Self::CallArg(e) => Throwable::$method(e),
6664
}
6765
};
6866
}
@@ -250,9 +248,6 @@ pub enum Error {
250248
#[error(transparent)]
251249
NotImplementThrowable(#[from] NotImplementThrowableError),
252250

253-
/// Call argument index out of bounds.
254-
#[error(transparent)]
255-
CallArg(#[from] CallArgError),
256251
}
257252

258253
impl Error {
@@ -388,23 +383,6 @@ impl Throwable for ThrowObject {
388383
}
389384
}
390385

391-
/// Call argument index out of bounds.
392-
#[derive(Debug, thiserror::Error, Constructor)]
393-
#[error(
394-
"call arg index {index} out of bounds: must be in [0, {declared_len}) (declared_len = \
395-
{declared_len})"
396-
)]
397-
pub struct CallArgError {
398-
index: usize,
399-
declared_len: usize,
400-
}
401-
402-
impl Throwable for CallArgError {
403-
fn get_class(&self) -> &ClassEntry {
404-
type_error_class()
405-
}
406-
}
407-
408386
/// Expect type is not the actual type.
409387
#[derive(Debug, thiserror::Error, Constructor)]
410388
#[error("type error: must be of type {expect_type}, {actual_type} given")]

phper/src/modules.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,7 @@ impl Module {
257257
/// access.
258258
///
259259
/// Unlike [`add_function`], the handler receives `&mut ExecuteData`
260-
/// alongside `&mut [ZVal]`, enabling methods like
261-
/// [`materialize_missing`](crate::values::ExecuteData::materialize_missing).
260+
/// alongside `&mut [ZVal]`.
262261
pub fn add_function_with_execute_data<F, Z, E>(
263262
&mut self, name: impl Into<String>, handler: F,
264263
) -> &mut FunctionEntity

phper/src/values.rs

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use crate::{
1414
arrays::{ZArr, ZArray},
1515
classes::ClassEntry,
16-
errors::{CallArgError, ExpectTypeError},
16+
errors::ExpectTypeError,
1717
functions::{ZFunc, call_internal},
1818
objects::{StateObject, ZObj, ZObject},
1919
references::ZRef,
@@ -242,56 +242,8 @@ impl ExecuteData {
242242
}
243243
}
244244

245-
/// Fills missing optional parameters with their default values.
246-
///
247-
/// `defaults` is the full list of default values for **all** optional
248-
/// parameters of the function. Already-provided optional arguments are
249-
/// skipped automatically.
250-
///
251-
/// `num_args` is updated to reflect the new count.
252-
///
253-
/// # Errors
254-
///
255-
/// Returns [`CallArgError`] if the total after filling would not match
256-
/// `common_num_args()`.
257-
pub fn materialize_missing(
258-
&mut self, defaults: impl IntoIterator<Item = ZVal>,
259-
) -> crate::Result<()> {
260-
let declared_len = self.common_num_args() as usize;
261-
let required_len = self.common_required_num_args();
262-
let passed_len = self.num_args();
263-
264-
if passed_len >= declared_len {
265-
return Ok(());
266-
}
267-
268-
let execute_data_ptr = self.as_mut_ptr();
269245

270-
let provided_optionals = passed_len.saturating_sub(required_len);
271-
let mut i = passed_len;
272246

273-
for mut default in defaults.into_iter().skip(provided_optionals) {
274-
if i >= declared_len {
275-
return Err(CallArgError::new(i, declared_len).into());
276-
}
277-
unsafe {
278-
phper_zend_init_call_arg(
279-
execute_data_ptr,
280-
i.try_into().unwrap(),
281-
default.as_mut_ptr(),
282-
);
283-
}
284-
i += 1;
285-
}
286-
287-
if i != declared_len {
288-
return Err(CallArgError::new(i, declared_len).into());
289-
}
290-
unsafe {
291-
phper_zend_set_call_num_args(execute_data_ptr, i.try_into().unwrap());
292-
}
293-
Ok(())
294-
}
295247
}
296248

297249
/// Wrapper of [zval].
Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +0,0 @@
1-
// Copyright (c) 2022 PHPER Framework Team
2-
// PHPER is licensed under Mulan PSL v2.
3-
// You can use this software according to the terms and conditions of the Mulan
4-
// PSL v2. You may obtain a copy of Mulan PSL v2 at:
5-
// http://license.coscl.org.cn/MulanPSL2
6-
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY
7-
// KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
8-
// NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
9-
// See the Mulan PSL v2 for more details.
10-
11-
use phper::{functions::Argument, modules::Module, values::ZVal};
12-
13-
pub fn integrate(module: &mut Module) {
14-
register_two_optionals(module);
15-
register_no_optionals(module);
16-
register_exceed_error(module);
17-
register_insufficient_error(module);
18-
}
19-
20-
fn register_two_optionals(module: &mut Module) {
21-
module
22-
.add_function_with_execute_data(
23-
"materialize_missing_two_optionals",
24-
|execute_data, _arguments| -> phper::Result<String> {
25-
execute_data.materialize_missing([ZVal::from(42), ZVal::from("hello")])?;
26-
let a = execute_data.get_parameter(0).expect_long()?;
27-
let b = execute_data.get_parameter(1).expect_z_str()?.to_str()?;
28-
let c = execute_data.get_parameter(2).expect_long()?;
29-
let d = execute_data.get_parameter(3).expect_z_str()?.to_str()?;
30-
Ok(format!("{}, {}, {}, {}", a, b, c, d))
31-
},
32-
)
33-
.arguments([
34-
Argument::new("a"),
35-
Argument::new("b"),
36-
Argument::new("c").optional(),
37-
Argument::new("d").optional(),
38-
]);
39-
}
40-
41-
fn register_no_optionals(module: &mut Module) {
42-
module
43-
.add_function_with_execute_data(
44-
"materialize_missing_no_optionals",
45-
|execute_data, _arguments| -> phper::Result<String> {
46-
execute_data.materialize_missing([])?;
47-
let a = execute_data.get_parameter(0).expect_long()?;
48-
let b = execute_data.get_parameter(1).expect_z_str()?.to_str()?;
49-
Ok(format!("{}, {}", a, b))
50-
},
51-
)
52-
.arguments([Argument::new("a"), Argument::new("b")]);
53-
}
54-
55-
fn register_exceed_error(module: &mut Module) {
56-
module
57-
.add_function_with_execute_data(
58-
"materialize_missing_exceed_error",
59-
|execute_data, _arguments| -> phper::Result<String> {
60-
execute_data.materialize_missing([ZVal::from(1), ZVal::from(2), ZVal::from(3)])?;
61-
Ok("ok".to_owned())
62-
},
63-
)
64-
.arguments([Argument::new("a").optional(), Argument::new("b").optional()]);
65-
}
66-
67-
fn register_insufficient_error(module: &mut Module) {
68-
module
69-
.add_function_with_execute_data(
70-
"materialize_missing_insufficient_error",
71-
|execute_data, _arguments| -> phper::Result<String> {
72-
execute_data.materialize_missing(std::iter::empty())?;
73-
Ok("ok".to_owned())
74-
},
75-
)
76-
.arguments([Argument::new("a").optional(), Argument::new("b").optional()]);
77-
}

tests/integration/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ mod classes;
1616
mod constants;
1717
mod enums;
1818
mod errors;
19-
mod execute_data;
2019
mod functions;
2120
mod ini;
2221
mod macros;
@@ -47,7 +46,6 @@ pub fn get_module() -> Module {
4746
ini::integrate(&mut module);
4847
macros::integrate(&mut module);
4948
errors::integrate(&mut module);
50-
execute_data::integrate(&mut module);
5149
references::integrate(&mut module);
5250
typehints::integrate(&mut module);
5351
#[cfg(all(phper_major_version = "8", not(phper_minor_version = "0")))]
Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +0,0 @@
1-
<?php
2-
3-
// Copyright (c) 2026 PHPER Framework Team
4-
// PHPER is licensed under Mulan PSL v2.
5-
// You can use this software according to the terms and conditions of the Mulan
6-
// PSL v2. You may obtain a copy of Mulan PSL v2 at:
7-
// http://license.coscl.org.cn/MulanPSL2
8-
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY
9-
// KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
10-
// NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
11-
// See the Mulan PSL v2 for more details.
12-
13-
14-
require_once __DIR__ . '/_common.php';
15-
16-
// 2 required + 2 optional, 2 args provided → fill both optionals
17-
assert_eq(materialize_missing_two_optionals(1, "world"), "1, world, 42, hello");
18-
19-
// 2 required + 2 optional, 3 args provided → skip 1st default, fill 2nd
20-
assert_eq(materialize_missing_two_optionals(1, "world", 10), "1, world, 10, hello");
21-
22-
// 2 required + 2 optional, all 4 args provided → no-op
23-
assert_eq(materialize_missing_two_optionals(1, "world", 10, "foo"), "1, world, 10, foo");
24-
25-
// no optional params → no-op
26-
assert_eq(materialize_missing_no_optionals(1, "world"), "1, world");
27-
28-
// defaults exceed declared param count
29-
assert_throw(
30-
function () { materialize_missing_exceed_error(); },
31-
"TypeError",
32-
0,
33-
"call arg index 2 out of bounds: must be in [0, 2) (declared_len = 2)"
34-
);
35-
36-
// not enough defaults
37-
assert_throw(
38-
function () { materialize_missing_insufficient_error(); },
39-
"TypeError",
40-
0,
41-
"call arg index 0 out of bounds: must be in [0, 2) (declared_len = 2)"
42-
);

0 commit comments

Comments
 (0)