Skip to content

Commit fe59a32

Browse files
authored
Rename example hello to complex. (#75)
1 parent 87822e2 commit fe59a32

File tree

8 files changed

+30
-22
lines changed

8 files changed

+30
-22
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ members = [
1818
"phper-test",
1919

2020
# internal
21-
"examples/hello",
21+
"examples/complex",
2222
"examples/http-client",
2323
"examples/http-server",
2424
"examples/logging",

examples/hello/Cargo.toml renamed to examples/complex/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# See the Mulan PSL v2 for more details.
1010

1111
[package]
12-
name = "hello"
12+
name = "complex"
1313
version = "0.0.0"
1414
authors = { workspace = true }
1515
edition = { workspace = true }
File renamed without changes.

examples/hello/README.md renamed to examples/complex/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# hello
1+
# complex
22

3-
Hello world example.
3+
Complex example.
44

55
## Environment
66

@@ -24,7 +24,7 @@ cargo test --release
2424
## Install
2525

2626
```bash
27-
cp target/release/libhello.so `${PHP_CONFIG:=php-config} --extension-dir`
27+
cp target/release/libcomplex.so `${PHP_CONFIG:=php-config} --extension-dir`
2828
```
2929

3030
## License
File renamed without changes.

examples/hello/src/lib.rs renamed to examples/complex/src/lib.rs

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,14 @@ pub fn get_module() -> Module {
4040
);
4141

4242
// register module ini
43-
module.add_ini("hello.enable", false, Policy::All);
44-
module.add_ini("hello.num", 100, Policy::All);
45-
module.add_ini("hello.ratio", 1.5, Policy::All);
46-
module.add_ini("hello.description", "hello world.".to_owned(), Policy::All);
43+
module.add_ini("complex.enable", false, Policy::All);
44+
module.add_ini("complex.num", 100, Policy::All);
45+
module.add_ini("complex.ratio", 1.5, Policy::All);
46+
module.add_ini(
47+
"complex.description",
48+
"hello world.".to_owned(),
49+
Policy::All,
50+
);
4751

4852
// register hook functions
4953
module.on_module_init(|_: ModuleContext| true);
@@ -52,18 +56,22 @@ pub fn get_module() -> Module {
5256
module.on_request_shutdown(|_| true);
5357

5458
// register functions
55-
module.add_function("hello_say_hello", say_hello, vec![Argument::by_val("name")]);
56-
module.add_function("hello_throw_exception", throw_exception, vec![]);
5759
module.add_function(
58-
"hello_get_all_ini",
60+
"complex_say_hello",
61+
say_hello,
62+
vec![Argument::by_val("name")],
63+
);
64+
module.add_function("complex_throw_exception", throw_exception, vec![]);
65+
module.add_function(
66+
"complex_get_all_ini",
5967
|_: &mut [ZVal]| {
6068
let mut arr = ZArray::new();
6169

62-
let hello_enable = ZVal::from(ini_get::<bool>("hello.enable"));
63-
arr.insert("hello.enable", hello_enable);
70+
let complex_enable = ZVal::from(ini_get::<bool>("complex.enable"));
71+
arr.insert("complex.enable", complex_enable);
6472

65-
let hello_description = ZVal::from(ini_get::<Option<&CStr>>("hello.description"));
66-
arr.insert("hello.description", hello_description);
73+
let complex_description = ZVal::from(ini_get::<Option<&CStr>>("complex.description"));
74+
arr.insert("complex.description", complex_description);
6775

6876
arr
6977
},

examples/hello/tests/integration.rs renamed to examples/complex/tests/integration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fn test_php() {
2222
.join("..")
2323
.join("..")
2424
.join("target"),
25-
"hello",
25+
"complex",
2626
),
2727
&[&Path::new(env!("CARGO_MANIFEST_DIR"))
2828
.join("tests")

examples/hello/tests/php/test.php renamed to examples/complex/tests/php/test.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@
1515
ini_set("display_startup_errors", "On");
1616
error_reporting(E_ALL);
1717

18-
assert_eq(hello_say_hello("world"), "Hello, world!\n");
18+
assert_eq(complex_say_hello("world"), "Hello, world!\n");
1919

2020
try {
21-
hello_throw_exception();
21+
complex_throw_exception();
2222
} catch (ErrorException $e) {
2323
assert_eq($e->getMessage(), "I am sorry");
2424
}
2525

26-
assert_eq(hello_get_all_ini(), [
27-
"hello.enable" => false,
28-
"hello.description" => "hello world.",
26+
assert_eq(complex_get_all_ini(), [
27+
"complex.enable" => false,
28+
"complex.description" => "hello world.",
2929
]);
3030

3131
$foo = new FooClass();

0 commit comments

Comments
 (0)