Skip to content

Commit bdfe3fd

Browse files
committed
Fuller type hints
1 parent a0f45a4 commit bdfe3fd

6 files changed

Lines changed: 56 additions & 56 deletions

File tree

module-1/client/notes.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Module1 extends CLI
1818
const TABLE_WIDTH = ['9', '*'];
1919
const TABLE_STYLE = [Colors::C_CYAN, Colors::C_GREEN];
2020

21-
protected function setup(Options $options)
21+
protected function setup(Options $options): void
2222
{
2323
$options->setHelp('This client is built to operate against the server defined in Module 1 only.');
2424

@@ -34,7 +34,7 @@ protected function setup(Options $options)
3434
$this->client = new GuzzleHttp\Client(['base_uri' => 'http://localhost:8888']);
3535
}
3636

37-
protected function createNote($contents)
37+
protected function createNote(string $contents): void
3838
{
3939
if (empty($contents)) {
4040
$this->error('Invalid/Empty note. Cannot send to server!');
@@ -71,7 +71,7 @@ private function initTable(): TableFormatter
7171
return $tf;
7272
}
7373

74-
private function printNote(array $note, TableFormatter $tf)
74+
private function printNote(array $note, TableFormatter $tf): void
7575
{
7676
echo $tf->format(
7777
self::TABLE_WIDTH,
@@ -92,7 +92,7 @@ private function printNote(array $note, TableFormatter $tf)
9292
);
9393
}
9494

95-
protected function getNote($noteId)
95+
protected function getNote(string $noteId): void
9696
{
9797
$response = $this->client->request('GET', sprintf('notes/%s', $noteId));
9898

@@ -109,7 +109,7 @@ protected function getNote($noteId)
109109
}
110110
}
111111

112-
protected function deleteNote($noteId)
112+
protected function deleteNote(string $noteId): void
113113
{
114114
try {
115115
$this->client->request('DELETE', sprintf('notes/%s', $noteId));
@@ -119,7 +119,7 @@ protected function deleteNote($noteId)
119119
}
120120
}
121121

122-
protected function getAllNotes()
122+
protected function getAllNotes(): void
123123
{
124124
$response = $this->client->request('GET', 'notes');
125125

@@ -138,7 +138,7 @@ protected function getAllNotes()
138138
}
139139
}
140140

141-
protected function main(Options $options)
141+
protected function main(Options $options): void
142142
{
143143

144144
switch ($options->getCmd()) {

module-2/client/notes.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Module2 extends CLI
2222
const TABLE_WIDTH = ['9', '*'];
2323
const TABLE_STYLE = [Colors::C_CYAN, Colors::C_GREEN];
2424

25-
protected function setup(Options $options)
25+
protected function setup(Options $options): void
2626
{
2727
$options->setHelp('This client is built to operate against the server defined in Module 2 only.');
2828

@@ -55,7 +55,7 @@ protected function setup(Options $options)
5555
$this->client = new GuzzleHttp\Client(['base_uri' => 'http://localhost:8888']);
5656
}
5757

58-
protected function createNote($contents)
58+
protected function createNote(string $contents): void
5959
{
6060
if (empty($contents)) {
6161
$this->error('Invalid/Empty note. Cannot send to server!');
@@ -93,7 +93,7 @@ private function initTable(): TableFormatter
9393
return $tf;
9494
}
9595

96-
private function printNote(array $note, TableFormatter $tf)
96+
private function printNote(array $note, TableFormatter $tf): void
9797
{
9898
echo $tf->format(
9999
self::TABLE_WIDTH,
@@ -114,7 +114,7 @@ private function printNote(array $note, TableFormatter $tf)
114114
);
115115
}
116116

117-
protected function getNote($noteId)
117+
protected function getNote(string $noteId): void
118118
{
119119
$response = $this->client->request('GET', sprintf('notes/%s', $noteId), ['auth' => [$this->user, $this->pass]]);
120120

@@ -131,7 +131,7 @@ protected function getNote($noteId)
131131
}
132132
}
133133

134-
protected function deleteNote($noteId)
134+
protected function deleteNote(string $noteId): void
135135
{
136136
try {
137137
$this->client->request('DELETE', sprintf('notes/%s', $noteId), ['auth' => [$this->user, $this->pass]]);
@@ -141,7 +141,7 @@ protected function deleteNote($noteId)
141141
}
142142
}
143143

144-
protected function getAllNotes()
144+
protected function getAllNotes(): void
145145
{
146146
$response = $this->client->request('GET', 'notes', ['auth' => [$this->user, $this->pass]]);
147147

@@ -160,7 +160,7 @@ protected function getAllNotes()
160160
}
161161
}
162162

163-
protected function register(Options $options)
163+
protected function register(Options $options): void
164164
{
165165
$email = $options->getOpt('email');
166166
$password = $options->getOpt('password');
@@ -205,7 +205,7 @@ protected function register(Options $options)
205205
}
206206
}
207207

208-
protected function changePassword(Options $options)
208+
protected function changePassword(Options $options): void
209209
{
210210
$email = $options->getOpt('email');
211211
$oldPassword = $options->getOpt('old-password');
@@ -247,7 +247,7 @@ protected function changePassword(Options $options)
247247
}
248248
}
249249

250-
protected function main(Options $options)
250+
protected function main(Options $options): void
251251
{
252252
$args = $options->getArgs();
253253
$this->user = $options->getOpt('email');

module-3/client/notes.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Module3 extends CLI
2323
const TABLE_WIDTH = ['9', '*'];
2424
const TABLE_STYLE = [Colors::C_CYAN, Colors::C_GREEN];
2525

26-
protected function setup(Options $options)
26+
protected function setup(Options $options): void
2727
{
2828
$options->setHelp('This client is built to operate against the server defined in Module 3 only.');
2929

@@ -58,7 +58,7 @@ protected function setup(Options $options)
5858
$this->token = @file_get_contents('.session');
5959
}
6060

61-
protected function createNote($contents)
61+
protected function createNote(string $contents): void
6262
{
6363
if (empty($contents)) {
6464
$this->error('Invalid/Empty note. Cannot send to server!');
@@ -98,7 +98,7 @@ private function initTable(): TableFormatter
9898
return $tf;
9999
}
100100

101-
private function printNote(array $note, TableFormatter $tf)
101+
private function printNote(array $note, TableFormatter $tf): void
102102
{
103103
echo $tf->format(
104104
self::TABLE_WIDTH,
@@ -119,7 +119,7 @@ private function printNote(array $note, TableFormatter $tf)
119119
);
120120
}
121121

122-
protected function getNote($noteId)
122+
protected function getNote(string $noteId): void
123123
{
124124
$response = $this->client->request(
125125
'GET',
@@ -140,7 +140,7 @@ protected function getNote($noteId)
140140
}
141141
}
142142

143-
protected function deleteNote($noteId)
143+
protected function deleteNote(string $noteId): void
144144
{
145145
try {
146146
$this->client->request(
@@ -154,7 +154,7 @@ protected function deleteNote($noteId)
154154
}
155155
}
156156

157-
protected function getAllNotes()
157+
protected function getAllNotes(): void
158158
{
159159
$response = $this->client->request(
160160
'GET',
@@ -177,7 +177,7 @@ protected function getAllNotes()
177177
}
178178
}
179179

180-
protected function register(Options $options)
180+
protected function register(Options $options): void
181181
{
182182
$email = $options->getOpt('email');
183183
$password = $options->getOpt('password');
@@ -222,7 +222,7 @@ protected function register(Options $options)
222222
}
223223
}
224224

225-
protected function changePassword(Options $options)
225+
protected function changePassword(Options $options): void
226226
{
227227
$email = $options->getOpt('email');
228228
$oldPassword = $options->getOpt('old-password');
@@ -264,7 +264,7 @@ protected function changePassword(Options $options)
264264
}
265265
}
266266

267-
protected function login(Options $options)
267+
protected function login(Options $options): void
268268
{
269269
try {
270270
$response = $this->client->request('GET', 'login', ['auth' => [$this->user, $this->pass]]);
@@ -293,7 +293,7 @@ protected function login(Options $options)
293293
}
294294
}
295295

296-
protected function main(Options $options)
296+
protected function main(Options $options): void
297297
{
298298
$args = $options->getArgs();
299299
$this->user = $options->getOpt('email');

module-4/client/notes.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Module4 extends CLI
2323
const TABLE_WIDTH = ['9', '*'];
2424
const TABLE_STYLE = [Colors::C_CYAN, Colors::C_GREEN];
2525

26-
protected function setup(Options $options)
26+
protected function setup(Options $options): void
2727
{
2828
$options->setHelp('This client is built to operate against the server defined in Module 4 only.');
2929

@@ -58,7 +58,7 @@ protected function setup(Options $options)
5858
$this->token = @file_get_contents('.session');
5959
}
6060

61-
protected function createNote($contents)
61+
protected function createNote(string $contents): void
6262
{
6363
if (empty($this->token)) {
6464
$this->error('Please log in first!');
@@ -103,7 +103,7 @@ private function initTable(): TableFormatter
103103
return $tf;
104104
}
105105

106-
private function printNote(array $note, TableFormatter $tf)
106+
private function printNote(array $note, TableFormatter $tf): void
107107
{
108108
echo $tf->format(
109109
self::TABLE_WIDTH,
@@ -124,7 +124,7 @@ private function printNote(array $note, TableFormatter $tf)
124124
);
125125
}
126126

127-
protected function getNote($noteId)
127+
protected function getNote(string $noteId): void
128128
{
129129
if (empty($this->token)) {
130130
$this->error('Please log in first!');
@@ -150,7 +150,7 @@ protected function getNote($noteId)
150150
}
151151
}
152152

153-
protected function deleteNote($noteId)
153+
protected function deleteNote(string $noteId): void
154154
{
155155
if (empty($this->token)) {
156156
$this->error('Please log in first!');
@@ -169,7 +169,7 @@ protected function deleteNote($noteId)
169169
}
170170
}
171171

172-
protected function getAllNotes()
172+
protected function getAllNotes(): void
173173
{
174174
if (empty($this->token)) {
175175
$this->error('Please log in first!');
@@ -197,7 +197,7 @@ protected function getAllNotes()
197197
}
198198
}
199199

200-
protected function register(Options $options)
200+
protected function register(Options $options): void
201201
{
202202
$email = $options->getOpt('email');
203203
$password = $options->getOpt('password');
@@ -242,7 +242,7 @@ protected function register(Options $options)
242242
}
243243
}
244244

245-
protected function changePassword(Options $options)
245+
protected function changePassword(Options $options): void
246246
{
247247
$email = $options->getOpt('email');
248248
$oldPassword = $options->getOpt('old-password');
@@ -284,7 +284,7 @@ protected function changePassword(Options $options)
284284
}
285285
}
286286

287-
protected function login(Options $options)
287+
protected function login(Options $options): void
288288
{
289289
try {
290290
$response = $this->client->request('GET', 'login', ['auth' => [$this->user, $this->pass]]);
@@ -313,7 +313,7 @@ protected function login(Options $options)
313313
}
314314
}
315315

316-
protected function main(Options $options)
316+
protected function main(Options $options): void
317317
{
318318
$args = $options->getArgs();
319319
$this->user = $options->getOpt('email');

0 commit comments

Comments
 (0)