diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 9512b01d..e7125b61 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -18,9 +18,11 @@ public function __construct(array $urlParams = []) { parent::__construct('survey_client', $urlParams); } + #[\Override] public function register(IRegistrationContext $context): void { } + #[\Override] public function boot(IBootContext $context): void { $notificationManager = $context->getServerContainer()->getNotificationManager(); $notificationManager->registerNotifierService(Notifier::class); diff --git a/lib/BackgroundJobs/AdminNotification.php b/lib/BackgroundJobs/AdminNotification.php index de2f74f2..e16c03c7 100644 --- a/lib/BackgroundJobs/AdminNotification.php +++ b/lib/BackgroundJobs/AdminNotification.php @@ -23,6 +23,7 @@ public function __construct( parent::__construct($time); } + #[\Override] protected function run($argument): void { $notification = $this->manager->createNotification(); diff --git a/lib/BackgroundJobs/MonthlyReport.php b/lib/BackgroundJobs/MonthlyReport.php index 26c42190..f1521cef 100644 --- a/lib/BackgroundJobs/MonthlyReport.php +++ b/lib/BackgroundJobs/MonthlyReport.php @@ -34,6 +34,7 @@ public function __construct( $this->setTimeSensitivity(IJob::TIME_SENSITIVE); } + #[\Override] protected function run($argument) { if ($this->appConfig->getAppValueBool('never_again')) { $this->jobList->remove(self::class); diff --git a/lib/Categories/Apps.php b/lib/Categories/Apps.php index b8f3a91c..b6b1cedf 100644 --- a/lib/Categories/Apps.php +++ b/lib/Categories/Apps.php @@ -1,4 +1,7 @@ connection = $connection; - $this->l = $l; + public function __construct( + protected IDBConnection $connection, + protected IL10N $l, + ) { } - /** - * @return string - */ - public function getCategory() { + #[\Override] + public function getCategory(): string { return 'apps'; } - /** - * @return string - */ - public function getDisplayName() { + #[\Override] + public function getDisplayName(): string { return $this->l->t('App list (for each app: name, version, enabled status)'); } /** - * @return array (string => string|int) + * @return array */ - public function getData() { + #[\Override] + public function getData(): array { $query = $this->connection->getQueryBuilder(); $query->select('*') diff --git a/lib/Categories/Database.php b/lib/Categories/Database.php index 512a0f8f..f54450e5 100644 --- a/lib/Categories/Database.php +++ b/lib/Categories/Database.php @@ -1,4 +1,7 @@ config = $config; - $this->connection = $connection; - $this->l = $l; + public function __construct( + protected IConfig $config, + protected IDBConnection $connection, + protected IL10N $l, + ) { } - /** - * @return string - */ - public function getCategory() { + #[\Override] + public function getCategory(): string { return 'database'; } - /** - * @return string - */ - public function getDisplayName() { + #[\Override] + public function getDisplayName(): string { return $this->l->t('Database environment (type, version, database size)'); } /** - * @return array (string => string|int) + * @return array */ - public function getData() { + #[\Override] + public function getData(): array { return [ 'type' => $this->config->getSystemValue('dbtype'), 'version' => $this->databaseVersion(), @@ -57,7 +49,7 @@ public function getData() { ]; } - protected function databaseVersion() { + protected function databaseVersion(): string { switch ($this->config->getSystemValue('dbtype')) { case 'sqlite': case 'sqlite3': @@ -171,7 +163,7 @@ protected function databaseSize() { * @param string $version E.g. `5.6.27-0ubuntu0.14.04.1` * @return string `5.6.27` */ - protected function cleanVersion($version) { + protected function cleanVersion($version): string { $matches = []; preg_match('/^(\d+)(\.\d+)(\.\d+)/', $version, $matches); if (isset($matches[0])) { diff --git a/lib/Categories/Encryption.php b/lib/Categories/Encryption.php index 49c66c12..629f74bd 100644 --- a/lib/Categories/Encryption.php +++ b/lib/Categories/Encryption.php @@ -1,4 +1,7 @@ config = $config; - $this->l = $l; + public function __construct( + protected IConfig $config, + protected IL10N $l, + ) { } - /** - * @return string - */ - public function getCategory() { + #[\Override] + public function getCategory(): string { return 'encryption'; } - /** - * @return string - */ - public function getDisplayName() { + #[\Override] + public function getDisplayName(): string { return $this->l->t('Encryption information (is it enabled?, what is the default module)'); } /** - * @return array (string => string|int) + * @return array */ - public function getData() { + #[\Override] + public function getData(): array { $data = [ 'enabled' => $this->config->getAppValue('core', 'encryption_enabled', 'no') === 'yes' ? 'yes' : 'no', 'default_module' => $this->config->getAppValue('core', 'default_encryption_module') === 'OC_DEFAULT_MODULE' ? 'yes' : 'no', diff --git a/lib/Categories/FilesSharing.php b/lib/Categories/FilesSharing.php index 4ae5c783..6717b478 100644 --- a/lib/Categories/FilesSharing.php +++ b/lib/Categories/FilesSharing.php @@ -1,4 +1,7 @@ connection = $connection; - $this->l = $l; + public function __construct( + protected IDBConnection $connection, + protected IL10N $l, + ) { } - /** - * @return string - */ - public function getCategory() { + #[\Override] + public function getCategory(): string { return 'files_sharing'; } - /** - * @return string - */ - public function getDisplayName() { + #[\Override] + public function getDisplayName(): string { return $this->l->t('Number of shares (per type and permission setting)'); } /** - * @return array (string => string|int) + * @return array */ - public function getData() { + #[\Override] + public function getData(): array { $query = $this->connection->getQueryBuilder(); $query->select($query->func()->count('*', 'num_entries')) ->addSelect(['permissions', 'share_type']) @@ -74,11 +65,7 @@ public function getData() { return $data; } - /** - * @param string $tableName - * @return int - */ - protected function countEntries($tableName) { + protected function countEntries(string $tableName): int { $query = $this->connection->getQueryBuilder(); $query->select($query->func()->count('*', 'num_entries')) ->from($tableName); @@ -89,12 +76,7 @@ protected function countEntries($tableName) { return (int)$row['num_entries']; } - /** - * @param int $type - * @param bool $noShareWith - * @return int - */ - protected function countShares($type, $noShareWith = false) { + protected function countShares(int $type, bool $noShareWith = false): int { $query = $this->connection->getQueryBuilder(); $query->select($query->func()->count('*', 'num_entries')) ->from('share') diff --git a/lib/Categories/ICategory.php b/lib/Categories/ICategory.php index c725acc6..12b7c3d8 100644 --- a/lib/Categories/ICategory.php +++ b/lib/Categories/ICategory.php @@ -1,4 +1,7 @@ string|int) + * @return array */ - public function getData(); + public function getData(): array; } diff --git a/lib/Categories/Php.php b/lib/Categories/Php.php index 4f716b2f..aff4c8af 100644 --- a/lib/Categories/Php.php +++ b/lib/Categories/Php.php @@ -1,4 +1,7 @@ phpIni = $phpIni; - $this->l = $l; + public function __construct( + protected IniGetWrapper $phpIni, + protected IL10N $l, + ) { } - /** - * @return string - */ - public function getCategory() { + #[\Override] + public function getCategory(): string { return 'php'; } - /** - * @return string - */ - public function getDisplayName() { + #[\Override] + public function getDisplayName(): string { return $this->l->t('PHP environment (version, memory limit, max. execution time, max. file size)'); } /** - * @return array (string => string|int) + * @return array */ - public function getData() { + #[\Override] + public function getData(): array { return [ 'version' => $this->cleanVersion(PHP_VERSION), 'memory_limit' => $this->phpIni->getBytes('memory_limit'), @@ -63,7 +54,7 @@ public function getData() { * @param string $version E.g. `5.5.30-1+deb.sury.org~trusty+1` * @return string `5.5.30` */ - protected function cleanVersion($version) { + protected function cleanVersion(string $version): string { $matches = []; preg_match('/^(\d+)(\.\d+)(\.\d+)/', $version, $matches); if (isset($matches[0])) { diff --git a/lib/Categories/Server.php b/lib/Categories/Server.php index 2f152d27..76d247f7 100644 --- a/lib/Categories/Server.php +++ b/lib/Categories/Server.php @@ -1,4 +1,7 @@ config = $config; - $this->l = $l; + public function __construct( + protected IConfig $config, + protected IL10N $l, + ) { } - /** - * @return string - */ - public function getCategory() { + #[\Override] + public function getCategory(): string { return 'server'; } - /** - * @return string - */ - public function getDisplayName() { + #[\Override] + public function getDisplayName(): string { return $this->l->t('Server instance details (version, memcache used, status of locking/previews/avatars)'); } /** - * @return array (string => string|int) + * @return array */ - public function getData() { + #[\Override] + public function getData(): array { return [ 'version' => $this->config->getSystemValue('version'), 'code' => $this->codeLocation(), @@ -64,7 +55,7 @@ public function getData() { ]; } - protected function codeLocation() { + protected function codeLocation(): string { if (file_exists(\OC::$SERVERROOT . '/.git') && is_dir(\OC::$SERVERROOT . '/.git')) { return 'git'; } diff --git a/lib/Categories/Stats.php b/lib/Categories/Stats.php index a4631ee7..d795ba26 100644 --- a/lib/Categories/Stats.php +++ b/lib/Categories/Stats.php @@ -1,4 +1,7 @@ connection = $connection; - $this->l = $l; + public function __construct( + protected IDBConnection $connection, + protected IL10N $l, + ) { } - /** - * @return string - */ - public function getCategory() { + #[\Override] + public function getCategory(): string { return 'stats'; } - /** - * @return string - */ - public function getDisplayName() { + #[\Override] + public function getDisplayName(): string { return $this->l->t('Statistic (number of files, users, storages per type, comments and tags)'); } /** - * @return array (string => string|int) + * @return array */ - public function getData() { + #[\Override] + public function getData(): array { return [ 'num_files' => $this->countEntries('filecache'), 'num_users' => $this->countUserEntries(), @@ -67,7 +58,7 @@ public function getData() { /** * @return int */ - protected function countUserEntries() { + protected function countUserEntries(): int { $query = $this->connection->getQueryBuilder(); $query->select($query->func()->count('*', 'num_entries')) ->from('preferences') @@ -79,11 +70,7 @@ protected function countUserEntries() { return (int)$row['num_entries']; } - /** - * @param string $type - * @return int - */ - protected function countStorages($type) { + protected function countStorages(string $type): int { $query = $this->connection->getQueryBuilder(); $query->select($query->func()->count('*', 'num_entries')) ->from('storages'); @@ -109,7 +96,7 @@ protected function countStorages($type) { * @param string $column * @return int */ - protected function countEntries($tableName, $column = '*') { + protected function countEntries(string $tableName, string $column = '*'): int { $query = $this->connection->getQueryBuilder(); if ($column !== '*') { diff --git a/lib/Collector.php b/lib/Collector.php index f03d3197..70ebe20c 100644 --- a/lib/Collector.php +++ b/lib/Collector.php @@ -1,4 +1,7 @@ registerCategories(); $tuples = []; diff --git a/lib/Migration/SendAdminNotification.php b/lib/Migration/SendAdminNotification.php index e104ed68..368b7de8 100644 --- a/lib/Migration/SendAdminNotification.php +++ b/lib/Migration/SendAdminNotification.php @@ -23,10 +23,12 @@ public function __construct( ) { } + #[\Override] public function getName(): string { return 'Send an admin notification if monthly report is disabled'; } + #[\Override] public function run(IOutput $output): void { if ($this->appConfig->getAppValueBool('never_again')) { return; diff --git a/lib/Notifier.php b/lib/Notifier.php index c5bf7eef..8fb625b2 100644 --- a/lib/Notifier.php +++ b/lib/Notifier.php @@ -32,6 +32,7 @@ public function __construct( * @return string * @since 17.0.0 */ + #[\Override] public function getID(): string { return 'survey_client'; } @@ -42,6 +43,7 @@ public function getID(): string { * @return string * @since 17.0.0 */ + #[\Override] public function getName(): string { return $this->l10nFactory->get('survey_client')->t('Usage survey'); } @@ -53,6 +55,7 @@ public function getName(): string { * @throws UnknownNotificationException When the notification was not prepared by a notifier * @throws AlreadyProcessedException When the notification is no longer applicable */ + #[\Override] public function prepare(INotification $notification, string $languageCode): INotification { if ($notification->getApp() !== 'survey_client') { // Not my app => throw diff --git a/lib/Settings/AdminSection.php b/lib/Settings/AdminSection.php index 8ab9da0d..5617f64e 100644 --- a/lib/Settings/AdminSection.php +++ b/lib/Settings/AdminSection.php @@ -1,10 +1,12 @@ l = $l; - $this->url = $url; + public function __construct( + protected IL10N $l, + protected IURLGenerator $url, + ) { } /** @@ -28,7 +25,8 @@ public function __construct(IL10N $l, IURLGenerator $url) { * * @returns string */ - public function getID() { + #[\Override] + public function getID(): string { return 'survey_client'; } @@ -38,7 +36,8 @@ public function getID() { * * @return string */ - public function getName() { + #[\Override] + public function getName(): string { return $this->l->t('Usage survey'); } @@ -47,14 +46,16 @@ public function getName() { * the settings navigation. The sections are arranged in ascending order of * the priority values. It is required to return a value between 0 and 99. */ - public function getPriority() { + #[\Override] + public function getPriority(): int { return 80; } /** * {@inheritdoc} */ - public function getIcon() { + #[\Override] + public function getIcon(): string { return $this->url->imagePath('survey_client', 'app-dark.svg'); } } diff --git a/lib/Settings/AdminSettings.php b/lib/Settings/AdminSettings.php index 19952f1f..c6ff6f07 100644 --- a/lib/Settings/AdminSettings.php +++ b/lib/Settings/AdminSettings.php @@ -1,10 +1,12 @@ appConfig->getAppValueInt('last_sent'); if ($lastSentReportTime === 0) { @@ -57,6 +60,7 @@ public function getForm(): TemplateResponse { /** * @return string the section ID, e.g. 'sharing' */ + #[\Override] public function getSection(): string { return 'survey_client'; } @@ -66,6 +70,7 @@ public function getSection(): string { * the admin section. The forms are arranged in ascending order of the * priority values. It is required to return a value between 0 and 100. */ + #[\Override] public function getPriority(): int { return 50; } diff --git a/psalm.xml b/psalm.xml index cf59a65a..a23c7a89 100644 --- a/psalm.xml +++ b/psalm.xml @@ -18,9 +18,6 @@ - - - @@ -29,10 +26,5 @@ - - - - -