Internal types
DST & Owned Type
In Rust, there are many types that appear in pairs, like str / String, OsStr / OsString, CStr / CString.
For example:
- str: Dynamically sized type, implements
!Sized, usually used with reference notation, as&str. - String: Ownership type, encapsulates a pointer to a heap memory allocation.
PHPER follows this design, there are the following types:
It seems that there is no need to separate into two types, but
ZStr,ZArr, andZObjare all transparent types. Therefore, the fields of the struct cannot be changed. Separating an ownership structZString,ZArray, andZObject, and then we can change fields of the struct in the future.
Mapping relationship
Here is the mapping of relationships between Rust types and base PHP types.
| Rust type | PHP type |
|---|---|
() | null |
bool | bool |
i64 | long |
f64 | double |
ZStr / ZString | string |
ZArr / ZArray | array |
ZObj / ZObject | object |
ZRes | resource |
Why is there no ZResource? Because Resource is a relatively old type, it is generally replaced by Class now, and the role of ZRes is only compatible with old extension resources.