Skip to content

Commit

Permalink
Merge pull request #131 from plesk/dependabot/composer/vimeo/psalm-5.…
Browse files Browse the repository at this point in the history
…15.0

TECH Bump vimeo/psalm from 5.14.1 to 5.15.0
  • Loading branch information
sibprogrammer authored Aug 29, 2023
2 parents 4a2ec7c + 5c6317f commit 32563ff
Show file tree
Hide file tree
Showing 30 changed files with 101 additions and 65 deletions.
27 changes: 15 additions & 12 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/Api/AbstractStruct.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __set(string $property, $value)
*
* @throws \Exception
*/
protected function initScalarProperties($apiResponse, array $properties): void
protected function initScalarProperties(\SimpleXMLElement $apiResponse, array $properties): void
{
foreach ($properties as $property) {
if (is_array($property)) {
Expand Down
8 changes: 5 additions & 3 deletions src/Api/Operator/DatabaseServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ private function getBy($field = null, $value = null): array
if (!$xmlResult) {
continue;
}
$item = new Struct\Info($xmlResult->data);
$item->id = (int) $xmlResult->id;
$items[] = $item;
if (!is_null($xmlResult->data)) {
$item = new Struct\Info($xmlResult->data);
$item->id = (int) $xmlResult->id;
$items[] = $item;
}
}

return $items;
Expand Down
8 changes: 5 additions & 3 deletions src/Api/Operator/Dns.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,11 @@ public function getAll(string $field, $value): array
if (!$xmlResult) {
continue;
}
$item = new Struct\Info($xmlResult->data);
$item->id = (int) $xmlResult->id;
$items[] = $item;
if (!is_null($xmlResult->data)) {
$item = new Struct\Info($xmlResult->data);
$item->id = (int) $xmlResult->id;
$items[] = $item;
}
}

return $items;
Expand Down
8 changes: 5 additions & 3 deletions src/Api/Operator/DnsTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ public function getAll($field = null, $value = null): array
if (!$xmlResult) {
continue;
}
$item = new Struct\Info($xmlResult->data);
$item->id = (int) $xmlResult->id;
$items[] = $item;
if (!is_null($xmlResult->data)) {
$item = new Struct\Info($xmlResult->data);
$item->id = (int) $xmlResult->id;
$items[] = $item;
}
}

return $items;
Expand Down
4 changes: 2 additions & 2 deletions src/Api/Operator/EventLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function get(): array
$records = [];
$response = $this->request('get');

foreach ($response->event as $eventInfo) {
foreach ($response->event ?? [] as $eventInfo) {
$records[] = new Struct\Event($eventInfo);
}

Expand All @@ -32,7 +32,7 @@ public function getDetailedLog(): array
$records = [];
$response = $this->request('get_events');

foreach ($response->event as $eventInfo) {
foreach ($response->event ?? [] as $eventInfo) {
$records[] = new Struct\DetailedEvent($eventInfo);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Api/Operator/Ip.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function get(): array
$packet->addChild($this->wrapperTag)->addChild('get');
$response = $this->client->request($packet);

foreach ($response->addresses->ip_info as $ipInfo) {
foreach ($response->addresses->ip_info ?? [] as $ipInfo) {
$ips[] = new Struct\Info($ipInfo);
}

Expand Down
6 changes: 4 additions & 2 deletions src/Api/Operator/Locale.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ public function get($id = null)

$response = $this->client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);

foreach ($response->locale->get->result as $localeInfo) {
$locales[(string) $localeInfo->info->id] = new Struct\Info($localeInfo->info);
foreach ($response->locale->get->result ?? [] as $localeInfo) {
if (!is_null($localeInfo->info)) {
$locales[(string) $localeInfo->info->id] = new Struct\Info($localeInfo->info);
}
}

return !is_null($id) ? reset($locales) : $locales;
Expand Down
2 changes: 2 additions & 0 deletions src/Api/Operator/Mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ public function create(string $name, int $siteId, bool $mailbox = false, string
$mailname->addChild('mailbox')->addChild('enabled', 'true');
}
if (!empty($password)) {
/** @psalm-suppress UndefinedPropertyAssignment */
$mailname->addChild('password')->value = $password;
}

$response = $this->client->request($packet);

/** @psalm-suppress PossiblyNullArgument */
return new Struct\Info($response->mailname);
}

Expand Down
1 change: 1 addition & 0 deletions src/Api/Operator/ProtectedDirectory.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public function getAll(string $field, $value): array
* @param string $password
*
* @return Struct\UserInfo
* @psalm-suppress UndefinedPropertyAssignment
*/
public function addUser($protectedDirectory, $login, $password)
{
Expand Down
11 changes: 6 additions & 5 deletions src/Api/Operator/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public function getProtos(): array
$packet->addChild($this->wrapperTag)->addChild('get_protos');
$response = $this->client->request($packet);

/** @psalm-suppress PossiblyNullPropertyFetch */
return (array) $response->protos->proto;
}

Expand All @@ -37,7 +38,7 @@ public function getKeyInfo(): array
$keyInfo = [];
$keyInfoXml = $this->getInfo('key');

foreach ($keyInfoXml->property as $property) {
foreach ($keyInfoXml->property ?? [] as $property) {
$keyInfo[(string) $property->name] = (string) $property->value;
}

Expand All @@ -49,7 +50,7 @@ public function getComponents(): array
$components = [];
$componentsXml = $this->getInfo('components');

foreach ($componentsXml->component as $component) {
foreach ($componentsXml->component ?? [] as $component) {
$components[(string) $component->name] = (string) $component->version;
}

Expand All @@ -61,7 +62,7 @@ public function getServiceStates(): array
$states = [];
$statesXml = $this->getInfo('services_state');

foreach ($statesXml->srv as $service) {
foreach ($statesXml->srv ?? [] as $service) {
$states[(string) $service->id] = [
'id' => (string) $service->id,
'title' => (string) $service->title,
Expand All @@ -82,7 +83,7 @@ public function getShells(): array
$shells = [];
$shellsXml = $this->getInfo('shells');

foreach ($shellsXml->shell as $shell) {
foreach ($shellsXml->shell ?? [] as $shell) {
$shells[(string) $shell->name] = (string) $shell->path;
}

Expand All @@ -106,7 +107,7 @@ public function getSiteIsolationConfig(): array
$config = [];
$configXml = $this->getInfo('site-isolation-config');

foreach ($configXml->property as $property) {
foreach ($configXml->property ?? [] as $property) {
$config[(string) $property->name] = (string) $property->value;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Api/Operator/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function get(): array
$sessions = [];
$response = $this->request('get');

foreach ($response->session as $sessionInfo) {
foreach ($response->session ?? [] as $sessionInfo) {
$sessions[(string) $sessionInfo->id] = new Struct\Info($sessionInfo);
}

Expand Down
2 changes: 2 additions & 0 deletions src/Api/Operator/Site.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ public function create(array $properties): Struct\Info
$hostingNode = $info->addChild('hosting')->addChild('vrt_hst');
foreach ($properties[static::PROPERTIES_HOSTING] as $name => $value) {
$propertyNode = $hostingNode->addChild('property');
/** @psalm-suppress UndefinedPropertyAssignment */
$propertyNode->name = $name;
/** @psalm-suppress UndefinedPropertyAssignment */
$propertyNode->value = $value;
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/Api/Operator/SiteAlias.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ public function getAll($field = null, $value = null): array
if (!$xmlResult) {
continue;
}
$item = new Struct\GeneralInfo($xmlResult->info);
$items[] = $item;
if (!is_null($xmlResult->info)) {
$item = new Struct\GeneralInfo($xmlResult->info);
$items[] = $item;
}
}

return $items;
Expand Down
2 changes: 2 additions & 0 deletions src/Api/Operator/Subdomain.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ public function create(array $properties): Struct\Info
if (is_array($value)) {
foreach ($value as $propertyName => $propertyValue) {
$property = $info->addChild($name);
/** @psalm-suppress UndefinedPropertyAssignment */
$property->name = $propertyName;
/** @psalm-suppress UndefinedPropertyAssignment */
$property->value = $propertyValue;
}
continue;
Expand Down
1 change: 1 addition & 0 deletions src/Api/Operator/Ui.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public function getNavigation(): array
{
$response = $this->request('get-navigation');

/** @psalm-suppress ImplicitToStringCast, PossiblyNullArgument */
return unserialize(base64_decode($response->navigation));
}

Expand Down
2 changes: 2 additions & 0 deletions src/Api/Operator/Webspace.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ public function create(array $properties, array $hostingProperties = null, strin
$infoHosting = $info->addChild('hosting')->addChild('vrt_hst');
foreach ($hostingProperties as $name => $value) {
$property = $infoHosting->addChild('property');
/** @psalm-suppress UndefinedPropertyAssignment */
$property->name = $name;
/** @psalm-suppress UndefinedPropertyAssignment */
$property->value = $value;
}

Expand Down
12 changes: 7 additions & 5 deletions src/Api/Struct/Reseller/GeneralInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ class GeneralInfo extends AbstractStruct

public function __construct(\SimpleXMLElement $apiResponse)
{
$this->initScalarProperties($apiResponse->{'gen-info'}, [
['pname' => 'personalName'],
'login',
]);
if (!is_null($apiResponse->{'gen-info'})) {
$this->initScalarProperties($apiResponse->{'gen-info'}, [
['pname' => 'personalName'],
'login',
]);
}

$this->permissions = [];
foreach ($apiResponse->permissions->permission as $permissionInfo) {
foreach ($apiResponse->permissions->permission ?? [] as $permissionInfo) {
$this->permissions[(string) $permissionInfo->name] = (string) $permissionInfo->value;
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/Api/Struct/Server/Statistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ class Statistics extends AbstractStruct
/** @var Statistics\DiskSpace[] */
public $diskSpace;

/**
* @param \SimpleXMLElement $apiResponse
* @psalm-suppress PossiblyNullArgument
*/
public function __construct(\SimpleXMLElement $apiResponse)
{
$this->objects = new Statistics\Objects($apiResponse->objects);
Expand All @@ -38,7 +42,7 @@ public function __construct(\SimpleXMLElement $apiResponse)
$this->swap = new Statistics\Swap($apiResponse->swap);

$this->diskSpace = [];
foreach ($apiResponse->diskspace as $disk) {
foreach ($apiResponse->diskspace ?? [] as $disk) {
$this->diskSpace[(string) $disk->device->name] = new Statistics\DiskSpace($disk->device);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Api/Struct/Server/Statistics/LoadAverage.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class LoadAverage extends AbstractStruct

public function __construct(\SimpleXMLElement $apiResponse)
{
$this->load1min = $apiResponse->l1 / 100.0;
$this->load5min = $apiResponse->l5 / 100.0;
$this->load15min = $apiResponse->l15 / 100.0;
$this->load1min = (float) $apiResponse->l1 / 100.0;
$this->load5min = (float) $apiResponse->l5 / 100.0;
$this->load15min = (float) $apiResponse->l15 / 100.0;
}
}
2 changes: 1 addition & 1 deletion src/Api/Struct/Site/GeneralInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct(\SimpleXMLElement $apiResponse)
'webspace-id',
]);

foreach ($apiResponse->dns_ip_address as $ip) {
foreach ($apiResponse->dns_ip_address ?? [] as $ip) {
$this->ipAddresses[] = (string) $ip;
}
}
Expand Down
11 changes: 7 additions & 4 deletions src/Api/Struct/Site/HostingInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ class HostingInfo extends AbstractStruct

public function __construct(\SimpleXMLElement $apiResponse)
{
foreach ($apiResponse->vrt_hst->property as $property) {
foreach ($apiResponse->vrt_hst->property ?? [] as $property) {
$this->properties[(string) $property->name] = (string) $property->value;
}
$this->initScalarProperties($apiResponse->vrt_hst, [
'ip_address',
]);

if (!is_null($apiResponse->vrt_hst)) {
$this->initScalarProperties($apiResponse->vrt_hst, [
'ip_address',
]);
}
}
}
2 changes: 1 addition & 1 deletion src/Api/Struct/Subdomain/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct(\SimpleXMLElement $apiResponse)
'parent',
'name',
]);
foreach ($apiResponse->property as $propertyInfo) {
foreach ($apiResponse->property ?? [] as $propertyInfo) {
$this->properties[(string) $propertyInfo->name] = (string) $propertyInfo->value;
}
}
Expand Down
Loading

0 comments on commit 32563ff

Please sign in to comment.