diff --git a/lib/private/OCS/CoreCapabilities.php b/lib/private/OCS/CoreCapabilities.php index 9cead57c6a309..0e9be3460cacc 100644 --- a/lib/private/OCS/CoreCapabilities.php +++ b/lib/private/OCS/CoreCapabilities.php @@ -32,20 +32,18 @@ * @package OC\OCS */ class CoreCapabilities implements ICapability { - /** @var IConfig */ - private $config; - /** * @param IConfig $config */ - public function __construct(IConfig $config) { - $this->config = $config; + public function __construct( + private IConfig $config, + ) { } /** * Return this classes capabilities */ - public function getCapabilities() { + public function getCapabilities(): array { return [ 'core' => [ 'pollinterval' => $this->config->getSystemValue('pollinterval', 60), diff --git a/lib/private/OCS/DiscoveryService.php b/lib/private/OCS/DiscoveryService.php index f53d39465e8fc..9bc83d42b1af1 100644 --- a/lib/private/OCS/DiscoveryService.php +++ b/lib/private/OCS/DiscoveryService.php @@ -37,10 +37,10 @@ class DiscoveryService implements IDiscoveryService { /** @var ICache */ - private $cache; + private ICache $cache; /** @var IClient */ - private $client; + private IClient $client; /** * @param ICacheFactory $cacheFactory diff --git a/lib/private/OCS/Exception.php b/lib/private/OCS/Exception.php index ca3c3f704305e..a4e80d12dcc1b 100644 --- a/lib/private/OCS/Exception.php +++ b/lib/private/OCS/Exception.php @@ -23,15 +23,13 @@ namespace OC\OCS; class Exception extends \Exception { - /** @var Result */ - private $result; - - public function __construct(Result $result) { + public function __construct( + private Result $result, + ) { parent::__construct(); - $this->result = $result; } - public function getResult() { + public function getResult(): Result { return $this->result; } } diff --git a/lib/private/OCS/Provider.php b/lib/private/OCS/Provider.php index 83219c018f8d1..b9bcb389c57ef 100644 --- a/lib/private/OCS/Provider.php +++ b/lib/private/OCS/Provider.php @@ -24,26 +24,27 @@ */ namespace OC\OCS; -class Provider extends \OCP\AppFramework\Controller { - /** @var \OCP\App\IAppManager */ - private $appManager; +use OCP\App\IAppManager; +use OCP\AppFramework\Controller; +use OCP\AppFramework\Http\JSONResponse; +use OCP\IRequest; +class Provider extends Controller { /** * @param string $appName - * @param \OCP\IRequest $request - * @param \OCP\App\IAppManager $appManager + * @param IRequest $request + * @param IAppManager $appManager */ public function __construct($appName, \OCP\IRequest $request, - \OCP\App\IAppManager $appManager) { + private \OCP\App\IAppManager $appManager) { parent::__construct($appName, $request); - $this->appManager = $appManager; } /** - * @return \OCP\AppFramework\Http\JSONResponse + * @return JSONResponse */ - public function buildProviderList() { + public function buildProviderList(): JSONResponse { $services = [ 'PRIVATE_DATA' => [ 'version' => 1, @@ -108,7 +109,7 @@ public function buildProviderList() { ]; } - return new \OCP\AppFramework\Http\JSONResponse([ + return new JSONResponse([ 'version' => 2, 'services' => $services, ]); diff --git a/lib/private/OCS/Result.php b/lib/private/OCS/Result.php index d77e360e6d29e..567fe8378a993 100644 --- a/lib/private/OCS/Result.php +++ b/lib/private/OCS/Result.php @@ -31,14 +31,13 @@ namespace OC\OCS; class Result { - /** @var array */ - protected $data; + protected array $data; /** @var null|string */ - protected $message; + protected ?string $message; /** @var int */ - protected $statusCode; + protected int $statusCode; /** @var integer */ protected $items; @@ -47,16 +46,17 @@ class Result { protected $perPage; /** @var array */ - private $headers = []; + private array $headers = []; /** * create the OCS_Result object - * @param mixed $data the data to return + * + * @param mixed|null $data the data to return * @param int $code - * @param null|string $message + * @param string|null $message * @param array $headers */ - public function __construct($data = null, $code = 100, $message = null, $headers = []) { + public function __construct(mixed $data = null, int $code = 100, string $message = null, array $headers = []) { if ($data === null) { $this->data = []; } elseif (!is_array($data)) { @@ -71,17 +71,19 @@ public function __construct($data = null, $code = 100, $message = null, $headers /** * optionally set the total number of items available + * * @param int $items */ - public function setTotalItems($items) { + public function setTotalItems(int $items): void { $this->items = $items; } /** - * optionally set the the number of items per page + * optionally set the number of items per page + * * @param int $items */ - public function setItemsPerPage($items) { + public function setItemsPerPage(int $items): void { $this->perPage = $items; } @@ -89,7 +91,7 @@ public function setItemsPerPage($items) { * get the status code * @return int */ - public function getStatusCode() { + public function getStatusCode(): int { return $this->statusCode; } @@ -97,7 +99,7 @@ public function getStatusCode() { * get the meta data for the result * @return array */ - public function getMeta() { + public function getMeta(): array { $meta = []; $meta['status'] = $this->succeeded() ? 'ok' : 'failure'; $meta['statuscode'] = $this->statusCode; @@ -115,7 +117,7 @@ public function getMeta() { * get the result data * @return array */ - public function getData() { + public function getData(): array { return $this->data; } @@ -123,17 +125,18 @@ public function getData() { * return bool Whether the method succeeded * @return bool */ - public function succeeded() { + public function succeeded(): bool { return ($this->statusCode == 100); } /** * Adds a new header to the response + * * @param string $name The name of the HTTP header * @param string $value The value, null will delete it * @return $this */ - public function addHeader($name, $value) { + public function addHeader(string $name, ?string $value): static { $name = trim($name); // always remove leading and trailing whitespace // to be able to reliably check for security // headers @@ -151,7 +154,7 @@ public function addHeader($name, $value) { * Returns the set headers * @return array the headers */ - public function getHeaders() { + public function getHeaders(): array { return $this->headers; } }