diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2022-06-21 16:03:45 +0200 |
---|---|---|
committer | Côme Chilliet <come.chilliet@nextcloud.com> | 2022-06-21 16:17:52 +0200 |
commit | 1bd5222224bac9b8f1037c992367c9af85a9ec5a (patch) | |
tree | 2a36b991633734a0738a415c266bcdfeb290c58a /lib/private/App | |
parent | dbc2c2325ea194b4588515e5fad988b7ab9bcf3f (diff) | |
download | nextcloud-server-1bd5222224bac9b8f1037c992367c9af85a9ec5a.tar.gz nextcloud-server-1bd5222224bac9b8f1037c992367c9af85a9ec5a.zip |
Fix PHP 8.2 warnings about undeclared properties
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'lib/private/App')
-rw-r--r-- | lib/private/App/Platform.php | 35 | ||||
-rw-r--r-- | lib/private/App/PlatformRepository.php | 23 |
2 files changed, 17 insertions, 41 deletions
diff --git a/lib/private/App/Platform.php b/lib/private/App/Platform.php index 12097abbc78..8da16c038f1 100644 --- a/lib/private/App/Platform.php +++ b/lib/private/App/Platform.php @@ -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); } 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': |