]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix PHP 8.2 warnings about undeclared properties
authorCôme Chilliet <come.chilliet@nextcloud.com>
Tue, 21 Jun 2022 14:03:45 +0000 (16:03 +0200)
committerCôme Chilliet <come.chilliet@nextcloud.com>
Tue, 21 Jun 2022 14:17:52 +0000 (16:17 +0200)
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
lib/private/App/Platform.php
lib/private/App/PlatformRepository.php
lib/private/Contacts/ContactsMenu/ContactsStore.php
lib/private/DB/MigrationService.php
lib/private/Files/Node/File.php
lib/private/Files/Node/Folder.php
tests/lib/AppFramework/Http/DispatcherTest.php

index 12097abbc787eff540b0f9caef8e968f725073c7..8da16c038f186eef8f4e729bf8a0345f78b04f85 100644 (file)
@@ -36,39 +36,26 @@ use OCP\IConfig;
  */
 class Platform {
 
-       /**
-        * @param IConfig $config
-        */
+       private IConfig $config;
+
        public function __construct(IConfig $config) {
                $this->config = $config;
        }
 
-       /**
-        * @return string
-        */
-       public function getPhpVersion() {
+       public function getPhpVersion(): string {
                return phpversion();
        }
 
-       /**
-        * @return int
-        */
-       public function getIntSize() {
+       public function getIntSize(): int {
                return PHP_INT_SIZE;
        }
 
-       /**
-        * @return string
-        */
-       public function getOcVersion() {
+       public function getOcVersion(): string {
                $v = \OCP\Util::getVersion();
                return implode('.', $v);
        }
 
-       /**
-        * @return string
-        */
-       public function getDatabase() {
+       public function getDatabase(): string {
                $dbType = $this->config->getSystemValue('dbtype', 'sqlite');
                if ($dbType === 'sqlite3') {
                        $dbType = 'sqlite';
@@ -77,23 +64,19 @@ class Platform {
                return $dbType;
        }
 
-       /**
-        * @return string
-        */
-       public function getOS() {
+       public function getOS(): string {
                return php_uname('s');
        }
 
        /**
         * @param $command
-        * @return bool
         */
-       public function isCommandKnown($command) {
+       public function isCommandKnown($command): bool {
                $path = \OC_Helper::findBinaryPath($command);
                return ($path !== null);
        }
 
-       public function getLibraryVersion($name) {
+       public function getLibraryVersion(string $name): ?string {
                $repo = new PlatformRepository();
                return $repo->findLibrary($name);
        }
index 94fac5260e1555d8b8cffd7c6dd6e74b71f65b09..4166c2ead03b0add89b922d0a7eb35eafcf81086 100644 (file)
@@ -31,11 +31,13 @@ namespace OC\App;
  * @package OC\App
  */
 class PlatformRepository {
+       private array $packages;
+
        public function __construct() {
                $this->packages = $this->initialize();
        }
 
-       protected function initialize() {
+       protected function initialize(): array {
                $loadedExtensions = get_loaded_extensions();
                $packages = [];
 
@@ -121,15 +123,11 @@ class PlatformRepository {
                return $packages;
        }
 
-       private function buildPackageName($name) {
+       private function buildPackageName(string $name): string {
                return str_replace(' ', '-', $name);
        }
 
-       /**
-        * @param $name
-        * @return string
-        */
-       public function findLibrary($name) {
+       public function findLibrary(string $name): ?string {
                $extName = $this->buildPackageName($name);
                if (isset($this->packages[$extName])) {
                        return $this->packages[$extName];
@@ -137,19 +135,17 @@ class PlatformRepository {
                return null;
        }
 
-       private static $modifierRegex = '[._-]?(?:(stable|beta|b|RC|alpha|a|patch|pl|p)(?:[.-]?(\d+))?)?([.-]?dev)?';
+       private static string $modifierRegex = '[._-]?(?:(stable|beta|b|RC|alpha|a|patch|pl|p)(?:[.-]?(\d+))?)?([.-]?dev)?';
 
        /**
         * Normalizes a version string to be able to perform comparisons on it
         *
         * https://github.com/composer/composer/blob/master/src/Composer/Package/Version/VersionParser.php#L94
         *
-        * @param string $version
         * @param string $fullVersion optional complete version string to give more context
         * @throws \UnexpectedValueException
-        * @return string
         */
-       public function normalizeVersion($version, $fullVersion = null) {
+       public function normalizeVersion(string $version, ?string $fullVersion = null): string {
                $version = trim($version);
                if (null === $fullVersion) {
                        $fullVersion = $version;
@@ -204,10 +200,7 @@ class PlatformRepository {
                throw new \UnexpectedValueException('Invalid version string "' . $version . '"' . $extraMessage);
        }
 
-       /**
-        * @param string $stability
-        */
-       private function expandStability($stability) {
+       private function expandStability(string $stability): string {
                $stability = strtolower($stability);
                switch ($stability) {
                        case 'a':
index 020e8604910b671d9ede690384424c4fac552c8b..4d7fda39c6a4dc2e98eb8ccabd714815892f62d5 100644 (file)
@@ -150,7 +150,7 @@ class ContactsStore implements IContactsStore {
                $selfGroups = $this->groupManager->getUserGroupIds($self);
 
                if ($excludedGroups) {
-                       $excludedGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups_list');
+                       $excludedGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups_list', '');
                        $decodedExcludeGroups = json_decode($excludedGroups, true);
                        $excludeGroupsList = $decodedExcludeGroups ?? [];
 
index 13bbe8dc5d049df46a0e7ad18dc1256b218d8aec..22fffa596ec57c9b1769e70f0b5b11d7e245ec68 100644 (file)
@@ -46,34 +46,25 @@ use Psr\Log\LoggerInterface;
 
 class MigrationService {
 
-       /** @var boolean */
-       private $migrationTableCreated;
-       /** @var array */
-       private $migrations;
-       /** @var IOutput */
-       private $output;
-       /** @var Connection */
-       private $connection;
-       /** @var string */
-       private $appName;
-       /** @var bool */
-       private $checkOracle;
+       private bool $migrationTableCreated;
+       private array $migrations;
+       private string $migrationsPath;
+       private string $migrationsNamespace;
+       private IOutput $output;
+       private Connection $connection;
+       private string $appName;
+       private bool $checkOracle;
 
        /**
-        * MigrationService constructor.
-        *
-        * @param $appName
-        * @param Connection $connection
-        * @param AppLocator $appLocator
-        * @param IOutput|null $output
         * @throws \Exception
         */
-       public function __construct($appName, Connection $connection, IOutput $output = null, AppLocator $appLocator = null) {
+       public function __construct($appName, Connection $connection, ?IOutput $output = null, ?AppLocator $appLocator = null) {
                $this->appName = $appName;
                $this->connection = $connection;
-               $this->output = $output;
-               if (null === $this->output) {
+               if ($output === null) {
                        $this->output = new SimpleOutput(\OC::$server->get(LoggerInterface::class), $appName);
+               } else {
+                       $this->output = $output;
                }
 
                if ($appName === 'core') {
@@ -104,6 +95,7 @@ class MigrationService {
                                }
                        }
                }
+               $this->migrationTableCreated = false;
        }
 
        /**
index e125715e6a87d284c379888f4243f7823a0388ac..d8a6741dc6ee2a4fa2a48ed8894c10c9bc4b8411 100644 (file)
@@ -131,7 +131,6 @@ class File extends Node implements \OCP\Files\File {
                        $this->view->unlink($this->path);
                        $nonExisting = new NonExistingFile($this->root, $this->view, $this->path, $fileInfo);
                        $this->sendHooks(['postDelete'], [$nonExisting]);
-                       $this->exists = false;
                        $this->fileInfo = null;
                } else {
                        throw new NotPermittedException();
index 9c15f0edf416f7bee54dfa9dc424602657176694..b56b7e0f851dcfaf780d6d9a808fe12ecd49bc04 100644 (file)
@@ -388,7 +388,6 @@ class Folder extends Node implements \OCP\Files\Folder {
                        $this->view->rmdir($this->path);
                        $nonExisting = new NonExistingFolder($this->root, $this->view, $this->path, $fileInfo);
                        $this->sendHooks(['postDelete'], [$nonExisting]);
-                       $this->exists = false;
                } else {
                        throw new NotPermittedException('No delete permission for path');
                }
index e1d78082a2d35759e24e3bcc6492aaa8c14dc75b..8f591f26e58a6de5b7e594281121866701f66d2a 100644 (file)
@@ -89,6 +89,8 @@ class DispatcherTest extends \Test\TestCase {
        /** @var Dispatcher */
        private $dispatcher;
        private $controllerMethod;
+       /** @var Controller|MockObject  */
+       private $controller;
        private $response;
        /** @var IRequest|MockObject  */
        private $request;