From bdaad89f315c86f01c19ddbdf126de855f5cfb34 Mon Sep 17 00:00:00 2001 From: Alexei Yuzhakov Date: Thu, 7 Oct 2021 00:04:33 +0700 Subject: [PATCH] Fix issues reported by psalm --- psalm.xml | 2 +- src/Api/Client.php | 168 +++++------------- src/Api/Operator.php | 5 +- src/Api/Operator/Database.php | 10 +- src/Api/Operator/DatabaseServer.php | 6 +- src/Api/Operator/Dns.php | 18 +- src/Api/Operator/DnsTemplate.php | 8 +- src/Api/Operator/Mail.php | 18 +- src/Api/Operator/PhpHandler.php | 12 +- src/Api/Operator/ProtectedDirectory.php | 28 ++- src/Api/Operator/Reseller.php | 2 +- src/Api/Operator/ServicePlan.php | 4 +- src/Api/Operator/Site.php | 4 +- src/Api/Operator/SiteAlias.php | 6 +- src/Api/Operator/Subdomain.php | 4 +- src/Api/Operator/Webspace.php | 2 +- src/Api/Struct/Certificate/Info.php | 3 +- src/Api/Struct/Customer/GeneralInfo.php | 3 +- src/Api/Struct/Customer/Info.php | 3 +- src/Api/Struct/Database/Info.php | 3 +- src/Api/Struct/Database/UserInfo.php | 3 +- src/Api/Struct/DatabaseServer/Info.php | 3 +- src/Api/Struct/Dns/Info.php | 3 +- src/Api/Struct/EventLog/DetailedEvent.php | 3 +- src/Api/Struct/EventLog/Event.php | 3 +- src/Api/Struct/Ip/Info.php | 3 +- src/Api/Struct/Locale/Info.php | 3 +- src/Api/Struct/Mail/GeneralInfo.php | 3 +- src/Api/Struct/Mail/Info.php | 3 +- src/Api/Struct/PhpHandler/Info.php | 2 +- .../Struct/ProtectedDirectory/DataInfo.php | 3 +- src/Api/Struct/ProtectedDirectory/Info.php | 3 +- .../Struct/ProtectedDirectory/UserInfo.php | 3 +- src/Api/Struct/Reseller/GeneralInfo.php | 3 +- src/Api/Struct/Reseller/Info.php | 3 +- src/Api/Struct/SecretKey/Info.php | 3 +- src/Api/Struct/Server/Admin.php | 3 +- src/Api/Struct/Server/GeneralInfo.php | 3 +- src/Api/Struct/Server/Preferences.php | 3 +- src/Api/Struct/Server/SessionPreferences.php | 3 +- src/Api/Struct/Server/Statistics.php | 3 +- .../Struct/Server/Statistics/DiskSpace.php | 3 +- .../Struct/Server/Statistics/LoadAverage.php | 3 +- src/Api/Struct/Server/Statistics/Memory.php | 3 +- src/Api/Struct/Server/Statistics/Objects.php | 3 +- src/Api/Struct/Server/Statistics/Other.php | 3 +- src/Api/Struct/Server/Statistics/Swap.php | 3 +- src/Api/Struct/Server/Statistics/Version.php | 3 +- src/Api/Struct/Server/UpdatesInfo.php | 3 +- src/Api/Struct/ServicePlan/Info.php | 3 +- src/Api/Struct/Session/Info.php | 3 +- src/Api/Struct/Site/GeneralInfo.php | 3 +- src/Api/Struct/Site/HostingInfo.php | 3 +- src/Api/Struct/Site/Info.php | 3 +- src/Api/Struct/SiteAlias/GeneralInfo.php | 3 +- src/Api/Struct/SiteAlias/Info.php | 3 +- src/Api/Struct/Subdomain/Info.php | 3 +- src/Api/Struct/Ui/CustomButton.php | 3 +- src/Api/Struct/Webspace/DiskUsage.php | 3 +- src/Api/Struct/Webspace/GeneralInfo.php | 3 +- .../Struct/Webspace/HostingPropertyInfo.php | 3 +- src/Api/Struct/Webspace/Info.php | 3 +- src/Api/Struct/Webspace/Limit.php | 3 +- src/Api/Struct/Webspace/LimitDescriptor.php | 3 +- src/Api/Struct/Webspace/LimitInfo.php | 3 +- src/Api/Struct/Webspace/Limits.php | 3 +- .../Struct/Webspace/PermissionDescriptor.php | 3 +- src/Api/Struct/Webspace/PermissionInfo.php | 3 +- src/Api/Struct/Webspace/PhpSettings.php | 3 +- .../Webspace/PhysicalHostingDescriptor.php | 3 +- tests/PhpHandlerTest.php | 3 +- 71 files changed, 165 insertions(+), 296 deletions(-) diff --git a/psalm.xml b/psalm.xml index ab2b5f01..43b6fdac 100644 --- a/psalm.xml +++ b/psalm.xml @@ -1,6 +1,6 @@ call($requestXml->children()[0]->asXml(), $this->_login); } else { - $xml = $this->_performHttpRequest($request); + $xml = $this->_performHttpRequest((string) $request); } $this->_verifyResponseCallback @@ -212,22 +212,19 @@ private function _performHttpRequest($request) curl_close($curl); - $xml = new XmlResponse($result); - - return $xml; + return new XmlResponse((string) $result); } /** * Perform multiple API requests using single HTTP request. * - * @param $requests + * @param array $requests * @param int $mode * - * @throws Client\Exception - * * @return array + * @throws Client\Exception */ - public function multiRequest($requests, $mode = self::RESPONSE_SHORT) + public function multiRequest(array $requests, $mode = self::RESPONSE_SHORT): array { $requestXml = $this->getPacket(); @@ -237,23 +234,32 @@ public function multiRequest($requests, $mode = self::RESPONSE_SHORT) } else { if (is_array($request)) { $request = $this->_arrayToXml($request, $requestXml)->asXML(); + if (!$request) { + throw new Client\Exception('Failed to create an XML string for request'); + } } elseif (preg_match('/^[a-z]/', $request)) { $this->_expandRequestShortSyntax($request, $requestXml); } } - $responses[] = $this->request($request); } if ('sdk' == $this->_protocol) { throw new Client\Exception('Multi requests are not supported via SDK.'); } else { - $responseXml = $this->_performHttpRequest($requestXml->asXML()); + $xmlString = $requestXml->asXML(); + if (!$xmlString) { + throw new Client\Exception('Failed to create an XML string for request'); + } + $responseXml = $this->_performHttpRequest($xmlString); } $responses = []; foreach ($responseXml->children() as $childNode) { $xml = $this->getPacket(); $dom = dom_import_simplexml($xml)->ownerDocument; + if (!$dom) { + continue; + } $childDomNode = dom_import_simplexml($childNode); $childDomNode = $dom->importNode($childDomNode, true); @@ -371,230 +377,150 @@ protected function _isAssocArray(array $array) /** * @param string $name * - * @return \PleskX\Api\Operator + * @return mixed */ - protected function _getOperator($name) + protected function _getOperator(string $name) { if (!isset($this->_operatorsCache[$name])) { $className = '\\PleskX\\Api\\Operator\\'.$name; + /** @psalm-suppress InvalidStringClass */ $this->_operatorsCache[$name] = new $className($this); } return $this->_operatorsCache[$name]; } - /** - * @return Operator\Server - */ - public function server() + public function server(): Operator\Server { return $this->_getOperator('Server'); } - /** - * @return Operator\Customer - */ - public function customer() + public function customer(): Operator\Customer { return $this->_getOperator('Customer'); } - /** - * @return Operator\Webspace - */ - public function webspace() + public function webspace(): Operator\Webspace { return $this->_getOperator('Webspace'); } - /** - * @return Operator\Subdomain - */ - public function subdomain() + public function subdomain(): Operator\Subdomain { return $this->_getOperator('Subdomain'); } - /** - * @return Operator\Dns - */ - public function dns() + public function dns(): Operator\Dns { return $this->_getOperator('Dns'); } - /** - * @return Operator\DnsTemplate - */ - public function dnsTemplate() + public function dnsTemplate(): Operator\DnsTemplate { return $this->_getOperator('DnsTemplate'); } - /** - * @return Operator\DatabaseServer - */ - public function databaseServer() + public function databaseServer(): Operator\DatabaseServer { return $this->_getOperator('DatabaseServer'); } - /** - * @return Operator\Mail - */ - public function mail() + public function mail(): Operator\Mail { return $this->_getOperator('Mail'); } - /** - * @return Operator\Certificate - */ - public function certificate() + public function certificate(): Operator\Certificate { return $this->_getOperator('Certificate'); } - /** - * @return Operator\SiteAlias - */ - public function siteAlias() + public function siteAlias(): Operator\SiteAlias { return $this->_getOperator('SiteAlias'); } - /** - * @return Operator\Ip - */ - public function ip() + public function ip(): Operator\Ip { return $this->_getOperator('Ip'); } - /** - * @return Operator\EventLog - */ - public function eventLog() + public function eventLog(): Operator\EventLog { return $this->_getOperator('EventLog'); } - /** - * @return Operator\SecretKey - */ - public function secretKey() + public function secretKey(): Operator\SecretKey { return $this->_getOperator('SecretKey'); } - /** - * @return Operator\Ui - */ - public function ui() + public function ui(): Operator\Ui { return $this->_getOperator('Ui'); } - /** - * @return Operator\ServicePlan - */ - public function servicePlan() + public function servicePlan(): Operator\ServicePlan { return $this->_getOperator('ServicePlan'); } - /** - * @return Operator\VirtualDirectory - */ - public function virtualDirectory() + public function virtualDirectory(): Operator\VirtualDirectory { return $this->_getOperator('VirtualDirectory'); } - /** - * @return Operator\Database - */ - public function database() + public function database(): Operator\Database { return $this->_getOperator('Database'); } - /** - * @return Operator\Session - */ - public function session() + public function session(): Operator\Session { return $this->_getOperator('Session'); } - /** - * @return Operator\Locale - */ - public function locale() + public function locale(): Operator\Locale { return $this->_getOperator('Locale'); } - /** - * @return Operator\LogRotation - */ - public function logRotation() + public function logRotation(): Operator\LogRotation { return $this->_getOperator('LogRotation'); } - /** - * @return Operator\ProtectedDirectory - */ - public function protectedDirectory() + public function protectedDirectory(): Operator\ProtectedDirectory { return $this->_getOperator('ProtectedDirectory'); } - /** - * @return Operator\Reseller - */ - public function reseller() + public function reseller(): Operator\Reseller { return $this->_getOperator('Reseller'); } - /** - * @return Operator\ResellerPlan - */ - public function resellerPlan() + public function resellerPlan(): Operator\ResellerPlan { return $this->_getOperator('ResellerPlan'); } - /** - * @return Operator\Aps - */ - public function aps() + public function aps(): Operator\Aps { return $this->_getOperator('Aps'); } - /** - * @return Operator\ServicePlanAddon - */ - public function servicePlanAddon() + public function servicePlanAddon(): Operator\ServicePlanAddon { return $this->_getOperator('ServicePlanAddon'); } - /** - * @return Operator\Site - */ - public function site() + public function site(): Operator\Site { return $this->_getOperator('Site'); } - /** - * @return Operator\PhpHandler - */ - public function phpHandler() + public function phpHandler(): Operator\PhpHandler { return $this->_getOperator('PhpHandler'); } diff --git a/src/Api/Operator.php b/src/Api/Operator.php index 60b5b541..c577e366 100644 --- a/src/Api/Operator.php +++ b/src/Api/Operator.php @@ -8,7 +8,7 @@ class Operator protected string $_wrapperTag = ''; protected Client $_client; - public function __construct($client) + public function __construct(Client $client) { $this->_client = $client; @@ -78,7 +78,7 @@ protected function _getItems($structClass, $infoTag, $field = null, $value = nul $filterTag = $getTag->addChild('filter'); if (!is_null($field)) { - $filterTag->{$field} = $value; + $filterTag->{$field} = (string) $value; } $getTag->addChild('dataset')->addChild($infoTag); @@ -93,6 +93,7 @@ protected function _getItems($structClass, $infoTag, $field = null, $value = nul if (!isset($xmlResult->data) || !isset($xmlResult->data->$infoTag)) { continue; } + /** @psalm-suppress InvalidStringClass */ $item = new $structClass($xmlResult->data->$infoTag); if (isset($xmlResult->id) && property_exists($item, 'id')) { $item->id = (int) $xmlResult->id; diff --git a/src/Api/Operator/Database.php b/src/Api/Operator/Database.php index 8e5696ae..048841b8 100644 --- a/src/Api/Operator/Database.php +++ b/src/Api/Operator/Database.php @@ -128,19 +128,15 @@ public function getAllUsers($field, $value) * * @return \PleskX\Api\XmlResponse */ - private function _get($command, $field, $value) + private function _get(string $command, string $field, $value) { $packet = $this->_client->getPacket(); $getTag = $packet->addChild($this->_wrapperTag)->addChild($command); $filterTag = $getTag->addChild('filter'); - if (!is_null($field)) { - $filterTag->{$field} = $value; - } - - $response = $this->_client->request($packet, \PleskX\Api\Client::RESPONSE_FULL); + $filterTag->{$field} = (string) $value; - return $response; + return $this->_client->request($packet, \PleskX\Api\Client::RESPONSE_FULL); } /** diff --git a/src/Api/Operator/DatabaseServer.php b/src/Api/Operator/DatabaseServer.php index 8b830460..18cfbfa1 100644 --- a/src/Api/Operator/DatabaseServer.php +++ b/src/Api/Operator/DatabaseServer.php @@ -25,7 +25,7 @@ public function getSupportedTypes() * * @return Struct\Info */ - public function get($field, $value) + public function get(string $field, $value) { $items = $this->_get($field, $value); @@ -44,7 +44,7 @@ public function getAll() * @param string|null $field * @param int|string|null $value * - * @return Struct\Info|Struct\Info[] + * @return Struct\Info[] */ private function _get($field = null, $value = null) { @@ -53,7 +53,7 @@ private function _get($field = null, $value = null) $filterTag = $getTag->addChild('filter'); if (!is_null($field)) { - $filterTag->{$field} = $value; + $filterTag->{$field} = (string) $value; } $response = $this->_client->request($packet, \PleskX\Api\Client::RESPONSE_FULL); diff --git a/src/Api/Operator/Dns.php b/src/Api/Operator/Dns.php index 30920a71..c57ffef4 100644 --- a/src/Api/Operator/Dns.php +++ b/src/Api/Operator/Dns.php @@ -29,9 +29,9 @@ public function create($properties) * * @param array $records * - * @return \PleskX\Api\XmlResponse[] + * @return \SimpleXMLElement[] */ - public function bulkCreate(array $records) + public function bulkCreate(array $records): array { $packet = $this->_client->getPacket(); @@ -58,7 +58,7 @@ public function bulkCreate(array $records) * * @return Struct\Info */ - public function get($field, $value) + public function get(string $field, $value) { $items = $this->getAll($field, $value); @@ -71,15 +71,13 @@ public function get($field, $value) * * @return Struct\Info[] */ - public function getAll($field, $value) + public function getAll(string $field, $value): array { $packet = $this->_client->getPacket(); $getTag = $packet->addChild($this->_wrapperTag)->addChild('get_rec'); $filterTag = $getTag->addChild('filter'); - if (!is_null($field)) { - $filterTag->addChild($field, $value); - } + $filterTag->addChild($field, (string) $value); $response = $this->_client->request($packet, \PleskX\Api\Client::RESPONSE_FULL); $items = []; @@ -98,7 +96,7 @@ public function getAll($field, $value) * * @return bool */ - public function delete($field, $value) + public function delete(string $field, $value): bool { return $this->_delete($field, $value, 'del_rec'); } @@ -108,9 +106,9 @@ public function delete($field, $value) * * @param array $recordIds * - * @return \PleskX\Api\XmlResponse[] + * @return \SimpleXMLElement[] */ - public function bulkDelete(array $recordIds) + public function bulkDelete(array $recordIds): array { $packet = $this->_client->getPacket(); diff --git a/src/Api/Operator/DnsTemplate.php b/src/Api/Operator/DnsTemplate.php index b9b0af06..2e76ab9c 100644 --- a/src/Api/Operator/DnsTemplate.php +++ b/src/Api/Operator/DnsTemplate.php @@ -46,14 +46,14 @@ public function get($field, $value) * * @return Struct\Info[] */ - public function getAll($field = null, $value = null) + public function getAll($field = null, $value = null): array { $packet = $this->_client->getPacket(); $getTag = $packet->addChild($this->_wrapperTag)->addChild('get_rec'); $filterTag = $getTag->addChild('filter'); if (!is_null($field)) { - $filterTag->{$field} = $value; + $filterTag->{$field} = (string) $value; } $getTag->addChild('template'); @@ -74,11 +74,11 @@ public function getAll($field = null, $value = null) * * @return bool */ - public function delete($field, $value) + public function delete(string $field, $value): bool { $packet = $this->_client->getPacket(); $delTag = $packet->addChild($this->_wrapperTag)->addChild('del_rec'); - $delTag->addChild('filter')->addChild($field, $value); + $delTag->addChild('filter')->addChild($field, (string) $value); $delTag->addChild('template'); $response = $this->_client->request($packet); diff --git a/src/Api/Operator/Mail.php b/src/Api/Operator/Mail.php index 0fa01380..da5a630d 100644 --- a/src/Api/Operator/Mail.php +++ b/src/Api/Operator/Mail.php @@ -3,9 +3,11 @@ namespace PleskX\Api\Operator; +use PleskX\Api\Client; +use PleskX\Api\Operator; use PleskX\Api\Struct\Mail as Struct; -class Mail extends \PleskX\Api\Operator +class Mail extends Operator { /** * @param string $name @@ -21,7 +23,7 @@ public function create($name, $siteId, $mailbox = false, $password = '') $info = $packet->addChild($this->_wrapperTag)->addChild('create'); $filter = $info->addChild('filter'); - $filter->addChild('site-id', $siteId); + $filter->addChild('site-id', (string) $siteId); $mailname = $filter->addChild('mailname'); $mailname->addChild('name', $name); if ($mailbox) { @@ -43,12 +45,14 @@ public function create($name, $siteId, $mailbox = false, $password = '') * * @return bool */ - public function delete($field, $value, $siteId) + public function delete(string $field, $value, $siteId): bool { $packet = $this->_client->getPacket(); $filter = $packet->addChild($this->_wrapperTag)->addChild('remove')->addChild('filter'); - $filter->addChild('site-id', $siteId); - $filter->{$field} = $value; + + $filter->addChild('site-id', (string) $siteId); + $filter->{$field} = (string) $value; + $response = $this->_client->request($packet); return 'ok' === (string) $response->status; @@ -79,12 +83,12 @@ public function getAll($siteId, $name = null) $getTag = $packet->addChild($this->_wrapperTag)->addChild('get_info'); $filterTag = $getTag->addChild('filter'); - $filterTag->addChild('site-id', $siteId); + $filterTag->addChild('site-id', (string) $siteId); if (!is_null($name)) { $filterTag->addChild('name', $name); } - $response = $this->_client->request($packet, \PleskX\Api\Client::RESPONSE_FULL); + $response = $this->_client->request($packet, Client::RESPONSE_FULL); $items = []; foreach ($response->xpath('//result') as $xmlResult) { if (!isset($xmlResult->mailname)) { diff --git a/src/Api/Operator/PhpHandler.php b/src/Api/Operator/PhpHandler.php index 66f1ec1d..5adb1e8b 100644 --- a/src/Api/Operator/PhpHandler.php +++ b/src/Api/Operator/PhpHandler.php @@ -10,19 +10,19 @@ class PhpHandler extends Operator { /** - * @param string $field - * @param int|string $value + * @param string|null $field + * @param int|string|null $value * * @return Info */ - public function get($field, $value) + public function get($field = null, $value = null): Info { $packet = $this->_client->getPacket(); $getTag = $packet->addChild($this->_wrapperTag)->addChild('get'); $filterTag = $getTag->addChild('filter'); if (!is_null($field)) { - $filterTag->addChild($field, $value); + $filterTag->addChild($field, (string)$value); } $response = $this->_client->request($packet, Client::RESPONSE_FULL); @@ -37,14 +37,14 @@ public function get($field, $value) * * @return Info[] */ - public function getAll($field = null, $value = null) + public function getAll($field = null, $value = null): array { $packet = $this->_client->getPacket(); $getTag = $packet->addChild($this->_wrapperTag)->addChild('get'); $filterTag = $getTag->addChild('filter'); if (!is_null($field)) { - $filterTag->addChild($field, $value); + $filterTag->addChild($field, (string) $value); } $response = $this->_client->request($packet, Client::RESPONSE_FULL); diff --git a/src/Api/Operator/ProtectedDirectory.php b/src/Api/Operator/ProtectedDirectory.php index 80fc3819..29756d3a 100644 --- a/src/Api/Operator/ProtectedDirectory.php +++ b/src/Api/Operator/ProtectedDirectory.php @@ -3,9 +3,11 @@ namespace PleskX\Api\Operator; +use PleskX\Api\Client; +use PleskX\Api\Operator; use PleskX\Api\Struct\ProtectedDirectory as Struct; -class ProtectedDirectory extends \PleskX\Api\Operator +class ProtectedDirectory extends Operator { protected string $_wrapperTag = 'protected-dir'; @@ -21,7 +23,7 @@ public function add($name, $siteId, $header = '') $packet = $this->_client->getPacket(); $info = $packet->addChild($this->_wrapperTag)->addChild('add'); - $info->addChild('site-id', $siteId); + $info->addChild('site-id', (string) $siteId); $info->addChild('name', $name); $info->addChild('header', $header); @@ -45,7 +47,7 @@ public function delete($field, $value) * * @return Struct\DataInfo|false */ - public function get($field, $value) + public function get(string $field, $value) { $items = $this->getAll($field, $value); @@ -58,7 +60,7 @@ public function get($field, $value) * * @return Struct\DataInfo[] */ - public function getAll($field, $value) + public function getAll(string $field, $value): array { $response = $this->_get('get', $field, $value); $items = []; @@ -81,7 +83,7 @@ public function addUser($protectedDirectory, $login, $password) $packet = $this->_client->getPacket(); $info = $packet->addChild($this->_wrapperTag)->addChild('add-user'); - $info->{'pd-id'} = $protectedDirectory->id; + $info->{'pd-id'} = (string) $protectedDirectory->id; $info->login = $login; $info->password = $password; @@ -100,24 +102,20 @@ public function deleteUser($field, $value) } /** - * @param $command - * @param $field - * @param $value + * @param string $command + * @param string $field + * @param int|string $value * * @return \PleskX\Api\XmlResponse */ - private function _get($command, $field, $value) + private function _get(string $command, string $field, $value) { $packet = $this->_client->getPacket(); $getTag = $packet->addChild($this->_wrapperTag)->addChild($command); $filterTag = $getTag->addChild('filter'); - if (!is_null($field)) { - $filterTag->{$field} = $value; - } - - $response = $this->_client->request($packet, \PleskX\Api\Client::RESPONSE_FULL); + $filterTag->{$field} = (string) $value; - return $response; + return $this->_client->request($packet, Client::RESPONSE_FULL); } } diff --git a/src/Api/Operator/Reseller.php b/src/Api/Operator/Reseller.php index bcf76d32..f29391ff 100644 --- a/src/Api/Operator/Reseller.php +++ b/src/Api/Operator/Reseller.php @@ -63,7 +63,7 @@ public function getAll($field = null, $value = null) $filterTag = $getTag->addChild('filter'); if (!is_null($field)) { - $filterTag->addChild($field, $value); + $filterTag->addChild($field, (string) $value); } $datasetTag = $getTag->addChild('dataset'); diff --git a/src/Api/Operator/ServicePlan.php b/src/Api/Operator/ServicePlan.php index 41fa075e..d4c14899 100644 --- a/src/Api/Operator/ServicePlan.php +++ b/src/Api/Operator/ServicePlan.php @@ -55,7 +55,7 @@ public function getAll() * @param string|null $field * @param int|string|null $value * - * @return Struct\Info|Struct\Info[] + * @return Struct\Info[] */ private function _get($field = null, $value = null) { @@ -64,7 +64,7 @@ private function _get($field = null, $value = null) $filterTag = $getTag->addChild('filter'); if (!is_null($field)) { - $filterTag->addChild($field, $value); + $filterTag->addChild($field, (string) $value); } $response = $this->_client->request($packet, \PleskX\Api\Client::RESPONSE_FULL); diff --git a/src/Api/Operator/Site.php b/src/Api/Operator/Site.php index f92eae62..4da17822 100644 --- a/src/Api/Operator/Site.php +++ b/src/Api/Operator/Site.php @@ -24,7 +24,7 @@ public function create(array $properties) if (!is_scalar($value)) { continue; } - $infoGeneral->{$name} = $value; + $infoGeneral->{$name} = (string) $value; } // set hosting properties @@ -74,7 +74,7 @@ public function get($field, $value) */ public function getHosting($field, $value) { - $items = $this->_getItems(Struct\HostingInfo::class, 'hosting', $field, $value, function ($node) { + $items = $this->_getItems(Struct\HostingInfo::class, 'hosting', $field, $value, function (\SimpleXMLElement $node) { return isset($node->vrt_hst); }); diff --git a/src/Api/Operator/SiteAlias.php b/src/Api/Operator/SiteAlias.php index 5135e1cf..c013c17d 100644 --- a/src/Api/Operator/SiteAlias.php +++ b/src/Api/Operator/SiteAlias.php @@ -22,7 +22,7 @@ public function create(array $properties, array $preferences = []) $prefs = $info->addChild('pref'); foreach ($preferences as $key => $value) { - $prefs->addChild($key, is_bool($value) ? ($value ? 1 : 0) : $value); + $prefs->addChild($key, is_bool($value) ? ($value ? "1" : "0") : $value); } } @@ -64,14 +64,14 @@ public function get($field, $value) * * @return Struct\GeneralInfo[] */ - public function getAll($field = null, $value = null) + public function getAll($field = null, $value = null): array { $packet = $this->_client->getPacket(); $getTag = $packet->addChild($this->_wrapperTag)->addChild('get'); $filterTag = $getTag->addChild('filter'); if (!is_null($field)) { - $filterTag->{$field} = $value; + $filterTag->{$field} = (string) $value; } $response = $this->_client->request($packet, \PleskX\Api\Client::RESPONSE_FULL); diff --git a/src/Api/Operator/Subdomain.php b/src/Api/Operator/Subdomain.php index de1eb3a7..b748dcad 100644 --- a/src/Api/Operator/Subdomain.php +++ b/src/Api/Operator/Subdomain.php @@ -64,14 +64,14 @@ public function get($field, $value) * * @return Struct\Info[] */ - public function getAll($field = null, $value = null) + public function getAll($field = null, $value = null): array { $packet = $this->_client->getPacket(); $getTag = $packet->addChild($this->_wrapperTag)->addChild('get'); $filterTag = $getTag->addChild('filter'); if (!is_null($field)) { - $filterTag->addChild($field, $value); + $filterTag->addChild($field, (string) $value); } $response = $this->_client->request($packet, \PleskX\Api\Client::RESPONSE_FULL); diff --git a/src/Api/Operator/Webspace.php b/src/Api/Operator/Webspace.php index 16f77651..2aab504b 100644 --- a/src/Api/Operator/Webspace.php +++ b/src/Api/Operator/Webspace.php @@ -40,7 +40,7 @@ public function getPhpSettings(string $field, $value): Struct\PhpSettings $packet = $this->_client->getPacket(); $getTag = $packet->addChild($this->_wrapperTag)->addChild('get'); - $getTag->addChild('filter')->addChild($field, $value); + $getTag->addChild('filter')->addChild($field, (string) $value); $getTag->addChild('dataset')->addChild('php-settings'); $response = $this->_client->request($packet, \PleskX\Api\Client::RESPONSE_FULL); diff --git a/src/Api/Struct/Certificate/Info.php b/src/Api/Struct/Certificate/Info.php index 2185c110..467defac 100644 --- a/src/Api/Struct/Certificate/Info.php +++ b/src/Api/Struct/Certificate/Info.php @@ -4,14 +4,13 @@ namespace PleskX\Api\Struct\Certificate; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class Info extends Struct { public string $request; public string $privateKey; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, [ ['csr' => 'request'], diff --git a/src/Api/Struct/Customer/GeneralInfo.php b/src/Api/Struct/Customer/GeneralInfo.php index 43f8ab20..56b12bf1 100644 --- a/src/Api/Struct/Customer/GeneralInfo.php +++ b/src/Api/Struct/Customer/GeneralInfo.php @@ -4,7 +4,6 @@ namespace PleskX\Api\Struct\Customer; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class GeneralInfo extends Struct { @@ -24,7 +23,7 @@ class GeneralInfo extends Struct public string $description; public string $externalId; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, [ ['cname' => 'company'], diff --git a/src/Api/Struct/Customer/Info.php b/src/Api/Struct/Customer/Info.php index 926b5519..f9b4c514 100644 --- a/src/Api/Struct/Customer/Info.php +++ b/src/Api/Struct/Customer/Info.php @@ -4,14 +4,13 @@ namespace PleskX\Api\Struct\Customer; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class Info extends Struct { public int $id; public string $guid; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, [ 'id', diff --git a/src/Api/Struct/Database/Info.php b/src/Api/Struct/Database/Info.php index 9f705656..d706984b 100644 --- a/src/Api/Struct/Database/Info.php +++ b/src/Api/Struct/Database/Info.php @@ -4,7 +4,6 @@ namespace PleskX\Api\Struct\Database; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class Info extends Struct { @@ -15,7 +14,7 @@ class Info extends Struct public int $dbServerId; public int $defaultUserId; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, [ 'id', diff --git a/src/Api/Struct/Database/UserInfo.php b/src/Api/Struct/Database/UserInfo.php index cf40013a..230f4f34 100644 --- a/src/Api/Struct/Database/UserInfo.php +++ b/src/Api/Struct/Database/UserInfo.php @@ -4,7 +4,6 @@ namespace PleskX\Api\Struct\Database; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class UserInfo extends Struct { @@ -12,7 +11,7 @@ class UserInfo extends Struct public string $login; public int $dbId; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, [ 'id', diff --git a/src/Api/Struct/DatabaseServer/Info.php b/src/Api/Struct/DatabaseServer/Info.php index 3f2dbd5a..7db81f56 100644 --- a/src/Api/Struct/DatabaseServer/Info.php +++ b/src/Api/Struct/DatabaseServer/Info.php @@ -4,7 +4,6 @@ namespace PleskX\Api\Struct\DatabaseServer; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class Info extends Struct { @@ -13,7 +12,7 @@ class Info extends Struct public int $port; public string $type; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, [ 'id', diff --git a/src/Api/Struct/Dns/Info.php b/src/Api/Struct/Dns/Info.php index 161cbee9..c3a2e1e4 100644 --- a/src/Api/Struct/Dns/Info.php +++ b/src/Api/Struct/Dns/Info.php @@ -4,7 +4,6 @@ namespace PleskX\Api\Struct\Dns; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class Info extends Struct { @@ -16,7 +15,7 @@ class Info extends Struct public string $value; public string $opt; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, [ 'id', diff --git a/src/Api/Struct/EventLog/DetailedEvent.php b/src/Api/Struct/EventLog/DetailedEvent.php index b1cb7c08..1c35c713 100644 --- a/src/Api/Struct/EventLog/DetailedEvent.php +++ b/src/Api/Struct/EventLog/DetailedEvent.php @@ -4,7 +4,6 @@ namespace PleskX\Api\Struct\EventLog; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class DetailedEvent extends Struct { @@ -16,7 +15,7 @@ class DetailedEvent extends Struct public string $user; public string $host; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, [ 'id', diff --git a/src/Api/Struct/EventLog/Event.php b/src/Api/Struct/EventLog/Event.php index cc3be1cf..01e965d9 100644 --- a/src/Api/Struct/EventLog/Event.php +++ b/src/Api/Struct/EventLog/Event.php @@ -4,7 +4,6 @@ namespace PleskX\Api\Struct\EventLog; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class Event extends Struct { @@ -13,7 +12,7 @@ class Event extends Struct public string $class; public string $id; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, [ 'type', diff --git a/src/Api/Struct/Ip/Info.php b/src/Api/Struct/Ip/Info.php index 17cffdd3..41180166 100644 --- a/src/Api/Struct/Ip/Info.php +++ b/src/Api/Struct/Ip/Info.php @@ -4,7 +4,6 @@ namespace PleskX\Api\Struct\Ip; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class Info extends Struct { @@ -13,7 +12,7 @@ class Info extends Struct public string $type; public string $interface; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, [ 'ip_address', diff --git a/src/Api/Struct/Locale/Info.php b/src/Api/Struct/Locale/Info.php index 4fbe4478..2a7b9b6c 100644 --- a/src/Api/Struct/Locale/Info.php +++ b/src/Api/Struct/Locale/Info.php @@ -4,7 +4,6 @@ namespace PleskX\Api\Struct\Locale; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class Info extends Struct { @@ -12,7 +11,7 @@ class Info extends Struct public string $language; public string $country; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, [ 'id', diff --git a/src/Api/Struct/Mail/GeneralInfo.php b/src/Api/Struct/Mail/GeneralInfo.php index dfa1615f..a29c4f8b 100644 --- a/src/Api/Struct/Mail/GeneralInfo.php +++ b/src/Api/Struct/Mail/GeneralInfo.php @@ -4,7 +4,6 @@ namespace PleskX\Api\Struct\Mail; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class GeneralInfo extends Struct { @@ -12,7 +11,7 @@ class GeneralInfo extends Struct public string $name; public string $description; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, [ 'id', diff --git a/src/Api/Struct/Mail/Info.php b/src/Api/Struct/Mail/Info.php index 63cc84e0..13cb182d 100644 --- a/src/Api/Struct/Mail/Info.php +++ b/src/Api/Struct/Mail/Info.php @@ -4,14 +4,13 @@ namespace PleskX\Api\Struct\Mail; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class Info extends Struct { public int $id; public string $name; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, [ 'id', diff --git a/src/Api/Struct/PhpHandler/Info.php b/src/Api/Struct/PhpHandler/Info.php index d95c3a92..e4502314 100644 --- a/src/Api/Struct/PhpHandler/Info.php +++ b/src/Api/Struct/PhpHandler/Info.php @@ -19,7 +19,7 @@ class Info extends Struct public string $custom; public string $handlerStatus; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, [ 'id', diff --git a/src/Api/Struct/ProtectedDirectory/DataInfo.php b/src/Api/Struct/ProtectedDirectory/DataInfo.php index 4a1216cb..673928f6 100644 --- a/src/Api/Struct/ProtectedDirectory/DataInfo.php +++ b/src/Api/Struct/ProtectedDirectory/DataInfo.php @@ -4,14 +4,13 @@ namespace PleskX\Api\Struct\ProtectedDirectory; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class DataInfo extends Struct { public string $name; public string $header; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, [ 'name', diff --git a/src/Api/Struct/ProtectedDirectory/Info.php b/src/Api/Struct/ProtectedDirectory/Info.php index 90651336..19b5952f 100644 --- a/src/Api/Struct/ProtectedDirectory/Info.php +++ b/src/Api/Struct/ProtectedDirectory/Info.php @@ -4,13 +4,12 @@ namespace PleskX\Api\Struct\ProtectedDirectory; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class Info extends Struct { public int $id; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, [ 'id', diff --git a/src/Api/Struct/ProtectedDirectory/UserInfo.php b/src/Api/Struct/ProtectedDirectory/UserInfo.php index a6d4b74a..0d0cc7eb 100644 --- a/src/Api/Struct/ProtectedDirectory/UserInfo.php +++ b/src/Api/Struct/ProtectedDirectory/UserInfo.php @@ -4,13 +4,12 @@ namespace PleskX\Api\Struct\ProtectedDirectory; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class UserInfo extends Struct { public int $id; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, [ 'id', diff --git a/src/Api/Struct/Reseller/GeneralInfo.php b/src/Api/Struct/Reseller/GeneralInfo.php index c946356d..39757165 100644 --- a/src/Api/Struct/Reseller/GeneralInfo.php +++ b/src/Api/Struct/Reseller/GeneralInfo.php @@ -4,7 +4,6 @@ namespace PleskX\Api\Struct\Reseller; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class GeneralInfo extends Struct { @@ -13,7 +12,7 @@ class GeneralInfo extends Struct public string $login; public array $permissions; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse->{'gen-info'}, [ ['pname' => 'personalName'], diff --git a/src/Api/Struct/Reseller/Info.php b/src/Api/Struct/Reseller/Info.php index 1ef61d2b..f257b3e3 100644 --- a/src/Api/Struct/Reseller/Info.php +++ b/src/Api/Struct/Reseller/Info.php @@ -4,14 +4,13 @@ namespace PleskX\Api\Struct\Reseller; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class Info extends Struct { public int $id; public string $guid; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, [ 'id', diff --git a/src/Api/Struct/SecretKey/Info.php b/src/Api/Struct/SecretKey/Info.php index 2b2eec03..bbebd82e 100644 --- a/src/Api/Struct/SecretKey/Info.php +++ b/src/Api/Struct/SecretKey/Info.php @@ -4,7 +4,6 @@ namespace PleskX\Api\Struct\SecretKey; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class Info extends Struct { @@ -13,7 +12,7 @@ class Info extends Struct public string $description; public string $login; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, [ 'key', diff --git a/src/Api/Struct/Server/Admin.php b/src/Api/Struct/Server/Admin.php index 69bff6ea..4f08c399 100644 --- a/src/Api/Struct/Server/Admin.php +++ b/src/Api/Struct/Server/Admin.php @@ -4,7 +4,6 @@ namespace PleskX\Api\Struct\Server; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class Admin extends Struct { @@ -12,7 +11,7 @@ class Admin extends Struct public string $name; public string $email; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, [ ['admin_cname' => 'companyName'], diff --git a/src/Api/Struct/Server/GeneralInfo.php b/src/Api/Struct/Server/GeneralInfo.php index 9c1f63d2..2b28ab2d 100644 --- a/src/Api/Struct/Server/GeneralInfo.php +++ b/src/Api/Struct/Server/GeneralInfo.php @@ -4,7 +4,6 @@ namespace PleskX\Api\Struct\Server; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class GeneralInfo extends Struct { @@ -12,7 +11,7 @@ class GeneralInfo extends Struct public string $serverGuid; public string $mode; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, [ 'server_name', diff --git a/src/Api/Struct/Server/Preferences.php b/src/Api/Struct/Server/Preferences.php index e6529bf3..0f533c85 100644 --- a/src/Api/Struct/Server/Preferences.php +++ b/src/Api/Struct/Server/Preferences.php @@ -4,7 +4,6 @@ namespace PleskX\Api\Struct\Server; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class Preferences extends Struct { @@ -12,7 +11,7 @@ class Preferences extends Struct public int $trafficAccounting; public int $restartApacheInterval; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, [ 'stat_ttl', diff --git a/src/Api/Struct/Server/SessionPreferences.php b/src/Api/Struct/Server/SessionPreferences.php index 69a5c2aa..2feed452 100644 --- a/src/Api/Struct/Server/SessionPreferences.php +++ b/src/Api/Struct/Server/SessionPreferences.php @@ -4,13 +4,12 @@ namespace PleskX\Api\Struct\Server; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class SessionPreferences extends Struct { public int $loginTimeout; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, [ 'login_timeout', diff --git a/src/Api/Struct/Server/Statistics.php b/src/Api/Struct/Server/Statistics.php index 0894801e..aed4dd1f 100644 --- a/src/Api/Struct/Server/Statistics.php +++ b/src/Api/Struct/Server/Statistics.php @@ -4,7 +4,6 @@ namespace PleskX\Api\Struct\Server; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class Statistics extends Struct { @@ -29,7 +28,7 @@ class Statistics extends Struct /** @var Statistics\DiskSpace[] */ public $diskSpace; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->objects = new Statistics\Objects($apiResponse->objects); $this->version = new Statistics\Version($apiResponse->version); diff --git a/src/Api/Struct/Server/Statistics/DiskSpace.php b/src/Api/Struct/Server/Statistics/DiskSpace.php index 5fb6dca8..95ff3f1f 100644 --- a/src/Api/Struct/Server/Statistics/DiskSpace.php +++ b/src/Api/Struct/Server/Statistics/DiskSpace.php @@ -4,7 +4,6 @@ namespace PleskX\Api\Struct\Server\Statistics; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class DiskSpace extends Struct { @@ -12,7 +11,7 @@ class DiskSpace extends Struct public int $used; public int $free; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, [ 'total', diff --git a/src/Api/Struct/Server/Statistics/LoadAverage.php b/src/Api/Struct/Server/Statistics/LoadAverage.php index 69aefc22..005a0f32 100644 --- a/src/Api/Struct/Server/Statistics/LoadAverage.php +++ b/src/Api/Struct/Server/Statistics/LoadAverage.php @@ -4,7 +4,6 @@ namespace PleskX\Api\Struct\Server\Statistics; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class LoadAverage extends Struct { @@ -12,7 +11,7 @@ class LoadAverage extends Struct public float $load5min; public float $load15min; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->load1min = $apiResponse->l1 / 100.0; $this->load5min = $apiResponse->l5 / 100.0; diff --git a/src/Api/Struct/Server/Statistics/Memory.php b/src/Api/Struct/Server/Statistics/Memory.php index 44b12a38..a42b66c9 100644 --- a/src/Api/Struct/Server/Statistics/Memory.php +++ b/src/Api/Struct/Server/Statistics/Memory.php @@ -4,7 +4,6 @@ namespace PleskX\Api\Struct\Server\Statistics; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class Memory extends Struct { @@ -15,7 +14,7 @@ class Memory extends Struct public int $buffer; public int $cached; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, [ 'total', diff --git a/src/Api/Struct/Server/Statistics/Objects.php b/src/Api/Struct/Server/Statistics/Objects.php index 00d119c5..4c128960 100644 --- a/src/Api/Struct/Server/Statistics/Objects.php +++ b/src/Api/Struct/Server/Statistics/Objects.php @@ -4,7 +4,6 @@ namespace PleskX\Api\Struct\Server\Statistics; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class Objects extends Struct { @@ -20,7 +19,7 @@ class Objects extends Struct public int $problemClients; public int $problemDomains; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, [ 'clients', diff --git a/src/Api/Struct/Server/Statistics/Other.php b/src/Api/Struct/Server/Statistics/Other.php index e102fb5e..d65c4316 100644 --- a/src/Api/Struct/Server/Statistics/Other.php +++ b/src/Api/Struct/Server/Statistics/Other.php @@ -4,7 +4,6 @@ namespace PleskX\Api\Struct\Server\Statistics; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class Other extends Struct { @@ -12,7 +11,7 @@ class Other extends Struct public int $uptime; public bool $insideVz; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, [ 'cpu', diff --git a/src/Api/Struct/Server/Statistics/Swap.php b/src/Api/Struct/Server/Statistics/Swap.php index 23154ee4..b61a4ad9 100644 --- a/src/Api/Struct/Server/Statistics/Swap.php +++ b/src/Api/Struct/Server/Statistics/Swap.php @@ -4,7 +4,6 @@ namespace PleskX\Api\Struct\Server\Statistics; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class Swap extends Struct { @@ -12,7 +11,7 @@ class Swap extends Struct public int $used; public int $free; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, [ 'total', diff --git a/src/Api/Struct/Server/Statistics/Version.php b/src/Api/Struct/Server/Statistics/Version.php index 45fc541e..b3684ab3 100644 --- a/src/Api/Struct/Server/Statistics/Version.php +++ b/src/Api/Struct/Server/Statistics/Version.php @@ -4,7 +4,6 @@ namespace PleskX\Api\Struct\Server\Statistics; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class Version extends Struct { @@ -15,7 +14,7 @@ class Version extends Struct public string $osVersion; public string $osRelease; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, [ ['plesk_name' => 'internalName'], diff --git a/src/Api/Struct/Server/UpdatesInfo.php b/src/Api/Struct/Server/UpdatesInfo.php index 34c7501d..3a75d7b5 100644 --- a/src/Api/Struct/Server/UpdatesInfo.php +++ b/src/Api/Struct/Server/UpdatesInfo.php @@ -4,14 +4,13 @@ namespace PleskX\Api\Struct\Server; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class UpdatesInfo extends Struct { public string $lastInstalledUpdate; public bool $installUpdatesAutomatically; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, [ 'last_installed_update', diff --git a/src/Api/Struct/ServicePlan/Info.php b/src/Api/Struct/ServicePlan/Info.php index 794c82af..8d1a3c12 100644 --- a/src/Api/Struct/ServicePlan/Info.php +++ b/src/Api/Struct/ServicePlan/Info.php @@ -4,7 +4,6 @@ namespace PleskX\Api\Struct\ServicePlan; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class Info extends Struct { @@ -13,7 +12,7 @@ class Info extends Struct public string $guid; public string $externalId; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, [ 'id', diff --git a/src/Api/Struct/Session/Info.php b/src/Api/Struct/Session/Info.php index 70d2e866..e2060347 100644 --- a/src/Api/Struct/Session/Info.php +++ b/src/Api/Struct/Session/Info.php @@ -4,7 +4,6 @@ namespace PleskX\Api\Struct\Session; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class Info extends Struct { @@ -15,7 +14,7 @@ class Info extends Struct public string $loginTime; public string $idle; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, [ 'id', diff --git a/src/Api/Struct/Site/GeneralInfo.php b/src/Api/Struct/Site/GeneralInfo.php index f13913f3..1bc0c9a5 100644 --- a/src/Api/Struct/Site/GeneralInfo.php +++ b/src/Api/Struct/Site/GeneralInfo.php @@ -4,7 +4,6 @@ namespace PleskX\Api\Struct\Site; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class GeneralInfo extends Struct { @@ -20,7 +19,7 @@ class GeneralInfo extends Struct public string $webspaceGuid; public int $webspaceId; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, [ ['cr_date' => 'creationDate'], diff --git a/src/Api/Struct/Site/HostingInfo.php b/src/Api/Struct/Site/HostingInfo.php index 2cb08f17..34a307f3 100644 --- a/src/Api/Struct/Site/HostingInfo.php +++ b/src/Api/Struct/Site/HostingInfo.php @@ -4,14 +4,13 @@ namespace PleskX\Api\Struct\Site; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class HostingInfo extends Struct { public array $properties = []; public string $ipAddress; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { foreach ($apiResponse->vrt_hst->property as $property) { $this->properties[(string) $property->name] = (string) $property->value; diff --git a/src/Api/Struct/Site/Info.php b/src/Api/Struct/Site/Info.php index 5a12761e..99b57fe8 100644 --- a/src/Api/Struct/Site/Info.php +++ b/src/Api/Struct/Site/Info.php @@ -4,14 +4,13 @@ namespace PleskX\Api\Struct\Site; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class Info extends Struct { public int $id; public string $guid; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, [ 'id', diff --git a/src/Api/Struct/SiteAlias/GeneralInfo.php b/src/Api/Struct/SiteAlias/GeneralInfo.php index 73c2c8fe..0b77651b 100644 --- a/src/Api/Struct/SiteAlias/GeneralInfo.php +++ b/src/Api/Struct/SiteAlias/GeneralInfo.php @@ -4,7 +4,6 @@ namespace PleskX\Api\Struct\SiteAlias; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class GeneralInfo extends Struct { @@ -12,7 +11,7 @@ class GeneralInfo extends Struct public string $asciiName; public string $status; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, [ 'name', diff --git a/src/Api/Struct/SiteAlias/Info.php b/src/Api/Struct/SiteAlias/Info.php index 0950bcc9..a452ba96 100644 --- a/src/Api/Struct/SiteAlias/Info.php +++ b/src/Api/Struct/SiteAlias/Info.php @@ -4,14 +4,13 @@ namespace PleskX\Api\Struct\SiteAlias; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class Info extends Struct { public string $status; public int $id; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, [ 'id', diff --git a/src/Api/Struct/Subdomain/Info.php b/src/Api/Struct/Subdomain/Info.php index a766fc73..7c760433 100644 --- a/src/Api/Struct/Subdomain/Info.php +++ b/src/Api/Struct/Subdomain/Info.php @@ -4,7 +4,6 @@ namespace PleskX\Api\Struct\Subdomain; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class Info extends Struct { @@ -13,7 +12,7 @@ class Info extends Struct public string $name; public array $properties; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->properties = []; $this->_initScalarProperties($apiResponse, [ diff --git a/src/Api/Struct/Ui/CustomButton.php b/src/Api/Struct/Ui/CustomButton.php index 8b6622df..ccac0b26 100644 --- a/src/Api/Struct/Ui/CustomButton.php +++ b/src/Api/Struct/Ui/CustomButton.php @@ -4,7 +4,6 @@ namespace PleskX\Api\Struct\Ui; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class CustomButton extends Struct { @@ -17,7 +16,7 @@ class CustomButton extends Struct public string $url; public string $text; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, ['id']); $this->_initScalarProperties($apiResponse->properties, [ diff --git a/src/Api/Struct/Webspace/DiskUsage.php b/src/Api/Struct/Webspace/DiskUsage.php index 377700f5..6369717c 100644 --- a/src/Api/Struct/Webspace/DiskUsage.php +++ b/src/Api/Struct/Webspace/DiskUsage.php @@ -4,7 +4,6 @@ namespace PleskX\Api\Struct\Webspace; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class DiskUsage extends Struct { @@ -20,7 +19,7 @@ class DiskUsage extends Struct public int $configs; public int $chroot; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, [ 'httpdocs', diff --git a/src/Api/Struct/Webspace/GeneralInfo.php b/src/Api/Struct/Webspace/GeneralInfo.php index 33d39802..e77918b6 100644 --- a/src/Api/Struct/Webspace/GeneralInfo.php +++ b/src/Api/Struct/Webspace/GeneralInfo.php @@ -4,7 +4,6 @@ namespace PleskX\Api\Struct\Webspace; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class GeneralInfo extends Struct { @@ -23,7 +22,7 @@ class GeneralInfo extends Struct /** @var string */ public string $adminDescription; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, [ ['cr_date' => 'creationDate'], diff --git a/src/Api/Struct/Webspace/HostingPropertyInfo.php b/src/Api/Struct/Webspace/HostingPropertyInfo.php index c5f2f158..f761d36b 100644 --- a/src/Api/Struct/Webspace/HostingPropertyInfo.php +++ b/src/Api/Struct/Webspace/HostingPropertyInfo.php @@ -4,7 +4,6 @@ namespace PleskX\Api\Struct\Webspace; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class HostingPropertyInfo extends Struct { @@ -12,7 +11,7 @@ class HostingPropertyInfo extends Struct public string $type; public string $label; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, [ 'name', diff --git a/src/Api/Struct/Webspace/Info.php b/src/Api/Struct/Webspace/Info.php index 8fac2be0..cb6e4c2c 100644 --- a/src/Api/Struct/Webspace/Info.php +++ b/src/Api/Struct/Webspace/Info.php @@ -4,7 +4,6 @@ namespace PleskX\Api\Struct\Webspace; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class Info extends Struct { @@ -12,7 +11,7 @@ class Info extends Struct public string $guid; public string $name; - public function __construct(XmlResponse $apiResponse, string $name = '') + public function __construct(\SimpleXMLElement $apiResponse, string $name = '') { $this->_initScalarProperties($apiResponse, [ 'id', diff --git a/src/Api/Struct/Webspace/Limit.php b/src/Api/Struct/Webspace/Limit.php index 95d668d5..6d7b0a40 100644 --- a/src/Api/Struct/Webspace/Limit.php +++ b/src/Api/Struct/Webspace/Limit.php @@ -4,14 +4,13 @@ namespace PleskX\Api\Struct\Webspace; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class Limit extends Struct { public string $name; public string $value; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, [ 'name', diff --git a/src/Api/Struct/Webspace/LimitDescriptor.php b/src/Api/Struct/Webspace/LimitDescriptor.php index 6ceb0a74..0b4f7b7f 100644 --- a/src/Api/Struct/Webspace/LimitDescriptor.php +++ b/src/Api/Struct/Webspace/LimitDescriptor.php @@ -4,13 +4,12 @@ namespace PleskX\Api\Struct\Webspace; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class LimitDescriptor extends Struct { public array $limits; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->limits = []; diff --git a/src/Api/Struct/Webspace/LimitInfo.php b/src/Api/Struct/Webspace/LimitInfo.php index c3f20ee5..e0ff03ae 100644 --- a/src/Api/Struct/Webspace/LimitInfo.php +++ b/src/Api/Struct/Webspace/LimitInfo.php @@ -4,7 +4,6 @@ namespace PleskX\Api\Struct\Webspace; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class LimitInfo extends Struct { @@ -12,7 +11,7 @@ class LimitInfo extends Struct public string $type; public string $label; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, [ 'name', diff --git a/src/Api/Struct/Webspace/Limits.php b/src/Api/Struct/Webspace/Limits.php index bdb970d6..7a317c79 100644 --- a/src/Api/Struct/Webspace/Limits.php +++ b/src/Api/Struct/Webspace/Limits.php @@ -4,14 +4,13 @@ namespace PleskX\Api\Struct\Webspace; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class Limits extends Struct { public string $overuse; public array $limits; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, ['overuse']); $this->limits = []; diff --git a/src/Api/Struct/Webspace/PermissionDescriptor.php b/src/Api/Struct/Webspace/PermissionDescriptor.php index 3a56882e..1f09931f 100644 --- a/src/Api/Struct/Webspace/PermissionDescriptor.php +++ b/src/Api/Struct/Webspace/PermissionDescriptor.php @@ -4,13 +4,12 @@ namespace PleskX\Api\Struct\Webspace; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class PermissionDescriptor extends Struct { public array $permissions; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->permissions = []; diff --git a/src/Api/Struct/Webspace/PermissionInfo.php b/src/Api/Struct/Webspace/PermissionInfo.php index 8de0c84a..7cdfc4a0 100644 --- a/src/Api/Struct/Webspace/PermissionInfo.php +++ b/src/Api/Struct/Webspace/PermissionInfo.php @@ -4,7 +4,6 @@ namespace PleskX\Api\Struct\Webspace; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class PermissionInfo extends Struct { @@ -12,7 +11,7 @@ class PermissionInfo extends Struct public string $type; public string $label; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->_initScalarProperties($apiResponse, [ 'name', diff --git a/src/Api/Struct/Webspace/PhpSettings.php b/src/Api/Struct/Webspace/PhpSettings.php index 37dea7d5..8067571e 100644 --- a/src/Api/Struct/Webspace/PhpSettings.php +++ b/src/Api/Struct/Webspace/PhpSettings.php @@ -4,13 +4,12 @@ namespace PleskX\Api\Struct\Webspace; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class PhpSettings extends Struct { public array $properties; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->properties = []; diff --git a/src/Api/Struct/Webspace/PhysicalHostingDescriptor.php b/src/Api/Struct/Webspace/PhysicalHostingDescriptor.php index f49e615b..987b10ee 100644 --- a/src/Api/Struct/Webspace/PhysicalHostingDescriptor.php +++ b/src/Api/Struct/Webspace/PhysicalHostingDescriptor.php @@ -4,13 +4,12 @@ namespace PleskX\Api\Struct\Webspace; use PleskX\Api\Struct; -use PleskX\Api\XmlResponse; class PhysicalHostingDescriptor extends Struct { public array $properties; - public function __construct(XmlResponse $apiResponse) + public function __construct(\SimpleXMLElement $apiResponse) { $this->properties = []; diff --git a/tests/PhpHandlerTest.php b/tests/PhpHandlerTest.php index e622cfeb..47b0b67e 100644 --- a/tests/PhpHandlerTest.php +++ b/tests/PhpHandlerTest.php @@ -7,9 +7,8 @@ class PhpHandlerTest extends TestCase { public function testGet() { - $handler = static::$_client->phpHandler()->get(null, null); + $handler = static::$_client->phpHandler()->get(); - $this->assertIsObject($handler); $this->assertObjectHasAttribute('type', $handler); }