Skip to content

Commit 5c6317f

Browse files
committed
TECH Satisfy linters
1 parent 2234d0d commit 5c6317f

29 files changed

+86
-53
lines changed

src/Api/AbstractStruct.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function __set(string $property, $value)
2424
*
2525
* @throws \Exception
2626
*/
27-
protected function initScalarProperties($apiResponse, array $properties): void
27+
protected function initScalarProperties(\SimpleXMLElement $apiResponse, array $properties): void
2828
{
2929
foreach ($properties as $property) {
3030
if (is_array($property)) {

src/Api/Operator/DatabaseServer.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,11 @@ private function getBy($field = null, $value = null): array
6060
if (!$xmlResult) {
6161
continue;
6262
}
63-
$item = new Struct\Info($xmlResult->data);
64-
$item->id = (int) $xmlResult->id;
65-
$items[] = $item;
63+
if (!is_null($xmlResult->data)) {
64+
$item = new Struct\Info($xmlResult->data);
65+
$item->id = (int) $xmlResult->id;
66+
$items[] = $item;
67+
}
6668
}
6769

6870
return $items;

src/Api/Operator/Dns.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,11 @@ public function getAll(string $field, $value): array
8282
if (!$xmlResult) {
8383
continue;
8484
}
85-
$item = new Struct\Info($xmlResult->data);
86-
$item->id = (int) $xmlResult->id;
87-
$items[] = $item;
85+
if (!is_null($xmlResult->data)) {
86+
$item = new Struct\Info($xmlResult->data);
87+
$item->id = (int) $xmlResult->id;
88+
$items[] = $item;
89+
}
8890
}
8991

9092
return $items;

src/Api/Operator/DnsTemplate.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,11 @@ public function getAll($field = null, $value = null): array
6363
if (!$xmlResult) {
6464
continue;
6565
}
66-
$item = new Struct\Info($xmlResult->data);
67-
$item->id = (int) $xmlResult->id;
68-
$items[] = $item;
66+
if (!is_null($xmlResult->data)) {
67+
$item = new Struct\Info($xmlResult->data);
68+
$item->id = (int) $xmlResult->id;
69+
$items[] = $item;
70+
}
6971
}
7072

7173
return $items;

src/Api/Operator/EventLog.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function get(): array
1717
$records = [];
1818
$response = $this->request('get');
1919

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

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

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

src/Api/Operator/Ip.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function get(): array
1717
$packet->addChild($this->wrapperTag)->addChild('get');
1818
$response = $this->client->request($packet);
1919

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

src/Api/Operator/Locale.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ public function get($id = null)
2424

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

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

3133
return !is_null($id) ? reset($locales) : $locales;

src/Api/Operator/Mail.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ public function create(string $name, int $siteId, bool $mailbox = false, string
2222
$mailname->addChild('mailbox')->addChild('enabled', 'true');
2323
}
2424
if (!empty($password)) {
25+
/** @psalm-suppress UndefinedPropertyAssignment */
2526
$mailname->addChild('password')->value = $password;
2627
}
2728

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

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

src/Api/Operator/ProtectedDirectory.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public function getAll(string $field, $value): array
7373
* @param string $password
7474
*
7575
* @return Struct\UserInfo
76+
* @psalm-suppress UndefinedPropertyAssignment
7677
*/
7778
public function addUser($protectedDirectory, $login, $password)
7879
{

src/Api/Operator/Server.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public function getProtos(): array
1414
$packet->addChild($this->wrapperTag)->addChild('get_protos');
1515
$response = $this->client->request($packet);
1616

17+
/** @psalm-suppress PossiblyNullPropertyFetch */
1718
return (array) $response->protos->proto;
1819
}
1920

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

40-
foreach ($keyInfoXml->property as $property) {
41+
foreach ($keyInfoXml->property ?? [] as $property) {
4142
$keyInfo[(string) $property->name] = (string) $property->value;
4243
}
4344

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

52-
foreach ($componentsXml->component as $component) {
53+
foreach ($componentsXml->component ?? [] as $component) {
5354
$components[(string) $component->name] = (string) $component->version;
5455
}
5556

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

64-
foreach ($statesXml->srv as $service) {
65+
foreach ($statesXml->srv ?? [] as $service) {
6566
$states[(string) $service->id] = [
6667
'id' => (string) $service->id,
6768
'title' => (string) $service->title,
@@ -82,7 +83,7 @@ public function getShells(): array
8283
$shells = [];
8384
$shellsXml = $this->getInfo('shells');
8485

85-
foreach ($shellsXml->shell as $shell) {
86+
foreach ($shellsXml->shell ?? [] as $shell) {
8687
$shells[(string) $shell->name] = (string) $shell->path;
8788
}
8889

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

109-
foreach ($configXml->property as $property) {
110+
foreach ($configXml->property ?? [] as $property) {
110111
$config[(string) $property->name] = (string) $property->value;
111112
}
112113

0 commit comments

Comments
 (0)