Skip to content

Commit f3cbc27

Browse files
committed
add en doc
1 parent edfeb03 commit f3cbc27

File tree

3 files changed

+26
-58
lines changed

3 files changed

+26
-58
lines changed

docs/en/description.md

Lines changed: 0 additions & 16 deletions
This file was deleted.

docs/en/getting-started.md

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
## 快速开始
1+
## Quick Start
22

3-
### 安装
3+
### Installation
44

5-
使用 Composer 安装:
5+
Install using Composer:
66

77
```bash
8-
composer require astral/serialize
8+
composer require astral/php-serialize
99
```
1010

11-
### 基本用法
11+
### Basic Usage
1212

1313
```php
1414
use Astral\Serialize\Serialize;
@@ -18,28 +18,28 @@ class User extends Serialize {
1818
public int $age
1919
}
2020

21-
// 从数组创建对象
21+
// Create object from array
2222
$user = User::from([
23-
'name' => '张三',
23+
'name' => 'John Doe',
2424
'age' => 30
2525
]);
2626

27-
// 访问对象属性
28-
echo $user->name; // 输出: 张三
29-
echo $user->age; // 输出: 30
27+
// Access object properties
28+
echo $user->name; // Output: John Doe
29+
echo $user->age; // Output: 30
3030

31-
// 转换为数组
31+
// Convert to array
3232
$userArray = $user->toArray();
33-
// $userArray 的内容:
33+
// $userArray contents:
3434
// [
35-
// 'name' => '张三',
35+
// 'name' => 'John Doe',
3636
// 'age' => 30
3737
// ]
3838
```
3939

40-
### 其他特性
40+
#### Other Features
4141

42-
#### **不可变性**:只读属性在构造后无法修改
42+
1. **Immutability**: Read-only properties cannot be modified after construction
4343

4444
```php
4545
use Astral\Serialize\Serialize;
@@ -52,30 +52,30 @@ class User extends Serialize {
5252
}
5353

5454
$user = User::from([
55-
'name' => '张三',
55+
'name' => 'John Doe',
5656
'age' => 30
5757
]);
5858

5959
try {
60-
$user->name = '李四'; // 编译时错误:无法修改只读属性
60+
$user->name = 'Jane Doe'; // Compile-time error: cannot modify read-only property
6161
} catch (Error $e) {
62-
echo "只读属性不能被重新赋值";
62+
echo "Read-only properties cannot be reassigned";
6363
}
6464
```
6565

66-
#### **类型安全的初始化**
66+
2. **Type-Safe Initialization**
6767

6868
```php
6969
$user = User::from([
70-
'name' => 123, // 整数会被转换为字符串
71-
'age' => '35' // 字符串会被转换为整数
70+
'name' => 123, // Integer will be converted to string
71+
'age' => '35' // String will be converted to integer
7272
]);
7373

74-
echo $user->name; // 输出: "123"
75-
echo $user->age; // 输出: 35
74+
echo $user->name; // Output: "123"
75+
echo $user->age; // Output: 35
7676
```
7777

78-
#### **构造函数初始化**
78+
3. **Constructor Initialization**
7979

8080
```php
8181
use Astral\Serialize\Serialize;
@@ -85,9 +85,9 @@ class User extends Serialize {
8585
public readonly string $name,
8686
public readonly int $age
8787
) {
88-
// 可以在构造函数中添加额外的验证或处理逻辑
88+
// Can add additional validation or processing logic in the constructor
8989
if (strlen($name) < 2) {
90-
throw new \InvalidArgumentException('名称太短');
90+
throw new \InvalidArgumentException('Name is too short');
9191
}
9292
}
9393
}

docs/zh/description.md

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)