Skip to content

Commit 01b715c

Browse files
committed
Fix indentation
1 parent ae7ed51 commit 01b715c

File tree

1 file changed

+48
-48
lines changed

1 file changed

+48
-48
lines changed

basic/README.md

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,28 @@
1818

1919
class UsersBuilder
2020
{
21-
public function buildUser(int $id, string $name, string $birthday): array
22-
{
23-
$result = [
24-
'ID' => $id,
25-
'Name' => $name,
26-
'BirthDay' => new DateTimeImmutable($birthday),
27-
];
28-
29-
return $result;
30-
}
31-
32-
public function fetchUsers(): array
33-
{
34-
// 仮実装なので仮データを返す
35-
$users = [];
36-
$users[] = $this->buildUser(1, 'Miku', '2007-08-31');
37-
$users[] = $this->buildUser(2, 'Rin', '2007-12-27');
38-
$users[] = $this->buildUser(3, 'Len', '2007-12-27');
39-
$users[] = $this->buildUser(4, 'Luka', '2009-01-30');
40-
41-
return $users;
42-
}
21+
public function buildUser(int $id, string $name, string $birthday): array
22+
{
23+
$result = [
24+
'ID' => $id,
25+
'Name' => $name,
26+
'BirthDay' => new DateTimeImmutable($birthday),
27+
];
28+
29+
return $result;
30+
}
31+
32+
public function fetchUsers(): array
33+
{
34+
// 仮実装なので仮データを返す
35+
$users = [];
36+
$users[] = $this->buildUser(1, 'Miku', '2007-08-31');
37+
$users[] = $this->buildUser(2, 'Rin', '2007-12-27');
38+
$users[] = $this->buildUser(3, 'Len', '2007-12-27');
39+
$users[] = $this->buildUser(4, 'Luka', '2009-01-30');
40+
41+
return $users;
42+
}
4343
}
4444
```
4545

@@ -69,24 +69,24 @@ PHPDocで配列に詳細な型を記述する方法は大きく分けて二つ
6969
手始めに `buildUser()` メソッドに型をつけてみましょう。
7070
7171
```php
72-
public function buildUser(int $id, string $name, string $birthday): array
73-
{
74-
$result = [
75-
'ID' => $id,
76-
'Name' => $name,
77-
'BirthDay' => new DateTimeImmutable($birthday),
78-
];
79-
\PHPStan\dumpPhpDocType($result);
72+
public function buildUser(int $id, string $name, string $birthday): array
73+
{
74+
$result = [
75+
'ID' => $id,
76+
'Name' => $name,
77+
'BirthDay' => new DateTimeImmutable($birthday),
78+
];
79+
\PHPStan\dumpPhpDocType($result);
8080
# Dumped type: array{ID: int, Name: string, BirthDay: DateTimeImmutable}
8181
82-
return $result;
83-
}
82+
return $result;
83+
}
8484
```
8585
8686
型が出力されました。これをコピペしてPHPDocに貼り付けます。
8787

8888
```php
89-
/**
89+
/**
9090
* @return array{ID: int, Name: string, BirthDay: DateTimeImmutable}
9191
*/
9292
```
@@ -104,20 +104,20 @@ Dumped type: array{array{ID: int, Name: string, BirthDay: DateTimeImmutable}, ar
104104
整形すると以下のようになります。
105105

106106
```php
107-
/**
108-
* @return array{
109-
* 0: array{ID: int, Name: string, BirthDay: DateTimeImmutable},
110-
* 1: array{ID: int, Name: string, BirthDay: DateTimeImmutable},
111-
* 2: array{ID: int, Name: string, BirthDay: DateTimeImmutable},
112-
* 3: array{ID: int, Name: string, BirthDay: DateTimeImmutable},
113-
* }
114-
*/
107+
/**
108+
* @return array{
109+
* 0: array{ID: int, Name: string, BirthDay: DateTimeImmutable},
110+
* 1: array{ID: int, Name: string, BirthDay: DateTimeImmutable},
111+
* 2: array{ID: int, Name: string, BirthDay: DateTimeImmutable},
112+
* 3: array{ID: int, Name: string, BirthDay: DateTimeImmutable},
113+
* }
114+
*/
115115
```
116116

117117
これをコピペしてまたPHPDocに貼り付ける… でもいいのですが、コードにはこういうことが書いてあります
118118

119119
``` php
120-
// 仮実装なので仮データを返す
120+
// 仮実装なので仮データを返す
121121
```
122122

123123
ということは、本実装では何個になるかというのは、あまり具体的な意味はなさそうです。
@@ -134,18 +134,18 @@ Dumped type: array{array{ID: int, Name: string, BirthDay: DateTimeImmutable}, ar
134134
つまり、このように書けます。
135135

136136
```php
137-
/**
138-
* @return array<array{ID: int, Name: string, BirthDay: DateTimeImmutable}>
139-
*/
137+
/**
138+
* @return array<array{ID: int, Name: string, BirthDay: DateTimeImmutable}>
139+
*/
140140
```
141141
この型は読みやすいように改行しても構いません。
142142

143143
```php
144-
/**
145-
* @return array<array{
144+
/**
145+
* @return array<array{
146146
* ID: int,
147147
* Name: string,
148148
* BirthDay: DateTimeImmutable,
149149
* }>
150-
*/
150+
*/
151151
```

0 commit comments

Comments
 (0)