File tree Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -86,8 +86,10 @@ the `count` parameter is no longer long, but a reference.
86
86
Arguments can have type-hints, nullability and default values applied. Here we define a function that accepts
87
87
a nullable class (in this case, an interface), and a string with a default value:
88
88
89
- ``` rust,no-run
89
+ ``` rust,no_run
90
90
use phper::{modules::Module, php_get_module, functions::Argument, echo};
91
+ use phper::types::ArgumentTypeHint;
92
+ use std::ffi::CString;
91
93
92
94
#[php_get_module]
93
95
pub fn get_module() -> Module {
Original file line number Diff line number Diff line change @@ -106,21 +106,21 @@ foo.add_static_method(
106
106
107
107
Methods may add argument and return typehints as per functions. For example:
108
108
109
- ``` rust,no-run
109
+ ``` rust,no_run
110
110
use phper::classes::{ClassEntity, ClassEntry, Visibility};
111
- use phper::functions::Argument;
112
- use phper::types::{ArgumentTypeHint, ReturnTypeHint},
111
+ use phper::functions::{ Argument, ReturnType} ;
112
+ use phper::types::{ArgumentTypeHint, ReturnTypeHint};
113
113
114
114
let mut foo = ClassEntity::new("Foo");
115
115
foo.add_method(
116
116
"test",
117
117
Visibility::Public,
118
- |_this, _arguments| {
118
+ |_this, _arguments| -> phper::Result<()> {
119
119
Ok(())
120
120
},
121
121
)
122
122
.argument(Argument::by_val("a_string").with_type_hint(ArgumentTypeHint::String))
123
- .argument(Argument::by_val("an_interface").with_type_hint(ArgumentTypeHint::ClassEntry(String::from(r"\MyNamespace\MyInterface")))))
123
+ .argument(Argument::by_val("an_interface").with_type_hint(ArgumentTypeHint::ClassEntry(String::from(r"\MyNamespace\MyInterface"))))
124
124
.return_type(ReturnType::by_val(ReturnTypeHint::Bool).allow_null());
125
125
```
126
126
You can’t perform that action at this time.
0 commit comments