Skip to content

Commit 74878f0

Browse files
authored
Update grammar in documentation (#139)
1 parent 43ef456 commit 74878f0

File tree

18 files changed

+66
-71
lines changed

18 files changed

+66
-71
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111
The framework that allows us to write PHP extensions using pure and safe Rust whenever possible.
1212

13-
## Document & Tutorial
13+
## Documentation & Tutorial
1414

15-
- Document: <https://docs.rs/phper>
15+
- Documentation: <https://docs.rs/phper>
1616
- Tutorial: <https://docs.rs/phper-doc/>
1717

1818
## Requirement

examples/http-server/src/request.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub fn make_request_class() -> ClassEntity<()> {
4242
class
4343
}
4444

45-
/// New the object with class `HttpServer\HttpRequest`.
45+
/// Instantiate the object with class `HttpServer\HttpRequest`.
4646
pub fn new_request_object() -> phper::Result<StateObject<()>> {
4747
HTTP_REQUEST_CLASS.new_object([])
4848
}

examples/http-server/src/response.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub fn make_response_class() -> ClassEntity<Response<Body>> {
6363
class
6464
}
6565

66-
/// New the object with class `HttpServer\HttpResponse`.
66+
/// Instantiate the object with class `HttpServer\HttpResponse`.
6767
pub fn new_response_object() -> phper::Result<StateObject<Response<Body>>> {
6868
HTTP_RESPONSE_CLASS.new_object([])
6969
}

phper-doc/doc/_01_introduction/index.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ The crates are not only the PHP binding for Rust, but also the framework for wri
1010

1111
## Purpose
1212

13-
I used to use C language to write PHP extensions. At that time, C/C++ are the only way to write PHP extensions.
13+
I used to use the C language to write PHP extensions. At that time, C and C++ were the only ways to write PHP extensions.
1414

15-
But I found the problem is that using C language can easily cause memory problems, which is very troublesome when debugging PHP extensions.
15+
But I found the problem was that using the C language could easily cause memory problems, which were very troublesome when debugging PHP extensions.
1616

17-
Moreover, third-party libraries in C language are not easy to use, and version compatibility problems are often encountered in dynamic linking, which is inconvenient to use.
17+
Moreover, third-party libraries in the C language are not easy to use, and version compatibility problems are often encountered in dynamic linking, which is inconvenient to use.
1818

19-
Later, Rust appeared, and I started to use C to call Rust's FFI to develop PHP extensions. The experience is better than only use C language.
19+
Later, Rust appeared, and I started to use C to call Rust's FFI to develop PHP extensions. The experience was better than using only the C language.
2020

21-
However, it is not convenient for Rust to generate C ABI and then call C, so I got the idea of using pure Rust to write PHP extensions.
21+
However, it was not convenient for Rust to generate C ABI and then call C, so I got the idea of using pure Rust to write PHP extensions.
2222

23-
So I started to build the framework of phper.
23+
So I started building the framework for phper.
2424

25-
The other goal is to enable PHP to benefit from the Rust ecosystem.
25+
Another goal is to enable PHP to benefit from the Rust ecosystem.

phper-doc/doc/_02_quick_start/_01_write_your_first_extension/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Full example is <https://github.com/phper-framework/phper/tree/master/examples/h
3838
cargo add phper
3939
```
4040

41-
1. Create the `build.rs` ( Adapting MacOS ).
41+
1. Create the `build.rs` (adapting MacOS).
4242

4343
```rust,no_run
4444
fn main() {
@@ -50,7 +50,7 @@ Full example is <https://github.com/phper-framework/phper/tree/master/examples/h
5050
}
5151
```
5252

53-
1. Write these code in `src/lib.rs`.
53+
1. Add this code to `src/lib.rs`.
5454

5555
```rust
5656
use phper::{echo, functions::Argument, modules::Module, php_get_module, values::ZVal};
@@ -85,7 +85,7 @@ Full example is <https://github.com/phper-framework/phper/tree/master/examples/h
8585
}
8686
```
8787

88-
1. Build, if your php isn't installed globally, you should specify the path of `php-config`.
88+
1. Build, if your PHP isn't installed globally, you should specify the path of `php-config`.
8989

9090
```bash
9191
# Optional, specify if php isn't installed globally,

phper-doc/doc/_02_quick_start/_02_write_a_simple_http_client/index.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Write a simple http client
22

3-
Here we will use Rust crate [reqwest](https://crates.io/crates/reqwest) to write a simple http client,
3+
Here we will use Rust crate [reqwest](https://crates.io/crates/reqwest) to write a simple HTTP client,
44
like curl, but object-oriented.
55

6-
Full example is <https://github.com/phper-framework/phper/tree/master/examples/http-client>.
6+
Full example is at <https://github.com/phper-framework/phper/tree/master/examples/http-client>.
77

88
Imagine that our PHP API should look like this:
99

@@ -31,7 +31,7 @@ var_dump([
3131

3232
Here, the namespace of API is `HttpClient`.
3333

34-
And there are three class:
34+
And there are three classes:
3535

3636
- `HttpClientBuilder` is the builder of `HttpClient`.
3737
- `HttpClient` will send a http request and generate a http response.
@@ -73,7 +73,7 @@ Before writing the code, we first prepare the dependency and startup code.
7373
cargo add thiserror
7474
```
7575

76-
1. Create the `build.rs` ( Adapting MacOS ).
76+
1. Create the `build.rs` (adapting MacOS).
7777

7878
```rust,no_run
7979
fn main() {
@@ -245,7 +245,7 @@ Now let's begin to finish the logic.
245245
1. Register all classes in `src/lib.rs`.
246246

247247
1. All codes are finished, so we can build the extension `.so`, and run the
248-
php script of the beginning of the tutorial with the extension.
248+
PHP script in the beginning of the tutorial with the extension.
249249

250250
```shell
251251
cargo build

phper-doc/doc/_03_integrate_with_pecl/index.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
# Integrate with PECL
22

3-
As can be seen from the `quick start` example, using phper to develop
4-
PHP extension doesn't need the `phpize` and `make` processes like developing
5-
with C/C++.
3+
As can be seen from the `quick start` example, using phper to develop a PHP extension doesn't require the `phpize` and `make` processes, as you would when developing with C/C++.
64

7-
But, if you want to publish the extension on [PECL](https://pecl.php.net/)
8-
(the official repository of PHP extensions), you need to integrate phper
9-
project with `phpize` and `make`, because PECL install command will call them.
5+
However, if you intend to publish the extension on PECL (the official repository of PHP extensions), you will need to integrate the phper project with `phpize` and `make` since the PECL install command will call them.
106

11-
This chapter will guide you how to integrate phper project with `pecl` and
12-
`phpize`.
7+
This chapter will guide you on how to integrate the phper project with `pecl` and `phpize`.
138

149
## Steps
1510

phper-doc/doc/_04_zval/index.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ but there is only one type at a time, you can use
1919
The [`phper::values::ZVal`] implements a lot of [`std::convert::From`] for the
2020
conversion.
2121

22-
Here is the mapping relationship of Rust type and base PHP type.
22+
Here is the mapping of relationships between Rust types and base PHP types.
2323

2424
| Trait | Rust type | PHP type |
2525
| --------------- | --------------------------- | -------- |
@@ -35,10 +35,10 @@ Here is the mapping relationship of Rust type and base PHP type.
3535
| `From<ZArray>` | [`phper::arrays::ZArray`] | array |
3636
| `From<ZObject>` | [`phper::objects::ZObject`] | object |
3737

38-
Otherwise, there are also composite types that implement `From`.
38+
There are also composite types that implement `From`.
3939

4040
- `From<Option<T>>`: if Some(T), T will be converted to PHP type like `From<T>`,
41-
or `None` wll be converted to `null`.
41+
or `None` will be converted to `null`.
4242

4343
```rust,no_run
4444
use phper::values::ZVal;
@@ -66,7 +66,7 @@ fn say_hello(arguments: &mut [ZVal]) -> phper::Result<()> {
6666
// str.
6767
let name = arguments[0].expect_z_str()?.to_str()?;
6868
69-
// Macro which do php internal `echo`.
69+
// Macro which runs PHP internal function `echo`.
7070
echo!("Hello, {}!\n", name);
7171
7272
Ok(())
@@ -80,22 +80,22 @@ The [`phper::values::ZVal`] both implements [`std::clone::Clone`] and
8080

8181
- [`std::clone::Clone`]: represent value copy (Type ZObject is excluded because it is always passed by reference).
8282

83-
- [`phper::alloc::RefClone`]: represent reference counting copy (Type (), bool,
83+
- [`phper::alloc::RefClone`]: represent reference counting copy (Type (), bool,
8484
i64, f64 is excluded because they are not reference counting types).
8585

8686
## PHP internal cast
8787

8888
> Refer to: <https://www.phpinternalsbook.com/php7/zvals/casts_and_operations.html#casts>
8989
90-
PHP is a weakly typed language, supports type cast internally.
90+
PHP is a weakly typed language, yet it supports type casting internally.
9191

9292
The zend engine provides `convert_to_*` functions to do the type cast, and
9393
`ZVal` wraps them directly.
9494

9595
## Callable
9696

97-
The [`phper::values::ZVal`] can be call via [`phper::values::ZVal::call`], make
98-
sure the actual type is callable (string or array or closure).
97+
The [`phper::values::ZVal`] can be called via [`phper::values::ZVal::call`]. Make
98+
sure that the actual type is callable (string, array or closure).
9999

100100
```rust,no_run
101101
use phper::values::ZVal;

phper-doc/doc/_05_internal_types/_01_z_str/index.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
> Refer: <https://www.php.net/manual/en/language.types.string.php>
66
77
The [`&ZStr`](phper::strings::ZStr) and [`ZString`](phper::strings::ZString) are
8-
the wrapper of [`zend_string`](phper::sys::zend_string).
8+
wrappers for [`zend_string`](phper::sys::zend_string).
99

1010
`ZStr` can be converted to `&[u8]`, `&CStr` and `&str`.
1111

12-
`ZString` can be constructed from `impl AsRef<[u8]>`, has pair of `from_raw()`
12+
`ZString` can be constructed from `impl AsRef<[u8]>` and has pair of `from_raw()`
1313
and `into_raw()`, like in [`Box`].
1414

1515
```rust,no_run
@@ -38,7 +38,7 @@ let s = ZString::new("Hello world!");
3838
assert_eq!(s.to_str(), Ok("Hello world!"));
3939
```
4040

41-
`ZStr` implements `ToOwned`, can upgrade to `ZString` by value copy.
41+
`ZStr` implements `ToOwned`. It can upgrade to `ZString` by value copying.
4242

4343
Because `zend_string` is reference counting type, so `ZStr` also implements
4444
[`ToRefOwned`](phper::alloc::ToRefOwned) (just like
@@ -56,12 +56,12 @@ extern "C" {
5656
5757
let s = unsafe { ZStr::from_mut_ptr(something()) };
5858
59-
// By value copy.
60-
let _s = s.to_owned();
59+
// By value copying.
60+
let _s = s.to_owned();
6161
6262
// By refcount increment.
6363
let _s = s.to_ref_owned();
6464
```
6565

66-
Note that neither `ZStr` nor `ZString` implement `Send` and `Sync`, because PHP
66+
Note that neither `ZStr` nor `ZString` implements `Send` and `Sync`, because PHP
6767
is single-threaded.

phper-doc/doc/_05_internal_types/_02_z_arr/index.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
*a list. I think it is a waste of performance.*
1616

1717
The [`&ZArr`](phper::arrays::ZArr) and [`ZArray`](phper::arrays::ZArray) are
18-
the wrapper of [`zend_array`](phper::sys::zend_array) (same as `Hashtable`).
18+
the wrappers for [`zend_array`](phper::sys::zend_array) (same as `Hashtable`).
1919

2020
[`&ZArr`](phper::arrays::ZArr) acts like [`HashMap`](std::collections::HashMap),
2121
also has api `insert()`, `get()`, `remove()`, but it's key type is
2222
[`Key`](phper::arrays::Key) and value type is [`ZVal`](phper::values::ZVal).
2323

24-
Notice that phper prefer to use [`Symtables`](https://www.phpinternalsbook.com/php5/hashtables/array_api.html#symtables) api `zend_symtable_*`,
24+
Notice that phper prefers to use [`Symtables`](https://www.phpinternalsbook.com/php5/hashtables/array_api.html#symtables) api `zend_symtable_*`,
2525
so `get(42)` and `get("42")` should be considered the same.
2626

2727
`ZArray` can be dereferenced to `ZArr`.
@@ -53,13 +53,13 @@ for (k, v) in arr.iter() {
5353
}
5454
```
5555

56-
`ZArr` implements `ToOwned`, can upgrade to `ZArray` by value copy via
56+
`ZArr` implements `ToOwned` and it can upgrade to `ZArray` by value copying via
5757
`zend_array_dup`.
5858

59-
Because `zend_array` is reference counting type, so `ZArr` also implements
60-
[`ToRefOwned`](phper::alloc::ToRefOwned) (just like
61-
[`RefClone`](phper::alloc::RefClone) for [`ZVal`](phper::values::ZVal)), can
62-
upgrade to `ZArray` by refcount increment.
59+
Because `zend_array` is reference counting type, `ZArr` also implements
60+
[`ToRefOwned`](phper::alloc::ToRefOwned) (similar to
61+
[`RefClone`](phper::alloc::RefClone) for [`ZVal`](phper::values::ZVal)), allowing an
62+
upgrade to `ZArray` by incrementing the refcount.
6363

6464
```rust,no_run
6565
use phper::sys;
@@ -79,5 +79,5 @@ let _arr = arr.to_owned();
7979
let _arr = arr.to_ref_owned();
8080
```
8181

82-
Note that neither `ZArr` nor `ZArray` implement `Send` and `Sync`, because PHP
82+
Note that neither `ZArr` nor `ZArray` implements `Send` and `Sync`, because PHP
8383
is single-threaded.

0 commit comments

Comments
 (0)