mirror of
https://github.com/nextcloud/server.git
synced 2026-06-11 01:30:50 -04:00
Merge pull request #32960 from nextcloud/fix/avoid-using-undeclared-properties
Fix PHP 8.2 warnings about undeclared properties
This commit is contained in:
commit
64bff27c99
7 changed files with 32 additions and 66 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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':
|
||||
|
|
|
|||
|
|
@ -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 ?? [];
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue