You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: guide/src/types/functions.md
+2-4Lines changed: 2 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -5,8 +5,6 @@ PHP functions and methods are represented by the `Function` struct.
5
5
You can use the `try_from_function` and `try_from_method` methods to obtain a Function struct corresponding to the passed function or static method name.
6
6
It's heavily recommended you reuse returned `Function` objects, to avoid the overhead of looking up the function/method name.
7
7
8
-
You may also use the infallible `from_function` and `from_method` variants, for example when working with native PHP functions/classes that are guaranteed to be always available.
9
-
10
8
```rust,no_run
11
9
# #![cfg_attr(windows, feature(abi_vectorcall))]
12
10
# extern crate ext_php_rs;
@@ -16,13 +14,13 @@ use ext_php_rs::zend::Function;
16
14
17
15
#[php_function]
18
16
pub fn test_function() -> () {
19
-
let var_dump = Function::from_function("var_dump");
17
+
let var_dump = Function::try_from_function("var_dump").unwrap();
20
18
let _ = var_dump.try_call(vec![&"abc"]);
21
19
}
22
20
23
21
#[php_function]
24
22
pub fn test_method() -> () {
25
-
let f = Function::from_method("ClassName", "staticMethod");
23
+
let f = Function::try_from_method("ClassName", "staticMethod").unwrap();
0 commit comments