diff options
author | Côme Chilliet <91878298+come-nc@users.noreply.github.com> | 2022-06-28 12:05:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-28 12:05:16 +0200 |
commit | 64bff27c99fe387c79d5eecd19e549f61c3f8d4a (patch) | |
tree | cd1113c245e703da61ef09151dca1ea41ea4abff /lib | |
parent | 2956da417841cb045796b5e0ff9ab50d1db4ca94 (diff) | |
parent | c598e3cafa368cc9cd665b3857b4fb60251d1442 (diff) | |
download | nextcloud-server-64bff27c99fe387c79d5eecd19e549f61c3f8d4a.tar.gz nextcloud-server-64bff27c99fe387c79d5eecd19e549f61c3f8d4a.zip |
Merge pull request #32960 from nextcloud/fix/avoid-using-undeclared-properties
Fix PHP 8.2 warnings about undeclared properties
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/App/Platform.php | 34 | ||||
-rw-r--r-- | lib/private/App/PlatformRepository.php | 23 | ||||
-rw-r--r-- | lib/private/Contacts/ContactsMenu/ContactsStore.php | 2 | ||||
-rw-r--r-- | lib/private/DB/MigrationService.php | 35 | ||||
-rw-r--r-- | lib/private/Files/Node/File.php | 1 | ||||
-rw-r--r-- | lib/private/Files/Node/Folder.php | 1 |
6 files changed, 30 insertions, 66 deletions
diff --git a/lib/private/App/Platform.php b/lib/private/App/Platform.php index 12097abbc78..15966d85c34 100644 --- a/lib/private/App/Platform.php +++ b/lib/private/App/Platform.php @@ -35,40 +35,26 @@ use OCP\IConfig; * @package OC\App */ class Platform { + private IConfig $config; - /** - * @param 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 +63,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); } diff --git a/lib/private/App/PlatformRepository.php b/lib/private/App/PlatformRepository.php index 94fac5260e1..4166c2ead03 100644 --- a/lib/private/App/PlatformRepository.php +++ b/lib/private/App/PlatformRepository.php @@ -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': diff --git a/lib/private/Contacts/ContactsMenu/ContactsStore.php b/lib/private/Contacts/ContactsMenu/ContactsStore.php index 020e8604910..4d7fda39c6a 100644 --- a/lib/private/Contacts/ContactsMenu/ContactsStore.php +++ b/lib/private/Contacts/ContactsMenu/ContactsStore.php @@ -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 ?? []; diff --git a/lib/private/DB/MigrationService.php b/lib/private/DB/MigrationService.php index 13bbe8dc5d0..4b7e4d3a040 100644 --- a/lib/private/DB/MigrationService.php +++ b/lib/private/DB/MigrationService.php @@ -45,35 +45,25 @@ use OCP\Migration\IOutput; 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 +94,7 @@ class MigrationService { } } } + $this->migrationTableCreated = false; } /** diff --git a/lib/private/Files/Node/File.php b/lib/private/Files/Node/File.php index e125715e6a8..d8a6741dc6e 100644 --- a/lib/private/Files/Node/File.php +++ b/lib/private/Files/Node/File.php @@ -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(); diff --git a/lib/private/Files/Node/Folder.php b/lib/private/Files/Node/Folder.php index 9c15f0edf41..b56b7e0f851 100644 --- a/lib/private/Files/Node/Folder.php +++ b/lib/private/Files/Node/Folder.php @@ -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'); } |