Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/Commands/UpdateStorageStats.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public function __construct(StorageStatistics $storageStatistics) {
$this->storageStatistics = $storageStatistics;
}

#[\Override]
public function configure(): void {
parent::configure();
$this->setName('serverinfo:update-storage-statistics')
Expand Down
1 change: 1 addition & 0 deletions lib/Jobs/UpdateStorageStats.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public function __construct(ITimeFactory $time, StorageStatistics $storageStatis
/**
* @inheritDoc
*/
#[\Override]
protected function run($argument): void {
$this->storageStatistics->updateStorageCounts();
}
Expand Down
10 changes: 10 additions & 0 deletions lib/OperatingSystems/Dummy.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,32 @@
use OCA\ServerInfo\Resources\Memory;

class Dummy implements IOperatingSystem {
#[\Override]
public function supported(): bool {
return false;
}

#[\Override]
public function getMemory(): Memory {
return new Memory();
}

#[\Override]
public function getCpuName(): string {
return 'Unknown Processor';
}

#[\Override]
public function getTime(): string {
return '';
}

#[\Override]
public function getUptime(): int {
return -1;
}

#[\Override]
public function getNetworkInfo(): array {
return [
'hostname' => \gethostname(),
Expand All @@ -38,18 +44,22 @@ public function getNetworkInfo(): array {
];
}

#[\Override]
public function getNetworkInterfaces(): array {
return [];
}

#[\Override]
public function getDiskInfo(): array {
return [];
}

#[\Override]
public function getThermalZones(): array {
return [];
}

#[\Override]
public function getCpuCount(): int {
return 1;
}
Expand Down
10 changes: 10 additions & 0 deletions lib/OperatingSystems/FreeBSD.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ class FreeBSD implements IOperatingSystem {
private const AF_INET = 2;
private const AF_INET6 = 28;

#[\Override]
public function supported(): bool {
return false;
}

#[\Override]
public function getMemory(): Memory {
$data = new Memory();

Expand Down Expand Up @@ -57,6 +59,7 @@ public function getMemory(): Memory {
return $data;
}

#[\Override]
public function getCpuName(): string {
$data = 'Unknown Processor';

Expand All @@ -75,6 +78,7 @@ public function getCpuName(): string {
return $data;
}

#[\Override]
public function getCpuCount(): int {
$numCpu = -1;

Expand All @@ -87,6 +91,7 @@ public function getCpuCount(): int {
return $numCpu;
}

#[\Override]
public function getTime(): string {
try {
return $this->executeCommand('date');
Expand All @@ -95,6 +100,7 @@ public function getTime(): string {
}
}

#[\Override]
public function getUptime(): int {
$uptime = -1;

Expand All @@ -109,6 +115,7 @@ public function getUptime(): int {
return $uptime;
}

#[\Override]
public function getNetworkInfo(): array {
$result = [
'gateway' => '',
Expand All @@ -128,6 +135,7 @@ public function getNetworkInfo(): array {
return $result;
}

#[\Override]
public function getNetworkInterfaces(): array {
$data = [];

Expand Down Expand Up @@ -185,6 +193,7 @@ public function getNetworkInterfaces(): array {
return $data;
}

#[\Override]
public function getDiskInfo(): array {
$data = [];

Expand Down Expand Up @@ -223,6 +232,7 @@ public function getDiskInfo(): array {
return $data;
}

#[\Override]
public function getThermalZones(): array {
return [];
}
Expand Down
10 changes: 10 additions & 0 deletions lib/OperatingSystems/Linux.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ class Linux implements IOperatingSystem {
private const AF_INET = 2;
private const AF_INET6 = 10;

#[\Override]
public function supported(): bool {
return true;
}

#[\Override]
public function getMemory(): Memory {
$data = new Memory();

Expand Down Expand Up @@ -66,6 +68,7 @@ public function getMemory(): Memory {
return $data;
}

#[\Override]
public function getCpuName(): string {
$data = 'Unknown Processor';

Expand Down Expand Up @@ -103,6 +106,7 @@ public function getCpuName(): string {
return $data;
}

#[\Override]
public function getCpuCount(): int {
$numCpu = -1;

Expand All @@ -118,6 +122,7 @@ public function getCpuCount(): int {
return count($matches[1]);
}

#[\Override]
public function getTime(): string {
try {
return $this->executeCommand('date');
Expand All @@ -126,6 +131,7 @@ public function getTime(): string {
}
}

#[\Override]
public function getUptime(): int {
$data = -1;

Expand All @@ -140,6 +146,7 @@ public function getUptime(): int {
return $uptimeInSeconds;
}

#[\Override]
public function getNetworkInfo(): array {
$result = [
'gateway' => '',
Expand All @@ -153,6 +160,7 @@ public function getNetworkInfo(): array {
return $result;
}

#[\Override]
public function getNetworkInterfaces(): array {
$data = [];

Expand Down Expand Up @@ -202,6 +210,7 @@ public function getNetworkInterfaces(): array {
return $data;
}

#[\Override]
public function getDiskInfo(): array {
$data = [];

Expand Down Expand Up @@ -241,6 +250,7 @@ public function getDiskInfo(): array {
return $data;
}

#[\Override]
public function getThermalZones(): array {
$data = [];

Expand Down
10 changes: 10 additions & 0 deletions lib/Os.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function __construct(IConfig $config) {
$this->backend = $this->getBackend($restrictedMode ? 'Dummy' : PHP_OS);
}

#[\Override]
public function supported(): bool {
return $this->backend->supported();
}
Expand All @@ -37,26 +38,32 @@ public function getOSName(): string {
return PHP_OS . ' ' . php_uname('r') . ' ' . php_uname('m');
}

#[\Override]
public function getMemory(): Memory {
return $this->backend->getMemory();
}

#[\Override]
public function getCpuName(): string {
return $this->backend->getCpuName();
}

#[\Override]
public function getCpuCount(): int {
return $this->backend->getCpuCount();
}

#[\Override]
public function getTime(): string {
return $this->backend->getTime();
}

#[\Override]
public function getUptime(): int {
return $this->backend->getUptime();
}

#[\Override]
public function getDiskInfo(): array {
return $this->backend->getDiskInfo();
}
Expand All @@ -83,14 +90,17 @@ public function getDiskData(): array {
return $data;
}

#[\Override]
public function getNetworkInfo(): array {
return $this->backend->getNetworkInfo();
}

#[\Override]
public function getNetworkInterfaces(): array {
return $this->backend->getNetworkInterfaces();
}

#[\Override]
public function getThermalZones(): array {
return $this->backend->getThermalZones();
}
Expand Down
1 change: 1 addition & 0 deletions lib/PhpInfoResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function __construct() {
$this->setFeaturePolicy(new FeaturePolicy());
}

#[\Override]
public function render() {
ob_start();
phpinfo(INFO_ALL & ~INFO_ENVIRONMENT & ~INFO_VARIABLES);
Expand Down
1 change: 1 addition & 0 deletions lib/Resources/ThermalZone.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public function getTemp(): float {
return $this->temp;
}

#[\Override]
public function jsonSerialize(): array {
return [
'zone' => $this->zone,
Expand Down
4 changes: 4 additions & 0 deletions lib/Settings/AdminSection.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public function __construct(IL10N $l, IURLGenerator $url) {
/**
* returns the ID of the section. It is supposed to be a lower case string
*/
#[\Override]
public function getID(): string {
return 'serverinfo';
}
Expand All @@ -34,6 +35,7 @@ public function getID(): string {
* returns the translated name as it should be displayed, e.g. 'LDAP / AD
* integration'. Use the L10N service to translate it.
*/
#[\Override]
public function getName(): string {
return $this->l->t('System');
}
Expand All @@ -45,13 +47,15 @@ public function getName(): string {
*
* keep the server setting at the top, right after "overview" and "basic settings"
*/
#[\Override]
public function getPriority(): int {
return 90;
}

/**
* {@inheritdoc}
*/
#[\Override]
public function getIcon(): string {
return $this->url->imagePath('serverinfo', 'app-dark.svg');
}
Expand Down
3 changes: 3 additions & 0 deletions lib/Settings/AdminSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public function __construct(
) {
}

#[\Override]
public function getForm(): TemplateResponse {
$monitoringEndPoint = $this->urlGenerator->getAbsoluteURL('ocs/v2.php/apps/serverinfo/api/v1/info');
$params = [
Expand Down Expand Up @@ -69,6 +70,7 @@ public function getForm(): TemplateResponse {
/**
* @return string the section ID, e.g. 'sharing'
*/
#[\Override]
public function getSection(): string {
return 'serverinfo';
}
Expand All @@ -80,6 +82,7 @@ public function getSection(): string {
*
* keep the server setting at the top, right after "server settings"
*/
#[\Override]
public function getPriority(): int {
return 0;
}
Expand Down
6 changes: 3 additions & 3 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
<file name="tests/stub.phpstub" preloadClasses="true"/>
</stubs>
<projectFiles>
<directory name="lib" />
<directory name="lib"/>
<ignoreFiles>
<directory name="vendor" />
<directory name="vendor"/>
</ignoreFiles>
</projectFiles>
<extraFiles>
<directory name="vendor" />
<directory name="vendor"/>
</extraFiles>
</psalm>
8 changes: 4 additions & 4 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

use OCP\App\IAppManager;

if (!defined('PHPUNIT_RUN')) {
define('PHPUNIT_RUN', 1);
}

require_once __DIR__ . '/../../../lib/base.php';

if (!class_exists('\PHPUnit\Framework\TestCase')) {
require_once('PHPUnit/Autoload.php');
}
\OC_App::loadApp('serverinfo');
\OC::$server->get(IAppManager::class)->loadApp('serverinfo');
OC_Hook::clear();
Loading
Loading