Skip to content

Commit 490c396

Browse files
MarlincMarlin Cremers
andauthored
Level 8 (#59)
* BREAKING: refactor to phpstan level 7 * refactor: use native wait implementation in backend for await * fix: increase await timeout to be more efficient * fix: phpstan level 8 --------- Co-authored-by: Marlin Cremers <git@marlinc.nl>
1 parent 6da3b61 commit 490c396

4 files changed

Lines changed: 15 additions & 3 deletions

File tree

phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
parameters:
2-
level: 7
2+
level: 8
33
paths:
44
- src/
55
- tests/

src/Auth/TokenSources/CLITokenSource.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ protected function parseFile(string $filename): void
7171
}
7272

7373
/**
74-
* @return array{project_name?: string, 'oauth_token': array{'accesstoken': string, 'expiresin': int, 'expiry': string, 'refreshtoken': string, 'tokentype': string}}
74+
* @return array{project_name?: string, 'oauth_token': array{'accesstoken': string, 'expiresin': int, 'expiry': non-falsy-string|null, 'refreshtoken': string|null, 'tokentype': string}}
7575
*/
7676
protected function toFile(): array
7777
{
@@ -80,7 +80,7 @@ protected function toFile(): array
8080
'oauth_token' => [
8181
'accesstoken' => $this->accessToken,
8282
'expiresin' => $this->expiresIn,
83-
'expiry' => $this->expiry->format(DATE_RFC3339_EXTENDED),
83+
'expiry' => $this->expiry?->format(DATE_RFC3339_EXTENDED),
8484
'refreshtoken' => $this->refreshToken,
8585
'tokentype' => $this->tokenType,
8686
],

src/Compute/Models/Machine.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ public function updatedFields(): array
141141
*/
142142
public function stop(StopMachineRequest $request = new StopMachineRequest()): Operation
143143
{
144+
assert($this->client !== null);
145+
144146
return $this->client->stop($this->getID(), $request);
145147
}
146148

@@ -151,6 +153,8 @@ public function stop(StopMachineRequest $request = new StopMachineRequest()): Op
151153
*/
152154
public function start(StartMachineRequest $request = new StartMachineRequest()): Operation
153155
{
156+
assert($this->client !== null);
157+
154158
return $this->client->start($this->getID(), $request);
155159
}
156160

@@ -161,6 +165,8 @@ public function start(StartMachineRequest $request = new StartMachineRequest()):
161165
*/
162166
public function reset(ResetMachineRequest $request = new ResetMachineRequest()): Operation
163167
{
168+
assert($this->client !== null);
169+
164170
return $this->client->reset($this->getID(), $request);
165171
}
166172

@@ -171,6 +177,8 @@ public function reset(ResetMachineRequest $request = new ResetMachineRequest()):
171177
*/
172178
public function delete(DeleteMachineRequest $request = new DeleteMachineRequest()): Operation
173179
{
180+
assert($this->client !== null);
181+
174182
return $this->client->delete($this->getID(), $request);
175183
}
176184

tests/Integration/Compute/MachinesTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,21 @@ protected function tearDown(): void
4848

4949
public function test_list_machines(): void
5050
{
51+
assert($this->client !== null);
5152
$response = $this->client->machines()->list();
5253
self::assertGreaterThan(0, count($response->getMachines()), 'Expected at least one machine');
5354
}
5455

5556
public function test_get_machine(): void
5657
{
58+
assert($this->client !== null);
5759
$machine = $this->client->machines()->get('php-cbws-test1');
5860
self::assertEquals('zones/nl-ein-1/types/g2.1', $machine->getType(), 'Expected machine to have g2.1 type');
5961
}
6062

6163
public function test_stop_machine(): void
6264
{
65+
assert($this->client !== null);
6366
$machine = $this->client->machines()->get('php-cbws-test1');
6467
$operation = $machine->stop()->await();
6568

@@ -71,6 +74,7 @@ public function test_stop_machine(): void
7174

7275
public function test_start_machine(): void
7376
{
77+
assert($this->client !== null);
7478
$machine = $this->client->machines()->get('php-cbws-test1');
7579
$operation = $machine->start()->await();
7680

0 commit comments

Comments
 (0)