Skip to content

Commit c98029c

Browse files
committed
Fix document tests.
1 parent 44a9f5a commit c98029c

File tree

7 files changed

+18
-28
lines changed

7 files changed

+18
-28
lines changed

examples/hello/tests/integration.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@
88
// NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
99
// See the Mulan PSL v2 for more details.
1010

11-
use phper_test::{
12-
cli::{test_php_scripts, test_php_scripts_with_lib},
13-
utils::get_lib_path_by_example,
14-
};
11+
use phper_test::{cli::test_php_scripts_with_lib, utils::get_lib_path_by_example};
1512
use std::{env, path::Path};
1613

1714
#[test]

examples/http-client/tests/integration.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@
88
// NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
99
// See the Mulan PSL v2 for more details.
1010

11-
use phper_test::{
12-
cli::{test_php_scripts, test_php_scripts_with_lib},
13-
utils::get_lib_path_by_example,
14-
};
11+
use phper_test::{cli::test_php_scripts_with_lib, utils::get_lib_path_by_example};
1512
use std::{env, path::Path};
1613

1714
#[test]

examples/http-server/tests/integration.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@
1010

1111
use hyper::header::CONTENT_TYPE;
1212
use phper_test::{
13-
cli::{
14-
test_long_term_php_script_with_condition, test_long_term_php_script_with_condition_and_lib,
15-
},
16-
utils::get_lib_path_by_example,
13+
cli::test_long_term_php_script_with_condition_and_lib, utils::get_lib_path_by_example,
1714
};
1815
use reqwest::Client;
1916
use std::{env, path::Path, thread::sleep, time::Duration};

examples/logging/tests/integration.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@
88
// NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
99
// See the Mulan PSL v2 for more details.
1010

11-
use phper_test::{
12-
cli::{test_php_scripts_with_condition, test_php_scripts_with_condition_and_lib},
13-
utils::get_lib_path_by_example,
14-
};
11+
use phper_test::{cli::test_php_scripts_with_condition_and_lib, utils::get_lib_path_by_example};
1512
use std::{env, path::Path, str};
1613

1714
#[test]

phper/src/functions.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
//! TODO Add lambda.
1414
1515
use crate::{
16-
alloc::EBox,
1716
cg,
1817
classes::Visibility,
1918
errors::{ArgumentCountError, CallFunctionError, CallMethodError},
@@ -245,7 +244,7 @@ impl ZendFunction {
245244

246245
pub(crate) fn call(
247246
&mut self, mut object: Option<&mut ZObj>, mut arguments: impl AsMut<[ZVal]>,
248-
) -> crate::Result<EBox<ZVal>> {
247+
) -> crate::Result<ZVal> {
249248
let arguments = arguments.as_mut();
250249
let function_handler = self.as_mut_ptr();
251250

@@ -422,14 +421,14 @@ pub(crate) const fn create_zend_arg_info(
422421
/// Ok(())
423422
/// }
424423
/// ```
425-
pub fn call(fn_name: &str, arguments: impl AsMut<[ZVal]>) -> crate::Result<EBox<ZVal>> {
424+
pub fn call(fn_name: &str, arguments: impl AsMut<[ZVal]>) -> crate::Result<ZVal> {
426425
let mut func = fn_name.into();
427426
call_internal(&mut func, None, arguments)
428427
}
429428

430429
pub(crate) fn call_internal(
431430
func: &mut ZVal, mut object: Option<&mut ZObj>, mut arguments: impl AsMut<[ZVal]>,
432-
) -> crate::Result<EBox<ZVal>> {
431+
) -> crate::Result<ZVal> {
433432
let func_ptr = func.as_mut_ptr();
434433
let arguments = arguments.as_mut();
435434

@@ -469,8 +468,8 @@ pub(crate) fn call_internal(
469468
pub(crate) fn call_raw_common(
470469
call_fn: impl FnOnce(&mut ZVal) -> bool, name_fn: impl FnOnce() -> crate::Result<String>,
471470
object: Option<&mut ZObj>,
472-
) -> crate::Result<EBox<ZVal>> {
473-
let mut ret = EBox::new(ZVal::from(()));
471+
) -> crate::Result<ZVal> {
472+
let mut ret = ZVal::default();
474473

475474
if call_fn(&mut ret) && !ret.get_type_info().is_undef() {
476475
return Ok(ret);

phper/src/objects.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,16 +143,19 @@ impl ZObj {
143143
/// ```
144144
/// use phper::{alloc::EBox, classes::ClassEntry, values::ZVal};
145145
///
146-
/// fn example() -> phper::Result<EBox<Val>> {
147-
/// let mut memcached = StatelessClassEntry::from_globals("Memcached")?.new_object(&mut [])?;
148-
/// memcached.call("addServer", &mut [Val::new("127.0.0.1"), Val::new(11211)])?;
149-
/// let r = memcached.call("get", &mut [Val::new("hello")])?;
146+
/// fn example() -> phper::Result<ZVal> {
147+
/// let mut memcached = ClassEntry::from_globals("Memcached")?.new_object(&mut [])?;
148+
/// memcached.call(
149+
/// "addServer",
150+
/// &mut [ZVal::from("127.0.0.1"), ZVal::from(11211)],
151+
/// )?;
152+
/// let r = memcached.call("get", &mut [ZVal::from("hello")])?;
150153
/// Ok(r)
151154
/// }
152155
/// ```
153156
pub fn call(
154157
&mut self, method_name: &str, arguments: impl AsMut<[ZVal]>,
155-
) -> crate::Result<EBox<ZVal>> {
158+
) -> crate::Result<ZVal> {
156159
let mut method = method_name.into();
157160

158161
unsafe {

phper/src/values.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ impl ZVal {
327327
/// # Errors
328328
///
329329
/// Return Err when self is not callable.
330-
pub fn call(&mut self, arguments: impl AsMut<[ZVal]>) -> crate::Result<EBox<ZVal>> {
330+
pub fn call(&mut self, arguments: impl AsMut<[ZVal]>) -> crate::Result<ZVal> {
331331
call_internal(self, None, arguments)
332332
}
333333
}

0 commit comments

Comments
 (0)