mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-05 07:52:34 +00:00
Add phpstan level 7(#544)
This commit is contained in:
@ -53,7 +53,7 @@ public function data(array $input): array
|
||||
public function connect(?array $credentials = null): bool
|
||||
{
|
||||
try {
|
||||
$this->connectToEc2ClientTest($credentials);
|
||||
$this->connectToEc2ClientTest($credentials ?? []);
|
||||
$this->ec2Client->describeInstances();
|
||||
|
||||
return true;
|
||||
@ -120,7 +120,10 @@ public function regions(): array
|
||||
|
||||
$regions = $this->ec2Client->describeRegions();
|
||||
|
||||
return collect($regions->toArray()['Regions'] ?? [])
|
||||
/** @var array<int, array{RegionName: string}> $regionsArray */
|
||||
$regionsArray = $regions->toArray()['Regions'] ?? [];
|
||||
|
||||
return collect($regionsArray)
|
||||
->mapWithKeys(fn ($value) => [$value['RegionName'] => $value['RegionName']])
|
||||
->toArray();
|
||||
}
|
||||
@ -182,8 +185,8 @@ private function connectToEc2Client(?string $region = null): void
|
||||
{
|
||||
$credentials = $this->serverProvider->getCredentials();
|
||||
|
||||
if (! $region) {
|
||||
$region = $this->server?->provider_data['region'];
|
||||
if ($region === null || $region === '' || $region === '0') {
|
||||
$region = $this->server->provider_data['region'];
|
||||
}
|
||||
|
||||
$this->ec2Client = new Ec2Client([
|
||||
@ -196,7 +199,10 @@ private function connectToEc2Client(?string $region = null): void
|
||||
]);
|
||||
}
|
||||
|
||||
private function connectToEc2ClientTest($credentials): void
|
||||
/**
|
||||
* @param array<string, mixed> $credentials
|
||||
*/
|
||||
private function connectToEc2ClientTest(array $credentials): void
|
||||
{
|
||||
$this->ec2Client = new Ec2Client([
|
||||
'region' => 'us-east-1',
|
||||
@ -302,9 +308,7 @@ private function getImageId(string $os): string
|
||||
|
||||
if (! empty($images)) {
|
||||
// Sort images by creation date to get the latest one
|
||||
usort($images, function ($a, $b) {
|
||||
return strtotime($b['CreationDate']) - strtotime($a['CreationDate']);
|
||||
});
|
||||
usort($images, fn (array $a, array $b): int => strtotime((string) $b['CreationDate']) - strtotime((string) $a['CreationDate']));
|
||||
|
||||
return $images[0]['ImageId'];
|
||||
}
|
||||
|
Reference in New Issue
Block a user