diff --git a/phpstan.neon b/phpstan.neon index 748bd9a..e078d5a 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,5 +1,5 @@ parameters: - level: 7 + level: 8 paths: - src/ - tests/ diff --git a/src/Auth/TokenSources/CLITokenSource.php b/src/Auth/TokenSources/CLITokenSource.php index 1eba60e..3dd66fb 100644 --- a/src/Auth/TokenSources/CLITokenSource.php +++ b/src/Auth/TokenSources/CLITokenSource.php @@ -71,7 +71,7 @@ protected function parseFile(string $filename): void } /** - * @return array{project_name?: string, 'oauth_token': array{'accesstoken': string, 'expiresin': int, 'expiry': string, 'refreshtoken': string, 'tokentype': string}} + * @return array{project_name?: string, 'oauth_token': array{'accesstoken': string, 'expiresin': int, 'expiry': non-falsy-string|null, 'refreshtoken': string|null, 'tokentype': string}} */ protected function toFile(): array { @@ -80,7 +80,7 @@ protected function toFile(): array 'oauth_token' => [ 'accesstoken' => $this->accessToken, 'expiresin' => $this->expiresIn, - 'expiry' => $this->expiry->format(DATE_RFC3339_EXTENDED), + 'expiry' => $this->expiry?->format(DATE_RFC3339_EXTENDED), 'refreshtoken' => $this->refreshToken, 'tokentype' => $this->tokenType, ], diff --git a/src/Compute/Models/Machine.php b/src/Compute/Models/Machine.php index 968854b..9f79753 100644 --- a/src/Compute/Models/Machine.php +++ b/src/Compute/Models/Machine.php @@ -141,6 +141,8 @@ public function updatedFields(): array */ public function stop(StopMachineRequest $request = new StopMachineRequest()): Operation { + assert($this->client !== null); + return $this->client->stop($this->getID(), $request); } @@ -151,6 +153,8 @@ public function stop(StopMachineRequest $request = new StopMachineRequest()): Op */ public function start(StartMachineRequest $request = new StartMachineRequest()): Operation { + assert($this->client !== null); + return $this->client->start($this->getID(), $request); } @@ -161,6 +165,8 @@ public function start(StartMachineRequest $request = new StartMachineRequest()): */ public function reset(ResetMachineRequest $request = new ResetMachineRequest()): Operation { + assert($this->client !== null); + return $this->client->reset($this->getID(), $request); } @@ -171,6 +177,8 @@ public function reset(ResetMachineRequest $request = new ResetMachineRequest()): */ public function delete(DeleteMachineRequest $request = new DeleteMachineRequest()): Operation { + assert($this->client !== null); + return $this->client->delete($this->getID(), $request); } diff --git a/tests/Integration/Compute/MachinesTest.php b/tests/Integration/Compute/MachinesTest.php index 0c0d3d8..0955f01 100644 --- a/tests/Integration/Compute/MachinesTest.php +++ b/tests/Integration/Compute/MachinesTest.php @@ -48,18 +48,21 @@ protected function tearDown(): void public function test_list_machines(): void { + assert($this->client !== null); $response = $this->client->machines()->list(); self::assertGreaterThan(0, count($response->getMachines()), 'Expected at least one machine'); } public function test_get_machine(): void { + assert($this->client !== null); $machine = $this->client->machines()->get('php-cbws-test1'); self::assertEquals('zones/nl-ein-1/types/g2.1', $machine->getType(), 'Expected machine to have g2.1 type'); } public function test_stop_machine(): void { + assert($this->client !== null); $machine = $this->client->machines()->get('php-cbws-test1'); $operation = $machine->stop()->await(); @@ -71,6 +74,7 @@ public function test_stop_machine(): void public function test_start_machine(): void { + assert($this->client !== null); $machine = $this->client->machines()->get('php-cbws-test1'); $operation = $machine->start()->await();