diff --git a/lib/private/Accounts/Account.php b/lib/private/Accounts/Account.php index 946168d7755..e443f65870a 100644 --- a/lib/private/Accounts/Account.php +++ b/lib/private/Accounts/Account.php @@ -27,6 +27,7 @@ class Account implements IAccount { ) { } + #[\Override] public function setProperty(string $property, string $value, string $scope, string $verified, string $verificationData = ''): IAccount { if ($this->isCollection($property)) { throw new \InvalidArgumentException('setProperty cannot set an IAccountsPropertyCollection'); @@ -35,6 +36,7 @@ class Account implements IAccount { return $this; } + #[\Override] public function getProperty(string $property): IAccountProperty { if ($this->isCollection($property)) { throw new \InvalidArgumentException('getProperty cannot retrieve an IAccountsPropertyCollection'); @@ -45,12 +47,14 @@ class Account implements IAccount { return $this->properties[$property]; } + #[\Override] public function getProperties(): array { return array_filter($this->properties, function ($obj) { return $obj instanceof IAccountProperty; }); } + #[\Override] public function setAllPropertiesFromJson(array $properties): IAccount { foreach ($properties as $propertyName => $propertyObject) { if ($this->isCollection($propertyName)) { @@ -73,6 +77,7 @@ class Account implements IAccount { return $this; } + #[\Override] public function getAllProperties(): Generator { foreach ($this->properties as $propertyObject) { if ($propertyObject instanceof IAccountProperty) { @@ -85,6 +90,7 @@ class Account implements IAccount { } } + #[\Override] public function getFilteredProperties(?string $scope = null, ?string $verified = null): array { $result = $incrementals = []; /** @var IAccountProperty $obj */ @@ -106,6 +112,7 @@ class Account implements IAccount { } /** @return array> */ + #[\Override] public function jsonSerialize(): array { $properties = $this->properties; foreach ($properties as $propertyName => $propertyObject) { @@ -117,15 +124,18 @@ class Account implements IAccount { return $properties; } + #[\Override] public function getUser(): IUser { return $this->user; } + #[\Override] public function setPropertyCollection(IAccountPropertyCollection $propertyCollection): IAccount { $this->properties[$propertyCollection->getName()] = $propertyCollection; return $this; } + #[\Override] public function getPropertyCollection(string $propertyCollectionName): IAccountPropertyCollection { if (!$this->isCollection($propertyCollectionName)) { throw new PropertyDoesNotExistException($propertyCollectionName); diff --git a/lib/private/Accounts/AccountManager.php b/lib/private/Accounts/AccountManager.php index 102e6a8b9cb..f3d2878b254 100644 --- a/lib/private/Accounts/AccountManager.php +++ b/lib/private/Accounts/AccountManager.php @@ -216,6 +216,7 @@ class AccountManager implements IAccountManager { return $this->addMissingDefaultValues($userDataArray, $this->buildDefaultUserRecord($user)); } + #[\Override] public function searchUsers(string $property, array $values): array { // the value col is limited to 255 bytes. It is used for searches only. $values = array_map(function (string $value) { @@ -655,6 +656,7 @@ class AccountManager implements IAccountManager { return $account; } + #[\Override] public function getAccount(IUser $user): IAccount { $cached = $this->internalCache->get($user->getUID()); if ($cached !== null) { @@ -826,6 +828,7 @@ class AccountManager implements IAccountManager { } } + #[\Override] public function updateAccount(IAccount $account): void { $this->testValueLengths(iterator_to_array($account->getAllProperties()), true); try { diff --git a/lib/private/Accounts/AccountProperty.php b/lib/private/Accounts/AccountProperty.php index 11ad03d6c7f..685fa013ed2 100644 --- a/lib/private/Accounts/AccountProperty.php +++ b/lib/private/Accounts/AccountProperty.php @@ -29,6 +29,7 @@ class AccountProperty implements IAccountProperty { $this->setScope($scope); } + #[\Override] public function jsonSerialize(): array { return [ 'name' => $this->getName(), @@ -44,6 +45,7 @@ class AccountProperty implements IAccountProperty { * * @since 15.0.0 */ + #[\Override] public function setValue(string $value): IAccountProperty { $this->value = $value; return $this; @@ -54,6 +56,7 @@ class AccountProperty implements IAccountProperty { * * @since 15.0.0 */ + #[\Override] public function setScope(string $scope): IAccountProperty { $newScope = $this->mapScopeToV2($scope); if (!in_array($newScope, [ @@ -73,6 +76,7 @@ class AccountProperty implements IAccountProperty { * * @since 15.0.0 */ + #[\Override] public function setVerified(string $verified): IAccountProperty { $this->verified = $verified; return $this; @@ -83,6 +87,7 @@ class AccountProperty implements IAccountProperty { * * @since 15.0.0 */ + #[\Override] public function getName(): string { return $this->name; } @@ -92,6 +97,7 @@ class AccountProperty implements IAccountProperty { * * @since 15.0.0 */ + #[\Override] public function getValue(): string { return $this->value; } @@ -101,6 +107,7 @@ class AccountProperty implements IAccountProperty { * * @since 15.0.0 */ + #[\Override] public function getScope(): string { return $this->scope; } @@ -123,19 +130,23 @@ class AccountProperty implements IAccountProperty { * * @since 15.0.0 */ + #[\Override] public function getVerified(): string { return $this->verified; } + #[\Override] public function setVerificationData(string $verificationData): IAccountProperty { $this->verificationData = $verificationData; return $this; } + #[\Override] public function getVerificationData(): string { return $this->verificationData; } + #[\Override] public function setLocallyVerified(string $verified): IAccountProperty { if (!in_array($verified, [ IAccountManager::NOT_VERIFIED, @@ -148,6 +159,7 @@ class AccountProperty implements IAccountProperty { return $this; } + #[\Override] public function getLocallyVerified(): string { return $this->locallyVerified; } diff --git a/lib/private/Accounts/AccountPropertyCollection.php b/lib/private/Accounts/AccountPropertyCollection.php index 75eea76e686..b163b7ac87d 100644 --- a/lib/private/Accounts/AccountPropertyCollection.php +++ b/lib/private/Accounts/AccountPropertyCollection.php @@ -21,6 +21,7 @@ class AccountPropertyCollection implements IAccountPropertyCollection { ) { } + #[\Override] public function setProperties(array $properties): IAccountPropertyCollection { /** @var IAccountProperty $property */ $this->properties = []; @@ -30,10 +31,12 @@ class AccountPropertyCollection implements IAccountPropertyCollection { return $this; } + #[\Override] public function getProperties(): array { return $this->properties; } + #[\Override] public function addProperty(IAccountProperty $property): IAccountPropertyCollection { if ($property->getName() !== $this->collectionName) { throw new InvalidArgumentException('Provided property does not match collection name'); @@ -42,6 +45,7 @@ class AccountPropertyCollection implements IAccountPropertyCollection { return $this; } + #[\Override] public function addPropertyWithDefaults(string $value): IAccountPropertyCollection { $property = new AccountProperty( $this->collectionName, @@ -54,6 +58,7 @@ class AccountPropertyCollection implements IAccountPropertyCollection { return $this; } + #[\Override] public function removeProperty(IAccountProperty $property): IAccountPropertyCollection { $ref = array_search($property, $this->properties, true); if ($ref !== false) { @@ -62,6 +67,7 @@ class AccountPropertyCollection implements IAccountPropertyCollection { return $this; } + #[\Override] public function getPropertyByValue(string $value): ?IAccountProperty { foreach ($this->properties as $i => $property) { if ($property->getValue() === $value) { @@ -71,6 +77,7 @@ class AccountPropertyCollection implements IAccountPropertyCollection { return null; } + #[\Override] public function removePropertyByValue(string $value): IAccountPropertyCollection { foreach ($this->properties as $i => $property) { if ($property->getValue() === $value) { @@ -80,10 +87,12 @@ class AccountPropertyCollection implements IAccountPropertyCollection { return $this; } + #[\Override] public function jsonSerialize(): array { return [$this->collectionName => $this->properties]; } + #[\Override] public function getName(): string { return $this->collectionName; } diff --git a/lib/private/Accounts/Hooks.php b/lib/private/Accounts/Hooks.php index 12f2b4777f8..eebc2300f49 100644 --- a/lib/private/Accounts/Hooks.php +++ b/lib/private/Accounts/Hooks.php @@ -50,6 +50,7 @@ class Hooks implements IEventListener { } } + #[\Override] public function handle(Event $event): void { if (!$event instanceof UserChangedEvent) { return; diff --git a/lib/private/Activity/ActivitySettingsAdapter.php b/lib/private/Activity/ActivitySettingsAdapter.php index 27c85ee5554..a165d32dc98 100644 --- a/lib/private/Activity/ActivitySettingsAdapter.php +++ b/lib/private/Activity/ActivitySettingsAdapter.php @@ -23,30 +23,37 @@ class ActivitySettingsAdapter extends ActivitySettings { ) { } + #[\Override] public function getIdentifier() { return $this->oldSettings->getIdentifier(); } + #[\Override] public function getName() { return $this->oldSettings->getName(); } + #[\Override] public function getGroupIdentifier() { return 'other'; } + #[\Override] public function getGroupName() { return $this->l10n->t('Other activities'); } + #[\Override] public function getPriority() { return $this->oldSettings->getPriority(); } + #[\Override] public function canChangeMail() { return $this->oldSettings->canChangeMail(); } + #[\Override] public function isDefaultEnabledMail() { return $this->oldSettings->isDefaultEnabledMail(); } diff --git a/lib/private/Activity/Event.php b/lib/private/Activity/Event.php index 6a2bc5dba77..1c3ea936d82 100644 --- a/lib/private/Activity/Event.php +++ b/lib/private/Activity/Event.php @@ -70,6 +70,7 @@ class Event implements IEvent { /** * {@inheritDoc} */ + #[\Override] public function setApp(string $app): IEvent { if ($app === '' || isset($app[32])) { throw new InvalidValueException('app'); @@ -81,6 +82,7 @@ class Event implements IEvent { /** * @return string */ + #[\Override] public function getApp(): string { return $this->app; } @@ -88,6 +90,7 @@ class Event implements IEvent { /** * {@inheritDoc} */ + #[\Override] public function setType(string $type): IEvent { if ($type === '' || isset($type[255])) { throw new InvalidValueException('type'); @@ -99,6 +102,7 @@ class Event implements IEvent { /** * @return string */ + #[\Override] public function getType(): string { return $this->type; } @@ -106,6 +110,7 @@ class Event implements IEvent { /** * {@inheritDoc} */ + #[\Override] public function setAffectedUser(string $affectedUser): IEvent { if ($affectedUser === '' || isset($affectedUser[64])) { throw new InvalidValueException('affectedUser'); @@ -117,6 +122,7 @@ class Event implements IEvent { /** * @return string */ + #[\Override] public function getAffectedUser(): string { return $this->affectedUser; } @@ -124,6 +130,7 @@ class Event implements IEvent { /** * {@inheritDoc} */ + #[\Override] public function setAuthor(string $author): IEvent { if (isset($author[64])) { throw new InvalidValueException('author'); @@ -135,6 +142,7 @@ class Event implements IEvent { /** * @return string */ + #[\Override] public function getAuthor(): string { return $this->author; } @@ -142,6 +150,7 @@ class Event implements IEvent { /** * {@inheritDoc} */ + #[\Override] public function setTimestamp(int $timestamp): IEvent { if ($timestamp < 0) { throw new InvalidValueException('timestamp'); @@ -153,6 +162,7 @@ class Event implements IEvent { /** * @return int */ + #[\Override] public function getTimestamp(): int { return $this->timestamp; } @@ -160,6 +170,7 @@ class Event implements IEvent { /** * {@inheritDoc} */ + #[\Override] public function setSubject(string $subject, array $parameters = []): IEvent { if (isset($subject[255])) { throw new InvalidValueException('subject'); @@ -172,6 +183,7 @@ class Event implements IEvent { /** * @return string */ + #[\Override] public function getSubject(): string { return $this->subject; } @@ -179,6 +191,7 @@ class Event implements IEvent { /** * @return array */ + #[\Override] public function getSubjectParameters(): array { return $this->subjectParameters; } @@ -186,6 +199,7 @@ class Event implements IEvent { /** * {@inheritDoc} */ + #[\Override] public function setParsedSubject(string $subject): IEvent { if ($subject === '') { throw new InvalidValueException('parsedSubject'); @@ -198,6 +212,7 @@ class Event implements IEvent { * @return string * @since 11.0.0 */ + #[\Override] public function getParsedSubject(): string { return $this->subjectParsed; } @@ -205,6 +220,7 @@ class Event implements IEvent { /** * {@inheritDoc} */ + #[\Override] public function setRichSubject(string $subject, array $parameters = []): IEvent { if ($subject === '') { throw new InvalidValueException('richSubject'); @@ -227,6 +243,7 @@ class Event implements IEvent { * @return string * @since 11.0.0 */ + #[\Override] public function getRichSubject(): string { return $this->subjectRich; } @@ -235,6 +252,7 @@ class Event implements IEvent { * @return array> * @since 11.0.0 */ + #[\Override] public function getRichSubjectParameters(): array { return $this->subjectRichParameters; } @@ -242,6 +260,7 @@ class Event implements IEvent { /** * {@inheritDoc} */ + #[\Override] public function setMessage(string $message, array $parameters = []): IEvent { if (isset($message[255])) { throw new InvalidValueException('message'); @@ -254,6 +273,7 @@ class Event implements IEvent { /** * @return string */ + #[\Override] public function getMessage(): string { return $this->message; } @@ -261,6 +281,7 @@ class Event implements IEvent { /** * @return array */ + #[\Override] public function getMessageParameters(): array { return $this->messageParameters; } @@ -268,6 +289,7 @@ class Event implements IEvent { /** * {@inheritDoc} */ + #[\Override] public function setParsedMessage(string $message): IEvent { $this->messageParsed = $message; return $this; @@ -277,6 +299,7 @@ class Event implements IEvent { * @return string * @since 11.0.0 */ + #[\Override] public function getParsedMessage(): string { return $this->messageParsed; } @@ -284,6 +307,7 @@ class Event implements IEvent { /** * {@inheritDoc} */ + #[\Override] public function setRichMessage(string $message, array $parameters = []): IEvent { $this->messageRich = $message; $this->messageRichParameters = $parameters; @@ -303,6 +327,7 @@ class Event implements IEvent { * @return string * @since 11.0.0 */ + #[\Override] public function getRichMessage(): string { return $this->messageRich; } @@ -311,6 +336,7 @@ class Event implements IEvent { * @return array> * @since 11.0.0 */ + #[\Override] public function getRichMessageParameters(): array { return $this->messageRichParameters; } @@ -318,6 +344,7 @@ class Event implements IEvent { /** * {@inheritDoc} */ + #[\Override] public function setObject(string $objectType, string|int $objectId, string $objectName = ''): IEvent { if (isset($objectType[255])) { throw new InvalidValueException('objectType'); @@ -337,6 +364,7 @@ class Event implements IEvent { /** * @return string */ + #[\Override] public function getObjectType(): string { return $this->objectType; } @@ -344,6 +372,7 @@ class Event implements IEvent { /** * @return int|string */ + #[\Override] public function getObjectId(): string|int { return $this->objectId; } @@ -351,6 +380,7 @@ class Event implements IEvent { /** * @return string */ + #[\Override] public function getObjectName(): string { return $this->objectName; } @@ -358,6 +388,7 @@ class Event implements IEvent { /** * {@inheritDoc} */ + #[\Override] public function setLink(string $link): IEvent { if (isset($link[4000])) { throw new InvalidValueException('link'); @@ -369,6 +400,7 @@ class Event implements IEvent { /** * @return string */ + #[\Override] public function getLink(): string { return $this->link; } @@ -376,6 +408,7 @@ class Event implements IEvent { /** * {@inheritDoc} */ + #[\Override] public function setIcon(string $icon): IEvent { if (isset($icon[4000])) { throw new InvalidValueException('icon'); @@ -388,6 +421,7 @@ class Event implements IEvent { * @return string * @since 11.0.0 */ + #[\Override] public function getIcon(): string { return $this->icon; } @@ -397,6 +431,7 @@ class Event implements IEvent { * @return $this * @since 11.0.0 - Since 15.0.0 returns $this */ + #[\Override] public function setChildEvent(IEvent $child): IEvent { $this->child = $child; return $this; @@ -406,6 +441,7 @@ class Event implements IEvent { * @return IEvent|null * @since 11.0.0 */ + #[\Override] public function getChildEvent() { return $this->child; } @@ -414,6 +450,7 @@ class Event implements IEvent { * @return bool * @since 8.2.0 */ + #[\Override] public function isValid(): bool { return $this->isValidCommon() @@ -425,6 +462,7 @@ class Event implements IEvent { * @return bool * @since 8.2.0 */ + #[\Override] public function isValidParsed(): bool { if ($this->getRichSubject() !== '' || !empty($this->getRichSubjectParameters())) { try { @@ -463,11 +501,13 @@ class Event implements IEvent { ; } + #[\Override] public function setGenerateNotification(bool $generate): IEvent { $this->generateNotification = $generate; return $this; } + #[\Override] public function getGenerateNotification(): bool { return $this->generateNotification; } diff --git a/lib/private/Activity/EventMerger.php b/lib/private/Activity/EventMerger.php index 2b9294f5852..486874ddae9 100644 --- a/lib/private/Activity/EventMerger.php +++ b/lib/private/Activity/EventMerger.php @@ -47,6 +47,7 @@ class EventMerger implements IEventMerger { * @param IEvent|null $previousEvent * @return IEvent */ + #[\Override] public function mergeEvents($mergeParameter, IEvent $event, ?IEvent $previousEvent = null) { // No second event => can not combine if (!$previousEvent instanceof IEvent) { diff --git a/lib/private/Activity/Manager.php b/lib/private/Activity/Manager.php index 186ef843e2f..3981345c698 100644 --- a/lib/private/Activity/Manager.php +++ b/lib/private/Activity/Manager.php @@ -92,6 +92,7 @@ class Manager implements IManager { * * @return IEvent */ + #[\Override] public function generateEvent(): IEvent { return new Event($this->validator, $this->richTextFormatter); } @@ -99,6 +100,7 @@ class Manager implements IManager { /** * {@inheritDoc} */ + #[\Override] public function publish(IEvent $event): void { if ($event->getAuthor() === '' && $this->session->getUser() instanceof IUser) { $event->setAuthor($this->session->getUser()->getUID()); @@ -120,6 +122,7 @@ class Manager implements IManager { /** * {@inheritDoc} */ + #[\Override] public function bulkPublish(IEvent $event, array $affectedUserIds, ISetting $setting): void { if (empty($affectedUserIds)) { throw new IncompleteActivityException('The given event is invalid'); @@ -158,6 +161,7 @@ class Manager implements IManager { * * @param \Closure $callable */ + #[\Override] public function registerConsumer(\Closure $callable): void { $this->consumersClosures[] = $callable; $this->consumers = []; @@ -173,6 +177,7 @@ class Manager implements IManager { * @param string $filter Class must implement OCA\Activity\IFilter * @return void */ + #[\Override] public function registerFilter(string $filter): void { $this->filterClasses[$filter] = false; } @@ -181,6 +186,7 @@ class Manager implements IManager { * @return IFilter[] * @throws \InvalidArgumentException */ + #[\Override] public function getFilters(): array { foreach ($this->filterClasses as $class => $false) { /** @var IFilter $filter */ @@ -200,6 +206,7 @@ class Manager implements IManager { /** * {@inheritDoc} */ + #[\Override] public function getFilterById(string $id): IFilter { $filters = $this->getFilters(); @@ -220,6 +227,7 @@ class Manager implements IManager { * @param string $provider Class must implement OCA\Activity\IProvider * @return void */ + #[\Override] public function registerProvider(string $provider): void { $this->providerClasses[$provider] = false; } @@ -228,6 +236,7 @@ class Manager implements IManager { * @return IProvider[] * @throws \InvalidArgumentException */ + #[\Override] public function getProviders(): array { foreach ($this->providerClasses as $class => $false) { /** @var IProvider $provider */ @@ -254,6 +263,7 @@ class Manager implements IManager { * @param string $setting Class must implement OCA\Activity\ISetting * @return void */ + #[\Override] public function registerSetting(string $setting): void { $this->settingsClasses[$setting] = false; } @@ -262,6 +272,7 @@ class Manager implements IManager { * @return ActivitySettings[] * @throws \InvalidArgumentException */ + #[\Override] public function getSettings(): array { foreach ($this->settingsClasses as $class => $false) { /** @var ISetting $setting */ @@ -285,6 +296,7 @@ class Manager implements IManager { /** * {@inheritDoc} */ + #[\Override] public function getSettingById(string $id): ActivitySettings { $settings = $this->getSettings(); @@ -300,6 +312,7 @@ class Manager implements IManager { * @param string $type * @param int|numeric-string $id */ + #[\Override] public function setFormattingObject(string $type, int|string $id): void { $this->formattingObjectType = $type; $this->formattingObjectId = $id; @@ -308,6 +321,7 @@ class Manager implements IManager { /** * @return bool */ + #[\Override] public function isFormattingFilteredObject(): bool { return $this->formattingObjectType !== null && $this->formattingObjectId !== null && $this->formattingObjectType === $this->request->getParam('object_type') @@ -317,6 +331,7 @@ class Manager implements IManager { /** * @param bool $status Set to true, when parsing events should not use SVG icons */ + #[\Override] public function setRequirePNG(bool $status): void { $this->requirePNG = $status; } @@ -324,6 +339,7 @@ class Manager implements IManager { /** * @return bool */ + #[\Override] public function getRequirePNG(): bool { return $this->requirePNG; } @@ -333,6 +349,7 @@ class Manager implements IManager { * * @param string|null $currentUserId */ + #[\Override] public function setCurrentUserId(?string $currentUserId = null): void { $this->currentUserId = $currentUserId; } @@ -345,6 +362,7 @@ class Manager implements IManager { * @return string * @throws \UnexpectedValueException If the token is invalid, does not exist or is not unique */ + #[\Override] public function getCurrentUserId(): string { if ($this->currentUserId !== null) { return $this->currentUserId; diff --git a/lib/private/AllConfig.php b/lib/private/AllConfig.php index 4f8229a8f99..9779c91ae59 100644 --- a/lib/private/AllConfig.php +++ b/lib/private/AllConfig.php @@ -30,6 +30,7 @@ class AllConfig implements IConfig { * @param array $configs Associative array with `key => value` pairs * If value is null, the config key will be deleted */ + #[\Override] public function setSystemValues(array $configs) { $this->systemConfig->setValues($configs); } @@ -40,6 +41,7 @@ class AllConfig implements IConfig { * @param string $key the key of the value, under which will be saved * @param mixed $value the value that should be stored */ + #[\Override] public function setSystemValue($key, $value) { $this->systemConfig->setValue($key, $value); } @@ -51,6 +53,7 @@ class AllConfig implements IConfig { * @param mixed $default the default value to be returned if the value isn't set * @return mixed the value or $default */ + #[\Override] public function getSystemValue($key, $default = '') { return $this->systemConfig->getValue($key, $default); } @@ -65,6 +68,7 @@ class AllConfig implements IConfig { * * @since 16.0.0 */ + #[\Override] public function getSystemValueBool(string $key, bool $default = false): bool { return (bool)$this->getSystemValue($key, $default); } @@ -79,6 +83,7 @@ class AllConfig implements IConfig { * * @since 16.0.0 */ + #[\Override] public function getSystemValueInt(string $key, int $default = 0): int { return (int)$this->getSystemValue($key, $default); } @@ -93,6 +98,7 @@ class AllConfig implements IConfig { * * @since 16.0.0 */ + #[\Override] public function getSystemValueString(string $key, string $default = ''): string { return (string)$this->getSystemValue($key, $default); } @@ -104,6 +110,7 @@ class AllConfig implements IConfig { * @param mixed $default the default value to be returned if the value isn't set * @return mixed the value or $default */ + #[\Override] public function getFilteredSystemValue($key, $default = '') { return $this->systemConfig->getFilteredValue($key, $default); } @@ -113,6 +120,7 @@ class AllConfig implements IConfig { * * @param string $key the key of the value, under which it was saved */ + #[\Override] public function deleteSystemValue($key) { $this->systemConfig->deleteValue($key); } @@ -124,6 +132,7 @@ class AllConfig implements IConfig { * @return string[] the keys stored for the app * @deprecated 29.0.0 Use {@see IAppConfig} directly */ + #[\Override] public function getAppKeys($appName) { return Server::get(AppConfig::class)->getKeys($appName); } @@ -136,6 +145,7 @@ class AllConfig implements IConfig { * @param string|float|int $value the value that should be stored * @deprecated 29.0.0 Use {@see IAppConfig} directly */ + #[\Override] public function setAppValue($appName, $key, $value) { Server::get(AppConfig::class)->setValue($appName, $key, $value); } @@ -149,6 +159,7 @@ class AllConfig implements IConfig { * @return string the saved value * @deprecated 29.0.0 Use {@see IAppConfig} directly */ + #[\Override] public function getAppValue($appName, $key, $default = '') { return Server::get(AppConfig::class)->getValue($appName, $key, $default) ?? $default; } @@ -160,6 +171,7 @@ class AllConfig implements IConfig { * @param string $key the key of the value, under which it was saved * @deprecated 29.0.0 Use {@see IAppConfig} directly */ + #[\Override] public function deleteAppValue($appName, $key) { Server::get(AppConfig::class)->deleteKey($appName, $key); } @@ -170,6 +182,7 @@ class AllConfig implements IConfig { * @param string $appName the appName the configs are stored under * @deprecated 29.0.0 Use {@see IAppConfig} directly */ + #[\Override] public function deleteAppValues($appName) { Server::get(AppConfig::class)->deleteApp($appName); } @@ -193,6 +206,7 @@ class AllConfig implements IConfig { * @see IUserConfig::getValueArray * @see IUserConfig::getValueBool */ + #[\Override] public function setUserValue($userId, $appName, $key, $value, $preCondition = null) { if (!is_int($value) && !is_float($value) && !is_string($value)) { throw new \UnexpectedValueException('Only integers, floats and strings are allowed as value'); @@ -228,6 +242,7 @@ class AllConfig implements IConfig { * @see IUserConfig::getValueArray * @see IUserConfig::getValueBool */ + #[\Override] public function getUserValue($userId, $appName, $key, $default = '') { if ($userId === null || $userId === '') { return $default; @@ -250,6 +265,7 @@ class AllConfig implements IConfig { * @return string[] * @deprecated 31.0.0 - use {@see IUserConfig::getKeys} directly */ + #[\Override] public function getUserKeys($userId, $appName) { return Server::get(IUserConfig::class)->getKeys($userId, $appName); } @@ -263,6 +279,7 @@ class AllConfig implements IConfig { * * @deprecated 31.0.0 - use {@see IUserConfig::deleteUserConfig} directly */ + #[\Override] public function deleteUserValue($userId, $appName, $key) { Server::get(IUserConfig::class)->deleteUserConfig($userId, $appName, $key); } @@ -274,6 +291,7 @@ class AllConfig implements IConfig { * * @deprecated 31.0.0 - use {@see IUserConfig::deleteAllUserConfig} directly */ + #[\Override] public function deleteAllUserValues($userId) { if ($userId === null) { return; @@ -288,6 +306,7 @@ class AllConfig implements IConfig { * * @deprecated 31.0.0 - use {@see IUserConfig::deleteApp} directly */ + #[\Override] public function deleteAppFromAllUsers($appName) { Server::get(IUserConfig::class)->deleteApp($appName); } @@ -304,6 +323,7 @@ class AllConfig implements IConfig { * ] * @deprecated 31.0.0 - use {@see IUserConfig::getAllValues} directly */ + #[\Override] public function getAllUserValues(?string $userId): array { if ($userId === null || $userId === '') { return []; @@ -329,6 +349,7 @@ class AllConfig implements IConfig { * @return array Mapped values: userId => value * @deprecated 31.0.0 - use {@see IUserConfig::getValuesByUsers} directly */ + #[\Override] public function getUserValueForUsers($appName, $key, $userIds) { return Server::get(IUserConfig::class)->getValuesByUsers($appName, $key, ValueType::MIXED, $userIds); } @@ -343,6 +364,7 @@ class AllConfig implements IConfig { * @return list of user IDs * @deprecated 31.0.0 - use {@see IUserConfig::searchUsersByValueString} directly */ + #[\Override] public function getUsersForUserValue($appName, $key, $value) { /** @var list $result */ $result = iterator_to_array(Server::get(IUserConfig::class)->searchUsersByValueString($appName, $key, $value)); diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php index 2859e00aa8f..3cf84ef9046 100644 --- a/lib/private/App/AppManager.php +++ b/lib/private/App/AppManager.php @@ -104,6 +104,7 @@ class AppManager implements IAppManager { return $this->navigationManager; } + #[\Override] public function getAppIcon(string $appId, bool $dark = false): ?string { $possibleIcons = $dark ? [$appId . '-dark.svg', 'app-dark.svg'] : [$appId . '.svg', 'app.svg']; $icon = null; @@ -168,6 +169,7 @@ class AppManager implements IAppManager { * * @return string[] */ + #[\Override] public function getInstalledApps() { return $this->getEnabledApps(); } @@ -177,6 +179,7 @@ class AppManager implements IAppManager { * * @return list */ + #[\Override] public function getEnabledApps(): array { return array_keys($this->getEnabledAppsValues()); } @@ -186,6 +189,7 @@ class AppManager implements IAppManager { * * @return list an array of app names (string IDs) */ + #[\Override] public function getAllAppsInAppsFolders(): array { $apps = []; @@ -218,6 +222,7 @@ class AppManager implements IAppManager { * @param IUser $user * @return list */ + #[\Override] public function getEnabledAppsForUser(IUser $user) { $apps = $this->getEnabledAppsValues(); $appsForUser = array_filter($apps, function ($enabled) use ($user) { @@ -226,6 +231,7 @@ class AppManager implements IAppManager { return array_keys($appsForUser); } + #[\Override] public function getEnabledAppsForGroup(IGroup $group): array { $apps = $this->getEnabledAppsValues(); $appsForGroups = array_filter($apps, function ($enabled) use ($group) { @@ -246,6 +252,7 @@ class AppManager implements IAppManager { * * if $types is set to non-empty array, only apps of those types will be loaded */ + #[\Override] public function loadApps(array $types = []): bool { if ($this->config->getSystemValueBool('maintenance', false)) { return false; @@ -295,6 +302,7 @@ class AppManager implements IAppManager { * @param array $types * @return bool */ + #[\Override] public function isType(string $app, array $types): bool { $appTypes = $this->getAppTypes($app); foreach ($types as $type) { @@ -331,6 +339,7 @@ class AppManager implements IAppManager { return $this->autoDisabledApps; } + #[\Override] public function getAppRestriction(string $appId): array { $values = $this->getEnabledAppsValues(); @@ -351,6 +360,7 @@ class AppManager implements IAppManager { * @param IUser|null $user (optional) if not defined, the currently logged in user will be used * @return bool */ + #[\Override] public function isEnabledForUser($appId, $user = null) { if ($this->isAlwaysEnabled($appId)) { return true; @@ -425,10 +435,12 @@ class AppManager implements IAppManager { * * @param string $appId */ + #[\Override] public function isInstalled($appId): bool { return $this->isEnabledForAnyone($appId); } + #[\Override] public function isEnabledForAnyone(string $appId): bool { $enabledAppsValues = $this->getEnabledAppsValues(); return isset($enabledAppsValues[$appId]); @@ -455,6 +467,7 @@ class AppManager implements IAppManager { $this->config->setSystemValue('app_install_overwrite', $ignoreMaxApps); } + #[\Override] public function loadApp(string $app): void { if (isset($this->loadedApps[$app])) { return; @@ -569,6 +582,7 @@ class AppManager implements IAppManager { * @param string $app app id * @since 26.0.0 */ + #[\Override] public function isAppLoaded(string $app): bool { return isset($this->loadedApps[$app]); } @@ -581,6 +595,7 @@ class AppManager implements IAppManager { * @throws AppPathNotFoundException * @throws \InvalidArgumentException if the application is not installed yet */ + #[\Override] public function enableApp(string $appId, bool $forceEnable = false): void { // Check if app exists $this->getAppPath($appId); @@ -610,6 +625,7 @@ class AppManager implements IAppManager { * @param string[] $types * @return bool */ + #[\Override] public function hasProtectedAppType($types) { if (empty($types)) { return false; @@ -628,6 +644,7 @@ class AppManager implements IAppManager { * @throws \InvalidArgumentException if app can't be enabled for groups * @throws AppPathNotFoundException */ + #[\Override] public function enableAppForGroups(string $appId, array $groups, bool $forceEnable = false): void { // Check if app exists $this->getAppPath($appId); @@ -671,6 +688,7 @@ class AppManager implements IAppManager { * @param bool $automaticDisabled * @throws \Exception if app can't be disabled */ + #[\Override] public function disableApp($appId, $automaticDisabled = false): void { if ($this->isAlwaysEnabled($appId)) { throw new \Exception("$appId can't be disabled."); @@ -707,6 +725,7 @@ class AppManager implements IAppManager { * * @throws AppPathNotFoundException if app folder can't be found */ + #[\Override] public function getAppPath(string $appId, bool $ignoreCache = false): string { $appId = $this->cleanAppId($appId); if ($appId === '') { @@ -726,6 +745,7 @@ class AppManager implements IAppManager { * * @throws AppPathNotFoundException if app path can't be found */ + #[\Override] public function getAppWebPath(string $appId): string { if (($dir = $this->findAppInDirectories($appId)) != false) { return \OC::$WEBROOT . $dir['url'] . '/' . $appId; @@ -787,6 +807,7 @@ class AppManager implements IAppManager { /** * Clear the cached list of apps when enabling/disabling an app */ + #[\Override] public function clearAppsCache(): void { $this->appInfos = []; } @@ -823,6 +844,7 @@ class AppManager implements IAppManager { * @param string|null $lang * @return array|null app info */ + #[\Override] public function getAppInfo(string $appId, bool $path = false, $lang = null) { if ($path) { throw new \InvalidArgumentException('Calling IAppManager::getAppInfo() with a path is no longer supported. Please call IAppManager::getAppInfoByPath() instead and verify that the path is good before calling.'); @@ -846,6 +868,7 @@ class AppManager implements IAppManager { return $data; } + #[\Override] public function getAppInfoByPath(string $path, ?string $lang = null): ?array { if (!str_ends_with($path, '/appinfo/info.xml')) { return null; @@ -861,6 +884,7 @@ class AppManager implements IAppManager { return $data; } + #[\Override] public function getAppVersion(string $appId, bool $useCache = true): string { if (!$useCache || !isset($this->appVersions[$appId])) { if ($appId === 'core') { @@ -878,6 +902,7 @@ class AppManager implements IAppManager { * * @return array */ + #[\Override] public function getAppInstalledVersions(bool $onlyEnabled = false): array { return $this->getAppConfig()->getAppInstalledVersions($onlyEnabled); } @@ -909,6 +934,7 @@ class AppManager implements IAppManager { * @inheritdoc * In case you change this method, also change \OC\App\CodeChecker\InfoChecker::isShipped() */ + #[\Override] public function isShipped($appId) { $this->loadShippedJson(); return in_array($appId, $this->shippedApps, true); @@ -943,6 +969,7 @@ class AppManager implements IAppManager { /** * @inheritdoc */ + #[\Override] public function getAlwaysEnabledApps() { $this->loadShippedJson(); return $this->alwaysEnabled; @@ -951,6 +978,7 @@ class AppManager implements IAppManager { /** * @inheritdoc */ + #[\Override] public function isDefaultEnabled(string $appId): bool { return (in_array($appId, $this->getDefaultEnabledApps())); } @@ -958,6 +986,7 @@ class AppManager implements IAppManager { /** * @inheritdoc */ + #[\Override] public function getDefaultEnabledApps(): array { $this->loadShippedJson(); @@ -967,6 +996,7 @@ class AppManager implements IAppManager { /** * @inheritdoc */ + #[\Override] public function getDefaultAppForUser(?IUser $user = null, bool $withFallbacks = true): string { $id = $this->getNavigationManager()->getDefaultEntryIdForUser($user, $withFallbacks); $entry = $this->getNavigationManager()->get($id); @@ -976,6 +1006,7 @@ class AppManager implements IAppManager { /** * @inheritdoc */ + #[\Override] public function getDefaultApps(): array { $ids = $this->getNavigationManager()->getDefaultEntryIds(); @@ -988,6 +1019,7 @@ class AppManager implements IAppManager { /** * @inheritdoc */ + #[\Override] public function setDefaultApps(array $defaultApps): void { $entries = $this->getNavigationManager()->getAll(); $ids = []; @@ -1002,6 +1034,7 @@ class AppManager implements IAppManager { $this->getNavigationManager()->setDefaultEntryIds($ids); } + #[\Override] public function isBackendRequired(string $backend): bool { foreach ($this->appInfos as $appInfo) { if ( @@ -1031,6 +1064,7 @@ class AppManager implements IAppManager { * @psalm-taint-escape sql * @psalm-taint-escape unserialize */ + #[\Override] public function cleanAppId(string $app): string { /* Only lowercase alphanumeric is allowed */ $cleanAppId = preg_replace('/(^[0-9_-]+|[^a-z0-9_-]+|[_-]+$)/', '', $app, -1, $count); @@ -1068,6 +1102,7 @@ class AppManager implements IAppManager { * * @throws AppPathNotFoundException if app folder can't be found */ + #[\Override] public function upgradeApp(string $appId): bool { // for apps distributed with core, we refresh app path in case the downloaded version // have been installed in custom apps and not in the default path @@ -1138,6 +1173,7 @@ class AppManager implements IAppManager { return true; } + #[\Override] public function isUpgradeRequired(string $appId): bool { $versions = $this->getAppInstalledVersions(); $currentVersion = $this->getAppVersion($appId); @@ -1157,6 +1193,7 @@ class AppManager implements IAppManager { return false; } + #[\Override] public function isAppCompatible(string $serverVersion, array $appInfo, bool $ignoreMax = false): bool { return count($this->dependencyAnalyzer->analyzeServerVersion($serverVersion, $appInfo, $ignoreMax)) === 0; } diff --git a/lib/private/App/AppStore/Bundles/EducationBundle.php b/lib/private/App/AppStore/Bundles/EducationBundle.php index 47a14d3c530..e91fa3b49e2 100644 --- a/lib/private/App/AppStore/Bundles/EducationBundle.php +++ b/lib/private/App/AppStore/Bundles/EducationBundle.php @@ -12,6 +12,7 @@ class EducationBundle extends Bundle { /** * {@inheritDoc} */ + #[\Override] public function getName() { return $this->l10n->t('Education bundle'); } @@ -19,6 +20,7 @@ class EducationBundle extends Bundle { /** * {@inheritDoc} */ + #[\Override] public function getAppIdentifiers() { return [ 'dashboard', diff --git a/lib/private/App/AppStore/Bundles/EnterpriseBundle.php b/lib/private/App/AppStore/Bundles/EnterpriseBundle.php index fbc4019353b..d8845830cf7 100644 --- a/lib/private/App/AppStore/Bundles/EnterpriseBundle.php +++ b/lib/private/App/AppStore/Bundles/EnterpriseBundle.php @@ -12,6 +12,7 @@ class EnterpriseBundle extends Bundle { /** * {@inheritDoc} */ + #[\Override] public function getName(): string { return $this->l10n->t('Enterprise bundle'); } @@ -19,6 +20,7 @@ class EnterpriseBundle extends Bundle { /** * {@inheritDoc} */ + #[\Override] public function getAppIdentifiers(): array { return [ 'admin_audit', diff --git a/lib/private/App/AppStore/Bundles/GroupwareBundle.php b/lib/private/App/AppStore/Bundles/GroupwareBundle.php index cddb18cf817..6cc535329a2 100644 --- a/lib/private/App/AppStore/Bundles/GroupwareBundle.php +++ b/lib/private/App/AppStore/Bundles/GroupwareBundle.php @@ -12,6 +12,7 @@ class GroupwareBundle extends Bundle { /** * {@inheritDoc} */ + #[\Override] public function getName() { return $this->l10n->t('Groupware bundle'); } @@ -19,6 +20,7 @@ class GroupwareBundle extends Bundle { /** * {@inheritDoc} */ + #[\Override] public function getAppIdentifiers() { return [ 'calendar', diff --git a/lib/private/App/AppStore/Bundles/HubBundle.php b/lib/private/App/AppStore/Bundles/HubBundle.php index 354e01e25c2..640e8a610a3 100644 --- a/lib/private/App/AppStore/Bundles/HubBundle.php +++ b/lib/private/App/AppStore/Bundles/HubBundle.php @@ -9,10 +9,12 @@ declare(strict_types=1); namespace OC\App\AppStore\Bundles; class HubBundle extends Bundle { + #[\Override] public function getName() { return $this->l10n->t('Hub bundle'); } + #[\Override] public function getAppIdentifiers() { $hubApps = [ 'spreed', diff --git a/lib/private/App/AppStore/Bundles/PublicSectorBundle.php b/lib/private/App/AppStore/Bundles/PublicSectorBundle.php index 06c5c6c2c39..759e0e551c2 100644 --- a/lib/private/App/AppStore/Bundles/PublicSectorBundle.php +++ b/lib/private/App/AppStore/Bundles/PublicSectorBundle.php @@ -12,6 +12,7 @@ class PublicSectorBundle extends Bundle { /** * {@inheritDoc} */ + #[\Override] public function getName(): string { return $this->l10n->t('Public sector bundle'); } @@ -19,6 +20,7 @@ class PublicSectorBundle extends Bundle { /** * {@inheritDoc} */ + #[\Override] public function getAppIdentifiers(): array { return [ diff --git a/lib/private/App/AppStore/Bundles/SocialSharingBundle.php b/lib/private/App/AppStore/Bundles/SocialSharingBundle.php index 013e8db3a83..533fafb2d92 100644 --- a/lib/private/App/AppStore/Bundles/SocialSharingBundle.php +++ b/lib/private/App/AppStore/Bundles/SocialSharingBundle.php @@ -12,6 +12,7 @@ class SocialSharingBundle extends Bundle { /** * {@inheritDoc} */ + #[\Override] public function getName() { return $this->l10n->t('Social sharing bundle'); } @@ -19,6 +20,7 @@ class SocialSharingBundle extends Bundle { /** * {@inheritDoc} */ + #[\Override] public function getAppIdentifiers() { return [ 'socialsharing_twitter', diff --git a/lib/private/App/AppStore/Fetcher/AppDiscoverFetcher.php b/lib/private/App/AppStore/Fetcher/AppDiscoverFetcher.php index 8389e525750..535ad42665c 100644 --- a/lib/private/App/AppStore/Fetcher/AppDiscoverFetcher.php +++ b/lib/private/App/AppStore/Fetcher/AppDiscoverFetcher.php @@ -47,6 +47,7 @@ class AppDiscoverFetcher extends Fetcher { * * @param bool $allowUnstable Include also upcoming entries */ + #[\Override] public function get($allowUnstable = false) { $entries = parent::get(false); $now = new DateTimeImmutable(); diff --git a/lib/private/App/AppStore/Fetcher/AppFetcher.php b/lib/private/App/AppStore/Fetcher/AppFetcher.php index bbf4b00245b..8b4c31573ef 100644 --- a/lib/private/App/AppStore/Fetcher/AppFetcher.php +++ b/lib/private/App/AppStore/Fetcher/AppFetcher.php @@ -51,6 +51,7 @@ class AppFetcher extends Fetcher { * * @return array */ + #[\Override] protected function fetch($ETag, $content, $allowUnstable = false) { /** @var mixed[] $response */ $response = parent::fetch($ETag, $content); @@ -145,12 +146,14 @@ class AppFetcher extends Fetcher { * @param string $fileName * @param bool $ignoreMaxVersion */ + #[\Override] public function setVersion(string $version, string $fileName = 'apps.json', bool $ignoreMaxVersion = true) { parent::setVersion($version); $this->fileName = $fileName; $this->ignoreMaxVersion = $ignoreMaxVersion; } + #[\Override] public function get($allowUnstable = false): array { $allowPreReleases = $allowUnstable || $this->getChannel() === 'beta' || $this->getChannel() === 'daily' || $this->getChannel() === 'git'; diff --git a/lib/private/AppConfig.php b/lib/private/AppConfig.php index e4da80b94d9..40e5a84d8b2 100644 --- a/lib/private/AppConfig.php +++ b/lib/private/AppConfig.php @@ -98,6 +98,7 @@ class AppConfig implements IAppConfig { * @return list list of app ids * @since 7.0.0 */ + #[\Override] public function getApps(): array { $this->loadConfig(lazy: true); $apps = array_merge(array_keys($this->fastCache), array_keys($this->lazyCache)); @@ -115,6 +116,7 @@ class AppConfig implements IAppConfig { * * @since 29.0.0 */ + #[\Override] public function getKeys(string $app): array { $this->assertParams($app); $this->loadConfig($app, true); @@ -133,6 +135,7 @@ class AppConfig implements IAppConfig { * @return list list of stored config keys * @since 32.0.0 */ + #[\Override] public function searchKeys(string $app, string $prefix = '', bool $lazy = false): array { $this->assertParams($app); $this->loadConfig($app, $lazy); @@ -161,6 +164,7 @@ class AppConfig implements IAppConfig { * @since 7.0.0 * @since 29.0.0 Added the $lazy argument */ + #[\Override] public function hasKey(string $app, string $key, ?bool $lazy = false): bool { $this->assertParams($app, $key); $this->loadConfig($app, $lazy ?? true); @@ -184,6 +188,7 @@ class AppConfig implements IAppConfig { * @throws AppConfigUnknownKeyException if config key is not known * @since 29.0.0 */ + #[\Override] public function isSensitive(string $app, string $key, ?bool $lazy = false): bool { $this->assertParams($app, $key); $this->loadConfig(null, $lazy ?? true); @@ -207,6 +212,7 @@ class AppConfig implements IAppConfig { * @see IAppConfig for details about lazy loading * @since 29.0.0 */ + #[\Override] public function isLazy(string $app, string $key): bool { $this->assertParams($app, $key); $this->matchAndApplyLexiconDefinition($app, $key); @@ -235,6 +241,7 @@ class AppConfig implements IAppConfig { * @return array [configKey => configValue] * @since 29.0.0 */ + #[\Override] public function getAllValues(string $app, string $prefix = '', bool $filtered = false): array { $this->assertParams($app, $prefix); // if we want to filter values, we need to get sensitivity @@ -280,6 +287,7 @@ class AppConfig implements IAppConfig { * @return array [appId => configValue] * @since 29.0.0 */ + #[\Override] public function searchValues(string $key, bool $lazy = false, ?int $typedAs = null): array { $this->assertParams('', $key, true); $this->loadConfig(null, $lazy); @@ -360,6 +368,7 @@ class AppConfig implements IAppConfig { * @since 29.0.0 * @see IAppConfig for explanation about lazy loading */ + #[\Override] public function getValueString( string $app, string $key, @@ -383,6 +392,7 @@ class AppConfig implements IAppConfig { * @since 29.0.0 * @see IAppConfig for explanation about lazy loading */ + #[\Override] public function getValueInt( string $app, string $key, @@ -406,6 +416,7 @@ class AppConfig implements IAppConfig { * @since 29.0.0 * @see IAppConfig for explanation about lazy loading */ + #[\Override] public function getValueFloat(string $app, string $key, float $default = 0, bool $lazy = false): float { return (float)$this->getTypedValue($app, $key, (string)$default, $lazy, self::VALUE_FLOAT); } @@ -424,6 +435,7 @@ class AppConfig implements IAppConfig { * @since 29.0.0 * @see IAppConfig for explanation about lazy loading */ + #[\Override] public function getValueBool(string $app, string $key, bool $default = false, bool $lazy = false): bool { $b = strtolower($this->getTypedValue($app, $key, $default ? 'true' : 'false', $lazy, self::VALUE_BOOL)); return in_array($b, ['1', 'true', 'yes', 'on']); @@ -443,6 +455,7 @@ class AppConfig implements IAppConfig { * @since 29.0.0 * @see IAppConfig for explanation about lazy loading */ + #[\Override] public function getValueArray( string $app, string $key, @@ -552,6 +565,7 @@ class AppConfig implements IAppConfig { * @see VALUE_BOOL * @see VALUE_ARRAY */ + #[\Override] public function getValueType(string $app, string $key, ?bool $lazy = null): int { $type = self::VALUE_MIXED; $ignorable = $lazy ?? false; @@ -627,6 +641,7 @@ class AppConfig implements IAppConfig { * @since 29.0.0 * @see IAppConfig for explanation about lazy loading */ + #[\Override] public function setValueString( string $app, string $key, @@ -657,6 +672,7 @@ class AppConfig implements IAppConfig { * @since 29.0.0 * @see IAppConfig for explanation about lazy loading */ + #[\Override] public function setValueInt( string $app, string $key, @@ -691,6 +707,7 @@ class AppConfig implements IAppConfig { * @since 29.0.0 * @see IAppConfig for explanation about lazy loading */ + #[\Override] public function setValueFloat( string $app, string $key, @@ -720,6 +737,7 @@ class AppConfig implements IAppConfig { * @since 29.0.0 * @see IAppConfig for explanation about lazy loading */ + #[\Override] public function setValueBool( string $app, string $key, @@ -750,6 +768,7 @@ class AppConfig implements IAppConfig { * @since 29.0.0 * @see IAppConfig for explanation about lazy loading */ + #[\Override] public function setValueArray( string $app, string $key, @@ -973,6 +992,7 @@ class AppConfig implements IAppConfig { * @return bool TRUE if entry was found in database and an update was necessary * @since 29.0.0 */ + #[\Override] public function updateSensitive(string $app, string $key, bool $sensitive): bool { $this->assertParams($app, $key); $this->loadConfig(lazy: true); @@ -1033,6 +1053,7 @@ class AppConfig implements IAppConfig { * @return bool TRUE if entry was found in database and an update was necessary * @since 29.0.0 */ + #[\Override] public function updateLazy(string $app, string $key, bool $lazy): bool { $this->assertParams($app, $key); $this->loadConfig(lazy: true); @@ -1069,6 +1090,7 @@ class AppConfig implements IAppConfig { * @throws AppConfigUnknownKeyException if config key is not known in database * @since 29.0.0 */ + #[\Override] public function getDetails(string $app, string $key): array { $this->assertParams($app, $key); $this->loadConfig(lazy: true); @@ -1119,6 +1141,7 @@ class AppConfig implements IAppConfig { * @return array{app: string, key: string, lazy?: bool, valueType?: ValueType, valueTypeName?: string, sensitive?: bool, internal?: bool, default?: string, definition?: string, note?: string} * @since 32.0.0 */ + #[\Override] public function getKeyDetails(string $app, string $key): array { $this->assertParams($app, $key); try { @@ -1161,6 +1184,7 @@ class AppConfig implements IAppConfig { * @throws AppConfigIncorrectTypeException * @since 29.0.0 */ + #[\Override] public function convertTypeToInt(string $type): int { return match (strtolower($type)) { 'mixed' => IAppConfig::VALUE_MIXED, @@ -1180,6 +1204,7 @@ class AppConfig implements IAppConfig { * @throws AppConfigIncorrectTypeException * @since 29.0.0 */ + #[\Override] public function convertTypeToString(int $type): string { $type &= ~self::VALUE_SENSITIVE; @@ -1202,6 +1227,7 @@ class AppConfig implements IAppConfig { * * @since 29.0.0 */ + #[\Override] public function deleteKey(string $app, string $key): void { $this->assertParams($app, $key); $this->matchAndApplyLexiconDefinition($app, $key); @@ -1225,6 +1251,7 @@ class AppConfig implements IAppConfig { * * @since 29.0.0 */ + #[\Override] public function deleteApp(string $app): void { $this->assertParams($app); $qb = $this->connection->getQueryBuilder(); @@ -1243,6 +1270,7 @@ class AppConfig implements IAppConfig { * @internal * @since 29.0.0 */ + #[\Override] public function clearCache(bool $reload = false): void { $this->lazyLoaded = $this->fastLoaded = false; $this->lazyCache = $this->fastCache = $this->valueTypes = $this->configLexiconDetails = []; @@ -1448,6 +1476,7 @@ class AppConfig implements IAppConfig { * @return array|false * @deprecated 29.0.0 use {@see getAllValues()} */ + #[\Override] public function getValues($app, $key) { if (($app !== false) === ($key !== false)) { return false; @@ -1469,6 +1498,7 @@ class AppConfig implements IAppConfig { * @return array * @deprecated 29.0.0 use {@see getAllValues()} */ + #[\Override] public function getFilteredValues($app) { return $this->getAllValues($app, filtered: true); } @@ -1828,6 +1858,7 @@ class AppConfig implements IAppConfig { * * @return array */ + #[\Override] public function getAppInstalledVersions(bool $onlyEnabled = false): array { if ($this->appVersionsCache === null) { /** @var array */ diff --git a/lib/private/AppFramework/Bootstrap/BootContext.php b/lib/private/AppFramework/Bootstrap/BootContext.php index 5240f18d3b8..60b30c9c799 100644 --- a/lib/private/AppFramework/Bootstrap/BootContext.php +++ b/lib/private/AppFramework/Bootstrap/BootContext.php @@ -18,14 +18,17 @@ class BootContext implements IBootContext { ) { } + #[\Override] public function getAppContainer(): IAppContainer { return $this->appContainer; } + #[\Override] public function getServerContainer(): IServerContainer { return $this->appContainer->get(IServerContainer::class); } + #[\Override] public function injectFn(callable $fn) { return (new FunctionInjector($this->appContainer))->injectFn($fn); } diff --git a/lib/private/AppFramework/Bootstrap/RegistrationContext.php b/lib/private/AppFramework/Bootstrap/RegistrationContext.php index ec880706da2..1119d1b8fb7 100644 --- a/lib/private/AppFramework/Bootstrap/RegistrationContext.php +++ b/lib/private/AppFramework/Bootstrap/RegistrationContext.php @@ -179,6 +179,7 @@ class RegistrationContext { ) { } + #[\Override] public function registerCapability(string $capability): void { $this->context->registerCapability( $this->appId, @@ -186,6 +187,7 @@ class RegistrationContext { ); } + #[\Override] public function registerCrashReporter(string $reporterClass): void { $this->context->registerCrashReporter( $this->appId, @@ -193,6 +195,7 @@ class RegistrationContext { ); } + #[\Override] public function registerDashboardWidget(string $widgetClass): void { $this->context->registerDashboardPanel( $this->appId, @@ -200,6 +203,7 @@ class RegistrationContext { ); } + #[\Override] public function registerService(string $name, callable $factory, bool $shared = true): void { $this->context->registerService( $this->appId, @@ -209,6 +213,7 @@ class RegistrationContext { ); } + #[\Override] public function registerServiceAlias(string $alias, string $target): void { $this->context->registerServiceAlias( $this->appId, @@ -217,6 +222,7 @@ class RegistrationContext { ); } + #[\Override] public function registerParameter(string $name, $value): void { $this->context->registerParameter( $this->appId, @@ -225,6 +231,7 @@ class RegistrationContext { ); } + #[\Override] public function registerEventListener(string $event, string $listener, int $priority = 0): void { $this->context->registerEventListener( $this->appId, @@ -234,6 +241,7 @@ class RegistrationContext { ); } + #[\Override] public function registerMiddleware(string $class, bool $global = false): void { $this->context->registerMiddleware( $this->appId, @@ -242,6 +250,7 @@ class RegistrationContext { ); } + #[\Override] public function registerSearchProvider(string $class): void { $this->context->registerSearchProvider( $this->appId, @@ -249,6 +258,7 @@ class RegistrationContext { ); } + #[\Override] public function registerAlternativeLogin(string $class): void { $this->context->registerAlternativeLogin( $this->appId, @@ -264,6 +274,7 @@ class RegistrationContext { ); } + #[\Override] public function registerInitialStateProvider(string $class): void { $this->context->registerInitialState( $this->appId, @@ -271,6 +282,7 @@ class RegistrationContext { ); } + #[\Override] public function registerWellKnownHandler(string $class): void { $this->context->registerWellKnown( $this->appId, @@ -278,12 +290,14 @@ class RegistrationContext { ); } + #[\Override] public function registerSpeechToTextProvider(string $providerClass): void { $this->context->registerSpeechToTextProvider( $this->appId, $providerClass ); } + #[\Override] public function registerTextProcessingProvider(string $providerClass): void { $this->context->registerTextProcessingProvider( $this->appId, @@ -291,6 +305,7 @@ class RegistrationContext { ); } + #[\Override] public function registerTextToImageProvider(string $providerClass): void { $this->context->registerTextToImageProvider( $this->appId, @@ -298,6 +313,7 @@ class RegistrationContext { ); } + #[\Override] public function registerTemplateProvider(string $providerClass): void { $this->context->registerTemplateProvider( $this->appId, @@ -305,6 +321,7 @@ class RegistrationContext { ); } + #[\Override] public function registerTranslationProvider(string $providerClass): void { $this->context->registerTranslationProvider( $this->appId, @@ -312,6 +329,7 @@ class RegistrationContext { ); } + #[\Override] public function registerNotifierService(string $notifierClass): void { $this->context->registerNotifierService( $this->appId, @@ -319,6 +337,7 @@ class RegistrationContext { ); } + #[\Override] public function registerTwoFactorProvider(string $twoFactorProviderClass): void { $this->context->registerTwoFactorProvider( $this->appId, @@ -326,6 +345,7 @@ class RegistrationContext { ); } + #[\Override] public function registerPreviewProvider(string $previewProviderClass, string $mimeTypeRegex): void { $this->context->registerPreviewProvider( $this->appId, @@ -334,6 +354,7 @@ class RegistrationContext { ); } + #[\Override] public function registerCalendarProvider(string $class): void { $this->context->registerCalendarProvider( $this->appId, @@ -341,6 +362,7 @@ class RegistrationContext { ); } + #[\Override] public function registerReferenceProvider(string $class): void { $this->context->registerReferenceProvider( $this->appId, @@ -348,6 +370,7 @@ class RegistrationContext { ); } + #[\Override] public function registerProfileLinkAction(string $actionClass): void { $this->context->registerProfileLinkAction( $this->appId, @@ -355,6 +378,7 @@ class RegistrationContext { ); } + #[\Override] public function registerTalkBackend(string $backend): void { $this->context->registerTalkBackend( $this->appId, @@ -362,6 +386,7 @@ class RegistrationContext { ); } + #[\Override] public function registerCalendarResourceBackend(string $class): void { $this->context->registerCalendarResourceBackend( $this->appId, @@ -369,6 +394,7 @@ class RegistrationContext { ); } + #[\Override] public function registerTeamResourceProvider(string $class) : void { $this->context->registerTeamResourceProvider( $this->appId, @@ -376,6 +402,7 @@ class RegistrationContext { ); } + #[\Override] public function registerCalendarRoomBackend(string $class): void { $this->context->registerCalendarRoomBackend( $this->appId, @@ -383,6 +410,7 @@ class RegistrationContext { ); } + #[\Override] public function registerUserMigrator(string $migratorClass): void { $this->context->registerUserMigrator( $this->appId, @@ -390,6 +418,7 @@ class RegistrationContext { ); } + #[\Override] public function registerSensitiveMethods(string $class, array $methods): void { $this->context->registerSensitiveMethods( $this->appId, @@ -398,6 +427,7 @@ class RegistrationContext { ); } + #[\Override] public function registerPublicShareTemplateProvider(string $class): void { $this->context->registerPublicShareTemplateProvider( $this->appId, @@ -405,6 +435,7 @@ class RegistrationContext { ); } + #[\Override] public function registerSetupCheck(string $setupCheckClass): void { $this->context->registerSetupCheck( $this->appId, @@ -412,6 +443,7 @@ class RegistrationContext { ); } + #[\Override] public function registerDeclarativeSettings(string $declarativeSettingsClass): void { $this->context->registerDeclarativeSettings( $this->appId, @@ -419,6 +451,7 @@ class RegistrationContext { ); } + #[\Override] public function registerTaskProcessingProvider(string $taskProcessingProviderClass): void { $this->context->registerTaskProcessingProvider( $this->appId, @@ -426,6 +459,7 @@ class RegistrationContext { ); } + #[\Override] public function registerTaskProcessingTaskType(string $taskProcessingTaskTypeClass): void { $this->context->registerTaskProcessingTaskType( $this->appId, @@ -433,6 +467,7 @@ class RegistrationContext { ); } + #[\Override] public function registerFileConversionProvider(string $class): void { $this->context->registerFileConversionProvider( $this->appId, @@ -440,6 +475,7 @@ class RegistrationContext { ); } + #[\Override] public function registerMailProvider(string $class): void { $this->context->registerMailProvider( $this->appId, @@ -447,6 +483,7 @@ class RegistrationContext { ); } + #[\Override] public function registerConfigLexicon(string $configLexiconClass): void { $this->context->registerConfigLexicon( $this->appId, diff --git a/lib/private/AppFramework/DependencyInjection/DIContainer.php b/lib/private/AppFramework/DependencyInjection/DIContainer.php index 7527d249586..942e4787d88 100644 --- a/lib/private/AppFramework/DependencyInjection/DIContainer.php +++ b/lib/private/AppFramework/DependencyInjection/DIContainer.php @@ -256,6 +256,7 @@ class DIContainer extends SimpleContainer implements IAppContainer { $this->registerAlias(IInitialState::class, InitialState::class); } + #[\Override] public function getServer(): ServerContainer { return $this->server; } @@ -263,6 +264,7 @@ class DIContainer extends SimpleContainer implements IAppContainer { /** * @param string $middleWare */ + #[\Override] public function registerMiddleWare($middleWare): bool { if (in_array($middleWare, $this->middleWares, true) !== false) { return false; @@ -275,6 +277,7 @@ class DIContainer extends SimpleContainer implements IAppContainer { * used to return the appname of the set application * @return string the name of your application */ + #[\Override] public function getAppName() { return $this->query('appName'); } @@ -305,12 +308,14 @@ class DIContainer extends SimpleContainer implements IAppContainer { * * @param string $serviceName e.g. 'OCA\Files\Capabilities' */ + #[\Override] public function registerCapability($serviceName) { $this->query(CapabilitiesManager::class)->registerCapability(function () use ($serviceName) { return $this->query($serviceName); }); } + #[\Override] public function has($id): bool { if (parent::has($id)) { return true; @@ -327,6 +332,7 @@ class DIContainer extends SimpleContainer implements IAppContainer { * @inheritDoc * @param list $chain */ + #[\Override] public function query(string $name, bool $autoload = true, array $chain = []): mixed { if ($name === 'AppName' || $name === 'appName') { return $this->appName; diff --git a/lib/private/AppFramework/Http/Output.php b/lib/private/AppFramework/Http/Output.php index b4a8672fdc7..aee009b4654 100644 --- a/lib/private/AppFramework/Http/Output.php +++ b/lib/private/AppFramework/Http/Output.php @@ -21,6 +21,7 @@ class Output implements IOutput { /** * @param string $out */ + #[\Override] public function setOutput($out) { print($out); } @@ -30,6 +31,7 @@ class Output implements IOutput { * * @return bool false if an error occurred */ + #[\Override] public function setReadfile($path) { if (is_resource($path)) { $output = fopen('php://output', 'w'); @@ -42,6 +44,7 @@ class Output implements IOutput { /** * @param string $header */ + #[\Override] public function setHeader($header) { header($header); } @@ -49,6 +52,7 @@ class Output implements IOutput { /** * @param int $code sets the http status code */ + #[\Override] public function setHttpResponseCode($code) { http_response_code($code); } @@ -56,6 +60,7 @@ class Output implements IOutput { /** * @return int returns the current http response code */ + #[\Override] public function getHttpResponseCode() { return http_response_code(); } @@ -69,6 +74,7 @@ class Output implements IOutput { * @param bool $secure * @param bool $httpOnly */ + #[\Override] public function setCookie($name, $value, $expire, $path, $domain, $secure, $httpOnly, $sameSite = 'Lax') { $path = $this->webRoot ? : '/'; diff --git a/lib/private/AppFramework/Http/Request.php b/lib/private/AppFramework/Http/Request.php index a66860dbe60..eb8b5b33fc6 100644 --- a/lib/private/AppFramework/Http/Request.php +++ b/lib/private/AppFramework/Http/Request.php @@ -119,6 +119,7 @@ class Request implements \ArrayAccess, \Countable, IRequest { * Countable method * @return int */ + #[\Override] public function count(): int { return \count($this->items['parameters']); } @@ -143,6 +144,7 @@ class Request implements \ArrayAccess, \Countable, IRequest { * @param string $offset The key to lookup * @return boolean */ + #[\Override] public function offsetExists($offset): bool { return isset($this->items['parameters'][$offset]); } @@ -152,6 +154,7 @@ class Request implements \ArrayAccess, \Countable, IRequest { * @param string $offset * @return mixed */ + #[\Override] #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->items['parameters'][$offset] ?? null; @@ -162,6 +165,7 @@ class Request implements \ArrayAccess, \Countable, IRequest { * @param string $offset * @param mixed $value */ + #[\Override] public function offsetSet($offset, $value): void { throw new \RuntimeException('You cannot change the contents of the request object'); } @@ -170,6 +174,7 @@ class Request implements \ArrayAccess, \Countable, IRequest { * @see offsetExists * @param string $offset */ + #[\Override] public function offsetUnset($offset): void { throw new \RuntimeException('You cannot change the contents of the request object'); } @@ -254,6 +259,7 @@ class Request implements \ArrayAccess, \Countable, IRequest { * @param string $name * @return string */ + #[\Override] public function getHeader(string $name): string { $name = strtoupper(str_replace('-', '_', $name)); if (isset($this->server['HTTP_' . $name])) { @@ -288,6 +294,7 @@ class Request implements \ArrayAccess, \Countable, IRequest { * @param mixed $default If the key is not found, this value will be returned * @return mixed the content of the array */ + #[\Override] public function getParam(string $key, $default = null) { return isset($this->parameters[$key]) ? $this->parameters[$key] @@ -299,6 +306,7 @@ class Request implements \ArrayAccess, \Countable, IRequest { * (as GET or POST) or through the URL by the route * @return array the array with all parameters */ + #[\Override] public function getParams(): array { return is_array($this->parameters) ? $this->parameters : []; } @@ -307,6 +315,7 @@ class Request implements \ArrayAccess, \Countable, IRequest { * Returns the method of the request * @return string the method of the request (POST, GET, etc) */ + #[\Override] public function getMethod(): string { return $this->method; } @@ -316,6 +325,7 @@ class Request implements \ArrayAccess, \Countable, IRequest { * @param string $key the key that will be taken from the $_FILES array * @return array the file in the $_FILES element */ + #[\Override] public function getUploadedFile(string $key) { return isset($this->files[$key]) ? $this->files[$key] : null; } @@ -325,6 +335,7 @@ class Request implements \ArrayAccess, \Countable, IRequest { * @param string $key the key that will be taken from the $_ENV array * @return array the value in the $_ENV element */ + #[\Override] public function getEnv(string $key) { return isset($this->env[$key]) ? $this->env[$key] : null; } @@ -334,6 +345,7 @@ class Request implements \ArrayAccess, \Countable, IRequest { * @param string $key the key that will be taken from the $_COOKIE array * @return string the value in the $_COOKIE element */ + #[\Override] public function getCookie(string $key) { return isset($this->cookies[$key]) ? $this->cookies[$key] : null; } @@ -416,6 +428,7 @@ class Request implements \ArrayAccess, \Countable, IRequest { $this->contentDecoded = true; } + #[\Override] public function throwDecodingExceptionIfAny(): void { if ($this->decodingException !== null) { throw $this->decodingException; @@ -427,6 +440,7 @@ class Request implements \ArrayAccess, \Countable, IRequest { * Checks if the CSRF check was correct * @return bool true if CSRF check passed */ + #[\Override] public function passesCSRFCheck(): bool { if ($this->csrfTokenManager === null) { return false; @@ -503,6 +517,7 @@ class Request implements \ArrayAccess, \Countable, IRequest { * @return bool * @since 9.1.0 */ + #[\Override] public function passesStrictCookieCheck(): bool { if (!$this->cookieCheckRequired()) { return true; @@ -523,6 +538,7 @@ class Request implements \ArrayAccess, \Countable, IRequest { * @return bool * @since 9.1.0 */ + #[\Override] public function passesLaxCookieCheck(): bool { if (!$this->cookieCheckRequired()) { return true; @@ -541,6 +557,7 @@ class Request implements \ArrayAccess, \Countable, IRequest { * If `mod_unique_id` is installed this value will be taken. * @return string */ + #[\Override] public function getId(): string { return $this->requestId->getId(); } @@ -568,6 +585,7 @@ class Request implements \ArrayAccess, \Countable, IRequest { * Do always use this instead of $_SERVER['REMOTE_ADDR'] * @return string IP address */ + #[\Override] public function getRemoteAddress(): string { $remoteAddress = isset($this->server['REMOTE_ADDR']) ? $this->server['REMOTE_ADDR'] : ''; $trustedProxies = $this->config->getSystemValue('trusted_proxies', []); @@ -630,6 +648,7 @@ class Request implements \ArrayAccess, \Countable, IRequest { * * @return string Server protocol (http or https) */ + #[\Override] public function getServerProtocol(): string { $proto = 'http'; @@ -669,6 +688,7 @@ class Request implements \ArrayAccess, \Countable, IRequest { * * @return string HTTP protocol. HTTP/2, HTTP/1.1 or HTTP/1.0. */ + #[\Override] public function getHttpProtocol(): string { $claimedProtocol = $this->server['SERVER_PROTOCOL'] ?? ''; @@ -694,6 +714,7 @@ class Request implements \ArrayAccess, \Countable, IRequest { * reverse proxies * @return string */ + #[\Override] public function getRequestUri(): string { $uri = isset($this->server['REQUEST_URI']) ? $this->server['REQUEST_URI'] : ''; if ($this->config->getSystemValueString('overwritewebroot') !== '' && $this->isOverwriteCondition()) { @@ -707,6 +728,7 @@ class Request implements \ArrayAccess, \Countable, IRequest { * @throws \Exception * @return string Path info */ + #[\Override] public function getRawPathInfo(): string { $requestUri = isset($this->server['REQUEST_URI']) ? $this->server['REQUEST_URI'] : ''; // remove too many slashes - can be caused by reverse proxy configuration @@ -752,6 +774,7 @@ class Request implements \ArrayAccess, \Countable, IRequest { * @throws \Exception * @return string|false Path info or false when not found */ + #[\Override] public function getPathInfo(): string|false { $pathInfo = $this->getRawPathInfo(); return \Sabre\HTTP\decodePath($pathInfo); @@ -762,6 +785,7 @@ class Request implements \ArrayAccess, \Countable, IRequest { * reverse proxies * @return string the script name */ + #[\Override] public function getScriptName(): string { $name = $this->server['SCRIPT_NAME'] ?? ''; $overwriteWebRoot = $this->config->getSystemValueString('overwritewebroot'); @@ -779,6 +803,7 @@ class Request implements \ArrayAccess, \Countable, IRequest { * @param array $agent array of agent names * @return bool true if at least one of the given agent matches, false otherwise */ + #[\Override] public function isUserAgent(array $agent): bool { if (!isset($this->server['HTTP_USER_AGENT'])) { return false; @@ -796,6 +821,7 @@ class Request implements \ArrayAccess, \Countable, IRequest { * whether it is a trusted domain * @return string Server host */ + #[\Override] public function getInsecureServerHost(): string { if ($this->fromTrustedProxy() && $this->getOverwriteHost() !== null) { return $this->getOverwriteHost(); @@ -826,6 +852,7 @@ class Request implements \ArrayAccess, \Countable, IRequest { * trusted domain if the host isn't in the trusted list * @return string Server host */ + #[\Override] public function getServerHost(): string { // overwritehost is always trusted $host = $this->getOverwriteHost(); @@ -872,6 +899,7 @@ class Request implements \ArrayAccess, \Countable, IRequest { return \is_array($trustedProxies) && $this->isTrustedProxy($trustedProxies, $remoteAddress); } + #[\Override] public function getFormat(): ?string { $format = $this->getParam('format'); if ($format !== null) { diff --git a/lib/private/AppFramework/Http/RequestId.php b/lib/private/AppFramework/Http/RequestId.php index 1fa2d351456..45dd2246be6 100644 --- a/lib/private/AppFramework/Http/RequestId.php +++ b/lib/private/AppFramework/Http/RequestId.php @@ -22,6 +22,7 @@ class RequestId implements IRequestId { * If `mod_unique_id` is installed this value will be taken. * @return string */ + #[\Override] public function getId(): string { if (empty($this->requestId)) { $validChars = ISecureRandom::CHAR_ALPHANUMERIC; diff --git a/lib/private/AppFramework/Middleware/AdditionalScriptsMiddleware.php b/lib/private/AppFramework/Middleware/AdditionalScriptsMiddleware.php index 4f1c69b104f..281e52a159d 100644 --- a/lib/private/AppFramework/Middleware/AdditionalScriptsMiddleware.php +++ b/lib/private/AppFramework/Middleware/AdditionalScriptsMiddleware.php @@ -25,6 +25,7 @@ class AdditionalScriptsMiddleware extends Middleware { ) { } + #[\Override] public function afterController($controller, $methodName, Response $response): Response { if ($response instanceof TemplateResponse) { if ($controller instanceof LoginController) { diff --git a/lib/private/AppFramework/Middleware/CompressionMiddleware.php b/lib/private/AppFramework/Middleware/CompressionMiddleware.php index 1cdd8c19f05..a6e4f65035f 100644 --- a/lib/private/AppFramework/Middleware/CompressionMiddleware.php +++ b/lib/private/AppFramework/Middleware/CompressionMiddleware.php @@ -26,6 +26,7 @@ class CompressionMiddleware extends Middleware { $this->useGZip = false; } + #[\Override] public function afterController($controller, $methodName, Response $response) { // By default we do not gzip $allowGzip = false; @@ -60,6 +61,7 @@ class CompressionMiddleware extends Middleware { return $response; } + #[\Override] public function beforeOutput($controller, $methodName, $output) { if (!$this->useGZip) { return $output; diff --git a/lib/private/AppFramework/Middleware/FlowV2EphemeralSessionsMiddleware.php b/lib/private/AppFramework/Middleware/FlowV2EphemeralSessionsMiddleware.php index 658a120320e..56f5babcc6f 100644 --- a/lib/private/AppFramework/Middleware/FlowV2EphemeralSessionsMiddleware.php +++ b/lib/private/AppFramework/Middleware/FlowV2EphemeralSessionsMiddleware.php @@ -34,6 +34,7 @@ class FlowV2EphemeralSessionsMiddleware extends Middleware { ) { } + #[\Override] public function beforeController(Controller $controller, string $methodName) { $sessionCreationTime = $this->session->get(ClientFlowLoginV2Controller::EPHEMERAL_NAME); diff --git a/lib/private/AppFramework/Middleware/NotModifiedMiddleware.php b/lib/private/AppFramework/Middleware/NotModifiedMiddleware.php index 60cf06f7b9c..07a7ed0addf 100644 --- a/lib/private/AppFramework/Middleware/NotModifiedMiddleware.php +++ b/lib/private/AppFramework/Middleware/NotModifiedMiddleware.php @@ -20,6 +20,7 @@ class NotModifiedMiddleware extends Middleware { ) { } + #[\Override] public function afterController($controller, $methodName, Response $response) { $etagHeader = $this->request->getHeader('IF_NONE_MATCH'); if ($etagHeader !== '' && $response->getETag() !== null && trim($etagHeader) === '"' . $response->getETag() . '"') { diff --git a/lib/private/AppFramework/Middleware/OCSMiddleware.php b/lib/private/AppFramework/Middleware/OCSMiddleware.php index d592b24a289..dc2bf5cb4e1 100644 --- a/lib/private/AppFramework/Middleware/OCSMiddleware.php +++ b/lib/private/AppFramework/Middleware/OCSMiddleware.php @@ -35,6 +35,7 @@ class OCSMiddleware extends Middleware { * @param Controller $controller * @param string $methodName */ + #[\Override] public function beforeController($controller, $methodName) { if ($controller instanceof OCSController) { if (substr_compare($this->request->getScriptName(), '/ocs/v2.php', -strlen('/ocs/v2.php')) === 0) { @@ -53,6 +54,7 @@ class OCSMiddleware extends Middleware { * @throws \Exception * @return BaseResponse */ + #[\Override] public function afterException($controller, $methodName, \Exception $exception) { if ($controller instanceof OCSController && $exception instanceof OCSException) { $code = $exception->getCode(); @@ -72,6 +74,7 @@ class OCSMiddleware extends Middleware { * @param Response $response * @return Response */ + #[\Override] public function afterController($controller, $methodName, Response $response) { /* * If a different middleware has detected that a request unauthorized or forbidden diff --git a/lib/private/AppFramework/Middleware/PublicShare/PublicShareMiddleware.php b/lib/private/AppFramework/Middleware/PublicShare/PublicShareMiddleware.php index 83e799e3d3b..a8aacc63724 100644 --- a/lib/private/AppFramework/Middleware/PublicShare/PublicShareMiddleware.php +++ b/lib/private/AppFramework/Middleware/PublicShare/PublicShareMiddleware.php @@ -29,6 +29,7 @@ class PublicShareMiddleware extends Middleware { ) { } + #[\Override] public function beforeController($controller, $methodName) { if (!($controller instanceof PublicShareController)) { return; @@ -79,6 +80,7 @@ class PublicShareMiddleware extends Middleware { throw new NotFoundException(); } + #[\Override] public function afterException($controller, $methodName, \Exception $exception) { if (!($controller instanceof PublicShareController)) { throw $exception; diff --git a/lib/private/AppFramework/Middleware/Security/BruteForceMiddleware.php b/lib/private/AppFramework/Middleware/Security/BruteForceMiddleware.php index 4b4425517e0..2630e7821f8 100644 --- a/lib/private/AppFramework/Middleware/Security/BruteForceMiddleware.php +++ b/lib/private/AppFramework/Middleware/Security/BruteForceMiddleware.php @@ -44,6 +44,7 @@ class BruteForceMiddleware extends Middleware { /** * {@inheritDoc} */ + #[\Override] public function beforeController($controller, $methodName) { parent::beforeController($controller, $methodName); @@ -70,6 +71,7 @@ class BruteForceMiddleware extends Middleware { /** * {@inheritDoc} */ + #[\Override] public function afterController($controller, $methodName, Response $response) { if ($response->isThrottled()) { try { @@ -123,6 +125,7 @@ class BruteForceMiddleware extends Middleware { * @throws \Exception * @return Response */ + #[\Override] public function afterException($controller, $methodName, \Exception $exception): Response { if ($exception instanceof MaxDelayReached) { if ($controller instanceof OCSController) { diff --git a/lib/private/AppFramework/Middleware/Security/CSPMiddleware.php b/lib/private/AppFramework/Middleware/Security/CSPMiddleware.php index e88c9563c00..3cc4fe1a101 100644 --- a/lib/private/AppFramework/Middleware/Security/CSPMiddleware.php +++ b/lib/private/AppFramework/Middleware/Security/CSPMiddleware.php @@ -33,6 +33,7 @@ class CSPMiddleware extends Middleware { * @param Response $response * @return Response */ + #[\Override] public function afterController($controller, $methodName, Response $response): Response { $policy = !is_null($response->getContentSecurityPolicy()) ? $response->getContentSecurityPolicy() : new ContentSecurityPolicy(); diff --git a/lib/private/AppFramework/Middleware/Security/FeaturePolicyMiddleware.php b/lib/private/AppFramework/Middleware/Security/FeaturePolicyMiddleware.php index 632eceaa71b..d1d9bfbe5b4 100644 --- a/lib/private/AppFramework/Middleware/Security/FeaturePolicyMiddleware.php +++ b/lib/private/AppFramework/Middleware/Security/FeaturePolicyMiddleware.php @@ -30,6 +30,7 @@ class FeaturePolicyMiddleware extends Middleware { * @param Response $response * @return Response */ + #[\Override] public function afterController($controller, $methodName, Response $response): Response { $policy = !is_null($response->getFeaturePolicy()) ? $response->getFeaturePolicy() : new FeaturePolicy(); diff --git a/lib/private/AppFramework/Middleware/Security/PasswordConfirmationMiddleware.php b/lib/private/AppFramework/Middleware/Security/PasswordConfirmationMiddleware.php index 60b925876b1..94fc329d5c7 100644 --- a/lib/private/AppFramework/Middleware/Security/PasswordConfirmationMiddleware.php +++ b/lib/private/AppFramework/Middleware/Security/PasswordConfirmationMiddleware.php @@ -45,6 +45,7 @@ class PasswordConfirmationMiddleware extends Middleware { /** * @throws NotConfirmedException */ + #[\Override] public function beforeController(Controller $controller, string $methodName) { if (!$this->needsPasswordConfirmation()) { return; diff --git a/lib/private/AppFramework/Middleware/Security/RateLimitingMiddleware.php b/lib/private/AppFramework/Middleware/Security/RateLimitingMiddleware.php index 906e57a86ef..bec5a3c3db3 100644 --- a/lib/private/AppFramework/Middleware/Security/RateLimitingMiddleware.php +++ b/lib/private/AppFramework/Middleware/Security/RateLimitingMiddleware.php @@ -68,6 +68,7 @@ class RateLimitingMiddleware extends Middleware { * {@inheritDoc} * @throws RateLimitExceededException */ + #[\Override] public function beforeController(Controller $controller, string $methodName): void { parent::beforeController($controller, $methodName); $rateLimitIdentifier = get_class($controller) . '::' . $methodName; @@ -184,6 +185,7 @@ class RateLimitingMiddleware extends Middleware { /** * {@inheritDoc} */ + #[\Override] public function afterException(Controller $controller, string $methodName, \Exception $exception): Response { if ($exception instanceof RateLimitExceededException) { if (stripos($this->request->getHeader('Accept'), 'html') === false) { diff --git a/lib/private/AppFramework/Middleware/Security/ReloadExecutionMiddleware.php b/lib/private/AppFramework/Middleware/Security/ReloadExecutionMiddleware.php index 298921eedaa..488093149ad 100644 --- a/lib/private/AppFramework/Middleware/Security/ReloadExecutionMiddleware.php +++ b/lib/private/AppFramework/Middleware/Security/ReloadExecutionMiddleware.php @@ -25,12 +25,14 @@ class ReloadExecutionMiddleware extends Middleware { ) { } + #[\Override] public function beforeController($controller, $methodName) { if ($this->session->exists('clearingExecutionContexts')) { throw new ReloadExecutionException(); } } + #[\Override] public function afterException($controller, $methodName, \Exception $exception) { if ($exception instanceof ReloadExecutionException) { $this->session->remove('clearingExecutionContexts'); diff --git a/lib/private/AppFramework/Middleware/Security/SameSiteCookieMiddleware.php b/lib/private/AppFramework/Middleware/Security/SameSiteCookieMiddleware.php index 7334b56bac1..99263d125cf 100644 --- a/lib/private/AppFramework/Middleware/Security/SameSiteCookieMiddleware.php +++ b/lib/private/AppFramework/Middleware/Security/SameSiteCookieMiddleware.php @@ -24,6 +24,7 @@ class SameSiteCookieMiddleware extends Middleware { ) { } + #[\Override] public function beforeController($controller, $methodName) { $requestUri = $this->request->getScriptName(); $processingScript = explode('/', $requestUri); @@ -44,6 +45,7 @@ class SameSiteCookieMiddleware extends Middleware { } } + #[\Override] public function afterException($controller, $methodName, \Exception $exception) { if ($exception instanceof LaxSameSiteCookieFailedException) { $response = new Response(); diff --git a/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php b/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php index 2a7b058fd51..8731dab4835 100644 --- a/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php +++ b/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php @@ -105,6 +105,7 @@ class SecurityMiddleware extends Middleware { * * @suppress PhanUndeclaredClassConstant */ + #[\Override] public function beforeController($controller, $methodName) { // this will set the current navigation entry of the app, use this only // for normal HTML requests and not for AJAX requests @@ -250,6 +251,7 @@ class SecurityMiddleware extends Middleware { * @return Response a Response object or null in case that the exception could not be handled * @throws \Exception the passed in exception if it can't handle it */ + #[\Override] public function afterException($controller, $methodName, \Exception $exception): Response { if ($exception instanceof SecurityException) { if ($exception instanceof StrictCookieMissingException) { diff --git a/lib/private/AppFramework/Middleware/SessionMiddleware.php b/lib/private/AppFramework/Middleware/SessionMiddleware.php index c1cff28ce78..2f10b24ec60 100644 --- a/lib/private/AppFramework/Middleware/SessionMiddleware.php +++ b/lib/private/AppFramework/Middleware/SessionMiddleware.php @@ -26,6 +26,7 @@ class SessionMiddleware extends Middleware { * @param Controller $controller * @param string $methodName */ + #[\Override] public function beforeController($controller, $methodName) { if ($this->reflector->hasAnnotationOrAttribute('UseSession', UseSession::class)) { $this->session->reopen(); @@ -38,6 +39,7 @@ class SessionMiddleware extends Middleware { * @param Response $response * @return Response */ + #[\Override] public function afterController($controller, $methodName, Response $response) { if ($this->reflector->hasAnnotationOrAttribute('UseSession', UseSession::class)) { $this->session->close(); diff --git a/lib/private/AppFramework/OCS/V1Response.php b/lib/private/AppFramework/OCS/V1Response.php index c628a2c7b50..11d674b57f5 100644 --- a/lib/private/AppFramework/OCS/V1Response.php +++ b/lib/private/AppFramework/OCS/V1Response.php @@ -23,6 +23,7 @@ class V1Response extends BaseResponse { * * @return Http::STATUS_* */ + #[\Override] public function getStatus() { $status = parent::getStatus(); if ($status === OCSController::RESPOND_UNAUTHORISED) { @@ -37,6 +38,7 @@ class V1Response extends BaseResponse { * * @return int */ + #[\Override] public function getOCSStatus() { $status = parent::getOCSStatus(); @@ -53,6 +55,7 @@ class V1Response extends BaseResponse { * * @return string */ + #[\Override] public function render() { $meta = [ 'status' => $this->getOCSStatus() === 100 ? 'ok' : 'failure', diff --git a/lib/private/AppFramework/OCS/V2Response.php b/lib/private/AppFramework/OCS/V2Response.php index 0398a587ec4..1c6c2cd076e 100644 --- a/lib/private/AppFramework/OCS/V2Response.php +++ b/lib/private/AppFramework/OCS/V2Response.php @@ -23,6 +23,7 @@ class V2Response extends BaseResponse { * * @return Http::STATUS_* */ + #[\Override] public function getStatus() { $status = parent::getStatus(); if ($status === OCSController::RESPOND_UNAUTHORISED) { @@ -44,6 +45,7 @@ class V2Response extends BaseResponse { * * @return string */ + #[\Override] public function render() { $status = parent::getStatus(); diff --git a/lib/private/AppFramework/ScopedPsrLogger.php b/lib/private/AppFramework/ScopedPsrLogger.php index a413710a7d7..4a14a9d0b03 100644 --- a/lib/private/AppFramework/ScopedPsrLogger.php +++ b/lib/private/AppFramework/ScopedPsrLogger.php @@ -18,6 +18,7 @@ class ScopedPsrLogger implements LoggerInterface { ) { } + #[\Override] public function emergency($message, array $context = []): void { $this->inner->emergency( $message, @@ -30,6 +31,7 @@ class ScopedPsrLogger implements LoggerInterface { ); } + #[\Override] public function alert($message, array $context = []): void { $this->inner->alert( $message, @@ -42,6 +44,7 @@ class ScopedPsrLogger implements LoggerInterface { ); } + #[\Override] public function critical($message, array $context = []): void { $this->inner->critical( $message, @@ -54,6 +57,7 @@ class ScopedPsrLogger implements LoggerInterface { ); } + #[\Override] public function error($message, array $context = []): void { $this->inner->error( $message, @@ -66,6 +70,7 @@ class ScopedPsrLogger implements LoggerInterface { ); } + #[\Override] public function warning($message, array $context = []): void { $this->inner->warning( $message, @@ -78,6 +83,7 @@ class ScopedPsrLogger implements LoggerInterface { ); } + #[\Override] public function notice($message, array $context = []): void { $this->inner->notice( $message, @@ -90,6 +96,7 @@ class ScopedPsrLogger implements LoggerInterface { ); } + #[\Override] public function info($message, array $context = []): void { $this->inner->info( $message, @@ -102,6 +109,7 @@ class ScopedPsrLogger implements LoggerInterface { ); } + #[\Override] public function debug($message, array $context = []): void { $this->inner->debug( $message, @@ -114,6 +122,7 @@ class ScopedPsrLogger implements LoggerInterface { ); } + #[\Override] public function log($level, $message, array $context = []): void { $this->inner->log( $level, diff --git a/lib/private/AppFramework/Services/AppConfig.php b/lib/private/AppFramework/Services/AppConfig.php index 04d97738483..04178d042c4 100644 --- a/lib/private/AppFramework/Services/AppConfig.php +++ b/lib/private/AppFramework/Services/AppConfig.php @@ -30,6 +30,7 @@ class AppConfig implements IAppConfig { * @return string[] list of stored config keys * @since 20.0.0 */ + #[\Override] public function getAppKeys(): array { return $this->appConfig->getKeys($this->appName); } @@ -43,6 +44,7 @@ class AppConfig implements IAppConfig { * @return bool TRUE if key exists * @since 29.0.0 */ + #[\Override] public function hasAppKey(string $key, ?bool $lazy = false): bool { return $this->appConfig->hasKey($this->appName, $key, $lazy); } @@ -55,6 +57,7 @@ class AppConfig implements IAppConfig { * @throws AppConfigUnknownKeyException if config key is not known * @since 29.0.0 */ + #[\Override] public function isSensitive(string $key, ?bool $lazy = false): bool { return $this->appConfig->isSensitive($this->appName, $key, $lazy); } @@ -69,6 +72,7 @@ class AppConfig implements IAppConfig { * @see \OCP\IAppConfig for details about lazy loading * @since 29.0.0 */ + #[\Override] public function isLazy(string $key): bool { return $this->appConfig->isLazy($this->appName, $key); } @@ -82,6 +86,7 @@ class AppConfig implements IAppConfig { * @return array [configKey => configValue] * @since 29.0.0 */ + #[\Override] public function getAllAppValues(string $key = '', bool $filtered = false): array { return $this->appConfig->getAllValues($this->appName, $key, $filtered); } @@ -94,6 +99,7 @@ class AppConfig implements IAppConfig { * @since 20.0.0 * @deprecated 29.0.0 use {@see setAppValueString()} */ + #[\Override] public function setAppValue(string $key, string $value): void { /** @psalm-suppress InternalMethod */ $this->appConfig->setValueMixed($this->appName, $key, $value); @@ -112,6 +118,7 @@ class AppConfig implements IAppConfig { * @since 29.0.0 * @see \OCP\IAppConfig for explanation about lazy loading */ + #[\Override] public function setAppValueString( string $key, string $value, @@ -134,6 +141,7 @@ class AppConfig implements IAppConfig { * @since 29.0.0 * @see \OCP\IAppConfig for explanation about lazy loading */ + #[\Override] public function setAppValueInt( string $key, int $value, @@ -156,6 +164,7 @@ class AppConfig implements IAppConfig { * @since 29.0.0 * @see \OCP\IAppConfig for explanation about lazy loading */ + #[\Override] public function setAppValueFloat( string $key, float $value, @@ -177,6 +186,7 @@ class AppConfig implements IAppConfig { * @since 29.0.0 * @see \OCP\IAppConfig for explanation about lazy loading */ + #[\Override] public function setAppValueBool( string $key, bool $value, @@ -199,6 +209,7 @@ class AppConfig implements IAppConfig { * @since 29.0.0 * @see \OCP\IAppConfig for explanation about lazy loading */ + #[\Override] public function setAppValueArray( string $key, array $value, @@ -216,6 +227,7 @@ class AppConfig implements IAppConfig { * @deprecated 29.0.0 use {@see getAppValueString()} * @return string */ + #[\Override] public function getAppValue(string $key, string $default = ''): string { /** @psalm-suppress InternalMethod */ /** @psalm-suppress UndefinedInterfaceMethod */ @@ -235,6 +247,7 @@ class AppConfig implements IAppConfig { * @since 29.0.0 * @see \OCP\IAppConfig for explanation about lazy loading */ + #[\Override] public function getAppValueString(string $key, string $default = '', bool $lazy = false): string { return $this->appConfig->getValueString($this->appName, $key, $default, $lazy); } @@ -252,6 +265,7 @@ class AppConfig implements IAppConfig { * @since 29.0.0 * @see \OCP\IAppConfig for explanation about lazy loading */ + #[\Override] public function getAppValueInt(string $key, int $default = 0, bool $lazy = false): int { return $this->appConfig->getValueInt($this->appName, $key, $default, $lazy); } @@ -269,6 +283,7 @@ class AppConfig implements IAppConfig { * @since 29.0.0 * @see \OCP\IAppConfig for explanation about lazy loading */ + #[\Override] public function getAppValueFloat(string $key, float $default = 0, bool $lazy = false): float { return $this->appConfig->getValueFloat($this->appName, $key, $default, $lazy); } @@ -286,6 +301,7 @@ class AppConfig implements IAppConfig { * @since 29.0.0 * @see \OCP\IAppConfig for explanation about lazy loading */ + #[\Override] public function getAppValueBool(string $key, bool $default = false, bool $lazy = false): bool { return $this->appConfig->getValueBool($this->appName, $key, $default, $lazy); } @@ -303,6 +319,7 @@ class AppConfig implements IAppConfig { * @since 29.0.0 * @see \OCP\IAppConfig for explanation about lazy loading */ + #[\Override] public function getAppValueArray(string $key, array $default = [], bool $lazy = false): array { return $this->appConfig->getValueArray($this->appName, $key, $default, $lazy); } @@ -313,6 +330,7 @@ class AppConfig implements IAppConfig { * @param string $key the key of the value, under which it was saved * @since 20.0.0 */ + #[\Override] public function deleteAppValue(string $key): void { $this->appConfig->deleteKey($this->appName, $key); } @@ -322,18 +340,22 @@ class AppConfig implements IAppConfig { * * @since 20.0.0 */ + #[\Override] public function deleteAppValues(): void { $this->appConfig->deleteApp($this->appName); } + #[\Override] public function setUserValue(string $userId, string $key, string $value, ?string $preCondition = null): void { $this->config->setUserValue($userId, $this->appName, $key, $value, $preCondition); } + #[\Override] public function getUserValue(string $userId, string $key, string $default = ''): string { return $this->config->getUserValue($userId, $this->appName, $key, $default); } + #[\Override] public function deleteUserValue(string $userId, string $key): void { $this->config->deleteUserValue($userId, $this->appName, $key); } diff --git a/lib/private/AppFramework/Services/InitialState.php b/lib/private/AppFramework/Services/InitialState.php index 51c5fbe672d..d2caca47f7e 100644 --- a/lib/private/AppFramework/Services/InitialState.php +++ b/lib/private/AppFramework/Services/InitialState.php @@ -18,10 +18,12 @@ class InitialState implements IInitialState { ) { } + #[\Override] public function provideInitialState(string $key, $data): void { $this->state->provideInitialState($this->appName, $key, $data); } + #[\Override] public function provideLazyInitialState(string $key, \Closure $closure): void { $this->state->provideLazyInitialState($this->appName, $key, $closure); } diff --git a/lib/private/AppFramework/Utility/ControllerMethodReflector.php b/lib/private/AppFramework/Utility/ControllerMethodReflector.php index 1d30ff2e137..8d76d6a1028 100644 --- a/lib/private/AppFramework/Utility/ControllerMethodReflector.php +++ b/lib/private/AppFramework/Utility/ControllerMethodReflector.php @@ -102,6 +102,7 @@ class ControllerMethodReflector implements IControllerMethodReflector { * @return string|null type in the type parameters (@param int $something) * would return int or null if not existing */ + #[\Override] public function getType(string $parameter) { if (array_key_exists($parameter, $this->types)) { return $this->types[$parameter]; @@ -121,6 +122,7 @@ class ControllerMethodReflector implements IControllerMethodReflector { /** * @return array the arguments of the method with key => default value */ + #[\Override] public function getParameters(): array { return $this->parameters; } @@ -130,6 +132,7 @@ class ControllerMethodReflector implements IControllerMethodReflector { * * @param class-string $attributeClass */ + #[\Override] public function hasAnnotationOrAttribute(?string $annotationName, string $attributeClass): bool { if (!empty($this->reflectionMethod->getAttributes($attributeClass))) { return true; @@ -148,6 +151,7 @@ class ControllerMethodReflector implements IControllerMethodReflector { * @param string $name the name of the annotation * @return bool true if the annotation is found */ + #[\Override] public function hasAnnotation(string $name): bool { $name = strtolower($name); return array_key_exists($name, $this->annotations); diff --git a/lib/private/AppFramework/Utility/SimpleContainer.php b/lib/private/AppFramework/Utility/SimpleContainer.php index 429b7d617ed..9afdfbef718 100644 --- a/lib/private/AppFramework/Utility/SimpleContainer.php +++ b/lib/private/AppFramework/Utility/SimpleContainer.php @@ -39,10 +39,12 @@ class SimpleContainer implements ArrayAccess, ContainerInterface, IContainer { * @param class-string|string $id * @return ($id is class-string ? T : mixed) */ + #[\Override] public function get(string $id): mixed { return $this->query($id); } + #[\Override] public function has(string $id): bool { // If a service is no registered but is an existing class, we can probably load it return isset($this->container[$id]) || class_exists($id); @@ -120,6 +122,7 @@ class SimpleContainer implements ArrayAccess, ContainerInterface, IContainer { * @inheritDoc * @param list $chain */ + #[\Override] public function resolve(string $name, array $chain = []): mixed { $baseMsg = 'Could not resolve ' . $name . '!'; try { @@ -140,6 +143,7 @@ class SimpleContainer implements ArrayAccess, ContainerInterface, IContainer { * @inheritDoc * @param list $chain */ + #[\Override] public function query(string $name, bool $autoload = true, array $chain = []): mixed { $name = $this->sanitizeName($name); if (isset($this->container[$name])) { @@ -161,10 +165,12 @@ class SimpleContainer implements ArrayAccess, ContainerInterface, IContainer { throw new QueryNotFoundException('Could not resolve ' . $name . '!'); } + #[\Override] public function registerParameter(string $name, mixed $value): void { $this[$name] = $value; } + #[\Override] public function registerService(string $name, Closure $closure, bool $shared = true): void { $wrapped = function () use ($closure) { return $closure($this); @@ -187,6 +193,7 @@ class SimpleContainer implements ArrayAccess, ContainerInterface, IContainer { * @param string $alias the alias that should be registered * @param string $target the target that should be resolved instead */ + #[\Override] public function registerAlias(string $alias, string $target): void { $this->registerService($alias, function (ContainerInterface $container) use ($target): mixed { return $container->get($target); @@ -222,6 +229,7 @@ class SimpleContainer implements ArrayAccess, ContainerInterface, IContainer { /** * @deprecated 20.0.0 use \Psr\Container\ContainerInterface::has */ + #[\Override] public function offsetExists($id): bool { return $this->container->offsetExists($id); } @@ -230,6 +238,7 @@ class SimpleContainer implements ArrayAccess, ContainerInterface, IContainer { * @deprecated 20.0.0 use \Psr\Container\ContainerInterface::get * @return mixed */ + #[\Override] #[\ReturnTypeWillChange] public function offsetGet($id) { return $this->container->offsetGet($id); @@ -238,6 +247,7 @@ class SimpleContainer implements ArrayAccess, ContainerInterface, IContainer { /** * @deprecated 20.0.0 use \OCP\IContainer::registerService */ + #[\Override] public function offsetSet($offset, $value): void { $this->container->offsetSet($offset, $value); } @@ -245,6 +255,7 @@ class SimpleContainer implements ArrayAccess, ContainerInterface, IContainer { /** * @deprecated 20.0.0 */ + #[\Override] public function offsetUnset($offset): void { $this->container->offsetUnset($offset); } diff --git a/lib/private/AppFramework/Utility/TimeFactory.php b/lib/private/AppFramework/Utility/TimeFactory.php index 0584fd05ef9..5aba31577b2 100644 --- a/lib/private/AppFramework/Utility/TimeFactory.php +++ b/lib/private/AppFramework/Utility/TimeFactory.php @@ -29,6 +29,7 @@ class TimeFactory implements ITimeFactory { * @since 8.0.0 * @deprecated 26.0.0 {@see ITimeFactory::now()} */ + #[\Override] public function getTime(): int { return time(); } @@ -40,13 +41,16 @@ class TimeFactory implements ITimeFactory { * @since 15.0.0 * @deprecated 26.0.0 {@see ITimeFactory::now()} */ + #[\Override] public function getDateTime(string $time = 'now', ?\DateTimeZone $timezone = null): \DateTime { return new \DateTime($time, $timezone); } + #[\Override] public function now(): \DateTimeImmutable { return new \DateTimeImmutable('now', $this->timezone); } + #[\Override] public function withTimeZone(\DateTimeZone $timezone): static { $clone = clone $this; $clone->timezone = $timezone; @@ -54,6 +58,7 @@ class TimeFactory implements ITimeFactory { return $clone; } + #[\Override] public function getTimeZone(?string $timezone = null): \DateTimeZone { if ($timezone !== null) { return new \DateTimeZone($timezone); diff --git a/lib/private/Archive/TAR.php b/lib/private/Archive/TAR.php index 4de0f35ccfa..1376e428060 100644 --- a/lib/private/Archive/TAR.php +++ b/lib/private/Archive/TAR.php @@ -61,6 +61,7 @@ class TAR extends Archive { /** * add an empty folder to the archive */ + #[\Override] public function addFolder(string $path): bool { $tmpBase = Server::get(ITempManager::class)->getTemporaryFolder(); $path = rtrim($path, '/') . '/'; @@ -87,6 +88,7 @@ class TAR extends Archive { * * @param string $source either a local file or string data */ + #[\Override] public function addFile(string $path, string $source = ''): bool { if ($this->fileExists($path)) { $this->remove($path); @@ -103,6 +105,7 @@ class TAR extends Archive { /** * rename a file or folder in the archive */ + #[\Override] public function rename(string $source, string $dest): bool { //no proper way to delete, rename entire archive, rename file and remake archive $tmp = Server::get(ITempManager::class)->getTemporaryFolder(); @@ -137,6 +140,7 @@ class TAR extends Archive { /** * get the uncompressed size of a file in the archive */ + #[\Override] public function filesize(string $path): false|int|float { $stat = $this->getHeader($path); return $stat['size'] ?? false; @@ -147,6 +151,7 @@ class TAR extends Archive { * * @return int|false */ + #[\Override] public function mtime(string $path) { $stat = $this->getHeader($path); return $stat['mtime'] ?? false; @@ -155,6 +160,7 @@ class TAR extends Archive { /** * get the files in a folder */ + #[\Override] public function getFolder(string $path): array { $files = $this->getFiles(); $folderContent = []; @@ -179,6 +185,7 @@ class TAR extends Archive { /** * get all files in the archive */ + #[\Override] public function getFiles(): array { if ($this->fileList !== false) { return $this->fileList; @@ -204,6 +211,7 @@ class TAR extends Archive { * * @return string|false */ + #[\Override] public function getFile(string $path) { $string = $this->tar->extractInString($path); /** @var ?string $string */ @@ -217,6 +225,7 @@ class TAR extends Archive { /** * extract a single file from the archive */ + #[\Override] public function extractFile(string $path, string $dest): bool { $tmp = Server::get(ITempManager::class)->getTemporaryFolder(); if (!$this->fileExists($path)) { @@ -237,6 +246,7 @@ class TAR extends Archive { /** * extract the archive */ + #[\Override] public function extract(string $dest): bool { return $this->tar->extract($dest); } @@ -244,6 +254,7 @@ class TAR extends Archive { /** * check if a file or folder exists in the archive */ + #[\Override] public function fileExists(string $path): bool { $files = $this->getFiles(); if ((in_array($path, $files)) || (in_array($path . '/', $files))) { @@ -267,6 +278,7 @@ class TAR extends Archive { /** * remove a file or folder from the archive */ + #[\Override] public function remove(string $path): bool { if (!$this->fileExists($path)) { return false; @@ -288,6 +300,7 @@ class TAR extends Archive { * * @return bool|resource */ + #[\Override] public function getStream(string $path, string $mode) { $lastPoint = strrpos($path, '.'); if ($lastPoint !== false) { diff --git a/lib/private/Archive/ZIP.php b/lib/private/Archive/ZIP.php index 0ed83110632..e3d20ccfd66 100644 --- a/lib/private/Archive/ZIP.php +++ b/lib/private/Archive/ZIP.php @@ -33,6 +33,7 @@ class ZIP extends Archive { * @param string $path * @return bool */ + #[\Override] public function addFolder(string $path): bool { return $this->zip->addEmptyDir($path); } @@ -41,6 +42,7 @@ class ZIP extends Archive { * add a file to the archive * @param string $source either a local file or string data */ + #[\Override] public function addFile(string $path, string $source = ''): bool { if ($source && $source[0] === '/' && file_exists($source)) { $result = $this->zip->addFile($source, $path); @@ -57,6 +59,7 @@ class ZIP extends Archive { /** * rename a file or folder in the archive */ + #[\Override] public function rename(string $source, string $dest): bool { $source = $this->stripPath($source); $dest = $this->stripPath($dest); @@ -66,6 +69,7 @@ class ZIP extends Archive { /** * get the uncompressed size of a file in the archive */ + #[\Override] public function filesize(string $path): false|int|float { $stat = $this->zip->statName($path); return $stat['size'] ?? false; @@ -75,6 +79,7 @@ class ZIP extends Archive { * get the last modified time of a file in the archive * @return int|false */ + #[\Override] public function mtime(string $path) { return filemtime($this->path); } @@ -82,6 +87,7 @@ class ZIP extends Archive { /** * get the files in a folder */ + #[\Override] public function getFolder(string $path): array { // FIXME: multiple calls on getFolder would traverse // the whole file list over and over again @@ -128,6 +134,7 @@ class ZIP extends Archive { /** * get all files in the archive */ + #[\Override] public function getFiles(): array { $fileCount = $this->zip->numFiles; $files = []; @@ -141,6 +148,7 @@ class ZIP extends Archive { * get the content of a file * @return string|false */ + #[\Override] public function getFile(string $path) { return $this->zip->getFromName($path); } @@ -148,6 +156,7 @@ class ZIP extends Archive { /** * extract a single file from the archive */ + #[\Override] public function extractFile(string $path, string $dest): bool { $fp = $this->zip->getStream($path); if ($fp === false) { @@ -159,6 +168,7 @@ class ZIP extends Archive { /** * extract the archive */ + #[\Override] public function extract(string $dest): bool { return $this->zip->extractTo($dest); } @@ -166,6 +176,7 @@ class ZIP extends Archive { /** * check if a file or folder exists in the archive */ + #[\Override] public function fileExists(string $path): bool { return ($this->zip->locateName($path) !== false) || ($this->zip->locateName($path . '/') !== false); } @@ -173,6 +184,7 @@ class ZIP extends Archive { /** * remove a file or folder from the archive */ + #[\Override] public function remove(string $path): bool { if ($this->fileExists($path . '/')) { return $this->zip->deleteName($path . '/'); @@ -185,6 +197,7 @@ class ZIP extends Archive { * get a file handler * @return bool|resource */ + #[\Override] public function getStream(string $path, string $mode) { if ($mode === 'r' || $mode === 'rb') { return $this->zip->getStream($path); diff --git a/lib/private/Authentication/Exceptions/ExpiredTokenException.php b/lib/private/Authentication/Exceptions/ExpiredTokenException.php index eed2358d29d..58ee79dd41c 100644 --- a/lib/private/Authentication/Exceptions/ExpiredTokenException.php +++ b/lib/private/Authentication/Exceptions/ExpiredTokenException.php @@ -20,6 +20,7 @@ class ExpiredTokenException extends \OCP\Authentication\Exceptions\ExpiredTokenE parent::__construct($token); } + #[\Override] public function getToken(): IToken { $token = parent::getToken(); /** @var IToken $token We know that we passed OC interface from constructor */ diff --git a/lib/private/Authentication/Exceptions/WipeTokenException.php b/lib/private/Authentication/Exceptions/WipeTokenException.php index 6bf0565434a..00b28e8e2a1 100644 --- a/lib/private/Authentication/Exceptions/WipeTokenException.php +++ b/lib/private/Authentication/Exceptions/WipeTokenException.php @@ -20,6 +20,7 @@ class WipeTokenException extends \OCP\Authentication\Exceptions\WipeTokenExcepti parent::__construct($token); } + #[\Override] public function getToken(): IToken { $token = parent::getToken(); /** @var IToken $token We know that we passed OC interface from constructor */ diff --git a/lib/private/Authentication/Listeners/LoginFailedListener.php b/lib/private/Authentication/Listeners/LoginFailedListener.php index 7e46d2e7b24..c8747d53b55 100644 --- a/lib/private/Authentication/Listeners/LoginFailedListener.php +++ b/lib/private/Authentication/Listeners/LoginFailedListener.php @@ -27,6 +27,7 @@ class LoginFailedListener implements IEventListener { ) { } + #[\Override] public function handle(Event $event): void { if (!($event instanceof LoginFailed)) { return; diff --git a/lib/private/Authentication/Listeners/RemoteWipeActivityListener.php b/lib/private/Authentication/Listeners/RemoteWipeActivityListener.php index b071886fd74..a7c605569f4 100644 --- a/lib/private/Authentication/Listeners/RemoteWipeActivityListener.php +++ b/lib/private/Authentication/Listeners/RemoteWipeActivityListener.php @@ -28,6 +28,7 @@ class RemoteWipeActivityListener implements IEventListener { ) { } + #[\Override] public function handle(Event $event): void { if ($event instanceof RemoteWipeStarted) { $this->publishActivity('remote_wipe_start', $event->getToken()); diff --git a/lib/private/Authentication/Listeners/RemoteWipeEmailListener.php b/lib/private/Authentication/Listeners/RemoteWipeEmailListener.php index cf18ae2afcc..943df1e44e1 100644 --- a/lib/private/Authentication/Listeners/RemoteWipeEmailListener.php +++ b/lib/private/Authentication/Listeners/RemoteWipeEmailListener.php @@ -41,6 +41,7 @@ class RemoteWipeEmailListener implements IEventListener { /** * @param Event $event */ + #[\Override] public function handle(Event $event): void { if ($event instanceof RemoteWipeStarted) { $uid = $event->getToken()->getUID(); diff --git a/lib/private/Authentication/Listeners/RemoteWipeNotificationsListener.php b/lib/private/Authentication/Listeners/RemoteWipeNotificationsListener.php index 5e5b0fcaa50..b3fafa44c98 100644 --- a/lib/private/Authentication/Listeners/RemoteWipeNotificationsListener.php +++ b/lib/private/Authentication/Listeners/RemoteWipeNotificationsListener.php @@ -27,6 +27,7 @@ class RemoteWipeNotificationsListener implements IEventListener { ) { } + #[\Override] public function handle(Event $event): void { if ($event instanceof RemoteWipeStarted) { $this->sendNotification('remote_wipe_start', $event->getToken()); diff --git a/lib/private/Authentication/Listeners/UserDeletedFilesCleanupListener.php b/lib/private/Authentication/Listeners/UserDeletedFilesCleanupListener.php index a619021d192..45de836482d 100644 --- a/lib/private/Authentication/Listeners/UserDeletedFilesCleanupListener.php +++ b/lib/private/Authentication/Listeners/UserDeletedFilesCleanupListener.php @@ -29,6 +29,7 @@ class UserDeletedFilesCleanupListener implements IEventListener { ) { } + #[\Override] public function handle(Event $event): void { $user = $event->getUser(); diff --git a/lib/private/Authentication/Listeners/UserDeletedStoreCleanupListener.php b/lib/private/Authentication/Listeners/UserDeletedStoreCleanupListener.php index d7a9bf4fb29..a3933116bd2 100644 --- a/lib/private/Authentication/Listeners/UserDeletedStoreCleanupListener.php +++ b/lib/private/Authentication/Listeners/UserDeletedStoreCleanupListener.php @@ -22,6 +22,7 @@ class UserDeletedStoreCleanupListener implements IEventListener { ) { } + #[\Override] public function handle(Event $event): void { if (!($event instanceof UserDeletedEvent)) { return; diff --git a/lib/private/Authentication/Listeners/UserDeletedTokenCleanupListener.php b/lib/private/Authentication/Listeners/UserDeletedTokenCleanupListener.php index 6365e973ec6..bc67ef0feec 100644 --- a/lib/private/Authentication/Listeners/UserDeletedTokenCleanupListener.php +++ b/lib/private/Authentication/Listeners/UserDeletedTokenCleanupListener.php @@ -25,6 +25,7 @@ class UserDeletedTokenCleanupListener implements IEventListener { ) { } + #[\Override] public function handle(Event $event): void { if (!($event instanceof UserDeletedEvent)) { // Unrelated diff --git a/lib/private/Authentication/Listeners/UserDeletedWebAuthnCleanupListener.php b/lib/private/Authentication/Listeners/UserDeletedWebAuthnCleanupListener.php index d025a2150a3..cd3f9af5924 100644 --- a/lib/private/Authentication/Listeners/UserDeletedWebAuthnCleanupListener.php +++ b/lib/private/Authentication/Listeners/UserDeletedWebAuthnCleanupListener.php @@ -21,6 +21,7 @@ class UserDeletedWebAuthnCleanupListener implements IEventListener { ) { } + #[\Override] public function handle(Event $event): void { if (!($event instanceof UserDeletedEvent)) { return; diff --git a/lib/private/Authentication/Listeners/UserLoggedInListener.php b/lib/private/Authentication/Listeners/UserLoggedInListener.php index a4fc2d50611..2eafc7e1c4e 100644 --- a/lib/private/Authentication/Listeners/UserLoggedInListener.php +++ b/lib/private/Authentication/Listeners/UserLoggedInListener.php @@ -22,6 +22,7 @@ class UserLoggedInListener implements IEventListener { ) { } + #[\Override] public function handle(Event $event): void { if (!($event instanceof PostLoginEvent)) { return; diff --git a/lib/private/Authentication/Login/ClearLostPasswordTokensCommand.php b/lib/private/Authentication/Login/ClearLostPasswordTokensCommand.php index cd40348b056..0b6bb19da80 100644 --- a/lib/private/Authentication/Login/ClearLostPasswordTokensCommand.php +++ b/lib/private/Authentication/Login/ClearLostPasswordTokensCommand.php @@ -19,6 +19,7 @@ class ClearLostPasswordTokensCommand extends ALoginCommand { /** * User has successfully logged in, now remove the password reset link, when it is available */ + #[\Override] public function process(LoginData $loginData): LoginResult { $this->config->deleteUserValue( $loginData->getUser()->getUID(), diff --git a/lib/private/Authentication/Login/CompleteLoginCommand.php b/lib/private/Authentication/Login/CompleteLoginCommand.php index 974775a2a3d..3726de7cc3a 100644 --- a/lib/private/Authentication/Login/CompleteLoginCommand.php +++ b/lib/private/Authentication/Login/CompleteLoginCommand.php @@ -16,6 +16,7 @@ class CompleteLoginCommand extends ALoginCommand { ) { } + #[\Override] public function process(LoginData $loginData): LoginResult { $this->userSession->completeLogin( $loginData->getUser(), diff --git a/lib/private/Authentication/Login/CreateSessionTokenCommand.php b/lib/private/Authentication/Login/CreateSessionTokenCommand.php index 806af13eae4..8ad098cebe1 100644 --- a/lib/private/Authentication/Login/CreateSessionTokenCommand.php +++ b/lib/private/Authentication/Login/CreateSessionTokenCommand.php @@ -19,6 +19,7 @@ class CreateSessionTokenCommand extends ALoginCommand { ) { } + #[\Override] public function process(LoginData $loginData): LoginResult { if ($this->config->getSystemValueInt('remember_login_cookie_lifetime', 60 * 60 * 24 * 15) === 0) { $loginData->setRememberLogin(false); diff --git a/lib/private/Authentication/Login/FinishRememberedLoginCommand.php b/lib/private/Authentication/Login/FinishRememberedLoginCommand.php index e455a67f31d..e76ecd61407 100644 --- a/lib/private/Authentication/Login/FinishRememberedLoginCommand.php +++ b/lib/private/Authentication/Login/FinishRememberedLoginCommand.php @@ -18,6 +18,7 @@ class FinishRememberedLoginCommand extends ALoginCommand { ) { } + #[\Override] public function process(LoginData $loginData): LoginResult { if ($loginData->isRememberLogin() && !$this->config->getSystemValueBool('auto_logout', false)) { $this->userSession->createRememberMeToken($loginData->getUser()); diff --git a/lib/private/Authentication/Login/FlowV2EphemeralSessionsCommand.php b/lib/private/Authentication/Login/FlowV2EphemeralSessionsCommand.php index 362aab7933e..40b78229306 100644 --- a/lib/private/Authentication/Login/FlowV2EphemeralSessionsCommand.php +++ b/lib/private/Authentication/Login/FlowV2EphemeralSessionsCommand.php @@ -21,6 +21,7 @@ class FlowV2EphemeralSessionsCommand extends ALoginCommand { ) { } + #[\Override] public function process(LoginData $loginData): LoginResult { $loginV2GrantRoute = $this->urlGenerator->linkToRoute('core.ClientFlowLoginV2.grantPage'); if (str_starts_with($loginData->getRedirectUrl() ?? '', $loginV2GrantRoute)) { diff --git a/lib/private/Authentication/Login/LoggedInCheckCommand.php b/lib/private/Authentication/Login/LoggedInCheckCommand.php index 58a07691943..7b359c619aa 100644 --- a/lib/private/Authentication/Login/LoggedInCheckCommand.php +++ b/lib/private/Authentication/Login/LoggedInCheckCommand.php @@ -20,6 +20,7 @@ class LoggedInCheckCommand extends ALoginCommand { ) { } + #[\Override] public function process(LoginData $loginData): LoginResult { if ($loginData->getUser() === false) { $loginName = $loginData->getUsername(); diff --git a/lib/private/Authentication/Login/PreLoginHookCommand.php b/lib/private/Authentication/Login/PreLoginHookCommand.php index 5fd8a9dbaef..71f545f79b7 100644 --- a/lib/private/Authentication/Login/PreLoginHookCommand.php +++ b/lib/private/Authentication/Login/PreLoginHookCommand.php @@ -17,6 +17,7 @@ class PreLoginHookCommand extends ALoginCommand { ) { } + #[\Override] public function process(LoginData $loginData): LoginResult { if ($this->userManager instanceof PublicEmitter) { $this->userManager->emit( diff --git a/lib/private/Authentication/Login/SetUserTimezoneCommand.php b/lib/private/Authentication/Login/SetUserTimezoneCommand.php index 635be703336..182e6967227 100644 --- a/lib/private/Authentication/Login/SetUserTimezoneCommand.php +++ b/lib/private/Authentication/Login/SetUserTimezoneCommand.php @@ -20,6 +20,7 @@ class SetUserTimezoneCommand extends ALoginCommand { ) { } + #[\Override] public function process(LoginData $loginData): LoginResult { if ($loginData->getTimeZoneOffset() !== '' && $this->isValidTimezone($loginData->getTimeZone())) { $userId = $loginData->getUser()->getUID(); diff --git a/lib/private/Authentication/Login/TwoFactorCommand.php b/lib/private/Authentication/Login/TwoFactorCommand.php index af425744122..f770067824d 100644 --- a/lib/private/Authentication/Login/TwoFactorCommand.php +++ b/lib/private/Authentication/Login/TwoFactorCommand.php @@ -23,6 +23,7 @@ class TwoFactorCommand extends ALoginCommand { ) { } + #[\Override] public function process(LoginData $loginData): LoginResult { if (!$this->twoFactorManager->isTwoFactorAuthenticated($loginData->getUser())) { return $this->processNextOrFinishSuccessfully($loginData); diff --git a/lib/private/Authentication/Login/UidLoginCommand.php b/lib/private/Authentication/Login/UidLoginCommand.php index c722a5057cc..09c87ad3a8d 100644 --- a/lib/private/Authentication/Login/UidLoginCommand.php +++ b/lib/private/Authentication/Login/UidLoginCommand.php @@ -22,6 +22,7 @@ class UidLoginCommand extends ALoginCommand { * * @return LoginResult */ + #[\Override] public function process(LoginData $loginData): LoginResult { /* @var $loginResult IUser */ $user = $this->userManager->checkPasswordNoLogging( diff --git a/lib/private/Authentication/Login/UpdateLastPasswordConfirmCommand.php b/lib/private/Authentication/Login/UpdateLastPasswordConfirmCommand.php index a13dd1d6f17..a03ccd5d243 100644 --- a/lib/private/Authentication/Login/UpdateLastPasswordConfirmCommand.php +++ b/lib/private/Authentication/Login/UpdateLastPasswordConfirmCommand.php @@ -16,6 +16,7 @@ class UpdateLastPasswordConfirmCommand extends ALoginCommand { ) { } + #[\Override] public function process(LoginData $loginData): LoginResult { $this->session->set( 'last-password-confirm', diff --git a/lib/private/Authentication/Login/UserDisabledCheckCommand.php b/lib/private/Authentication/Login/UserDisabledCheckCommand.php index b8977b58304..d9c5fc3aa92 100644 --- a/lib/private/Authentication/Login/UserDisabledCheckCommand.php +++ b/lib/private/Authentication/Login/UserDisabledCheckCommand.php @@ -19,6 +19,7 @@ class UserDisabledCheckCommand extends ALoginCommand { ) { } + #[\Override] public function process(LoginData $loginData): LoginResult { $user = $this->userManager->get($loginData->getUsername()); if ($user !== null && $user->isEnabled() === false) { diff --git a/lib/private/Authentication/Login/WebAuthnLoginCommand.php b/lib/private/Authentication/Login/WebAuthnLoginCommand.php index 3c9dcacbc8f..3ceec3eeb6e 100644 --- a/lib/private/Authentication/Login/WebAuthnLoginCommand.php +++ b/lib/private/Authentication/Login/WebAuthnLoginCommand.php @@ -16,6 +16,7 @@ class WebAuthnLoginCommand extends ALoginCommand { ) { } + #[\Override] public function process(LoginData $loginData): LoginResult { $user = $this->userManager->get($loginData->getUsername()); $loginData->setUser($user); diff --git a/lib/private/Authentication/LoginCredentials/Store.php b/lib/private/Authentication/LoginCredentials/Store.php index 45812ba4350..bab1d1cf910 100644 --- a/lib/private/Authentication/LoginCredentials/Store.php +++ b/lib/private/Authentication/LoginCredentials/Store.php @@ -58,6 +58,7 @@ class Store implements IStore { * @return ICredentials the login credentials of the current user * @throws CredentialsUnavailableException */ + #[\Override] public function getLoginCredentials(): ICredentials { if ($this->tokenProvider === null) { throw new CredentialsUnavailableException(); diff --git a/lib/private/Authentication/Notifications/Notifier.php b/lib/private/Authentication/Notifications/Notifier.php index 7742eb95a2b..af92e476110 100644 --- a/lib/private/Authentication/Notifications/Notifier.php +++ b/lib/private/Authentication/Notifications/Notifier.php @@ -22,6 +22,7 @@ class Notifier implements INotifier { /** * @inheritDoc */ + #[\Override] public function prepare(INotification $notification, string $languageCode): INotification { if ($notification->getApp() !== 'auth') { // Not my app => throw @@ -60,6 +61,7 @@ class Notifier implements INotifier { * @return string * @since 17.0.0 */ + #[\Override] public function getID(): string { return 'auth'; } @@ -70,6 +72,7 @@ class Notifier implements INotifier { * @return string * @since 17.0.0 */ + #[\Override] public function getName(): string { return $this->factory->get('lib')->t('Authentication'); } diff --git a/lib/private/Authentication/Token/Manager.php b/lib/private/Authentication/Token/Manager.php index f3eb78876b0..836484dbf7f 100644 --- a/lib/private/Authentication/Token/Manager.php +++ b/lib/private/Authentication/Token/Manager.php @@ -34,6 +34,7 @@ class Manager implements IProvider, OCPIProvider { * @param int $remember whether the session token should be used for remember-me * @return OCPIToken */ + #[\Override] public function generateToken(string $token, string $uid, string $loginName, @@ -82,6 +83,7 @@ class Manager implements IProvider, OCPIProvider { * @param OCPIToken $token * @throws InvalidTokenException */ + #[\Override] public function updateToken(OCPIToken $token) { $provider = $this->getProvider($token); $provider->updateToken($token); @@ -93,6 +95,7 @@ class Manager implements IProvider, OCPIProvider { * @throws InvalidTokenException * @param OCPIToken $token */ + #[\Override] public function updateTokenActivity(OCPIToken $token) { $provider = $this->getProvider($token); $provider->updateTokenActivity($token); @@ -102,6 +105,7 @@ class Manager implements IProvider, OCPIProvider { * @param string $uid * @return OCPIToken[] */ + #[\Override] public function getTokenByUser(string $uid): array { return $this->publicKeyTokenProvider->getTokenByUser($uid); } @@ -114,6 +118,7 @@ class Manager implements IProvider, OCPIProvider { * @throws \RuntimeException when OpenSSL reports a problem * @return OCPIToken */ + #[\Override] public function getToken(string $tokenId): OCPIToken { try { return $this->publicKeyTokenProvider->getToken($tokenId); @@ -133,6 +138,7 @@ class Manager implements IProvider, OCPIProvider { * @throws InvalidTokenException * @return OCPIToken */ + #[\Override] public function getTokenById(int $tokenId): OCPIToken { try { return $this->publicKeyTokenProvider->getTokenById($tokenId); @@ -151,6 +157,7 @@ class Manager implements IProvider, OCPIProvider { * @throws InvalidTokenException * @return OCPIToken */ + #[\Override] public function renewSessionToken(string $oldSessionId, string $sessionId): OCPIToken { try { return $this->publicKeyTokenProvider->renewSessionToken($oldSessionId, $sessionId); @@ -168,28 +175,34 @@ class Manager implements IProvider, OCPIProvider { * @throws PasswordlessTokenException * @return string */ + #[\Override] public function getPassword(OCPIToken $savedToken, string $tokenId): string { $provider = $this->getProvider($savedToken); return $provider->getPassword($savedToken, $tokenId); } + #[\Override] public function setPassword(OCPIToken $token, string $tokenId, string $password) { $provider = $this->getProvider($token); $provider->setPassword($token, $tokenId, $password); } + #[\Override] public function invalidateToken(string $token) { $this->publicKeyTokenProvider->invalidateToken($token); } + #[\Override] public function invalidateTokenById(string $uid, int $id) { $this->publicKeyTokenProvider->invalidateTokenById($uid, $id); } + #[\Override] public function invalidateOldTokens() { $this->publicKeyTokenProvider->invalidateOldTokens(); } + #[\Override] public function invalidateLastUsedBefore(string $uid, int $before): void { $this->publicKeyTokenProvider->invalidateLastUsedBefore($uid, $before); } @@ -202,6 +215,7 @@ class Manager implements IProvider, OCPIProvider { * @throws InvalidTokenException * @throws \RuntimeException when OpenSSL reports a problem */ + #[\Override] public function rotate(OCPIToken $token, string $oldTokenId, string $newTokenId): OCPIToken { if ($token instanceof PublicKeyToken) { return $this->publicKeyTokenProvider->rotate($token, $oldTokenId, $newTokenId); @@ -225,14 +239,17 @@ class Manager implements IProvider, OCPIProvider { } + #[\Override] public function markPasswordInvalid(OCPIToken $token, string $tokenId) { $this->getProvider($token)->markPasswordInvalid($token, $tokenId); } + #[\Override] public function updatePasswords(string $uid, string $password) { $this->publicKeyTokenProvider->updatePasswords($uid, $password); } + #[\Override] public function invalidateTokensOfUser(string $uid, ?string $clientName) { $tokens = $this->getTokenByUser($uid); foreach ($tokens as $token) { diff --git a/lib/private/Authentication/Token/PublicKeyToken.php b/lib/private/Authentication/Token/PublicKeyToken.php index cf3a8b16141..11739507851 100644 --- a/lib/private/Authentication/Token/PublicKeyToken.php +++ b/lib/private/Authentication/Token/PublicKeyToken.php @@ -101,11 +101,13 @@ class PublicKeyToken extends Entity implements INamedToken, IWipeableToken { $this->addType('passwordInvalid', Types::BOOLEAN); } + #[\Override] public function getId(): int { assert(!is_string($this->id) && $this->id !== null); return $this->id; } + #[\Override] public function getUID(): string { return $this->uid; } @@ -115,6 +117,7 @@ class PublicKeyToken extends Entity implements INamedToken, IWipeableToken { * * @return string */ + #[\Override] public function getLoginName(): string { return parent::getLoginName(); } @@ -122,10 +125,12 @@ class PublicKeyToken extends Entity implements INamedToken, IWipeableToken { /** * Get the (encrypted) login password */ + #[\Override] public function getPassword(): ?string { return parent::getPassword(); } + #[\Override] public function jsonSerialize(): array { return [ 'id' => $this->id, @@ -141,6 +146,7 @@ class PublicKeyToken extends Entity implements INamedToken, IWipeableToken { * * @return int */ + #[\Override] public function getLastCheck(): int { return parent::getLastCheck(); } @@ -148,10 +154,12 @@ class PublicKeyToken extends Entity implements INamedToken, IWipeableToken { /** * Get the timestamp of the last password check */ + #[\Override] public function setLastCheck(int $time): void { parent::setLastCheck($time); } + #[\Override] public function getScope(): string { $scope = parent::getScope(); if ($scope === null) { @@ -161,6 +169,7 @@ class PublicKeyToken extends Entity implements INamedToken, IWipeableToken { return $scope; } + #[\Override] public function getScopeAsArray(): array { $scope = json_decode($this->getScope(), true); if (!$scope) { @@ -171,6 +180,7 @@ class PublicKeyToken extends Entity implements INamedToken, IWipeableToken { return $scope; } + #[\Override] public function setScope(array|string|null $scope): void { if (is_array($scope)) { parent::setScope(json_encode($scope)); @@ -179,26 +189,32 @@ class PublicKeyToken extends Entity implements INamedToken, IWipeableToken { } } + #[\Override] public function getName(): string { return parent::getName(); } + #[\Override] public function setName(string $name): void { parent::setName($name); } + #[\Override] public function getRemember(): int { return parent::getRemember(); } + #[\Override] public function setToken(string $token): void { parent::setToken($token); } + #[\Override] public function setPassword(?string $password = null): void { parent::setPassword($password); } + #[\Override] public function setExpires($expires): void { parent::setExpires($expires); } @@ -214,6 +230,7 @@ class PublicKeyToken extends Entity implements INamedToken, IWipeableToken { parent::setPasswordInvalid($invalid); } + #[\Override] public function wipe(): void { parent::setType(IToken::WIPE_TOKEN); } diff --git a/lib/private/Authentication/Token/PublicKeyTokenProvider.php b/lib/private/Authentication/Token/PublicKeyTokenProvider.php index 14cd53435e3..a43d4a7f888 100644 --- a/lib/private/Authentication/Token/PublicKeyTokenProvider.php +++ b/lib/private/Authentication/Token/PublicKeyTokenProvider.php @@ -56,6 +56,7 @@ class PublicKeyTokenProvider implements IProvider { /** * {@inheritDoc} */ + #[\Override] public function generateToken(string $token, string $uid, string $loginName, @@ -102,6 +103,7 @@ class PublicKeyTokenProvider implements IProvider { return $dbToken; } + #[\Override] public function getToken(string $tokenId): OCPIToken { /** * Token length: 72 @@ -177,6 +179,7 @@ class PublicKeyTokenProvider implements IProvider { $this->cache->set($tokenHash, false, self::TOKEN_CACHE_TTL * 2); } + #[\Override] public function getTokenById(int $tokenId): OCPIToken { try { $token = $this->mapper->getTokenById($tokenId); @@ -204,6 +207,7 @@ class PublicKeyTokenProvider implements IProvider { } } + #[\Override] public function renewSessionToken(string $oldSessionId, string $sessionId): OCPIToken { return $this->atomic(function () use ($oldSessionId, $sessionId) { $token = $this->getToken($oldSessionId); @@ -238,6 +242,7 @@ class PublicKeyTokenProvider implements IProvider { }, $this->db); } + #[\Override] public function invalidateToken(string $token) { $tokenHash = $this->hashToken($token); $tokenEntry = null; @@ -253,6 +258,7 @@ class PublicKeyTokenProvider implements IProvider { } } + #[\Override] public function invalidateTokenById(string $uid, int $id) { $token = $this->mapper->getTokenById($id); if ($token->getUID() !== $uid) { @@ -263,6 +269,7 @@ class PublicKeyTokenProvider implements IProvider { $this->eventDispatcher->dispatchTyped(new TokenInvalidatedEvent($token)); } + #[\Override] public function invalidateOldTokens() { $olderThan = $this->time->getTime() - $this->config->getSystemValueInt('session_lifetime', 60 * 60 * 24); $this->logger->debug('Invalidating session tokens older than ' . date('c', $olderThan), ['app' => 'cron']); @@ -281,10 +288,12 @@ class PublicKeyTokenProvider implements IProvider { $this->mapper->invalidateOld($authTokenThreshold, OCPIToken::PERMANENT_TOKEN); } + #[\Override] public function invalidateLastUsedBefore(string $uid, int $before): void { $this->mapper->invalidateLastUsedBefore($uid, $before); } + #[\Override] public function updateToken(OCPIToken $token) { if (!($token instanceof PublicKeyToken)) { throw new InvalidTokenException('Invalid token type'); @@ -293,6 +302,7 @@ class PublicKeyTokenProvider implements IProvider { $this->cacheToken($token); } + #[\Override] public function updateTokenActivity(OCPIToken $token) { if (!($token instanceof PublicKeyToken)) { throw new InvalidTokenException('Invalid token type'); @@ -310,10 +320,12 @@ class PublicKeyTokenProvider implements IProvider { } } + #[\Override] public function getTokenByUser(string $uid): array { return $this->mapper->getTokenByUser($uid); } + #[\Override] public function getPassword(OCPIToken $savedToken, string $tokenId): string { if (!($savedToken instanceof PublicKeyToken)) { throw new InvalidTokenException('Invalid token type'); @@ -330,6 +342,7 @@ class PublicKeyTokenProvider implements IProvider { return $this->decryptPassword($savedToken->getPassword(), $privateKey); } + #[\Override] public function setPassword(OCPIToken $token, string $tokenId, string $password) { if (!($token instanceof PublicKeyToken)) { throw new InvalidTokenException('Invalid token type'); @@ -355,6 +368,7 @@ class PublicKeyTokenProvider implements IProvider { return $this->hasher->hash(sha1($password) . $password); } + #[\Override] public function rotate(OCPIToken $token, string $oldTokenId, string $newTokenId): OCPIToken { if (!($token instanceof PublicKeyToken)) { throw new InvalidTokenException('Invalid token type'); @@ -484,6 +498,7 @@ class PublicKeyTokenProvider implements IProvider { return $dbToken; } + #[\Override] public function markPasswordInvalid(OCPIToken $token, string $tokenId) { if (!($token instanceof PublicKeyToken)) { throw new InvalidTokenException('Invalid token type'); @@ -494,6 +509,7 @@ class PublicKeyTokenProvider implements IProvider { $this->cacheToken($token); } + #[\Override] public function updatePasswords(string $uid, string $password) { // prevent setting an empty pw as result of pw-less-login if ($password === '' || !$this->config->getSystemValueBool('auth.storeCryptedPassword', true)) { diff --git a/lib/private/Authentication/Token/TokenCleanupJob.php b/lib/private/Authentication/Token/TokenCleanupJob.php index 5834d40cb52..76998eea4c1 100644 --- a/lib/private/Authentication/Token/TokenCleanupJob.php +++ b/lib/private/Authentication/Token/TokenCleanupJob.php @@ -22,6 +22,7 @@ class TokenCleanupJob extends TimedJob { $this->setTimeSensitivity(self::TIME_INSENSITIVE); } + #[\Override] protected function run($argument) { $this->provider->invalidateOldTokens(); } diff --git a/lib/private/Authentication/TwoFactorAuth/EnforcementState.php b/lib/private/Authentication/TwoFactorAuth/EnforcementState.php index 05014e09128..f7b4e85e3ab 100644 --- a/lib/private/Authentication/TwoFactorAuth/EnforcementState.php +++ b/lib/private/Authentication/TwoFactorAuth/EnforcementState.php @@ -46,6 +46,7 @@ class EnforcementState implements JsonSerializable { return $this->excludedGroups; } + #[\Override] public function jsonSerialize(): array { return [ 'enforced' => $this->enforced, diff --git a/lib/private/Authentication/TwoFactorAuth/Registry.php b/lib/private/Authentication/TwoFactorAuth/Registry.php index 6534daa41ca..1224a6caaf0 100644 --- a/lib/private/Authentication/TwoFactorAuth/Registry.php +++ b/lib/private/Authentication/TwoFactorAuth/Registry.php @@ -26,10 +26,12 @@ class Registry implements IRegistry { ) { } + #[\Override] public function getProviderStates(IUser $user): array { return $this->assignmentDao->getState($user->getUID()); } + #[\Override] public function enableProviderFor(IProvider $provider, IUser $user) { $this->assignmentDao->persist($provider->getId(), $user->getUID(), 1); @@ -38,6 +40,7 @@ class Registry implements IRegistry { $this->dispatcher->dispatchTyped(new TwoFactorProviderForUserRegistered($user, $provider)); } + #[\Override] public function disableProviderFor(IProvider $provider, IUser $user) { $this->assignmentDao->persist($provider->getId(), $user->getUID(), 0); @@ -54,6 +57,7 @@ class Registry implements IRegistry { } } + #[\Override] public function cleanUp(string $providerId) { $this->assignmentDao->deleteAll($providerId); } diff --git a/lib/private/Authentication/WebAuthn/CredentialRepository.php b/lib/private/Authentication/WebAuthn/CredentialRepository.php index e6503d1c38a..bf24d2b0b77 100644 --- a/lib/private/Authentication/WebAuthn/CredentialRepository.php +++ b/lib/private/Authentication/WebAuthn/CredentialRepository.php @@ -21,6 +21,7 @@ class CredentialRepository implements PublicKeyCredentialSourceRepository { ) { } + #[\Override] public function findOneByCredentialId(string $publicKeyCredentialId): ?PublicKeyCredentialSource { try { $entity = $this->credentialMapper->findOneByCredentialId($publicKeyCredentialId); @@ -33,6 +34,7 @@ class CredentialRepository implements PublicKeyCredentialSourceRepository { /** * @return PublicKeyCredentialSource[] */ + #[\Override] public function findAllForUserEntity(PublicKeyCredentialUserEntity $publicKeyCredentialUserEntity): array { $uid = $publicKeyCredentialUserEntity->getId(); $entities = $this->credentialMapper->findAllForUid($uid); @@ -73,6 +75,7 @@ class CredentialRepository implements PublicKeyCredentialSourceRepository { return $this->credentialMapper->insertOrUpdate($entity); } + #[\Override] public function saveCredentialSource(PublicKeyCredentialSource $publicKeyCredentialSource, ?string $name = null): void { $this->saveAndReturnCredentialSource($publicKeyCredentialSource, $name); } diff --git a/lib/private/Authentication/WebAuthn/Db/PublicKeyCredentialEntity.php b/lib/private/Authentication/WebAuthn/Db/PublicKeyCredentialEntity.php index 6c4bc3ca81b..abc9a74f5c8 100644 --- a/lib/private/Authentication/WebAuthn/Db/PublicKeyCredentialEntity.php +++ b/lib/private/Authentication/WebAuthn/Db/PublicKeyCredentialEntity.php @@ -73,6 +73,7 @@ class PublicKeyCredentialEntity extends Entity implements JsonSerializable { /** * @inheritDoc */ + #[\Override] public function jsonSerialize(): array { return [ 'id' => $this->getId(), diff --git a/lib/private/Avatar/Avatar.php b/lib/private/Avatar/Avatar.php index 987298e0483..b92a7aafacd 100644 --- a/lib/private/Avatar/Avatar.php +++ b/lib/private/Avatar/Avatar.php @@ -64,6 +64,7 @@ abstract class Avatar implements IAvatar { /** * @inheritdoc */ + #[\Override] public function get(int $size = 64, bool $darkTheme = false) { try { $file = $this->getFile($size, $darkTheme); @@ -254,6 +255,7 @@ abstract class Avatar implements IAvatar { /** * @return Color Object containing r g b int in the range [0, 255] */ + #[\Override] public function avatarBackgroundColor(string $hash): Color { // Normalize hash $hash = strtolower($hash); diff --git a/lib/private/Avatar/AvatarManager.php b/lib/private/Avatar/AvatarManager.php index c68467085f0..d4ea69a9584 100644 --- a/lib/private/Avatar/AvatarManager.php +++ b/lib/private/Avatar/AvatarManager.php @@ -50,6 +50,7 @@ class AvatarManager implements IAvatarManager { * @throws \Exception In case the username is potentially dangerous * @throws NotFoundException In case there is no user folder yet */ + #[\Override] public function getAvatar(string $userId): IAvatar { $user = $this->userManager->get($userId); if ($user === null) { @@ -128,6 +129,7 @@ class AvatarManager implements IAvatarManager { * * @param string $name The guest name, e.g. "Albert". */ + #[\Override] public function getGuestAvatar(string $name): IAvatar { return new GuestAvatar($name, $this->config, $this->logger); } diff --git a/lib/private/Avatar/GuestAvatar.php b/lib/private/Avatar/GuestAvatar.php index 6d2e2df19fc..11e9a47223f 100644 --- a/lib/private/Avatar/GuestAvatar.php +++ b/lib/private/Avatar/GuestAvatar.php @@ -35,6 +35,7 @@ class GuestAvatar extends Avatar { /** * Tests if the user has an avatar. */ + #[\Override] public function exists(): bool { // Guests always have an avatar. return true; @@ -43,6 +44,7 @@ class GuestAvatar extends Avatar { /** * Returns the guest user display name. */ + #[\Override] public function getDisplayName(): string { return $this->userDisplayName; } @@ -52,6 +54,7 @@ class GuestAvatar extends Avatar { * * @param IImage|resource|string $data */ + #[\Override] public function set($data): void { // unimplemented for guest user avatars } @@ -59,6 +62,7 @@ class GuestAvatar extends Avatar { /** * Removing avatars isn't implemented for guests. */ + #[\Override] public function remove(bool $silent = false): void { // unimplemented for guest user avatars } @@ -66,6 +70,7 @@ class GuestAvatar extends Avatar { /** * Generates an avatar for the guest. */ + #[\Override] public function getFile(int $size, bool $darkTheme = false): ISimpleFile { $avatar = $this->generateAvatar($this->userDisplayName, $size, $darkTheme); return new InMemoryFile('avatar.png', $avatar); @@ -78,6 +83,7 @@ class GuestAvatar extends Avatar { * @param mixed $oldValue The previous value * @param mixed $newValue The new value */ + #[\Override] public function userChanged(string $feature, $oldValue, $newValue): void { if ($feature === 'displayName') { $this->userDisplayName = $newValue; @@ -87,6 +93,7 @@ class GuestAvatar extends Avatar { /** * Guests don't have custom avatars. */ + #[\Override] public function isCustomAvatar(): bool { return false; } @@ -96,6 +103,7 @@ class GuestAvatar extends Avatar { * Different color than for authorized user with the same name * to make it harder to impersonate people. */ + #[\Override] public function avatarBackgroundColor(string $hash): Color { return parent::avatarBackgroundColor($hash . ' (guest)'); } diff --git a/lib/private/Avatar/PlaceholderAvatar.php b/lib/private/Avatar/PlaceholderAvatar.php index 8edf4d39a68..7e3c35cbddf 100644 --- a/lib/private/Avatar/PlaceholderAvatar.php +++ b/lib/private/Avatar/PlaceholderAvatar.php @@ -38,6 +38,7 @@ class PlaceholderAvatar extends Avatar { /** * Check if an avatar exists for the user */ + #[\Override] public function exists(): bool { return true; } @@ -50,6 +51,7 @@ class PlaceholderAvatar extends Avatar { * @throws \Exception if the provided image is not valid * @throws NotSquareException if the image is not square */ + #[\Override] public function set($data): void { // unimplemented for placeholder avatars } @@ -57,6 +59,7 @@ class PlaceholderAvatar extends Avatar { /** * Removes the users avatar. */ + #[\Override] public function remove(bool $silent = false): void { $avatars = $this->folder->getDirectoryListing(); @@ -74,6 +77,7 @@ class PlaceholderAvatar extends Avatar { * @throws NotPermittedException * @throws PreConditionNotMetException */ + #[\Override] public function getFile(int $size, bool $darkTheme = false): ISimpleFile { $ext = 'png'; @@ -110,6 +114,7 @@ class PlaceholderAvatar extends Avatar { /** * Returns the user display name. */ + #[\Override] public function getDisplayName(): string { return $this->user->getDisplayName(); } @@ -123,6 +128,7 @@ class PlaceholderAvatar extends Avatar { * @throws NotPermittedException * @throws PreConditionNotMetException */ + #[\Override] public function userChanged(string $feature, $oldValue, $newValue): void { $this->remove(); } @@ -130,6 +136,7 @@ class PlaceholderAvatar extends Avatar { /** * Check if the avatar of a user is a custom uploaded one */ + #[\Override] public function isCustomAvatar(): bool { return false; } diff --git a/lib/private/Avatar/UserAvatar.php b/lib/private/Avatar/UserAvatar.php index 86fd1cf1220..f2dd98bcced 100644 --- a/lib/private/Avatar/UserAvatar.php +++ b/lib/private/Avatar/UserAvatar.php @@ -38,6 +38,7 @@ class UserAvatar extends Avatar { /** * Check if an avatar exists for the user */ + #[\Override] public function exists(): bool { return $this->folder->fileExists('avatar.jpg') || $this->folder->fileExists('avatar.png'); } @@ -50,6 +51,7 @@ class UserAvatar extends Avatar { * @throws \Exception if the provided image is not valid * @throws NotSquareException if the image is not square */ + #[\Override] public function set($data): void { $img = $this->getAvatarImage($data); $data = $img->data(); @@ -150,6 +152,7 @@ class UserAvatar extends Avatar { * @throws NotPermittedException * @throws PreConditionNotMetException */ + #[\Override] public function remove(bool $silent = false): void { $avatars = $this->folder->getDirectoryListing(); @@ -197,6 +200,7 @@ class UserAvatar extends Avatar { * @throws NotPermittedException * @throws PreConditionNotMetException */ + #[\Override] public function getFile(int $size, bool $darkTheme = false): ISimpleFile { $generated = $this->folder->fileExists('generated'); @@ -269,6 +273,7 @@ class UserAvatar extends Avatar { /** * Returns the user display name. */ + #[\Override] public function getDisplayName(): string { return $this->user->getDisplayName(); } @@ -282,6 +287,7 @@ class UserAvatar extends Avatar { * @throws NotPermittedException * @throws PreConditionNotMetException */ + #[\Override] public function userChanged(string $feature, $oldValue, $newValue): void { // If the avatar is not generated (so an uploaded image) we skip this if (!$this->folder->fileExists('generated')) { @@ -294,6 +300,7 @@ class UserAvatar extends Avatar { /** * Check if the avatar of a user is a custom uploaded one */ + #[\Override] public function isCustomAvatar(): bool { return $this->config->getUserValue($this->user->getUID(), 'avatar', 'generated', 'false') !== 'true'; } diff --git a/lib/private/BackgroundJob/JobList.php b/lib/private/BackgroundJob/JobList.php index b62bec1ae5f..242b78ade85 100644 --- a/lib/private/BackgroundJob/JobList.php +++ b/lib/private/BackgroundJob/JobList.php @@ -77,6 +77,7 @@ class JobList implements IJobList { $query->executeStatement(); } + #[\Override] public function scheduleAfter(string $job, int $runAfter, mixed $argument = null): void { $this->add($job, $argument, $runAfter); } @@ -346,6 +347,7 @@ class JobList implements IJobList { /** * set the job that was last ran */ + #[\Override] public function setLastJob(IJob $job): void { $this->unlockJob($job); $this->config->setAppValue('backgroundjob', 'lastjob', $job->getId()); diff --git a/lib/private/BinaryFinder.php b/lib/private/BinaryFinder.php index 221d05f5c27..d0598206fa3 100644 --- a/lib/private/BinaryFinder.php +++ b/lib/private/BinaryFinder.php @@ -42,6 +42,7 @@ class BinaryFinder implements IBinaryFinder { * * @return false|string */ + #[\Override] public function findBinaryPath(string $program) { $result = $this->cache->get($program); if ($result !== null) { diff --git a/lib/private/Blurhash/Listener/GenerateBlurhashMetadata.php b/lib/private/Blurhash/Listener/GenerateBlurhashMetadata.php index 8faf4627251..aa950874534 100644 --- a/lib/private/Blurhash/Listener/GenerateBlurhashMetadata.php +++ b/lib/private/Blurhash/Listener/GenerateBlurhashMetadata.php @@ -41,6 +41,7 @@ class GenerateBlurhashMetadata implements IEventListener { * @throws GenericFileException * @throws LockedException */ + #[\Override] public function handle(Event $event): void { if (!($event instanceof MetadataLiveEvent) && !($event instanceof MetadataBackgroundEvent)) { diff --git a/lib/private/Broadcast/Events/BroadcastEvent.php b/lib/private/Broadcast/Events/BroadcastEvent.php index c0227a75c6a..6d834e0b58d 100644 --- a/lib/private/Broadcast/Events/BroadcastEvent.php +++ b/lib/private/Broadcast/Events/BroadcastEvent.php @@ -20,18 +20,22 @@ class BroadcastEvent extends Event implements IBroadcastEvent { parent::__construct(); } + #[\Override] public function getName(): string { return $this->event->broadcastAs(); } + #[\Override] public function getUids(): array { return $this->event->getUids(); } + #[\Override] public function getPayload(): JsonSerializable { return $this->event; } + #[\Override] public function setBroadcasted(): void { $this->event->setBroadcasted(); } diff --git a/lib/private/Cache/File.php b/lib/private/Cache/File.php index d9a3e5e8b63..0d312bd9797 100644 --- a/lib/private/Cache/File.php +++ b/lib/private/Cache/File.php @@ -56,6 +56,7 @@ class File implements ICache { * @return mixed|null * @throws ForbiddenException */ + #[\Override] public function get($key) { $result = null; if ($this->hasKey($key)) { @@ -87,6 +88,7 @@ class File implements ICache { * @return bool|mixed * @throws ForbiddenException */ + #[\Override] public function set($key, $value, $ttl = 0) { $storage = $this->getStorage(); $result = false; @@ -114,6 +116,7 @@ class File implements ICache { * @return bool * @throws ForbiddenException */ + #[\Override] public function hasKey($key) { $storage = $this->getStorage(); if ($storage && $storage->is_file($key) && $storage->isReadable($key)) { @@ -127,6 +130,7 @@ class File implements ICache { * @return bool|mixed * @throws ForbiddenException */ + #[\Override] public function remove($key) { $storage = $this->getStorage(); if (!$storage) { @@ -140,6 +144,7 @@ class File implements ICache { * @return bool * @throws ForbiddenException */ + #[\Override] public function clear($prefix = '') { $storage = $this->getStorage(); if ($storage && $storage->is_dir('/')) { @@ -189,6 +194,7 @@ class File implements ICache { } } + #[\Override] public static function isAvailable(): bool { return true; } diff --git a/lib/private/Calendar/AvailabilityResult.php b/lib/private/Calendar/AvailabilityResult.php index 8031758f64e..0ee0ce10166 100644 --- a/lib/private/Calendar/AvailabilityResult.php +++ b/lib/private/Calendar/AvailabilityResult.php @@ -18,10 +18,12 @@ class AvailabilityResult implements IAvailabilityResult { ) { } + #[\Override] public function getAttendeeEmail(): string { return $this->attendee; } + #[\Override] public function isAvailable(): bool { return $this->available; } diff --git a/lib/private/Calendar/CalendarEventBuilder.php b/lib/private/Calendar/CalendarEventBuilder.php index 1aa11c2436d..818a034911b 100644 --- a/lib/private/Calendar/CalendarEventBuilder.php +++ b/lib/private/Calendar/CalendarEventBuilder.php @@ -34,46 +34,55 @@ class CalendarEventBuilder implements ICalendarEventBuilder { ) { } + #[\Override] public function setStartDate(DateTimeInterface $start): ICalendarEventBuilder { $this->startDate = $start; return $this; } + #[\Override] public function setEndDate(DateTimeInterface $end): ICalendarEventBuilder { $this->endDate = $end; return $this; } + #[\Override] public function setSummary(string $summary): ICalendarEventBuilder { $this->summary = $summary; return $this; } + #[\Override] public function setDescription(string $description): ICalendarEventBuilder { $this->description = $description; return $this; } + #[\Override] public function setLocation(string $location): ICalendarEventBuilder { $this->location = $location; return $this; } + #[\Override] public function setStatus(CalendarEventStatus $status): static { $this->status = $status; return $this; } + #[\Override] public function setOrganizer(string $email, ?string $commonName = null): ICalendarEventBuilder { $this->organizer = [$email, $commonName]; return $this; } + #[\Override] public function addAttendee(string $email, ?string $commonName = null): ICalendarEventBuilder { $this->attendees[] = [$email, $commonName]; return $this; } + #[\Override] public function toIcs(): string { if ($this->startDate === null) { throw new InvalidArgumentException('Event is missing a start date'); @@ -117,6 +126,7 @@ class CalendarEventBuilder implements ICalendarEventBuilder { return $vcalendar->serialize(); } + #[\Override] public function createInCalendar(ICreateFromString $calendar): string { $fileName = $this->uid . '.ics'; $calendar->createFromString($fileName, $this->toIcs()); diff --git a/lib/private/Calendar/CalendarQuery.php b/lib/private/Calendar/CalendarQuery.php index 4eb4a4cd636..f45a0ba30d7 100644 --- a/lib/private/Calendar/CalendarQuery.php +++ b/lib/private/Calendar/CalendarQuery.php @@ -39,6 +39,7 @@ class CalendarQuery implements ICalendarQuery { $this->principalUri = $principalUri; } + #[\Override] public function setSearchPattern(string $pattern): void { $this->searchPattern = $pattern; } @@ -47,6 +48,7 @@ class CalendarQuery implements ICalendarQuery { return $this->searchPattern; } + #[\Override] public function addSearchProperty(string $value): void { $this->searchProperties[] = $value; } @@ -55,6 +57,7 @@ class CalendarQuery implements ICalendarQuery { return $this->searchProperties; } + #[\Override] public function addSearchCalendar(string $calendarUri): void { $this->calendarUris[] = $calendarUri; } @@ -70,6 +73,7 @@ class CalendarQuery implements ICalendarQuery { return $this->limit; } + #[\Override] public function setLimit(int $limit): void { $this->limit = $limit; } @@ -78,18 +82,22 @@ class CalendarQuery implements ICalendarQuery { return $this->offset; } + #[\Override] public function setOffset(int $offset): void { $this->offset = $offset; } + #[\Override] public function addType(string $value): void { $this->options['types'][] = $value; } + #[\Override] public function setTimerangeStart(\DateTimeImmutable $startTime): void { $this->options['timerange']['start'] = $startTime; } + #[\Override] public function setTimerangeEnd(\DateTimeImmutable $endTime): void { $this->options['timerange']['end'] = $endTime; } diff --git a/lib/private/Calendar/Manager.php b/lib/private/Calendar/Manager.php index 0c1c9a0d725..1ef694ac6c2 100644 --- a/lib/private/Calendar/Manager.php +++ b/lib/private/Calendar/Manager.php @@ -76,6 +76,7 @@ class Manager implements IManager { * @return array an array of events/journals/todos which are arrays of arrays of key-value-pairs * @since 13.0.0 */ + #[\Override] public function search( $pattern, array $searchProperties = [], @@ -102,6 +103,7 @@ class Manager implements IManager { * @return bool true if enabled, false if not * @since 13.0.0 */ + #[\Override] public function isEnabled(): bool { return !empty($this->calendars) || !empty($this->calendarLoaders); } @@ -111,6 +113,7 @@ class Manager implements IManager { * * @since 13.0.0 */ + #[\Override] public function registerCalendar(ICalendar $calendar): void { $this->calendars[$calendar->getKey()] = $calendar; } @@ -120,6 +123,7 @@ class Manager implements IManager { * * @since 13.0.0 */ + #[\Override] public function unregisterCalendar(ICalendar $calendar): void { unset($this->calendars[$calendar->getKey()]); } @@ -130,6 +134,7 @@ class Manager implements IManager { * * @since 13.0.0 */ + #[\Override] public function register(\Closure $callable): void { $this->calendarLoaders[] = $callable; } @@ -139,6 +144,7 @@ class Manager implements IManager { * * @since 13.0.0 */ + #[\Override] public function getCalendars(): array { $this->loadCalendars(); @@ -150,6 +156,7 @@ class Manager implements IManager { * * @since 13.0.0 */ + #[\Override] public function clear(): void { $this->calendars = []; $this->calendarLoaders = []; @@ -168,6 +175,7 @@ class Manager implements IManager { /** * @return ICreateFromString[] */ + #[\Override] public function getCalendarsForPrincipal(string $principalUri, array $calendarUris = []): array { $context = $this->coordinator->getRegistrationContext(); if ($context === null) { @@ -191,6 +199,7 @@ class Manager implements IManager { ); } + #[\Override] public function searchForPrincipal(ICalendarQuery $query): array { /** @var CalendarQuery $query */ $calendars = $this->getCalendarsForPrincipal( @@ -217,6 +226,7 @@ class Manager implements IManager { return $results; } + #[\Override] public function newQuery(string $principalUri): ICalendarQuery { return new CalendarQuery($principalUri); } @@ -226,6 +236,7 @@ class Manager implements IManager { * * @throws \OCP\DB\Exception */ + #[\Override] public function handleIMip( string $userId, string $message, @@ -351,6 +362,7 @@ class Manager implements IManager { * * @throws \OCP\DB\Exception */ + #[\Override] public function handleIMipRequest( string $principalUri, string $sender, @@ -371,6 +383,7 @@ class Manager implements IManager { * * @throws \OCP\DB\Exception */ + #[\Override] public function handleIMipReply( string $principalUri, string $sender, @@ -391,6 +404,7 @@ class Manager implements IManager { * * @throws \OCP\DB\Exception */ + #[\Override] public function handleIMipCancel( string $principalUri, string $sender, @@ -407,11 +421,13 @@ class Manager implements IManager { return $this->handleIMip($userId, $calendarData, $options); } + #[\Override] public function createEventBuilder(): ICalendarEventBuilder { $uid = $this->random->generate(32, ISecureRandom::CHAR_ALPHANUMERIC); return new CalendarEventBuilder($uid, $this->timeFactory); } + #[\Override] public function checkAvailability( DateTimeInterface $start, DateTimeInterface $end, diff --git a/lib/private/Calendar/Resource/Manager.php b/lib/private/Calendar/Resource/Manager.php index 221b77d4704..4c5154ddbb9 100644 --- a/lib/private/Calendar/Resource/Manager.php +++ b/lib/private/Calendar/Resource/Manager.php @@ -39,6 +39,7 @@ class Manager implements IManager { * * @since 14.0.0 */ + #[\Override] public function registerBackend(string $backendClass): void { $this->backends[$backendClass] = $backendClass; } @@ -48,6 +49,7 @@ class Manager implements IManager { * * @since 14.0.0 */ + #[\Override] public function unregisterBackend(string $backendClass): void { unset($this->backends[$backendClass], $this->initializedBackends[$backendClass]); } @@ -73,6 +75,7 @@ class Manager implements IManager { * @throws QueryException * @since 14.0.0 */ + #[\Override] public function getBackends():array { $this->fetchBootstrapBackends(); @@ -91,6 +94,7 @@ class Manager implements IManager { * @param string $backendId * @throws QueryException */ + #[\Override] public function getBackend($backendId): ?IBackend { $backends = $this->getBackends(); foreach ($backends as $backend) { @@ -107,11 +111,13 @@ class Manager implements IManager { * * @since 14.0.0 */ + #[\Override] public function clear(): void { $this->backends = []; $this->initializedBackends = []; } + #[\Override] public function update(): void { $this->updater->updateResources(); } diff --git a/lib/private/Calendar/Room/Manager.php b/lib/private/Calendar/Room/Manager.php index 8097fecb2ac..b19727054e3 100644 --- a/lib/private/Calendar/Room/Manager.php +++ b/lib/private/Calendar/Room/Manager.php @@ -39,6 +39,7 @@ class Manager implements IManager { * * @since 14.0.0 */ + #[\Override] public function registerBackend(string $backendClass): void { $this->backends[$backendClass] = $backendClass; } @@ -49,6 +50,7 @@ class Manager implements IManager { * @param string $backendClass * @since 14.0.0 */ + #[\Override] public function unregisterBackend(string $backendClass): void { unset($this->backends[$backendClass], $this->initializedBackends[$backendClass]); } @@ -74,6 +76,7 @@ class Manager implements IManager { * @throws QueryException * @since 14.0.0 */ + #[\Override] public function getBackends():array { $this->fetchBootstrapBackends(); @@ -98,6 +101,7 @@ class Manager implements IManager { * @param string $backendId * @throws QueryException */ + #[\Override] public function getBackend($backendId): ?IBackend { $backends = $this->getBackends(); foreach ($backends as $backend) { @@ -114,11 +118,13 @@ class Manager implements IManager { * * @since 14.0.0 */ + #[\Override] public function clear(): void { $this->backends = []; $this->initializedBackends = []; } + #[\Override] public function update(): void { $this->updater->updateRooms(); } diff --git a/lib/private/Collaboration/AutoComplete/Manager.php b/lib/private/Collaboration/AutoComplete/Manager.php index cc5df78beea..d94e4c431bc 100644 --- a/lib/private/Collaboration/AutoComplete/Manager.php +++ b/lib/private/Collaboration/AutoComplete/Manager.php @@ -25,6 +25,7 @@ class Manager implements IManager { ) { } + #[\Override] public function runSorters(array $sorters, array &$sortArray, array $context): void { $sorterInstances = $this->getSorters(); while ($sorter = array_shift($sorters)) { @@ -38,6 +39,7 @@ class Manager implements IManager { } } + #[\Override] public function registerSorter($className): void { $this->sorters[] = $className; } diff --git a/lib/private/Collaboration/Collaborators/GroupPlugin.php b/lib/private/Collaboration/Collaborators/GroupPlugin.php index a59d5981825..36143b7479f 100644 --- a/lib/private/Collaboration/Collaborators/GroupPlugin.php +++ b/lib/private/Collaboration/Collaborators/GroupPlugin.php @@ -40,6 +40,7 @@ class GroupPlugin implements ISearchPlugin { } } + #[\Override] public function search($search, $limit, $offset, ISearchResult $searchResult): bool { if ($this->groupSharingDisabled) { return false; diff --git a/lib/private/Collaboration/Collaborators/LookupPlugin.php b/lib/private/Collaboration/Collaborators/LookupPlugin.php index b65431fe347..de1bfa9edb9 100644 --- a/lib/private/Collaboration/Collaborators/LookupPlugin.php +++ b/lib/private/Collaboration/Collaborators/LookupPlugin.php @@ -33,6 +33,7 @@ class LookupPlugin implements ISearchPlugin { $this->currentUserRemote = $cloudIdManager->resolveCloudId($currentUserCloudId)->getRemote(); } + #[\Override] public function search($search, $limit, $offset, ISearchResult $searchResult): bool { $isGlobalScaleEnabled = $this->config->getSystemValueBool('gs.enabled', false); $isLookupServerEnabled = $this->config->getAppValue('files_sharing', 'lookupServerEnabled', 'no') === 'yes'; diff --git a/lib/private/Collaboration/Collaborators/MailPlugin.php b/lib/private/Collaboration/Collaborators/MailPlugin.php index 84ff487203f..3149a4d14f9 100644 --- a/lib/private/Collaboration/Collaborators/MailPlugin.php +++ b/lib/private/Collaboration/Collaborators/MailPlugin.php @@ -59,6 +59,7 @@ class MailPlugin implements ISearchPlugin { /** * {@inheritdoc} */ + #[\Override] public function search($search, $limit, $offset, ISearchResult $searchResult): bool { if ($this->shareeEnumerationFullMatch && !$this->shareeEnumerationFullMatchEmail) { return false; diff --git a/lib/private/Collaboration/Collaborators/RemoteGroupPlugin.php b/lib/private/Collaboration/Collaborators/RemoteGroupPlugin.php index f4c1793ea0a..68d0a462f00 100644 --- a/lib/private/Collaboration/Collaborators/RemoteGroupPlugin.php +++ b/lib/private/Collaboration/Collaborators/RemoteGroupPlugin.php @@ -32,6 +32,7 @@ class RemoteGroupPlugin implements ISearchPlugin { } } + #[\Override] public function search($search, $limit, $offset, ISearchResult $searchResult): bool { $result = ['wide' => [], 'exact' => []]; $resultType = new SearchResultType('remote_groups'); diff --git a/lib/private/Collaboration/Collaborators/RemotePlugin.php b/lib/private/Collaboration/Collaborators/RemotePlugin.php index e52683cfd5a..5dd17c9527b 100644 --- a/lib/private/Collaboration/Collaborators/RemotePlugin.php +++ b/lib/private/Collaboration/Collaborators/RemotePlugin.php @@ -37,6 +37,7 @@ class RemotePlugin implements ISearchPlugin { } + #[\Override] public function search($search, $limit, $offset, ISearchResult $searchResult): bool { $result = ['wide' => [], 'exact' => []]; $resultType = new SearchResultType('remotes'); diff --git a/lib/private/Collaboration/Collaborators/Search.php b/lib/private/Collaboration/Collaborators/Search.php index 4fbfb787996..4eb3b275c67 100644 --- a/lib/private/Collaboration/Collaborators/Search.php +++ b/lib/private/Collaboration/Collaborators/Search.php @@ -29,6 +29,7 @@ class Search implements ISearch { * @param int|null $offset * @throws QueryException */ + #[\Override] public function search($search, array $shareTypes, $lookup, $limit, $offset): array { $hasMoreResults = false; @@ -81,6 +82,7 @@ class Search implements ISearch { return [$searchResult->asArray(), $hasMoreResults]; } + #[\Override] public function registerPlugin(array $pluginInfo): void { $shareType = constant(IShare::class . '::' . substr($pluginInfo['shareType'], strlen('SHARE_'))); if ($shareType === null) { diff --git a/lib/private/Collaboration/Collaborators/SearchResult.php b/lib/private/Collaboration/Collaborators/SearchResult.php index c9c2f032f36..0b887aac545 100644 --- a/lib/private/Collaboration/Collaborators/SearchResult.php +++ b/lib/private/Collaboration/Collaborators/SearchResult.php @@ -16,6 +16,7 @@ class SearchResult implements ISearchResult { protected array $exactIdMatches = []; + #[\Override] public function addResultSet(SearchResultType $type, array $matches, ?array $exactMatches = null): void { $type = $type->getLabel(); if (!isset($this->result[$type])) { @@ -29,14 +30,17 @@ class SearchResult implements ISearchResult { } } + #[\Override] public function markExactIdMatch(SearchResultType $type): void { $this->exactIdMatches[$type->getLabel()] = 1; } + #[\Override] public function hasExactIdMatch(SearchResultType $type): bool { return isset($this->exactIdMatches[$type->getLabel()]); } + #[\Override] public function hasResult(SearchResultType $type, $collaboratorId): bool { $type = $type->getLabel(); if (!isset($this->result[$type])) { @@ -55,10 +59,12 @@ class SearchResult implements ISearchResult { return false; } + #[\Override] public function asArray(): array { return $this->result; } + #[\Override] public function unsetResult(SearchResultType $type): void { $type = $type->getLabel(); $this->result[$type] = []; @@ -67,6 +73,7 @@ class SearchResult implements ISearchResult { } } + #[\Override] public function removeCollaboratorResult(SearchResultType $type, string $collaboratorId): bool { $type = $type->getLabel(); if (!isset($this->result[$type])) { diff --git a/lib/private/Collaboration/Collaborators/UserPlugin.php b/lib/private/Collaboration/Collaborators/UserPlugin.php index c21c5d03d8c..9ccdfc6b67a 100644 --- a/lib/private/Collaboration/Collaborators/UserPlugin.php +++ b/lib/private/Collaboration/Collaborators/UserPlugin.php @@ -34,6 +34,7 @@ readonly class UserPlugin implements ISearchPlugin { ) { } + #[\Override] public function search($search, $limit, $offset, ISearchResult $searchResult): bool { /** @var IUser $currentUser */ $currentUser = $this->userSession->getUser(); diff --git a/lib/private/Collaboration/Reference/File/FileReferenceEventListener.php b/lib/private/Collaboration/Reference/File/FileReferenceEventListener.php index 0b2385a0555..18f6894673c 100644 --- a/lib/private/Collaboration/Reference/File/FileReferenceEventListener.php +++ b/lib/private/Collaboration/Reference/File/FileReferenceEventListener.php @@ -37,6 +37,7 @@ class FileReferenceEventListener implements IEventListener { /** * @inheritDoc */ + #[\Override] public function handle(Event $event): void { if ($event instanceof NodeDeletedEvent) { try { diff --git a/lib/private/Collaboration/Reference/File/FileReferenceProvider.php b/lib/private/Collaboration/Reference/File/FileReferenceProvider.php index 3cb174d9607..acfa0c7d138 100644 --- a/lib/private/Collaboration/Reference/File/FileReferenceProvider.php +++ b/lib/private/Collaboration/Reference/File/FileReferenceProvider.php @@ -39,6 +39,7 @@ class FileReferenceProvider extends ADiscoverableReferenceProvider { $this->l10n = $l10n->get('files'); } + #[\Override] public function matchReference(string $referenceText): bool { return $this->getFilesAppLinkId($referenceText) !== null; } @@ -74,6 +75,7 @@ class FileReferenceProvider extends ADiscoverableReferenceProvider { return $fileId !== null ? (int)$fileId : null; } + #[\Override] public function resolveReference(string $referenceText): ?IReference { if ($this->matchReference($referenceText)) { $reference = new Reference($referenceText); @@ -135,26 +137,32 @@ class FileReferenceProvider extends ADiscoverableReferenceProvider { } } + #[\Override] public function getCachePrefix(string $referenceId): string { return (string)$this->getFilesAppLinkId($referenceId); } + #[\Override] public function getCacheKey(string $referenceId): ?string { return $this->userId ?? ''; } + #[\Override] public function getId(): string { return 'files'; } + #[\Override] public function getTitle(): string { return $this->l10n->t('Files'); } + #[\Override] public function getOrder(): int { return 0; } + #[\Override] public function getIconUrl(): string { return $this->urlGenerator->imagePath('files', 'folder.svg'); } diff --git a/lib/private/Collaboration/Reference/ReferenceManager.php b/lib/private/Collaboration/Reference/ReferenceManager.php index 9287b66b2a2..693d84fc99c 100644 --- a/lib/private/Collaboration/Reference/ReferenceManager.php +++ b/lib/private/Collaboration/Reference/ReferenceManager.php @@ -49,6 +49,7 @@ class ReferenceManager implements IReferenceManager { * * @return string[] */ + #[\Override] public function extractReferences(string $text): array { preg_match_all(IURLGenerator::URL_REGEX, $text, $matches); $references = $matches[0] ?? []; @@ -60,6 +61,7 @@ class ReferenceManager implements IReferenceManager { /** * Try to get a cached reference object from a reference string */ + #[\Override] public function getReferenceFromCache(string $referenceId, bool $public = false, string $sharingToken = ''): ?IReference { $matchedProvider = $this->getMatchedProvider($referenceId, $public); @@ -74,6 +76,7 @@ class ReferenceManager implements IReferenceManager { /** * Try to get a cached reference object from a full cache key */ + #[\Override] public function getReferenceByCacheKey(string $cacheKey): ?IReference { $cached = $this->cache->get($cacheKey); if ($cached) { @@ -87,6 +90,7 @@ class ReferenceManager implements IReferenceManager { * Get a reference object from a reference string with a matching provider * Use a cached reference if possible */ + #[\Override] public function resolveReference(string $referenceId, bool $public = false, $sharingToken = ''): ?IReference { $matchedProvider = $this->getMatchedProvider($referenceId, $public); @@ -162,6 +166,7 @@ class ReferenceManager implements IReferenceManager { /** * Remove a specific cache entry from its key+prefix */ + #[\Override] public function invalidateCache(string $cachePrefix, ?string $cacheKey = null): void { if ($cacheKey === null) { // clear might be a heavy operation, so we only do it if there have actually been keys set @@ -208,6 +213,7 @@ class ReferenceManager implements IReferenceManager { /** * @inheritDoc */ + #[\Override] public function getDiscoverableProviders(): array { // preserve 0 based index to avoid returning an object in data responses return array_values( @@ -220,6 +226,7 @@ class ReferenceManager implements IReferenceManager { /** * @inheritDoc */ + #[\Override] public function touchProvider(string $userId, string $providerId, ?int $timestamp = null): bool { $providers = $this->getDiscoverableProviders(); $matchingProviders = array_filter($providers, static function (IDiscoverableReferenceProvider $provider) use ($providerId) { @@ -240,6 +247,7 @@ class ReferenceManager implements IReferenceManager { /** * @inheritDoc */ + #[\Override] public function getUserProviderTimestamps(): array { $user = $this->userSession->getUser(); if ($user === null) { diff --git a/lib/private/Collaboration/Reference/RenderReferenceEventListener.php b/lib/private/Collaboration/Reference/RenderReferenceEventListener.php index 9e6192314cb..db26df60005 100644 --- a/lib/private/Collaboration/Reference/RenderReferenceEventListener.php +++ b/lib/private/Collaboration/Reference/RenderReferenceEventListener.php @@ -31,6 +31,7 @@ class RenderReferenceEventListener implements IEventListener { /** * @inheritDoc */ + #[\Override] public function handle(Event $event): void { if (!($event instanceof RenderReferenceEvent)) { return; diff --git a/lib/private/Collaboration/Resources/Collection.php b/lib/private/Collaboration/Resources/Collection.php index 9bee7ea8dc8..59d52b94344 100644 --- a/lib/private/Collaboration/Resources/Collection.php +++ b/lib/private/Collaboration/Resources/Collection.php @@ -35,6 +35,7 @@ class Collection implements ICollection { /** * @since 16.0.0 */ + #[\Override] public function getId(): int { return $this->id; } @@ -42,6 +43,7 @@ class Collection implements ICollection { /** * @since 16.0.0 */ + #[\Override] public function getName(): string { return $this->name; } @@ -49,6 +51,7 @@ class Collection implements ICollection { /** * @since 16.0.0 */ + #[\Override] public function setName(string $name): void { $query = $this->connection->getQueryBuilder(); $query->update(Manager::TABLE_COLLECTIONS) @@ -63,6 +66,7 @@ class Collection implements ICollection { * @return IResource[] * @since 16.0.0 */ + #[\Override] public function getResources(): array { if (empty($this->resources)) { $this->resources = $this->manager->getResourcesByCollectionForUser($this, $this->userForAccess); @@ -77,6 +81,7 @@ class Collection implements ICollection { * @throws ResourceException when the resource is already part of the collection * @since 16.0.0 */ + #[\Override] public function addResource(IResource $resource): void { array_map(function (IResource $r) use ($resource): void { if ($this->isSameResource($r, $resource)) { @@ -108,6 +113,7 @@ class Collection implements ICollection { * * @since 16.0.0 */ + #[\Override] public function removeResource(IResource $resource): void { $this->resources = array_filter($this->getResources(), function (IResource $r) use ($resource) { return !$this->isSameResource($r, $resource); @@ -132,6 +138,7 @@ class Collection implements ICollection { * * @since 16.0.0 */ + #[\Override] public function canAccess(?IUser $user): bool { if ($user instanceof IUser) { return $this->canUserAccess($user); diff --git a/lib/private/Collaboration/Resources/Manager.php b/lib/private/Collaboration/Resources/Manager.php index 7cf039c2174..3e6e7e5d5bc 100644 --- a/lib/private/Collaboration/Resources/Manager.php +++ b/lib/private/Collaboration/Resources/Manager.php @@ -40,6 +40,7 @@ class Manager implements IManager { * @throws CollectionException when the collection could not be found * @since 16.0.0 */ + #[\Override] public function getCollection(int $id): ICollection { $query = $this->connection->getQueryBuilder(); $query->select('*') @@ -60,6 +61,7 @@ class Manager implements IManager { * @throws CollectionException when the collection could not be found * @since 16.0.0 */ + #[\Override] public function getCollectionForUser(int $id, ?IUser $user): ICollection { $query = $this->connection->getQueryBuilder(); $userId = $user instanceof IUser ? $user->getUID() : ''; @@ -140,6 +142,7 @@ class Manager implements IManager { /** * @since 16.0.0 */ + #[\Override] public function newCollection(string $name): ICollection { $query = $this->connection->getQueryBuilder(); $query->insert(self::TABLE_COLLECTIONS) @@ -154,6 +157,7 @@ class Manager implements IManager { /** * @since 16.0.0 */ + #[\Override] public function createResource(string $type, string $id): IResource { return new Resource($this, $this->connection, $type, $id); } @@ -162,6 +166,7 @@ class Manager implements IManager { * @throws ResourceException * @since 16.0.0 */ + #[\Override] public function getResourceForUser(string $type, string $id, ?IUser $user): IResource { $query = $this->connection->getQueryBuilder(); $userId = $user instanceof IUser ? $user->getUID() : ''; @@ -230,6 +235,7 @@ class Manager implements IManager { * * @since 16.0.0 */ + #[\Override] public function getResourceRichObject(IResource $resource): array { foreach ($this->providerManager->getResourceProviders() as $provider) { if ($provider->getType() === $resource->getType()) { @@ -248,6 +254,7 @@ class Manager implements IManager { * * @since 16.0.0 */ + #[\Override] public function canAccessResource(IResource $resource, ?IUser $user): bool { $access = $this->checkAccessCacheForUserByResource($resource, $user); if (\is_bool($access)) { @@ -276,6 +283,7 @@ class Manager implements IManager { * * @since 16.0.0 */ + #[\Override] public function canAccessCollection(ICollection $collection, ?IUser $user): bool { $access = $this->checkAccessCacheForUserByCollection($collection, $user); if (\is_bool($access)) { @@ -377,6 +385,7 @@ class Manager implements IManager { } } + #[\Override] public function invalidateAccessCacheForUser(?IUser $user): void { $query = $this->connection->getQueryBuilder(); $userId = $user instanceof IUser ? $user->getUID() : ''; @@ -386,6 +395,7 @@ class Manager implements IManager { $query->executeStatement(); } + #[\Override] public function invalidateAccessCacheForResource(IResource $resource): void { $query = $this->connection->getQueryBuilder(); @@ -415,6 +425,7 @@ class Manager implements IManager { $query->executeStatement(); } + #[\Override] public function invalidateAccessCacheForProvider(IProvider $provider): void { $query = $this->connection->getQueryBuilder(); @@ -423,6 +434,7 @@ class Manager implements IManager { $query->executeStatement(); } + #[\Override] public function invalidateAccessCacheForResourceByUser(IResource $resource, ?IUser $user): void { $query = $this->connection->getQueryBuilder(); $userId = $user instanceof IUser ? $user->getUID() : ''; @@ -447,6 +459,7 @@ class Manager implements IManager { $query->executeStatement(); } + #[\Override] public function invalidateAccessCacheForProviderByUser(IProvider $provider, ?IUser $user): void { $query = $this->connection->getQueryBuilder(); $userId = $user instanceof IUser ? $user->getUID() : ''; @@ -462,6 +475,7 @@ class Manager implements IManager { * * @since 16.0.0 */ + #[\Override] public function getType(): string { return ''; } diff --git a/lib/private/Collaboration/Resources/ProviderManager.php b/lib/private/Collaboration/Resources/ProviderManager.php index 0ce4ae7155a..72155cf7fa4 100644 --- a/lib/private/Collaboration/Resources/ProviderManager.php +++ b/lib/private/Collaboration/Resources/ProviderManager.php @@ -27,6 +27,7 @@ class ProviderManager implements IProviderManager { ) { } + #[\Override] public function getResourceProviders(): array { if ($this->providers !== []) { foreach ($this->providers as $provider) { @@ -44,6 +45,7 @@ class ProviderManager implements IProviderManager { return $this->providerInstances; } + #[\Override] public function registerResourceProvider(string $provider): void { $this->providers[] = $provider; } diff --git a/lib/private/Collaboration/Resources/Resource.php b/lib/private/Collaboration/Resources/Resource.php index 05eaeb8f6aa..2af252da598 100644 --- a/lib/private/Collaboration/Resources/Resource.php +++ b/lib/private/Collaboration/Resources/Resource.php @@ -30,6 +30,7 @@ class Resource implements IResource { /** * @since 16.0.0 */ + #[\Override] public function getType(): string { return $this->type; } @@ -37,6 +38,7 @@ class Resource implements IResource { /** * @since 16.0.0 */ + #[\Override] public function getId(): string { return $this->id; } @@ -44,6 +46,7 @@ class Resource implements IResource { /** * @since 16.0.0 */ + #[\Override] public function getRichObject(): array { if ($this->data === null) { $this->data = $this->manager->getResourceRichObject($this); @@ -57,6 +60,7 @@ class Resource implements IResource { * * @since 16.0.0 */ + #[\Override] public function canAccess(?IUser $user): bool { if ($user instanceof IUser) { return $this->canUserAccess($user); @@ -92,6 +96,7 @@ class Resource implements IResource { * @return ICollection[] * @since 16.0.0 */ + #[\Override] public function getCollections(): array { $collections = []; diff --git a/lib/private/Command/AsyncBus.php b/lib/private/Command/AsyncBus.php index 54dc6d94e5a..0215b131238 100644 --- a/lib/private/Command/AsyncBus.php +++ b/lib/private/Command/AsyncBus.php @@ -26,6 +26,7 @@ abstract class AsyncBus implements IBus { /** * Schedule a command to be fired */ + #[\Override] public function push(ICommand $command): void { if ($this->canRunAsync($command)) { $this->queueCommand($command); @@ -44,6 +45,7 @@ abstract class AsyncBus implements IBus { * * @param string $trait */ + #[\Override] public function requireSync(string $trait): void { $this->syncTraits[] = trim($trait, '\\'); } diff --git a/lib/private/Command/CommandJob.php b/lib/private/Command/CommandJob.php index ac73987e59c..b00e6159f91 100644 --- a/lib/private/Command/CommandJob.php +++ b/lib/private/Command/CommandJob.php @@ -18,6 +18,7 @@ use Test\Command\StateFullCommand; * Wrap a command in the background job interface */ class CommandJob extends QueuedJob { + #[\Override] protected function run($argument) { $command = unserialize($argument, ['allowed_classes' => [ SimpleCommand::class, diff --git a/lib/private/Command/CronBus.php b/lib/private/Command/CronBus.php index 1fa8cd45e7a..0b059e2e5af 100644 --- a/lib/private/Command/CronBus.php +++ b/lib/private/Command/CronBus.php @@ -17,6 +17,7 @@ class CronBus extends AsyncBus { ) { } + #[\Override] protected function queueCommand(ICommand $command): void { $this->jobList->add(CommandJob::class, serialize($command)); } diff --git a/lib/private/Command/QueueBus.php b/lib/private/Command/QueueBus.php index 6a355c8ca6b..9c3c2467959 100644 --- a/lib/private/Command/QueueBus.php +++ b/lib/private/Command/QueueBus.php @@ -25,6 +25,7 @@ class QueueBus implements IBus { /** * Schedule a command to be fired */ + #[\Override] public function push(ICommand $command): void { $this->queue[] = $command; } @@ -32,6 +33,7 @@ class QueueBus implements IBus { /** * Require all commands using a trait to be run synchronous */ + #[\Override] public function requireSync(string $trait): void { } diff --git a/lib/private/Comments/Comment.php b/lib/private/Comments/Comment.php index 7d2d861e8b4..2736d14ccaf 100644 --- a/lib/private/Comments/Comment.php +++ b/lib/private/Comments/Comment.php @@ -52,6 +52,7 @@ class Comment implements IComment { * * @since 9.0.0 */ + #[\Override] public function getId(): string { return $this->data['id']; } @@ -69,6 +70,7 @@ class Comment implements IComment { * @throws IllegalIDChangeException * @since 9.0.0 */ + #[\Override] public function setId($id): IComment { if (!is_string($id)) { throw new \InvalidArgumentException('String expected.'); @@ -88,6 +90,7 @@ class Comment implements IComment { * * @since 9.0.0 */ + #[\Override] public function getParentId(): string { return $this->data['parentId']; } @@ -98,6 +101,7 @@ class Comment implements IComment { * @param string $parentId * @since 9.0.0 */ + #[\Override] public function setParentId($parentId): IComment { if (!is_string($parentId)) { throw new \InvalidArgumentException('String expected.'); @@ -111,6 +115,7 @@ class Comment implements IComment { * * @since 9.0.0 */ + #[\Override] public function getTopmostParentId(): string { return $this->data['topmostParentId']; } @@ -122,6 +127,7 @@ class Comment implements IComment { * @param string $id * @since 9.0.0 */ + #[\Override] public function setTopmostParentId($id): IComment { if (!is_string($id)) { throw new \InvalidArgumentException('String expected.'); @@ -135,6 +141,7 @@ class Comment implements IComment { * * @since 9.0.0 */ + #[\Override] public function getChildrenCount(): int { return $this->data['childrenCount']; } @@ -145,6 +152,7 @@ class Comment implements IComment { * @param int $count * @since 9.0.0 */ + #[\Override] public function setChildrenCount($count): IComment { if (!is_int($count)) { throw new \InvalidArgumentException('Integer expected.'); @@ -157,6 +165,7 @@ class Comment implements IComment { * Returns the message of the comment * @since 9.0.0 */ + #[\Override] public function getMessage(): string { return $this->data['message']; } @@ -169,6 +178,7 @@ class Comment implements IComment { * @throws MessageTooLongException * @since 9.0.0 */ + #[\Override] public function setMessage($message, $maxLength = self::MAX_MESSAGE_LENGTH): IComment { if (!is_string($message)) { throw new \InvalidArgumentException('String expected.'); @@ -194,6 +204,7 @@ class Comment implements IComment { * @since 17.0.0 Type 'guest' is supported * @since 11.0.0 */ + #[\Override] public function getMentions(bool $supportMarkdown = true): array { $message = $this->getMessage(); if ($supportMarkdown) { @@ -254,6 +265,7 @@ class Comment implements IComment { * * @since 9.0.0 */ + #[\Override] public function getVerb(): string { return $this->data['verb']; } @@ -264,6 +276,7 @@ class Comment implements IComment { * @param string $verb * @since 9.0.0 */ + #[\Override] public function setVerb($verb): IComment { if (!is_string($verb) || !trim($verb)) { throw new \InvalidArgumentException('Non-empty String expected.'); @@ -276,6 +289,7 @@ class Comment implements IComment { * Returns the actor type * @since 9.0.0 */ + #[\Override] public function getActorType(): string { return $this->data['actorType']; } @@ -284,6 +298,7 @@ class Comment implements IComment { * Returns the actor ID * @since 9.0.0 */ + #[\Override] public function getActorId(): string { return $this->data['actorId']; } @@ -295,6 +310,7 @@ class Comment implements IComment { * @param string $actorId e.g. 'zombie234' * @since 9.0.0 */ + #[\Override] public function setActor($actorType, $actorId): IComment { if ( !is_string($actorType) || !trim($actorType) @@ -314,6 +330,7 @@ class Comment implements IComment { * @since 9.0.0 * @throws \LogicException if creation date time is not set yet */ + #[\Override] public function getCreationDateTime(): \DateTime { if (!isset($this->data['creationDT'])) { throw new \LogicException('Cannot get creation date before setting one or writting to database'); @@ -325,6 +342,7 @@ class Comment implements IComment { * Sets the creation date of the comment and returns itself * @since 9.0.0 */ + #[\Override] public function setCreationDateTime(\DateTime $dateTime): IComment { $this->data['creationDT'] = $dateTime; return $this; @@ -334,6 +352,7 @@ class Comment implements IComment { * Returns the DateTime of the most recent child, if set, otherwise null * @since 9.0.0 */ + #[\Override] public function getLatestChildDateTime(): ?\DateTime { return $this->data['latestChildDT']; } @@ -341,6 +360,7 @@ class Comment implements IComment { /** * @inheritDoc */ + #[\Override] public function setLatestChildDateTime(?\DateTime $dateTime = null): IComment { $this->data['latestChildDT'] = $dateTime; return $this; @@ -350,6 +370,7 @@ class Comment implements IComment { * Returns the object type the comment is attached to * @since 9.0.0 */ + #[\Override] public function getObjectType(): string { return $this->data['objectType']; } @@ -358,6 +379,7 @@ class Comment implements IComment { * Returns the object id the comment is attached to * @since 9.0.0 */ + #[\Override] public function getObjectId(): string { return $this->data['objectId']; } @@ -369,6 +391,7 @@ class Comment implements IComment { * @param string $objectId e.g. '16435' * @since 9.0.0 */ + #[\Override] public function setObject($objectType, $objectId): IComment { if ( !is_string($objectType) || !trim($objectType) @@ -385,6 +408,7 @@ class Comment implements IComment { * Returns the reference id of the comment * @since 19.0.0 */ + #[\Override] public function getReferenceId(): ?string { return $this->data['referenceId']; } @@ -395,6 +419,7 @@ class Comment implements IComment { * @param string $referenceId e.g. sha256 hash sum * @since 19.0.0 */ + #[\Override] public function setReferenceId(?string $referenceId): IComment { if ($referenceId === null) { $this->data['referenceId'] = $referenceId; @@ -411,6 +436,7 @@ class Comment implements IComment { /** * @inheritDoc */ + #[\Override] public function getMetaData(): ?array { if ($this->data['metaData'] === null) { return null; @@ -427,6 +453,7 @@ class Comment implements IComment { /** * @inheritDoc */ + #[\Override] public function setMetaData(?array $metaData): IComment { if ($metaData === null) { $this->data['metaData'] = null; @@ -439,6 +466,7 @@ class Comment implements IComment { /** * @inheritDoc */ + #[\Override] public function getReactions(): array { return $this->data['reactions'] ?? []; } @@ -446,6 +474,7 @@ class Comment implements IComment { /** * @inheritDoc */ + #[\Override] public function setReactions(?array $reactions): IComment { $this->data['reactions'] = $reactions; return $this; @@ -454,6 +483,7 @@ class Comment implements IComment { /** * @inheritDoc */ + #[\Override] public function setExpireDate(?\DateTime $dateTime): IComment { $this->data['expire_date'] = $dateTime; return $this; @@ -462,6 +492,7 @@ class Comment implements IComment { /** * @inheritDoc */ + #[\Override] public function getExpireDate(): ?\DateTime { return $this->data['expire_date']; } diff --git a/lib/private/Comments/Manager.php b/lib/private/Comments/Manager.php index 59f4c824882..b4922f967e5 100644 --- a/lib/private/Comments/Manager.php +++ b/lib/private/Comments/Manager.php @@ -239,6 +239,7 @@ class Manager implements ICommentsManager { * @throws \InvalidArgumentException * @since 9.0.0 */ + #[\Override] public function get($id): IComment { if ((int)$id === 0) { throw new \InvalidArgumentException('IDs must be translatable to a number in this implementation.'); @@ -270,6 +271,7 @@ class Manager implements ICommentsManager { /** * @inheritDoc */ + #[\Override] public function getTree($id, $limit = 0, $offset = 0): array { $tree = []; $tree['comment'] = $this->get($id); @@ -318,6 +320,7 @@ class Manager implements ICommentsManager { * @return list * @since 9.0.0 */ + #[\Override] public function getForObject( $objectType, $objectId, @@ -370,6 +373,7 @@ class Manager implements ICommentsManager { * @param string $topmostParentId Limit the comments to a list of replies and its original root comment * @return list */ + #[\Override] public function getForObjectSince( string $objectType, string $objectId, @@ -403,6 +407,7 @@ class Manager implements ICommentsManager { * @param string $topmostParentId Limit the comments to a list of replies and its original root comment * @return list */ + #[\Override] public function getCommentsWithVerbForObjectSinceComment( string $objectType, string $objectId, @@ -560,6 +565,7 @@ class Manager implements ICommentsManager { * @param int $limit * @return list */ + #[\Override] public function search(string $search, string $objectType, string $objectId, string $verb, int $offset, int $limit = 50): array { $objectIds = []; if ($objectId) { @@ -579,6 +585,7 @@ class Manager implements ICommentsManager { * @param int $limit * @return list */ + #[\Override] public function searchForObjects(string $search, string $objectType, array $objectIds, string $verb, int $offset, int $limit = 50): array { $query = $this->dbConn->getQueryBuilder(); @@ -628,11 +635,13 @@ class Manager implements ICommentsManager { * @return Int * @since 9.0.0 */ + #[\Override] public function getNumberOfCommentsForObject($objectType, $objectId, ?\DateTime $notOlderThan = null, $verb = ''): int { return $this->getNumberOfCommentsForObjects($objectType, [$objectId], $notOlderThan, $verb)[$objectId]; } /** @inheritDoc */ + #[\Override] public function getNumberOfCommentsForObjects(string $objectType, array $objectIds, ?\DateTime $notOlderThan = null, string $verb = ''): array { $qb = $this->dbConn->getQueryBuilder(); $query = $qb->select($qb->func()->count('id', 'num_comments'), 'object_id') @@ -670,6 +679,7 @@ class Manager implements ICommentsManager { * @psalm-return array * @since 21.0.0 */ + #[\Override] public function getNumberOfUnreadCommentsForObjects(string $objectType, array $objectIds, IUser $user, $verb = ''): array { $unreadComments = []; $query = $this->dbConn->getQueryBuilder(); @@ -714,6 +724,7 @@ class Manager implements ICommentsManager { * @return int * @since 21.0.0 */ + #[\Override] public function getNumberOfCommentsForObjectSinceComment(string $objectType, string $objectId, int $lastRead, string $verb = ''): int { if ($verb !== '') { return $this->getNumberOfCommentsWithVerbsForObjectSinceComment($objectType, $objectId, $lastRead, [$verb]); @@ -730,6 +741,7 @@ class Manager implements ICommentsManager { * @return int * @since 24.0.0 */ + #[\Override] public function getNumberOfCommentsWithVerbsForObjectSinceComment(string $objectType, string $objectId, int $lastRead, array $verbs): int { $query = $this->dbConn->getQueryBuilder(); $query->select($query->func()->count('id', 'num_messages')) @@ -757,6 +769,7 @@ class Manager implements ICommentsManager { * @return int * @since 21.0.0 */ + #[\Override] public function getLastCommentBeforeDate(string $objectType, string $objectId, \DateTime $beforeDate, string $verb = ''): int { $query = $this->dbConn->getQueryBuilder(); $query->select('id') @@ -787,6 +800,7 @@ class Manager implements ICommentsManager { * @psalm-return array * @since 21.0.0 */ + #[\Override] public function getLastCommentDateByActor( string $objectType, string $objectId, @@ -825,6 +839,7 @@ class Manager implements ICommentsManager { * @param IUser $user * @return array [$fileId => $unreadCount] */ + #[\Override] public function getNumberOfUnreadCommentsForFolder($folderId, IUser $user) { $directory = $this->rootFolder->getFirstNodeById($folderId); if (!$directory instanceof Folder) { @@ -852,6 +867,7 @@ class Manager implements ICommentsManager { * @return IComment * @since 9.0.0 */ + #[\Override] public function create($actorType, $actorId, $objectType, $objectId) { $comment = new Comment(); $comment @@ -871,6 +887,7 @@ class Manager implements ICommentsManager { * @throws \InvalidArgumentException * @since 9.0.0 */ + #[\Override] public function delete($id) { if (!is_string($id)) { throw new \InvalidArgumentException('Parameter must be string'); @@ -936,6 +953,7 @@ class Manager implements ICommentsManager { * @throws PreConditionNotMetException * @since 24.0.0 */ + #[\Override] public function getReactionComment(int $parentId, string $actorType, string $actorId, string $reaction): IComment { $this->throwIfNotSupportReactions(); $qb = $this->dbConn->getQueryBuilder(); @@ -965,6 +983,7 @@ class Manager implements ICommentsManager { * @throws PreConditionNotMetException * @since 24.0.0 */ + #[\Override] public function retrieveAllReactions(int $parentId): array { $this->throwIfNotSupportReactions(); $qb = $this->dbConn->getQueryBuilder(); @@ -995,6 +1014,7 @@ class Manager implements ICommentsManager { * @throws PreConditionNotMetException * @since 24.0.0 */ + #[\Override] public function retrieveAllReactionsWithSpecificReaction(int $parentId, string $reaction): array { $this->throwIfNotSupportReactions(); $qb = $this->dbConn->getQueryBuilder(); @@ -1023,6 +1043,7 @@ class Manager implements ICommentsManager { * @return bool * @since 24.0.0 */ + #[\Override] public function supportReactions(): bool { return $this->emojiHelper->doesPlatformSupportEmoji(); } @@ -1094,6 +1115,7 @@ class Manager implements ICommentsManager { * @throws PreConditionNotMetException * @since 9.0.0 */ + #[\Override] public function save(IComment $comment) { if ($comment->getVerb() === 'reaction') { $this->throwIfNotSupportReactions(); @@ -1286,6 +1308,7 @@ class Manager implements ICommentsManager { /** * @inheritDoc */ + #[\Override] public function deleteReferencesOfActor($actorType, $actorId): bool { $this->checkRoleParameters('Actor', $actorType, $actorId); @@ -1306,6 +1329,7 @@ class Manager implements ICommentsManager { /** * @inheritDoc */ + #[\Override] public function deleteCommentsAtObject($objectType, $objectId): bool { $this->checkRoleParameters('Object', $objectType, $objectId); @@ -1329,6 +1353,7 @@ class Manager implements ICommentsManager { * @return bool * @since 9.0.0 */ + #[\Override] public function deleteReadMarksFromUser(IUser $user) { $qb = $this->dbConn->getQueryBuilder(); $query = $qb->delete('comments_read_markers') @@ -1357,6 +1382,7 @@ class Manager implements ICommentsManager { * @param IUser $user * @since 9.0.0 */ + #[\Override] public function setReadMark($objectType, $objectId, \DateTime $dateTime, IUser $user) { $this->checkRoleParameters('Object', $objectType, $objectId); @@ -1403,6 +1429,7 @@ class Manager implements ICommentsManager { * @return \DateTime|null * @since 9.0.0 */ + #[\Override] public function getReadMark($objectType, $objectId, IUser $user) { $qb = $this->dbConn->getQueryBuilder(); $resultStatement = $qb->select('marker_datetime') @@ -1432,6 +1459,7 @@ class Manager implements ICommentsManager { * @return bool * @since 9.0.0 */ + #[\Override] public function deleteReadMarksOnObject($objectType, $objectId) { $this->checkRoleParameters('Object', $objectType, $objectId); @@ -1460,6 +1488,7 @@ class Manager implements ICommentsManager { * * @param \Closure $closure */ + #[\Override] public function registerEventHandler(\Closure $closure) { $this->eventHandlerClosures[] = $closure; $this->eventHandlers = []; @@ -1476,6 +1505,7 @@ class Manager implements ICommentsManager { * Only one resolver shall be registered per type. Otherwise a * \OutOfBoundsException has to thrown. */ + #[\Override] public function registerDisplayNameResolver($type, \Closure $closure) { if (!is_string($type)) { throw new \InvalidArgumentException('String expected.'); @@ -1499,6 +1529,7 @@ class Manager implements ICommentsManager { * be thrown. It is upon the resolver discretion what to return of the * provided ID is unknown. It must be ensured that a string is returned. */ + #[\Override] public function resolveDisplayName($type, $id) { if (!is_string($type)) { throw new \InvalidArgumentException('String expected.'); @@ -1547,6 +1578,7 @@ class Manager implements ICommentsManager { * * @since 21.0.0 */ + #[\Override] public function load(): void { $this->initialStateService->provideInitialState('comments', 'max-message-length', IComment::MAX_MESSAGE_LENGTH); Util::addScript('comments', 'comments-app'); @@ -1555,6 +1587,7 @@ class Manager implements ICommentsManager { /** * @inheritDoc */ + #[\Override] public function deleteCommentsExpiredAtObject(string $objectType, string $objectId = ''): bool { $qb = $this->dbConn->getQueryBuilder(); $qb->delete('comments') diff --git a/lib/private/Comments/ManagerFactory.php b/lib/private/Comments/ManagerFactory.php index d377bf58696..2fd21598e91 100644 --- a/lib/private/Comments/ManagerFactory.php +++ b/lib/private/Comments/ManagerFactory.php @@ -33,6 +33,7 @@ class ManagerFactory implements ICommentsManagerFactory { * @return ICommentsManager * @since 9.0.0 */ + #[\Override] public function getManager() { return $this->serverContainer->get(Manager::class); } diff --git a/lib/private/Config/UserConfig.php b/lib/private/Config/UserConfig.php index 1c6b819571e..12222b02ebd 100644 --- a/lib/private/Config/UserConfig.php +++ b/lib/private/Config/UserConfig.php @@ -90,6 +90,7 @@ class UserConfig implements IUserConfig { * @return list list of userIds * @since 31.0.0 */ + #[\Override] public function getUserIds(string $appId = ''): array { $this->assertParams(app: $appId, allowEmptyUser: true, allowEmptyApp: true); @@ -117,6 +118,7 @@ class UserConfig implements IUserConfig { * @return list list of app ids * @since 31.0.0 */ + #[\Override] public function getApps(string $userId): array { $this->assertParams($userId, allowEmptyApp: true); $this->loadConfigAll($userId); @@ -135,6 +137,7 @@ class UserConfig implements IUserConfig { * @return list list of stored config keys * @since 31.0.0 */ + #[\Override] public function getKeys(string $userId, string $app): array { $this->assertParams($userId, $app); $this->loadConfigAll($userId); @@ -156,6 +159,7 @@ class UserConfig implements IUserConfig { * @return bool TRUE if key exists * @since 31.0.0 */ + #[\Override] public function hasKey(string $userId, string $app, string $key, ?bool $lazy = false): bool { $this->assertParams($userId, $app, $key); $this->loadConfig($userId, $lazy); @@ -185,6 +189,7 @@ class UserConfig implements IUserConfig { * @throws UnknownKeyException if config key is not known * @since 31.0.0 */ + #[\Override] public function isSensitive(string $userId, string $app, string $key, ?bool $lazy = false): bool { $this->assertParams($userId, $app, $key); $this->loadConfig($userId, $lazy); @@ -209,6 +214,7 @@ class UserConfig implements IUserConfig { * @throws UnknownKeyException if config key is not known * @since 31.0.0 */ + #[\Override] public function isIndexed(string $userId, string $app, string $key, ?bool $lazy = false): bool { $this->assertParams($userId, $app, $key); $this->loadConfig($userId, $lazy); @@ -233,6 +239,7 @@ class UserConfig implements IUserConfig { * @see IUserConfig for details about lazy loading * @since 31.0.0 */ + #[\Override] public function isLazy(string $userId, string $app, string $key): bool { $this->matchAndApplyLexiconDefinition($userId, $app, $key); @@ -262,6 +269,7 @@ class UserConfig implements IUserConfig { * @return array [key => value] * @since 31.0.0 */ + #[\Override] public function getValues( string $userId, string $app, @@ -292,6 +300,7 @@ class UserConfig implements IUserConfig { * @return array> [appId => [key => value]] * @since 31.0.0 */ + #[\Override] public function getAllValues(string $userId, bool $filtered = false): array { $this->assertParams($userId, allowEmptyApp: true); $this->loadConfigAll($userId); @@ -317,6 +326,7 @@ class UserConfig implements IUserConfig { * @return array [appId => value] * @since 31.0.0 */ + #[\Override] public function getValuesByApps(string $userId, string $key, bool $lazy = false, ?ValueType $typedAs = null): array { $this->assertParams($userId, '', $key, allowEmptyApp: true); $this->loadConfig($userId, $lazy); @@ -356,6 +366,7 @@ class UserConfig implements IUserConfig { * @return array [userId => value] * @since 31.0.0 */ + #[\Override] public function getValuesByUsers( string $app, string $key, @@ -416,6 +427,7 @@ class UserConfig implements IUserConfig { * @return Generator * @since 31.0.0 */ + #[\Override] public function searchUsersByValueString(string $app, string $key, string $value, bool $caseInsensitive = false): Generator { return $this->searchUsersByTypedValue($app, $key, $value, $caseInsensitive); } @@ -430,6 +442,7 @@ class UserConfig implements IUserConfig { * @return Generator * @since 31.0.0 */ + #[\Override] public function searchUsersByValueInt(string $app, string $key, int $value): Generator { return $this->searchUsersByValueString($app, $key, (string)$value); } @@ -444,6 +457,7 @@ class UserConfig implements IUserConfig { * @return Generator * @since 31.0.0 */ + #[\Override] public function searchUsersByValues(string $app, string $key, array $values): Generator { return $this->searchUsersByTypedValue($app, $key, $values); } @@ -458,6 +472,7 @@ class UserConfig implements IUserConfig { * @return Generator * @since 31.0.0 */ + #[\Override] public function searchUsersByValueBool(string $app, string $key, bool $value): Generator { $values = ['0', 'off', 'false', 'no']; if ($value) { @@ -604,6 +619,7 @@ class UserConfig implements IUserConfig { * @since 31.0.0 * @see IUserConfig for explanation about lazy loading */ + #[\Override] public function getValueString( string $userId, string $app, @@ -629,6 +645,7 @@ class UserConfig implements IUserConfig { * @since 31.0.0 * @see IUserConfig for explanation about lazy loading */ + #[\Override] public function getValueInt( string $userId, string $app, @@ -654,6 +671,7 @@ class UserConfig implements IUserConfig { * @since 31.0.0 * @see IUserConfig for explanation about lazy loading */ + #[\Override] public function getValueFloat( string $userId, string $app, @@ -679,6 +697,7 @@ class UserConfig implements IUserConfig { * @since 31.0.0 * @see IUserConfig for explanation about lazy loading */ + #[\Override] public function getValueBool( string $userId, string $app, @@ -705,6 +724,7 @@ class UserConfig implements IUserConfig { * @since 31.0.0 * @see IUserConfig for explanation about lazy loading */ + #[\Override] public function getValueArray( string $userId, string $app, @@ -809,6 +829,7 @@ class UserConfig implements IUserConfig { * @throws IncorrectTypeException if config value type is not known * @since 31.0.0 */ + #[\Override] public function getValueType(string $userId, string $app, string $key, ?bool $lazy = null): ValueType { $this->assertParams($userId, $app, $key); $this->loadConfig($userId, $lazy); @@ -834,6 +855,7 @@ class UserConfig implements IUserConfig { * @throws IncorrectTypeException if config value type is not known * @since 31.0.0 */ + #[\Override] public function getValueFlags(string $userId, string $app, string $key, bool $lazy = false): int { $this->assertParams($userId, $app, $key); $this->loadConfig($userId, $lazy); @@ -904,6 +926,7 @@ class UserConfig implements IUserConfig { * @since 31.0.0 * @see IUserConfig for explanation about lazy loading */ + #[\Override] public function setValueString( string $userId, string $app, @@ -938,6 +961,7 @@ class UserConfig implements IUserConfig { * @since 31.0.0 * @see IUserConfig for explanation about lazy loading */ + #[\Override] public function setValueInt( string $userId, string $app, @@ -976,6 +1000,7 @@ class UserConfig implements IUserConfig { * @since 31.0.0 * @see IUserConfig for explanation about lazy loading */ + #[\Override] public function setValueFloat( string $userId, string $app, @@ -1009,6 +1034,7 @@ class UserConfig implements IUserConfig { * @since 31.0.0 * @see IUserConfig for explanation about lazy loading */ + #[\Override] public function setValueBool( string $userId, string $app, @@ -1044,6 +1070,7 @@ class UserConfig implements IUserConfig { * @since 31.0.0 * @see IUserConfig for explanation about lazy loading */ + #[\Override] public function setValueArray( string $userId, string $app, @@ -1283,6 +1310,7 @@ class UserConfig implements IUserConfig { * @return bool TRUE if entry was found in database and an update was necessary * @since 31.0.0 */ + #[\Override] public function updateSensitive(string $userId, string $app, string $key, bool $sensitive): bool { $this->assertParams($userId, $app, $key); $this->loadConfigAll($userId); @@ -1340,6 +1368,7 @@ class UserConfig implements IUserConfig { * * @since 31.0.0 */ + #[\Override] public function updateGlobalSensitive(string $app, string $key, bool $sensitive): void { $this->assertParams('', $app, $key, allowEmptyUser: true); $this->matchAndApplyLexiconDefinition('', $app, $key); @@ -1370,6 +1399,7 @@ class UserConfig implements IUserConfig { * @throws UnknownKeyException * @since 31.0.0 */ + #[\Override] public function updateIndexed(string $userId, string $app, string $key, bool $indexed): bool { $this->assertParams($userId, $app, $key); $this->loadConfigAll($userId); @@ -1427,6 +1457,7 @@ class UserConfig implements IUserConfig { * * @since 31.0.0 */ + #[\Override] public function updateGlobalIndexed(string $app, string $key, bool $indexed): void { $this->assertParams('', $app, $key, allowEmptyUser: true); $this->matchAndApplyLexiconDefinition('', $app, $key); @@ -1473,6 +1504,7 @@ class UserConfig implements IUserConfig { * @return bool TRUE if entry was found in database and an update was necessary * @since 31.0.0 */ + #[\Override] public function updateLazy(string $userId, string $app, string $key, bool $lazy): bool { $this->assertParams($userId, $app, $key); $this->loadConfigAll($userId); @@ -1509,6 +1541,7 @@ class UserConfig implements IUserConfig { * * @since 31.0.0 */ + #[\Override] public function updateGlobalLazy(string $app, string $key, bool $lazy): void { $this->assertParams('', $app, $key, allowEmptyUser: true); $this->matchAndApplyLexiconDefinition('', $app, $key); @@ -1534,6 +1567,7 @@ class UserConfig implements IUserConfig { * @throws UnknownKeyException if config key is not known in database * @since 31.0.0 */ + #[\Override] public function getDetails(string $userId, string $app, string $key): array { $this->assertParams($userId, $app, $key); $this->loadConfigAll($userId); @@ -1584,6 +1618,7 @@ class UserConfig implements IUserConfig { * * @since 31.0.0 */ + #[\Override] public function deleteUserConfig(string $userId, string $app, string $key): void { $this->assertParams($userId, $app, $key); $this->matchAndApplyLexiconDefinition($userId, $app, $key); @@ -1608,6 +1643,7 @@ class UserConfig implements IUserConfig { * * @since 31.0.0 */ + #[\Override] public function deleteKey(string $app, string $key): void { $this->assertParams('', $app, $key, allowEmptyUser: true); $this->matchAndApplyLexiconDefinition('', $app, $key); @@ -1628,6 +1664,7 @@ class UserConfig implements IUserConfig { * * @since 31.0.0 */ + #[\Override] public function deleteApp(string $app): void { $this->assertParams('', $app, allowEmptyUser: true); @@ -1639,6 +1676,7 @@ class UserConfig implements IUserConfig { $this->clearCacheAll(); } + #[\Override] public function deleteAllUserConfig(string $userId): void { $this->assertParams($userId, '', allowEmptyApp: true); $qb = $this->connection->getQueryBuilder(); @@ -1657,6 +1695,7 @@ class UserConfig implements IUserConfig { * * @since 31.0.0 */ + #[\Override] public function clearCache(string $userId, bool $reload = false): void { $this->assertParams($userId, allowEmptyApp: true); $this->lazyLoaded[$userId] = $this->fastLoaded[$userId] = false; @@ -1674,6 +1713,7 @@ class UserConfig implements IUserConfig { * * @since 31.0.0 */ + #[\Override] public function clearCacheAll(): void { $this->lazyLoaded = $this->fastLoaded = []; $this->lazyCache = $this->fastCache = $this->valueDetails = $this->configLexiconDetails = []; diff --git a/lib/private/Console/TimestampFormatter.php b/lib/private/Console/TimestampFormatter.php index 2df34a84c87..44de18263e6 100644 --- a/lib/private/Console/TimestampFormatter.php +++ b/lib/private/Console/TimestampFormatter.php @@ -23,6 +23,7 @@ class TimestampFormatter implements OutputFormatterInterface { * * @param bool $decorated Whether to decorate the messages or not */ + #[\Override] public function setDecorated(bool $decorated): void { $this->formatter->setDecorated($decorated); } @@ -32,6 +33,7 @@ class TimestampFormatter implements OutputFormatterInterface { * * @return bool true if the output will decorate messages, false otherwise */ + #[\Override] public function isDecorated(): bool { return $this->formatter->isDecorated(); } @@ -42,6 +44,7 @@ class TimestampFormatter implements OutputFormatterInterface { * @param string $name The style name * @param OutputFormatterStyleInterface $style The style instance */ + #[\Override] public function setStyle(string $name, OutputFormatterStyleInterface $style): void { $this->formatter->setStyle($name, $style); } @@ -52,6 +55,7 @@ class TimestampFormatter implements OutputFormatterInterface { * @param string $name * @return bool */ + #[\Override] public function hasStyle(string $name): bool { return $this->formatter->hasStyle($name); } @@ -63,6 +67,7 @@ class TimestampFormatter implements OutputFormatterInterface { * @return OutputFormatterStyleInterface * @throws \InvalidArgumentException When style isn't defined */ + #[\Override] public function getStyle(string $name): OutputFormatterStyleInterface { return $this->formatter->getStyle($name); } @@ -74,6 +79,7 @@ class TimestampFormatter implements OutputFormatterInterface { * @return string|null The styled message, prepended with a timestamp using the * log timezone and dateformat, e.g. "2015-06-23T17:24:37+02:00" */ + #[\Override] public function format(?string $message): ?string { if (!$this->formatter->isDecorated()) { // Don't add anything to the output when we shouldn't diff --git a/lib/private/Contacts/ContactsMenu/ActionFactory.php b/lib/private/Contacts/ContactsMenu/ActionFactory.php index 40037598d49..ead893e5745 100644 --- a/lib/private/Contacts/ContactsMenu/ActionFactory.php +++ b/lib/private/Contacts/ContactsMenu/ActionFactory.php @@ -14,6 +14,7 @@ class ActionFactory implements IActionFactory { /** * {@inheritDoc} */ + #[\Override] public function newLinkAction(string $icon, string $name, string $href, string $appId = ''): ILinkAction { $action = new LinkAction(); $action->setName($name); @@ -26,6 +27,7 @@ class ActionFactory implements IActionFactory { /** * {@inheritDoc} */ + #[\Override] public function newEMailAction(string $icon, string $name, string $email, string $appId = ''): ILinkAction { return $this->newLinkAction($icon, $name, 'mailto:' . $email, $appId); } diff --git a/lib/private/Contacts/ContactsMenu/Actions/LinkAction.php b/lib/private/Contacts/ContactsMenu/Actions/LinkAction.php index 020d13996eb..bee6dce5677 100644 --- a/lib/private/Contacts/ContactsMenu/Actions/LinkAction.php +++ b/lib/private/Contacts/ContactsMenu/Actions/LinkAction.php @@ -20,30 +20,37 @@ class LinkAction implements ILinkAction { /** * @param string $icon absolute URI to an icon */ + #[\Override] public function setIcon(string $icon): void { $this->icon = $icon; } + #[\Override] public function setName(string $name): void { $this->name = $name; } + #[\Override] public function getName(): string { return $this->name; } + #[\Override] public function setPriority(int $priority): void { $this->priority = $priority; } + #[\Override] public function getPriority(): int { return $this->priority; } + #[\Override] public function setHref(string $href): void { $this->href = $href; } + #[\Override] public function getHref(): string { return $this->href; } @@ -51,6 +58,7 @@ class LinkAction implements ILinkAction { /** * @since 23.0.0 */ + #[\Override] public function setAppId(string $appId): void { $this->appId = $appId; } @@ -58,6 +66,7 @@ class LinkAction implements ILinkAction { /** * @since 23.0.0 */ + #[\Override] public function getAppId(): string { return $this->appId; } @@ -65,6 +74,7 @@ class LinkAction implements ILinkAction { /** * @return array{title: string, icon: string, hyperlink: string, appId: string} */ + #[\Override] public function jsonSerialize(): array { return [ 'title' => $this->name, diff --git a/lib/private/Contacts/ContactsMenu/ContactsStore.php b/lib/private/Contacts/ContactsMenu/ContactsStore.php index deb03ce37f3..7d3e9b8e470 100644 --- a/lib/private/Contacts/ContactsMenu/ContactsStore.php +++ b/lib/private/Contacts/ContactsMenu/ContactsStore.php @@ -44,6 +44,7 @@ class ContactsStore implements IContactsStore { /** * @return IEntry[] */ + #[\Override] public function getContacts(IUser $user, ?string $filter, ?int $limit = null, ?int $offset = null): array { $options = [ 'enumeration' => $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') === 'yes', @@ -279,6 +280,7 @@ class ContactsStore implements IContactsStore { })); } + #[\Override] public function findOne(IUser $user, int $shareType, string $shareWith): ?IEntry { switch ($shareType) { case 0: diff --git a/lib/private/Contacts/ContactsMenu/Entry.php b/lib/private/Contacts/ContactsMenu/Entry.php index d4f2dc7bf90..31d871210e4 100644 --- a/lib/private/Contacts/ContactsMenu/Entry.php +++ b/lib/private/Contacts/ContactsMenu/Entry.php @@ -48,6 +48,7 @@ class Entry implements IEntry { $this->fullName = $displayName; } + #[\Override] public function getFullName(): string { return $this->fullName; } @@ -59,6 +60,7 @@ class Entry implements IEntry { /** * @return string[] */ + #[\Override] public function getEMailAddresses(): array { return $this->emailAddresses; } @@ -67,6 +69,7 @@ class Entry implements IEntry { $this->avatar = $avatar; } + #[\Override] public function getAvatar(): ?string { return $this->avatar; } @@ -87,11 +90,13 @@ class Entry implements IEntry { return $this->profileUrl; } + #[\Override] public function addAction(IAction $action): void { $this->actions[] = $action; $this->sortActions(); } + #[\Override] public function setStatus(string $status, ?string $statusMessage = null, ?int $statusMessageTimestamp = null, @@ -138,6 +143,7 @@ class Entry implements IEntry { $this->properties = array_merge($this->properties, $properties); } + #[\Override] public function getProperty(string $key): mixed { if (!isset($this->properties[$key])) { return null; @@ -148,6 +154,7 @@ class Entry implements IEntry { /** * @return array{id: int|string|null, fullName: string, avatar: string|null, topAction: mixed, actions: array, lastMessage: '', emailAddresses: string[], profileTitle: string|null, profileUrl: string|null, status: string|null, statusMessage: null|string, statusMessageTimestamp: null|int, statusIcon: null|string, isUser: bool, uid: mixed} */ + #[\Override] public function jsonSerialize(): array { $topAction = !empty($this->actions) ? $this->actions[0]->jsonSerialize() : null; $otherActions = array_map(function (IAction $action) { diff --git a/lib/private/Contacts/ContactsMenu/Providers/EMailProvider.php b/lib/private/Contacts/ContactsMenu/Providers/EMailProvider.php index 266125f5ed5..75eeb0f5e34 100644 --- a/lib/private/Contacts/ContactsMenu/Providers/EMailProvider.php +++ b/lib/private/Contacts/ContactsMenu/Providers/EMailProvider.php @@ -18,6 +18,7 @@ class EMailProvider implements IProvider { ) { } + #[\Override] public function process(IEntry $entry): void { $iconUrl = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/mail.svg')); foreach ($entry->getEMailAddresses() as $address) { diff --git a/lib/private/Contacts/ContactsMenu/Providers/LocalTimeProvider.php b/lib/private/Contacts/ContactsMenu/Providers/LocalTimeProvider.php index f62e989fd64..0f9fe198dac 100644 --- a/lib/private/Contacts/ContactsMenu/Providers/LocalTimeProvider.php +++ b/lib/private/Contacts/ContactsMenu/Providers/LocalTimeProvider.php @@ -33,6 +33,7 @@ class LocalTimeProvider implements IProvider { ) { } + #[\Override] public function process(IEntry $entry): void { $targetUserId = $entry->getProperty('UID'); $targetUser = $this->userManager->get($targetUserId); diff --git a/lib/private/Contacts/ContactsMenu/Providers/ProfileProvider.php b/lib/private/Contacts/ContactsMenu/Providers/ProfileProvider.php index d00573aaa96..3f4af954989 100644 --- a/lib/private/Contacts/ContactsMenu/Providers/ProfileProvider.php +++ b/lib/private/Contacts/ContactsMenu/Providers/ProfileProvider.php @@ -25,6 +25,7 @@ class ProfileProvider implements IProvider { ) { } + #[\Override] public function process(IEntry $entry): void { $targetUserId = $entry->getProperty('UID'); $targetUser = $this->userManager->get($targetUserId); diff --git a/lib/private/ContactsManager.php b/lib/private/ContactsManager.php index 87b341ac36b..e19efb243b8 100644 --- a/lib/private/ContactsManager.php +++ b/lib/private/ContactsManager.php @@ -31,6 +31,7 @@ class ContactsManager implements IManager { * @psalm-param array{types?: bool, escape_like_param?: bool, limit?: int, offset?: int, enumeration?: bool, fullmatch?: bool, strict_search?: bool} $options * @return array an array of contacts which are arrays of key-value-pairs */ + #[\Override] public function search($pattern, $searchProperties = [], $options = []) { $this->loadAddressBooks(); $result = []; @@ -78,6 +79,7 @@ class ContactsManager implements IManager { * @param string $addressBookKey identifier of the address book in which the contact shall be deleted * @return bool successful or not */ + #[\Override] public function delete($id, $addressBookKey) { $addressBook = $this->getAddressBook($addressBookKey); if (!$addressBook) { @@ -99,6 +101,7 @@ class ContactsManager implements IManager { * @param string $addressBookKey identifier of the address book in which the contact shall be created or updated * @return ?array representing the contact just created or updated */ + #[\Override] public function createOrUpdate($properties, $addressBookKey) { $addressBook = $this->getAddressBook($addressBookKey); if (!$addressBook) { @@ -117,6 +120,7 @@ class ContactsManager implements IManager { * * @return bool true if enabled, false if not */ + #[\Override] public function isEnabled(): bool { return !empty($this->addressBooks) || !empty($this->addressBookLoaders); } @@ -124,6 +128,7 @@ class ContactsManager implements IManager { /** * @param IAddressBook $addressBook */ + #[\Override] public function registerAddressBook(IAddressBook $addressBook) { $this->addressBooks[$addressBook->getKey()] = $addressBook; } @@ -131,6 +136,7 @@ class ContactsManager implements IManager { /** * @param IAddressBook $addressBook */ + #[\Override] public function unregisterAddressBook(IAddressBook $addressBook) { unset($this->addressBooks[$addressBook->getKey()]); } @@ -141,6 +147,7 @@ class ContactsManager implements IManager { * @return IAddressBook[] * @since 16.0.0 */ + #[\Override] public function getUserAddressBooks(): array { $this->loadAddressBooks(); return $this->addressBooks; @@ -149,6 +156,7 @@ class ContactsManager implements IManager { /** * removes all registered address book instances */ + #[\Override] public function clear() { $this->addressBooks = []; $this->addressBookLoaders = []; @@ -170,6 +178,7 @@ class ContactsManager implements IManager { * * @param \Closure $callable */ + #[\Override] public function register(\Closure $callable) { $this->addressBookLoaders[] = $callable; } diff --git a/lib/private/ContextChat/ContentManager.php b/lib/private/ContextChat/ContentManager.php index 3324ce6c700..24e3dc4de6c 100644 --- a/lib/private/ContextChat/ContentManager.php +++ b/lib/private/ContextChat/ContentManager.php @@ -18,38 +18,47 @@ class ContentManager implements IContentManager { ) { } + #[\Override] public function isContextChatAvailable(): bool { return $this->contentManager !== null; } + #[\Override] public function registerContentProvider(string $appId, string $providerId, string $providerClass): void { $this->contentManager?->registerContentProvider($appId, $providerId, $providerClass); } + #[\Override] public function collectAllContentProviders(): void { $this->contentManager?->collectAllContentProviders(); } + #[\Override] public function submitContent(string $appId, array $items): void { $this->contentManager?->submitContent($appId, $items); } + #[\Override] public function updateAccess(string $appId, string $providerId, string $itemId, string $op, array $userIds): void { $this->contentManager?->updateAccess($appId, $providerId, $itemId, $op, $userIds); } + #[\Override] public function updateAccessProvider(string $appId, string $providerId, string $op, array $userIds): void { $this->contentManager?->updateAccessProvider($appId, $providerId, $op, $userIds); } + #[\Override] public function updateAccessDeclarative(string $appId, string $providerId, string $itemId, array $userIds): void { $this->contentManager?->updateAccessDeclarative($appId, $providerId, $itemId, $op, $userIds); } + #[\Override] public function deleteProvider(string $appId, string $providerId): void { $this->contentManager?->deleteProvider($appId, $providerId); } + #[\Override] public function deleteContent(string $appId, string $providerId, array $itemIds): void { $this->contentManager?->deleteContent($appId, $providerId, $itemIds); } diff --git a/lib/private/DB/AdapterMySQL.php b/lib/private/DB/AdapterMySQL.php index 63c75607379..b50e676249d 100644 --- a/lib/private/DB/AdapterMySQL.php +++ b/lib/private/DB/AdapterMySQL.php @@ -14,14 +14,17 @@ class AdapterMySQL extends Adapter { /** * @param string $tableName */ + #[\Override] public function lockTable($tableName) { $this->conn->executeUpdate('LOCK TABLES `' . $tableName . '` WRITE'); } + #[\Override] public function unlockTable() { $this->conn->executeUpdate('UNLOCK TABLES'); } + #[\Override] public function fixupStatement($statement) { $statement = str_replace(' ILIKE ', ' COLLATE ' . $this->getCollation() . ' LIKE ', $statement); return $statement; @@ -36,6 +39,7 @@ class AdapterMySQL extends Adapter { return $this->collation; } + #[\Override] public function insertIgnoreConflict(string $table, array $values): int { $builder = $this->conn->getQueryBuilder(); $builder->insert($table); diff --git a/lib/private/DB/AdapterOCI8.php b/lib/private/DB/AdapterOCI8.php index 0a509090bca..70fe9290cc5 100644 --- a/lib/private/DB/AdapterOCI8.php +++ b/lib/private/DB/AdapterOCI8.php @@ -8,6 +8,7 @@ namespace OC\DB; class AdapterOCI8 extends Adapter { + #[\Override] public function lastInsertId($table) { if (is_null($table)) { throw new \InvalidArgumentException('Oracle requires a table name to be passed into lastInsertId()'); @@ -21,6 +22,7 @@ class AdapterOCI8 extends Adapter { public const UNIX_TIMESTAMP_REPLACEMENT = "(cast(sys_extract_utc(systimestamp) as date) - date'1970-01-01') * 86400"; + #[\Override] public function fixupStatement($statement) { $statement = preg_replace('/`(\w+)` ILIKE \?/', 'REGEXP_LIKE(`$1`, \'^\' || REPLACE(?, \'%\', \'.*\') || \'$\', \'i\')', $statement); $statement = str_replace('`', '"', $statement); diff --git a/lib/private/DB/AdapterPgSql.php b/lib/private/DB/AdapterPgSql.php index db48c81c2c5..fe7181005df 100644 --- a/lib/private/DB/AdapterPgSql.php +++ b/lib/private/DB/AdapterPgSql.php @@ -9,6 +9,7 @@ namespace OC\DB; class AdapterPgSql extends Adapter { + #[\Override] public function lastInsertId($table) { $result = $this->conn->executeQuery('SELECT lastval()'); $val = $result->fetchOne(); @@ -17,12 +18,14 @@ class AdapterPgSql extends Adapter { } public const UNIX_TIMESTAMP_REPLACEMENT = 'cast(extract(epoch from current_timestamp) as integer)'; + #[\Override] public function fixupStatement($statement) { $statement = str_replace('`', '"', $statement); $statement = str_ireplace('UNIX_TIMESTAMP()', self::UNIX_TIMESTAMP_REPLACEMENT, $statement); return $statement; } + #[\Override] public function insertIgnoreConflict(string $table, array $values) : int { // "upsert" is only available since PgSQL 9.5, but the generic way // would leave error logs in the DB. diff --git a/lib/private/DB/AdapterSqlite.php b/lib/private/DB/AdapterSqlite.php index aeadf55ecf7..00fff562094 100644 --- a/lib/private/DB/AdapterSqlite.php +++ b/lib/private/DB/AdapterSqlite.php @@ -13,14 +13,17 @@ class AdapterSqlite extends Adapter { /** * @param string $tableName */ + #[\Override] public function lockTable($tableName) { $this->conn->executeUpdate('BEGIN EXCLUSIVE TRANSACTION'); } + #[\Override] public function unlockTable() { $this->conn->executeUpdate('COMMIT TRANSACTION'); } + #[\Override] public function fixupStatement($statement) { $statement = preg_replace('/`(\w+)` ILIKE \?/', 'LOWER($1) LIKE LOWER(?)', $statement); $statement = str_replace('`', '"', $statement); @@ -44,6 +47,7 @@ class AdapterSqlite extends Adapter { * @throws \Doctrine\DBAL\Exception * @deprecated 15.0.0 - use unique index and "try { $db->insert() } catch (UniqueConstraintViolationException $e) {}" instead, because it is more reliable and does not have the risk for deadlocks - see https://github.com/nextcloud/server/pull/12371 */ + #[\Override] public function insertIfNotExist($table, $input, ?array $compare = null) { if (empty($compare)) { $compare = array_keys($input); @@ -77,6 +81,7 @@ class AdapterSqlite extends Adapter { } } + #[\Override] public function insertIgnoreConflict(string $table, array $values): int { $builder = $this->conn->getQueryBuilder(); $builder->insert($table); diff --git a/lib/private/DB/BacktraceDebugStack.php b/lib/private/DB/BacktraceDebugStack.php index 4afd3ce6a13..cd5b53ea824 100644 --- a/lib/private/DB/BacktraceDebugStack.php +++ b/lib/private/DB/BacktraceDebugStack.php @@ -11,6 +11,7 @@ namespace OC\DB; use Doctrine\DBAL\Logging\DebugStack; class BacktraceDebugStack extends DebugStack { + #[\Override] public function startQuery($sql, ?array $params = null, ?array $types = null) { parent::startQuery($sql, $params, $types); $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); diff --git a/lib/private/DB/Connection.php b/lib/private/DB/Connection.php index 3eef60c6daf..27be1b327e2 100644 --- a/lib/private/DB/Connection.php +++ b/lib/private/DB/Connection.php @@ -204,6 +204,7 @@ class Connection extends PrimaryReadReplicaConnection { /** * @throws Exception */ + #[\Override] public function connect($connectionName = null) { try { if ($this->_conn) { @@ -228,6 +229,7 @@ class Connection extends PrimaryReadReplicaConnection { } } + #[\Override] protected function performConnect(?string $connectionName = null): bool { if (($connectionName ?? 'replica') === 'replica' && count($this->params['replica']) === 1 @@ -286,6 +288,7 @@ class Connection extends PrimaryReadReplicaConnection { * @return \Doctrine\DBAL\Query\QueryBuilder * @deprecated 8.0.0 please use $this->getQueryBuilder() instead */ + #[\Override] public function createQueryBuilder() { $backtrace = $this->getCallerBacktrace(); $this->logger->debug('Doctrine QueryBuilder retrieved in {backtrace}', ['app' => 'core', 'backtrace' => $backtrace]); @@ -299,6 +302,7 @@ class Connection extends PrimaryReadReplicaConnection { * @return \Doctrine\DBAL\Query\Expression\ExpressionBuilder * @deprecated 8.0.0 please use $this->getQueryBuilder()->expr() instead */ + #[\Override] public function getExpressionBuilder() { $backtrace = $this->getCallerBacktrace(); $this->logger->debug('Doctrine ExpressionBuilder retrieved in {backtrace}', ['app' => 'core', 'backtrace' => $backtrace]); @@ -337,6 +341,7 @@ class Connection extends PrimaryReadReplicaConnection { * @return Statement The prepared statement. * @throws Exception */ + #[\Override] public function prepare($sql, $limit = null, $offset = null): Statement { if ($limit === -1 || $limit === null) { $limit = null; @@ -370,6 +375,7 @@ class Connection extends PrimaryReadReplicaConnection { * * @throws \Doctrine\DBAL\Exception */ + #[\Override] public function executeQuery(string $sql, array $params = [], $types = [], ?QueryCacheProfile $qcp = null): Result { $tables = $this->getQueriedTables($sql); $now = $this->clock->now()->getTimestamp(); @@ -431,6 +437,7 @@ class Connection extends PrimaryReadReplicaConnection { /** * @throws Exception */ + #[\Override] public function executeUpdate(string $sql, array $params = [], array $types = []): int { return $this->executeStatement($sql, $params, $types); } @@ -449,6 +456,7 @@ class Connection extends PrimaryReadReplicaConnection { * * @throws \Doctrine\DBAL\Exception */ + #[\Override] public function executeStatement($sql, array $params = [], array $types = []): int { $tables = $this->getQueriedTables($sql); foreach ($tables as $table) { @@ -510,6 +518,7 @@ class Connection extends PrimaryReadReplicaConnection { * @return int the last inserted ID. * @throws Exception */ + #[\Override] public function lastInsertId($name = null): int { if ($name) { $name = $this->replaceTablePrefix($name); @@ -827,6 +836,7 @@ class Connection extends PrimaryReadReplicaConnection { } } + #[\Override] public function beginTransaction() { if (!$this->inTransaction()) { $this->transactionBacktrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); @@ -835,6 +845,7 @@ class Connection extends PrimaryReadReplicaConnection { return parent::beginTransaction(); } + #[\Override] public function commit() { $result = parent::commit(); if ($this->getTransactionNestingLevel() === 0) { @@ -861,6 +872,7 @@ class Connection extends PrimaryReadReplicaConnection { return $result; } + #[\Override] public function rollBack() { $result = parent::rollBack(); if ($this->getTransactionNestingLevel() === 0) { diff --git a/lib/private/DB/ConnectionAdapter.php b/lib/private/DB/ConnectionAdapter.php index d9e3e7ec549..0f275c3aae2 100644 --- a/lib/private/DB/ConnectionAdapter.php +++ b/lib/private/DB/ConnectionAdapter.php @@ -29,14 +29,17 @@ class ConnectionAdapter implements IDBConnection { ) { } + #[\Override] public function getQueryBuilder(): IQueryBuilder { return $this->inner->getQueryBuilder(); } + #[\Override] public function getTypedQueryBuilder(): ITypedQueryBuilder { return $this->inner->getTypedQueryBuilder(); } + #[\Override] public function prepare($sql, $limit = null, $offset = null): IPreparedStatement { try { return new PreparedStatement( @@ -47,6 +50,7 @@ class ConnectionAdapter implements IDBConnection { } } + #[\Override] public function executeQuery(string $sql, array $params = [], $types = []): IResult { try { return new ResultAdapter( @@ -57,6 +61,7 @@ class ConnectionAdapter implements IDBConnection { } } + #[\Override] public function executeUpdate(string $sql, array $params = [], array $types = []): int { try { return $this->inner->executeUpdate($sql, $params, $types); @@ -65,6 +70,7 @@ class ConnectionAdapter implements IDBConnection { } } + #[\Override] public function executeStatement($sql, array $params = [], array $types = []): int { try { return $this->inner->executeStatement($sql, $params, $types); @@ -73,6 +79,7 @@ class ConnectionAdapter implements IDBConnection { } } + #[\Override] public function lastInsertId(string $table): int { try { return $this->inner->lastInsertId($table); @@ -81,6 +88,7 @@ class ConnectionAdapter implements IDBConnection { } } + #[\Override] public function insertIfNotExist(string $table, array $input, ?array $compare = null) { try { return $this->inner->insertIfNotExist($table, $input, $compare); @@ -89,6 +97,7 @@ class ConnectionAdapter implements IDBConnection { } } + #[\Override] public function insertIgnoreConflict(string $table, array $values): int { try { return $this->inner->insertIgnoreConflict($table, $values); @@ -97,6 +106,7 @@ class ConnectionAdapter implements IDBConnection { } } + #[\Override] public function setValues($table, array $keys, array $values, array $updatePreconditionValues = []): int { try { return $this->inner->setValues($table, $keys, $values, $updatePreconditionValues); @@ -105,6 +115,7 @@ class ConnectionAdapter implements IDBConnection { } } + #[\Override] public function lockTable($tableName): void { try { $this->inner->lockTable($tableName); @@ -113,6 +124,7 @@ class ConnectionAdapter implements IDBConnection { } } + #[\Override] public function unlockTable(): void { try { $this->inner->unlockTable(); @@ -121,6 +133,7 @@ class ConnectionAdapter implements IDBConnection { } } + #[\Override] public function beginTransaction(): void { try { $this->inner->beginTransaction(); @@ -129,10 +142,12 @@ class ConnectionAdapter implements IDBConnection { } } + #[\Override] public function inTransaction(): bool { return $this->inner->inTransaction(); } + #[\Override] public function commit(): void { try { $this->inner->commit(); @@ -141,6 +156,7 @@ class ConnectionAdapter implements IDBConnection { } } + #[\Override] public function rollBack(): void { try { $this->inner->rollBack(); @@ -149,18 +165,22 @@ class ConnectionAdapter implements IDBConnection { } } + #[\Override] public function getError(): string { return $this->inner->getError(); } + #[\Override] public function errorCode() { return $this->inner->errorCode(); } + #[\Override] public function errorInfo() { return $this->inner->errorInfo(); } + #[\Override] public function connect(): bool { try { return $this->inner->connect(); @@ -169,10 +189,12 @@ class ConnectionAdapter implements IDBConnection { } } + #[\Override] public function close(): void { $this->inner->close(); } + #[\Override] public function quote($input, $type = IQueryBuilder::PARAM_STR) { return $this->inner->quote($input, $type); } @@ -180,10 +202,12 @@ class ConnectionAdapter implements IDBConnection { /** * @todo we are leaking a 3rdparty type here */ + #[\Override] public function getDatabasePlatform(): AbstractPlatform { return $this->inner->getDatabasePlatform(); } + #[\Override] public function dropTable(string $table): void { try { $this->inner->dropTable($table); @@ -192,6 +216,7 @@ class ConnectionAdapter implements IDBConnection { } } + #[\Override] public function truncateTable(string $table, bool $cascade): void { try { $this->inner->truncateTable($table, $cascade); @@ -200,6 +225,7 @@ class ConnectionAdapter implements IDBConnection { } } + #[\Override] public function tableExists(string $table): bool { try { return $this->inner->tableExists($table); @@ -208,10 +234,12 @@ class ConnectionAdapter implements IDBConnection { } } + #[\Override] public function escapeLikeParameter(string $param): string { return $this->inner->escapeLikeParameter($param); } + #[\Override] public function supports4ByteText(): bool { return $this->inner->supports4ByteText(); } @@ -219,6 +247,7 @@ class ConnectionAdapter implements IDBConnection { /** * @todo leaks a 3rdparty type */ + #[\Override] public function createSchema(): Schema { try { return $this->inner->createSchema(); @@ -227,6 +256,7 @@ class ConnectionAdapter implements IDBConnection { } } + #[\Override] public function migrateToSchema(Schema $toSchema): void { try { $this->inner->migrateToSchema($toSchema); @@ -242,6 +272,7 @@ class ConnectionAdapter implements IDBConnection { /** * @return self::PLATFORM_MYSQL|self::PLATFORM_ORACLE|self::PLATFORM_POSTGRES|self::PLATFORM_SQLITE|self::PLATFORM_MARIADB */ + #[\Override] public function getDatabaseProvider(bool $strict = false): string { return $this->inner->getDatabaseProvider($strict); } @@ -258,10 +289,12 @@ class ConnectionAdapter implements IDBConnection { $this->inner->logDatabaseException($exception); } + #[\Override] public function getShardDefinition(string $name): ?ShardDefinition { return $this->inner->getShardDefinition($name); } + #[\Override] public function getCrossShardMoveHelper(): CrossShardMoveHelper { return $this->inner->getCrossShardMoveHelper(); } diff --git a/lib/private/DB/DbDataCollector.php b/lib/private/DB/DbDataCollector.php index 828674586e0..9a6f45baae1 100644 --- a/lib/private/DB/DbDataCollector.php +++ b/lib/private/DB/DbDataCollector.php @@ -29,6 +29,7 @@ class DbDataCollector extends AbstractDataCollector { /** * @inheritDoc */ + #[\Override] public function collect(Request $request, Response $response, ?\Throwable $exception = null): void { $queries = $this->sanitizeQueries($this->debugStack->queries); @@ -37,6 +38,7 @@ class DbDataCollector extends AbstractDataCollector { ]; } + #[\Override] public function getName(): string { return 'db'; } diff --git a/lib/private/DB/Exceptions/DbalException.php b/lib/private/DB/Exceptions/DbalException.php index a34ebfe651d..483b3d8542f 100644 --- a/lib/private/DB/Exceptions/DbalException.php +++ b/lib/private/DB/Exceptions/DbalException.php @@ -59,6 +59,7 @@ class DbalException extends Exception { return $this->original instanceof RetryableException; } + #[\Override] public function getReason(): ?int { /** * Constraint errors diff --git a/lib/private/DB/OracleConnection.php b/lib/private/DB/OracleConnection.php index c572157d750..6b4efa8ca5a 100644 --- a/lib/private/DB/OracleConnection.php +++ b/lib/private/DB/OracleConnection.php @@ -26,6 +26,7 @@ class OracleConnection extends Connection { return $return; } + #[\Override] public function truncateTable(string $table, bool $cascade) { if ($table[0] !== $this->getDatabasePlatform()->getIdentifierQuoteCharacter()) { $table = $this->quoteIdentifier($table); @@ -36,6 +37,7 @@ class OracleConnection extends Connection { /** * {@inheritDoc} */ + #[\Override] public function insert($table, array $data, array $types = []) { if ($table[0] !== $this->getDatabasePlatform()->getIdentifierQuoteCharacter()) { $table = $this->quoteIdentifier($table); @@ -47,6 +49,7 @@ class OracleConnection extends Connection { /** * {@inheritDoc} */ + #[\Override] public function update($table, array $data, array $criteria, array $types = []) { if ($table[0] !== $this->getDatabasePlatform()->getIdentifierQuoteCharacter()) { $table = $this->quoteIdentifier($table); @@ -59,6 +62,7 @@ class OracleConnection extends Connection { /** * {@inheritDoc} */ + #[\Override] public function delete($table, array $criteria, array $types = []) { if ($table[0] !== $this->getDatabasePlatform()->getIdentifierQuoteCharacter()) { $table = $this->quoteIdentifier($table); @@ -72,6 +76,7 @@ class OracleConnection extends Connection { * * @param string $table table name without the prefix */ + #[\Override] public function dropTable($table) { $table = $this->tablePrefix . trim($table); $table = $this->quoteIdentifier($table); @@ -87,6 +92,7 @@ class OracleConnection extends Connection { * @param string $table table name without the prefix * @return bool */ + #[\Override] public function tableExists($table) { $table = $this->tablePrefix . trim($table); $table = $this->quoteIdentifier($table); diff --git a/lib/private/DB/OracleMigrator.php b/lib/private/DB/OracleMigrator.php index c5a7646dbb2..30e44af6e95 100644 --- a/lib/private/DB/OracleMigrator.php +++ b/lib/private/DB/OracleMigrator.php @@ -18,6 +18,7 @@ class OracleMigrator extends Migrator { * @return \Doctrine\DBAL\Schema\SchemaDiff * @throws Exception */ + #[\Override] protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection): \Doctrine\DBAL\Schema\SchemaDiff { // oracle forces us to quote the identifiers $quotedSchema = new Schema(); @@ -123,6 +124,7 @@ class OracleMigrator extends Migrator { * @param $statement * @return string */ + #[\Override] protected function convertStatementToScript($statement) { if (str_ends_with($statement, ';')) { return $statement . PHP_EOL . '/' . PHP_EOL; @@ -133,6 +135,7 @@ class OracleMigrator extends Migrator { return $script; } + #[\Override] protected function getFilterExpression() { return '/^"' . preg_quote($this->config->getSystemValueString('dbtableprefix', 'oc_')) . '/'; } diff --git a/lib/private/DB/PreparedStatement.php b/lib/private/DB/PreparedStatement.php index 54561ed96cd..f88ad0edc6c 100644 --- a/lib/private/DB/PreparedStatement.php +++ b/lib/private/DB/PreparedStatement.php @@ -35,40 +35,49 @@ class PreparedStatement implements IPreparedStatement { $this->statement = $statement; } + #[\Override] public function closeCursor(): bool { $this->getResult()->closeCursor(); return true; } + #[\Override] public function fetch(int $fetchMode = PDO::FETCH_ASSOC) { return $this->getResult()->fetch($fetchMode); } + #[\Override] public function fetchAll(int $fetchMode = PDO::FETCH_ASSOC): array { return $this->getResult()->fetchAll($fetchMode); } + #[\Override] public function fetchColumn() { return $this->getResult()->fetchOne(); } + #[\Override] public function fetchOne() { return $this->getResult()->fetchOne(); } + #[\Override] public function bindValue($param, $value, $type = ParameterType::STRING): bool { return $this->statement->bindValue($param, $value, $type); } + #[\Override] public function bindParam($param, &$variable, $type = ParameterType::STRING, $length = null): bool { return $this->statement->bindParam($param, $variable, $type, $length); } + #[\Override] public function execute($params = null): IResult { return ($this->result = new ResultAdapter($this->statement->execute($params))); } + #[\Override] public function rowCount(): int { return $this->getResult()->rowCount(); } diff --git a/lib/private/DB/QueryBuilder/CompositeExpression.php b/lib/private/DB/QueryBuilder/CompositeExpression.php index 18adf242c89..6a1d6c3f513 100644 --- a/lib/private/DB/QueryBuilder/CompositeExpression.php +++ b/lib/private/DB/QueryBuilder/CompositeExpression.php @@ -51,6 +51,7 @@ class CompositeExpression implements ICompositeExpression, \Countable { * * @return integer */ + #[\Override] public function count(): int { return count($this->parts); } @@ -60,6 +61,7 @@ class CompositeExpression implements ICompositeExpression, \Countable { * * @return string */ + #[\Override] public function getType(): string { return $this->type; } diff --git a/lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php b/lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php index 8436fd365a0..3565e97efd1 100644 --- a/lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php +++ b/lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php @@ -51,6 +51,7 @@ class ExpressionBuilder implements IExpressionBuilder { * * @return ICompositeExpression */ + #[\Override] public function andX(...$x): ICompositeExpression { if (empty($x)) { $this->logger->debug('Calling ' . IQueryBuilder::class . '::' . __FUNCTION__ . ' without parameters is deprecated and will throw soon.', ['exception' => new \Exception('No parameters in call to ' . __METHOD__)]); @@ -72,6 +73,7 @@ class ExpressionBuilder implements IExpressionBuilder { * * @return ICompositeExpression */ + #[\Override] public function orX(...$x): ICompositeExpression { if (empty($x)) { $this->logger->debug('Calling ' . IQueryBuilder::class . '::' . __FUNCTION__ . ' without parameters is deprecated and will throw soon.', ['exception' => new \Exception('No parameters in call to ' . __METHOD__)]); @@ -90,6 +92,7 @@ class ExpressionBuilder implements IExpressionBuilder { * * @return string */ + #[\Override] public function comparison($x, string $operator, $y, $type = null): string { $x = $this->prepareColumn($x, $type); $y = $this->prepareColumn($y, $type); @@ -113,6 +116,7 @@ class ExpressionBuilder implements IExpressionBuilder { * * @return string */ + #[\Override] public function eq($x, $y, $type = null): string { $x = $this->prepareColumn($x, $type); $y = $this->prepareColumn($y, $type); @@ -135,6 +139,7 @@ class ExpressionBuilder implements IExpressionBuilder { * * @return string */ + #[\Override] public function neq($x, $y, $type = null): string { $x = $this->prepareColumn($x, $type); $y = $this->prepareColumn($y, $type); @@ -157,6 +162,7 @@ class ExpressionBuilder implements IExpressionBuilder { * * @return string */ + #[\Override] public function lt($x, $y, $type = null): string { $x = $this->prepareColumn($x, $type); $y = $this->prepareColumn($y, $type); @@ -179,6 +185,7 @@ class ExpressionBuilder implements IExpressionBuilder { * * @return string */ + #[\Override] public function lte($x, $y, $type = null): string { $x = $this->prepareColumn($x, $type); $y = $this->prepareColumn($y, $type); @@ -201,6 +208,7 @@ class ExpressionBuilder implements IExpressionBuilder { * * @return string */ + #[\Override] public function gt($x, $y, $type = null): string { $x = $this->prepareColumn($x, $type); $y = $this->prepareColumn($y, $type); @@ -223,6 +231,7 @@ class ExpressionBuilder implements IExpressionBuilder { * * @return string */ + #[\Override] public function gte($x, $y, $type = null): string { $x = $this->prepareColumn($x, $type); $y = $this->prepareColumn($y, $type); @@ -236,6 +245,7 @@ class ExpressionBuilder implements IExpressionBuilder { * * @return string */ + #[\Override] public function isNull($x): string { $x = $this->helper->quoteColumnName($x); return $this->expressionBuilder->isNull($x); @@ -248,6 +258,7 @@ class ExpressionBuilder implements IExpressionBuilder { * * @return string */ + #[\Override] public function isNotNull($x): string { $x = $this->helper->quoteColumnName($x); return $this->expressionBuilder->isNotNull($x); @@ -263,6 +274,7 @@ class ExpressionBuilder implements IExpressionBuilder { * * @return string */ + #[\Override] public function like($x, $y, $type = null): string { $x = $this->helper->quoteColumnName($x); $y = $this->helper->quoteColumnName($y); @@ -280,6 +292,7 @@ class ExpressionBuilder implements IExpressionBuilder { * @return string * @since 9.0.0 */ + #[\Override] public function iLike($x, $y, $type = null): string { return $this->expressionBuilder->like($this->functionBuilder->lower($x), $this->functionBuilder->lower($y)); } @@ -294,6 +307,7 @@ class ExpressionBuilder implements IExpressionBuilder { * * @return string */ + #[\Override] public function notLike($x, $y, $type = null): string { $x = $this->helper->quoteColumnName($x); $y = $this->helper->quoteColumnName($y); @@ -310,6 +324,7 @@ class ExpressionBuilder implements IExpressionBuilder { * * @return string */ + #[\Override] public function in($x, $y, $type = null): string { $x = $this->helper->quoteColumnName($x); $y = $this->helper->quoteColumnNames($y); @@ -326,6 +341,7 @@ class ExpressionBuilder implements IExpressionBuilder { * * @return string */ + #[\Override] public function notIn($x, $y, $type = null): string { $x = $this->helper->quoteColumnName($x); $y = $this->helper->quoteColumnNames($y); @@ -339,6 +355,7 @@ class ExpressionBuilder implements IExpressionBuilder { * @return string * @since 13.0.0 */ + #[\Override] public function emptyString($x): string { return $this->eq($x, $this->literal('', IQueryBuilder::PARAM_STR)); } @@ -350,6 +367,7 @@ class ExpressionBuilder implements IExpressionBuilder { * @return string * @since 13.0.0 */ + #[\Override] public function nonEmptyString($x): string { return $this->neq($x, $this->literal('', IQueryBuilder::PARAM_STR)); } @@ -362,6 +380,7 @@ class ExpressionBuilder implements IExpressionBuilder { * @return IQueryFunction * @since 12.0.0 */ + #[\Override] public function bitwiseAnd($x, int $y): IQueryFunction { return new QueryFunction($this->connection->getDatabasePlatform()->getBitAndComparisonExpression( $this->helper->quoteColumnName($x), @@ -377,6 +396,7 @@ class ExpressionBuilder implements IExpressionBuilder { * @return IQueryFunction * @since 12.0.0 */ + #[\Override] public function bitwiseOr($x, int $y): IQueryFunction { return new QueryFunction($this->connection->getDatabasePlatform()->getBitOrComparisonExpression( $this->helper->quoteColumnName($x), @@ -392,6 +412,7 @@ class ExpressionBuilder implements IExpressionBuilder { * * @return ILiteral */ + #[\Override] public function literal($input, $type = IQueryBuilder::PARAM_STR): ILiteral { return new Literal($this->expressionBuilder->literal($input, $type)); } @@ -404,6 +425,7 @@ class ExpressionBuilder implements IExpressionBuilder { * @psalm-param IQueryBuilder::PARAM_* $type * @return IQueryFunction */ + #[\Override] public function castColumn($column, $type): IQueryFunction { return new QueryFunction( $this->helper->quoteColumnName($column) diff --git a/lib/private/DB/QueryBuilder/ExpressionBuilder/MySqlExpressionBuilder.php b/lib/private/DB/QueryBuilder/ExpressionBuilder/MySqlExpressionBuilder.php index 0227c3154e3..a604f6957a3 100644 --- a/lib/private/DB/QueryBuilder/ExpressionBuilder/MySqlExpressionBuilder.php +++ b/lib/private/DB/QueryBuilder/ExpressionBuilder/MySqlExpressionBuilder.php @@ -26,6 +26,7 @@ class MySqlExpressionBuilder extends ExpressionBuilder { /** * @inheritdoc */ + #[\Override] public function iLike($x, $y, $type = null): string { $x = $this->helper->quoteColumnName($x); $y = $this->helper->quoteColumnName($y); @@ -40,6 +41,7 @@ class MySqlExpressionBuilder extends ExpressionBuilder { * @psalm-param IQueryBuilder::PARAM_* $type * @return IQueryFunction */ + #[\Override] public function castColumn($column, $type): IQueryFunction { switch ($type) { case IQueryBuilder::PARAM_STR: diff --git a/lib/private/DB/QueryBuilder/ExpressionBuilder/OCIExpressionBuilder.php b/lib/private/DB/QueryBuilder/ExpressionBuilder/OCIExpressionBuilder.php index 20308b24550..f95cd98921f 100644 --- a/lib/private/DB/QueryBuilder/ExpressionBuilder/OCIExpressionBuilder.php +++ b/lib/private/DB/QueryBuilder/ExpressionBuilder/OCIExpressionBuilder.php @@ -19,6 +19,7 @@ class OCIExpressionBuilder extends ExpressionBuilder { * @param mixed|null $type * @return array|IQueryFunction|string */ + #[\Override] protected function prepareColumn($column, $type) { if ($type === IQueryBuilder::PARAM_STR && !is_array($column) && !($column instanceof IParameter) && !($column instanceof ILiteral)) { $column = $this->castColumn($column, $type); @@ -30,6 +31,7 @@ class OCIExpressionBuilder extends ExpressionBuilder { /** * @inheritdoc */ + #[\Override] public function eq($x, $y, $type = null): string { if ($type === IQueryBuilder::PARAM_JSON) { $x = $this->prepareColumn($x, $type); @@ -43,6 +45,7 @@ class OCIExpressionBuilder extends ExpressionBuilder { /** * @inheritdoc */ + #[\Override] public function neq($x, $y, $type = null): string { if ($type === IQueryBuilder::PARAM_JSON) { $x = $this->prepareColumn($x, $type); @@ -56,6 +59,7 @@ class OCIExpressionBuilder extends ExpressionBuilder { /** * @inheritdoc */ + #[\Override] public function in($x, $y, $type = null): string { $x = $this->prepareColumn($x, $type); $y = $this->prepareColumn($y, $type); @@ -66,6 +70,7 @@ class OCIExpressionBuilder extends ExpressionBuilder { /** * @inheritdoc */ + #[\Override] public function notIn($x, $y, $type = null): string { $x = $this->prepareColumn($x, $type); $y = $this->prepareColumn($y, $type); @@ -80,6 +85,7 @@ class OCIExpressionBuilder extends ExpressionBuilder { * @return string * @since 13.0.0 */ + #[\Override] public function emptyString($x): string { return $this->isNull($x); } @@ -91,6 +97,7 @@ class OCIExpressionBuilder extends ExpressionBuilder { * @return string * @since 13.0.0 */ + #[\Override] public function nonEmptyString($x): string { return $this->isNotNull($x); } @@ -103,6 +110,7 @@ class OCIExpressionBuilder extends ExpressionBuilder { * @psalm-param IQueryBuilder::PARAM_* $type * @return IQueryFunction */ + #[\Override] public function castColumn($column, $type): IQueryFunction { if ($type === IQueryBuilder::PARAM_STR) { $column = $this->helper->quoteColumnName($column); @@ -119,6 +127,7 @@ class OCIExpressionBuilder extends ExpressionBuilder { /** * @inheritdoc */ + #[\Override] public function like($x, $y, $type = null): string { return parent::like($x, $y, $type) . " ESCAPE '\\'"; } @@ -126,6 +135,7 @@ class OCIExpressionBuilder extends ExpressionBuilder { /** * @inheritdoc */ + #[\Override] public function iLike($x, $y, $type = null): string { return $this->like($this->functionBuilder->lower($x), $this->functionBuilder->lower($y)); } diff --git a/lib/private/DB/QueryBuilder/ExpressionBuilder/PgSqlExpressionBuilder.php b/lib/private/DB/QueryBuilder/ExpressionBuilder/PgSqlExpressionBuilder.php index f30fccadb1f..e3dd5841a11 100644 --- a/lib/private/DB/QueryBuilder/ExpressionBuilder/PgSqlExpressionBuilder.php +++ b/lib/private/DB/QueryBuilder/ExpressionBuilder/PgSqlExpressionBuilder.php @@ -22,6 +22,7 @@ class PgSqlExpressionBuilder extends ExpressionBuilder { * @psalm-param IQueryBuilder::PARAM_* $type * @return IQueryFunction */ + #[\Override] public function castColumn($column, $type): IQueryFunction { switch ($type) { case IQueryBuilder::PARAM_INT: @@ -37,6 +38,7 @@ class PgSqlExpressionBuilder extends ExpressionBuilder { /** * @inheritdoc */ + #[\Override] protected function prepareColumn($column, $type) { if ($type === IQueryBuilder::PARAM_JSON && !is_array($column) && !($column instanceof IParameter) && !($column instanceof ILiteral)) { $column = $this->castColumn($column, $type); @@ -48,6 +50,7 @@ class PgSqlExpressionBuilder extends ExpressionBuilder { /** * @inheritdoc */ + #[\Override] public function iLike($x, $y, $type = null): string { $x = $this->helper->quoteColumnName($x); $y = $this->helper->quoteColumnName($y); diff --git a/lib/private/DB/QueryBuilder/ExpressionBuilder/SqliteExpressionBuilder.php b/lib/private/DB/QueryBuilder/ExpressionBuilder/SqliteExpressionBuilder.php index 52f82db2232..f1ae4d06536 100644 --- a/lib/private/DB/QueryBuilder/ExpressionBuilder/SqliteExpressionBuilder.php +++ b/lib/private/DB/QueryBuilder/ExpressionBuilder/SqliteExpressionBuilder.php @@ -16,10 +16,12 @@ class SqliteExpressionBuilder extends ExpressionBuilder { /** * @inheritdoc */ + #[\Override] public function like($x, $y, $type = null): string { return parent::like($x, $y, $type) . " ESCAPE '\\'"; } + #[\Override] public function iLike($x, $y, $type = null): string { return $this->like($this->functionBuilder->lower($x), $this->functionBuilder->lower($y), $type); } @@ -29,6 +31,7 @@ class SqliteExpressionBuilder extends ExpressionBuilder { * @param mixed|null $type * @return array|IQueryFunction|string */ + #[\Override] protected function prepareColumn($column, $type) { if ($type !== null && !is_array($column) @@ -48,6 +51,7 @@ class SqliteExpressionBuilder extends ExpressionBuilder { * @param mixed $type One of IQueryBuilder::PARAM_* * @return IQueryFunction */ + #[\Override] public function castColumn($column, $type): IQueryFunction { switch ($type) { case IQueryBuilder::PARAM_DATE_MUTABLE: diff --git a/lib/private/DB/QueryBuilder/ExtendedQueryBuilder.php b/lib/private/DB/QueryBuilder/ExtendedQueryBuilder.php index 33901ace1d4..5cc0771c0be 100644 --- a/lib/private/DB/QueryBuilder/ExtendedQueryBuilder.php +++ b/lib/private/DB/QueryBuilder/ExtendedQueryBuilder.php @@ -22,276 +22,336 @@ abstract class ExtendedQueryBuilder extends TypedQueryBuilder { ) { } + #[\Override] public function automaticTablePrefix($enabled) { $this->builder->automaticTablePrefix($enabled); return $this; } + #[\Override] public function expr() { return $this->builder->expr(); } + #[\Override] public function func() { return $this->builder->func(); } + #[\Override] public function getType() { return $this->builder->getType(); } + #[\Override] public function getConnection() { return $this->builder->getConnection(); } + #[\Override] public function getState() { return $this->builder->getState(); } + #[\Override] public function getSQL() { return $this->builder->getSQL(); } + #[\Override] public function setParameter($key, $value, $type = null) { $this->builder->setParameter($key, $value, $type); return $this; } + #[\Override] public function setParameters(array $params, array $types = []) { $this->builder->setParameters($params, $types); return $this; } + #[\Override] public function getParameters() { return $this->builder->getParameters(); } + #[\Override] public function getParameter($key) { return $this->builder->getParameter($key); } + #[\Override] public function getParameterTypes() { return $this->builder->getParameterTypes(); } + #[\Override] public function getParameterType($key) { return $this->builder->getParameterType($key); } + #[\Override] public function setFirstResult($firstResult) { $this->builder->setFirstResult($firstResult); return $this; } + #[\Override] public function getFirstResult() { return $this->builder->getFirstResult(); } + #[\Override] public function setMaxResults($maxResults) { $this->builder->setMaxResults($maxResults); return $this; } + #[\Override] public function getMaxResults() { return $this->builder->getMaxResults(); } + #[\Override] public function select(...$selects) { $this->builder->select(...$selects); return $this; } + #[\Override] public function selectAlias($select, $alias): self { $this->builder->selectAlias($select, $alias); return $this; } + #[\Override] public function selectDistinct($select) { $this->builder->selectDistinct($select); return $this; } + #[\Override] public function addSelect(...$select) { $this->builder->addSelect(...$select); return $this; } + #[\Override] public function delete($delete = null, $alias = null) { $this->builder->delete($delete, $alias); return $this; } + #[\Override] public function update($update = null, $alias = null) { $this->builder->update($update, $alias); return $this; } + #[\Override] public function insert($insert = null) { $this->builder->insert($insert); return $this; } + #[\Override] public function from($from, $alias = null) { $this->builder->from($from, $alias); return $this; } + #[\Override] public function join($fromAlias, $join, $alias, $condition = null) { $this->builder->join($fromAlias, $join, $alias, $condition); return $this; } + #[\Override] public function innerJoin($fromAlias, $join, $alias, $condition = null) { $this->builder->innerJoin($fromAlias, $join, $alias, $condition); return $this; } + #[\Override] public function leftJoin($fromAlias, $join, $alias, $condition = null) { $this->builder->leftJoin($fromAlias, $join, $alias, $condition); return $this; } + #[\Override] public function rightJoin($fromAlias, $join, $alias, $condition = null) { $this->builder->rightJoin($fromAlias, $join, $alias, $condition); return $this; } + #[\Override] public function set($key, $value) { $this->builder->set($key, $value); return $this; } + #[\Override] public function where(...$predicates) { $this->builder->where(...$predicates); return $this; } + #[\Override] public function andWhere(...$where) { $this->builder->andWhere(...$where); return $this; } + #[\Override] public function orWhere(...$where) { $this->builder->orWhere(...$where); return $this; } + #[\Override] public function groupBy(...$groupBys) { $this->builder->groupBy(...$groupBys); return $this; } + #[\Override] public function addGroupBy(...$groupBy) { $this->builder->addGroupBy(...$groupBy); return $this; } + #[\Override] public function setValue($column, $value) { $this->builder->setValue($column, $value); return $this; } + #[\Override] public function values(array $values) { $this->builder->values($values); return $this; } + #[\Override] public function having(...$having) { $this->builder->having(...$having); return $this; } + #[\Override] public function andHaving(...$having) { $this->builder->andHaving(...$having); return $this; } + #[\Override] public function orHaving(...$having) { $this->builder->orHaving(...$having); return $this; } + #[\Override] public function orderBy($sort, $order = null) { $this->builder->orderBy($sort, $order); return $this; } + #[\Override] public function addOrderBy($sort, $order = null) { $this->builder->addOrderBy($sort, $order); return $this; } + #[\Override] public function getQueryPart($queryPartName) { return $this->builder->getQueryPart($queryPartName); } + #[\Override] public function getQueryParts() { return $this->builder->getQueryParts(); } + #[\Override] public function resetQueryParts($queryPartNames = null) { $this->builder->resetQueryParts($queryPartNames); return $this; } + #[\Override] public function resetQueryPart($queryPartName) { $this->builder->resetQueryPart($queryPartName); return $this; } + #[\Override] public function createNamedParameter($value, $type = self::PARAM_STR, $placeHolder = null) { return $this->builder->createNamedParameter($value, $type, $placeHolder); } + #[\Override] public function createPositionalParameter($value, $type = self::PARAM_STR) { return $this->builder->createPositionalParameter($value, $type); } + #[\Override] public function createParameter($name) { return $this->builder->createParameter($name); } + #[\Override] public function createFunction($call) { return $this->builder->createFunction($call); } + #[\Override] public function getLastInsertId(): int { return $this->builder->getLastInsertId(); } + #[\Override] public function getTableName($table) { return $this->builder->getTableName($table); } + #[\Override] public function getColumnName($column, $tableAlias = '') { return $this->builder->getColumnName($column, $tableAlias); } + #[\Override] public function executeQuery(?IDBConnection $connection = null): IResult { return $this->builder->executeQuery($connection); } + #[\Override] public function executeStatement(?IDBConnection $connection = null): int { return $this->builder->executeStatement($connection); } + #[\Override] public function hintShardKey(string $column, mixed $value, bool $overwrite = false): self { $this->builder->hintShardKey($column, $value, $overwrite); return $this; } + #[\Override] public function runAcrossAllShards(): self { $this->builder->runAcrossAllShards(); return $this; } + #[\Override] public function getOutputColumns(): array { return $this->builder->getOutputColumns(); } + #[\Override] public function prefixTableName(string $table): string { return $this->builder->prefixTableName($table); } + #[\Override] public function forUpdate(ConflictResolutionMode $conflictResolutionMode = ConflictResolutionMode::Ordinary): self { $this->builder->forUpdate($conflictResolutionMode); return $this; diff --git a/lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php b/lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php index c488bb7ff95..acdf19189a7 100644 --- a/lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php +++ b/lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php @@ -22,10 +22,12 @@ class FunctionBuilder implements IFunctionBuilder { ) { } + #[\Override] public function md5($input): IQueryFunction { return new QueryFunction('MD5(' . $this->helper->quoteColumnName($input) . ')'); } + #[\Override] public function concat($x, ...$expr): IQueryFunction { $args = func_get_args(); $list = []; @@ -35,11 +37,13 @@ class FunctionBuilder implements IFunctionBuilder { return new QueryFunction(sprintf('CONCAT(%s)', implode(', ', $list))); } + #[\Override] public function groupConcat($expr, ?string $separator = ','): IQueryFunction { $separator = $this->connection->quote($separator); return new QueryFunction('GROUP_CONCAT(' . $this->helper->quoteColumnName($expr) . ' SEPARATOR ' . $separator . ')'); } + #[\Override] public function substring($input, $start, $length = null): IQueryFunction { if ($length) { return new QueryFunction('SUBSTR(' . $this->helper->quoteColumnName($input) . ', ' . $this->helper->quoteColumnName($start) . ', ' . $this->helper->quoteColumnName($length) . ')'); @@ -48,52 +52,63 @@ class FunctionBuilder implements IFunctionBuilder { } } + #[\Override] public function sum($field): IQueryFunction { return new QueryFunction('SUM(' . $this->helper->quoteColumnName($field) . ')'); } + #[\Override] public function lower($field): IQueryFunction { return new QueryFunction('LOWER(' . $this->helper->quoteColumnName($field) . ')'); } + #[\Override] public function add($x, $y): IQueryFunction { return new QueryFunction($this->helper->quoteColumnName($x) . ' + ' . $this->helper->quoteColumnName($y)); } + #[\Override] public function subtract($x, $y): IQueryFunction { return new QueryFunction($this->helper->quoteColumnName($x) . ' - ' . $this->helper->quoteColumnName($y)); } + #[\Override] public function count($count = '', $alias = ''): IQueryFunction { $alias = $alias ? (' AS ' . $this->helper->quoteColumnName($alias)) : ''; $quotedName = $count === '' ? '*' : $this->helper->quoteColumnName($count); return new QueryFunction('COUNT(' . $quotedName . ')' . $alias); } + #[\Override] public function octetLength($field, $alias = ''): IQueryFunction { $alias = $alias ? (' AS ' . $this->helper->quoteColumnName($alias)) : ''; $quotedName = $this->helper->quoteColumnName($field); return new QueryFunction('OCTET_LENGTH(' . $quotedName . ')' . $alias); } + #[\Override] public function charLength($field, $alias = ''): IQueryFunction { $alias = $alias ? (' AS ' . $this->helper->quoteColumnName($alias)) : ''; $quotedName = $this->helper->quoteColumnName($field); return new QueryFunction('CHAR_LENGTH(' . $quotedName . ')' . $alias); } + #[\Override] public function max($field): IQueryFunction { return new QueryFunction('MAX(' . $this->helper->quoteColumnName($field) . ')'); } + #[\Override] public function min($field): IQueryFunction { return new QueryFunction('MIN(' . $this->helper->quoteColumnName($field) . ')'); } + #[\Override] public function greatest($x, $y): IQueryFunction { return new QueryFunction('GREATEST(' . $this->helper->quoteColumnName($x) . ', ' . $this->helper->quoteColumnName($y) . ')'); } + #[\Override] public function least($x, $y): IQueryFunction { return new QueryFunction('LEAST(' . $this->helper->quoteColumnName($x) . ', ' . $this->helper->quoteColumnName($y) . ')'); } diff --git a/lib/private/DB/QueryBuilder/FunctionBuilder/OCIFunctionBuilder.php b/lib/private/DB/QueryBuilder/FunctionBuilder/OCIFunctionBuilder.php index 6959d13b720..606d1e6b288 100644 --- a/lib/private/DB/QueryBuilder/FunctionBuilder/OCIFunctionBuilder.php +++ b/lib/private/DB/QueryBuilder/FunctionBuilder/OCIFunctionBuilder.php @@ -13,6 +13,7 @@ use OCP\DB\QueryBuilder\IParameter; use OCP\DB\QueryBuilder\IQueryFunction; class OCIFunctionBuilder extends FunctionBuilder { + #[\Override] public function md5($input): IQueryFunction { /** @var ConnectionAdapter $co */ $co = $this->connection; @@ -34,6 +35,7 @@ class OCIFunctionBuilder extends FunctionBuilder { * @param string|ILiteral|IParameter|IQueryFunction $y * @return IQueryFunction */ + #[\Override] public function greatest($x, $y): IQueryFunction { if (is_string($y) || $y instanceof IQueryFunction) { return parent::greatest($y, $x); @@ -54,6 +56,7 @@ class OCIFunctionBuilder extends FunctionBuilder { * @param string|ILiteral|IParameter|IQueryFunction $y * @return IQueryFunction */ + #[\Override] public function least($x, $y): IQueryFunction { if (is_string($y) || $y instanceof IQueryFunction) { return parent::least($y, $x); @@ -62,6 +65,7 @@ class OCIFunctionBuilder extends FunctionBuilder { return parent::least($x, $y); } + #[\Override] public function concat($x, ...$expr): IQueryFunction { $args = func_get_args(); $list = []; @@ -71,6 +75,7 @@ class OCIFunctionBuilder extends FunctionBuilder { return new QueryFunction(sprintf('(%s)', implode(' || ', $list))); } + #[\Override] public function groupConcat($expr, ?string $separator = ','): IQueryFunction { $orderByClause = ' WITHIN GROUP(ORDER BY NULL)'; if (is_null($separator)) { @@ -81,12 +86,14 @@ class OCIFunctionBuilder extends FunctionBuilder { return new QueryFunction('LISTAGG(' . $this->helper->quoteColumnName($expr) . ', ' . $separator . ')' . $orderByClause); } + #[\Override] public function octetLength($field, $alias = ''): IQueryFunction { $alias = $alias ? (' AS ' . $this->helper->quoteColumnName($alias)) : ''; $quotedName = $this->helper->quoteColumnName($field); return new QueryFunction('COALESCE(LENGTHB(' . $quotedName . '), 0)' . $alias); } + #[\Override] public function charLength($field, $alias = ''): IQueryFunction { $alias = $alias ? (' AS ' . $this->helper->quoteColumnName($alias)) : ''; $quotedName = $this->helper->quoteColumnName($field); diff --git a/lib/private/DB/QueryBuilder/FunctionBuilder/PgSqlFunctionBuilder.php b/lib/private/DB/QueryBuilder/FunctionBuilder/PgSqlFunctionBuilder.php index 354a2b126d7..c41f9ff1bfd 100644 --- a/lib/private/DB/QueryBuilder/FunctionBuilder/PgSqlFunctionBuilder.php +++ b/lib/private/DB/QueryBuilder/FunctionBuilder/PgSqlFunctionBuilder.php @@ -11,6 +11,7 @@ use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\DB\QueryBuilder\IQueryFunction; class PgSqlFunctionBuilder extends FunctionBuilder { + #[\Override] public function concat($x, ...$expr): IQueryFunction { $args = func_get_args(); $list = []; @@ -20,6 +21,7 @@ class PgSqlFunctionBuilder extends FunctionBuilder { return new QueryFunction(sprintf('(%s)', implode(' || ', $list))); } + #[\Override] public function groupConcat($expr, ?string $separator = ','): IQueryFunction { $castedExpression = $this->queryBuilder->expr()->castColumn($expr, IQueryBuilder::PARAM_STR); diff --git a/lib/private/DB/QueryBuilder/FunctionBuilder/SqliteFunctionBuilder.php b/lib/private/DB/QueryBuilder/FunctionBuilder/SqliteFunctionBuilder.php index 53aa530054b..b317d9f21b9 100644 --- a/lib/private/DB/QueryBuilder/FunctionBuilder/SqliteFunctionBuilder.php +++ b/lib/private/DB/QueryBuilder/FunctionBuilder/SqliteFunctionBuilder.php @@ -10,6 +10,7 @@ use OC\DB\QueryBuilder\QueryFunction; use OCP\DB\QueryBuilder\IQueryFunction; class SqliteFunctionBuilder extends FunctionBuilder { + #[\Override] public function concat($x, ...$expr): IQueryFunction { $args = func_get_args(); $list = []; @@ -19,25 +20,30 @@ class SqliteFunctionBuilder extends FunctionBuilder { return new QueryFunction(sprintf('(%s)', implode(' || ', $list))); } + #[\Override] public function groupConcat($expr, ?string $separator = ','): IQueryFunction { $separator = $this->connection->quote($separator); return new QueryFunction('GROUP_CONCAT(' . $this->helper->quoteColumnName($expr) . ', ' . $separator . ')'); } + #[\Override] public function greatest($x, $y): IQueryFunction { return new QueryFunction('MAX(' . $this->helper->quoteColumnName($x) . ', ' . $this->helper->quoteColumnName($y) . ')'); } + #[\Override] public function least($x, $y): IQueryFunction { return new QueryFunction('MIN(' . $this->helper->quoteColumnName($x) . ', ' . $this->helper->quoteColumnName($y) . ')'); } + #[\Override] public function octetLength($field, $alias = ''): IQueryFunction { $alias = $alias ? (' AS ' . $this->helper->quoteColumnName($alias)) : ''; $quotedName = $this->helper->quoteColumnName($field); return new QueryFunction('LENGTH(CAST(' . $quotedName . ' as BLOB))' . $alias); } + #[\Override] public function charLength($field, $alias = ''): IQueryFunction { $alias = $alias ? (' AS ' . $this->helper->quoteColumnName($alias)) : ''; $quotedName = $this->helper->quoteColumnName($field); diff --git a/lib/private/DB/QueryBuilder/Partitioned/PartitionedQueryBuilder.php b/lib/private/DB/QueryBuilder/Partitioned/PartitionedQueryBuilder.php index 2a9c2eb9124..3e66bab1f4d 100644 --- a/lib/private/DB/QueryBuilder/Partitioned/PartitionedQueryBuilder.php +++ b/lib/private/DB/QueryBuilder/Partitioned/PartitionedQueryBuilder.php @@ -75,6 +75,7 @@ class PartitionedQueryBuilder extends ShardedQueryBuilder { } // we need to save selects until we know all the table aliases + #[\Override] public function select(...$selects) { if (count($selects) === 1 && is_array($selects[0])) { $selects = $selects[0]; @@ -84,6 +85,7 @@ class PartitionedQueryBuilder extends ShardedQueryBuilder { return $this; } + #[\Override] public function addSelect(...$select) { $select = array_map(function ($select) { return ['select' => $select, 'alias' => null]; @@ -92,6 +94,7 @@ class PartitionedQueryBuilder extends ShardedQueryBuilder { return $this; } + #[\Override] public function selectAlias($select, $alias): self { $this->selects[] = ['select' => $select, 'alias' => $alias]; return $this; @@ -190,6 +193,7 @@ class PartitionedQueryBuilder extends ShardedQueryBuilder { return null; } + #[\Override] public function from($from, $alias = null) { if (is_string($from) && $partition = $this->getPartition($from)) { $this->mainPartition = $partition; @@ -200,14 +204,17 @@ class PartitionedQueryBuilder extends ShardedQueryBuilder { return parent::from($from, $alias); } + #[\Override] public function innerJoin($fromAlias, $join, $alias, $condition = null): self { return $this->join($fromAlias, $join, $alias, $condition); } + #[\Override] public function leftJoin($fromAlias, $join, $alias, $condition = null): self { return $this->join($fromAlias, $join, $alias, $condition, PartitionQuery::JOIN_MODE_LEFT); } + #[\Override] public function join($fromAlias, $join, $alias, $condition = null, $joinMode = PartitionQuery::JOIN_MODE_INNER): self { if ($join instanceof IQueryFunction) { $partition = null; @@ -333,10 +340,12 @@ class PartitionedQueryBuilder extends ShardedQueryBuilder { return $partitionPredicates; } + #[\Override] public function where(...$predicates) { return $this->andWhere(...$predicates); } + #[\Override] public function andWhere(...$where) { if ($where) { foreach ($this->splitPredicatesByParts($where) as $alias => $predicates) { @@ -380,18 +389,22 @@ class PartitionedQueryBuilder extends ShardedQueryBuilder { return null; } + #[\Override] public function update($update = null, $alias = null) { return parent::update($update, $alias); } + #[\Override] public function insert($insert = null) { return parent::insert($insert); } + #[\Override] public function delete($delete = null, $alias = null) { return parent::delete($delete, $alias); } + #[\Override] public function setMaxResults($maxResults) { if ($maxResults > 0) { $this->limit = (int)$maxResults; @@ -399,6 +412,7 @@ class PartitionedQueryBuilder extends ShardedQueryBuilder { return parent::setMaxResults($maxResults); } + #[\Override] public function setFirstResult($firstResult) { if ($firstResult > 0) { $this->offset = (int)$firstResult; @@ -406,6 +420,7 @@ class PartitionedQueryBuilder extends ShardedQueryBuilder { return parent::setFirstResult($firstResult); } + #[\Override] public function executeQuery(?IDBConnection $connection = null): IResult { $this->applySelects(); if ($this->splitQueries && $this->hasPositionalParameter) { @@ -437,6 +452,7 @@ class PartitionedQueryBuilder extends ShardedQueryBuilder { } } + #[\Override] public function executeStatement(?IDBConnection $connection = null): int { if (count($this->splitQueries)) { throw new InvalidPartitionedQueryException("Partitioning write queries isn't supported"); @@ -444,6 +460,7 @@ class PartitionedQueryBuilder extends ShardedQueryBuilder { return parent::executeStatement($connection); } + #[\Override] public function getSQL() { $this->applySelects(); return parent::getSQL(); @@ -453,6 +470,7 @@ class PartitionedQueryBuilder extends ShardedQueryBuilder { return count($this->splitQueries) + 1; } + #[\Override] public function hintShardKey(string $column, mixed $value, bool $overwrite = false): self { if (str_contains($column, '.')) { [$alias, $column] = explode('.', $column); diff --git a/lib/private/DB/QueryBuilder/Partitioned/PartitionedResult.php b/lib/private/DB/QueryBuilder/Partitioned/PartitionedResult.php index b3b59e26298..6fd857c5b2f 100644 --- a/lib/private/DB/QueryBuilder/Partitioned/PartitionedResult.php +++ b/lib/private/DB/QueryBuilder/Partitioned/PartitionedResult.php @@ -29,20 +29,24 @@ class PartitionedResult extends ArrayResult { parent::__construct([]); } + #[\Override] public function closeCursor(): bool { return $this->result->closeCursor(); } + #[\Override] public function fetch(int $fetchMode = PDO::FETCH_ASSOC) { $this->fetchRows(); return parent::fetch($fetchMode); } + #[\Override] public function fetchAll(int $fetchMode = PDO::FETCH_ASSOC): array { $this->fetchRows(); return parent::fetchAll($fetchMode); } + #[\Override] public function rowCount(): int { $this->fetchRows(); return parent::rowCount(); diff --git a/lib/private/DB/QueryBuilder/QueryBuilder.php b/lib/private/DB/QueryBuilder/QueryBuilder.php index 1129970265c..30e85675a75 100644 --- a/lib/private/DB/QueryBuilder/QueryBuilder.php +++ b/lib/private/DB/QueryBuilder/QueryBuilder.php @@ -59,6 +59,7 @@ class QueryBuilder extends TypedQueryBuilder { * owncloud database prefix automatically. * @since 8.2.0 */ + #[\Override] public function automaticTablePrefix($enabled) { $this->automaticTablePrefix = (bool)$enabled; } @@ -79,6 +80,7 @@ class QueryBuilder extends TypedQueryBuilder { * * @return IExpressionBuilder */ + #[\Override] public function expr() { return match($this->connection->getDatabaseProvider()) { IDBConnection::PLATFORM_ORACLE => new OCIExpressionBuilder($this->connection, $this, $this->logger), @@ -105,6 +107,7 @@ class QueryBuilder extends TypedQueryBuilder { * * @return IFunctionBuilder */ + #[\Override] public function func() { return match($this->connection->getDatabaseProvider()) { IDBConnection::PLATFORM_ORACLE => new OCIFunctionBuilder($this->connection, $this, $this->helper), @@ -120,6 +123,7 @@ class QueryBuilder extends TypedQueryBuilder { * * @return integer */ + #[\Override] public function getType() { return $this->queryBuilder->getType(); } @@ -129,6 +133,7 @@ class QueryBuilder extends TypedQueryBuilder { * * @return IDBConnection */ + #[\Override] public function getConnection() { return $this->connection; } @@ -140,6 +145,7 @@ class QueryBuilder extends TypedQueryBuilder { * @deprecated 30.0.0 This function is going to be removed with the next Doctrine/DBAL update * and we can not fix this in our wrapper. */ + #[\Override] public function getState() { $this->logger->debug(IQueryBuilder::class . '::' . __FUNCTION__ . ' is deprecated and will be removed soon.', ['exception' => new \Exception('Deprecated call to ' . __METHOD__)]); return $this->queryBuilder->getState(); @@ -241,6 +247,7 @@ class QueryBuilder extends TypedQueryBuilder { } } + #[\Override] public function executeQuery(?IDBConnection $connection = null): IResult { if ($this->getType() !== \Doctrine\DBAL\Query\QueryBuilder::SELECT) { throw new RuntimeException('Invalid query type, expected SELECT query'); @@ -258,6 +265,7 @@ class QueryBuilder extends TypedQueryBuilder { ); } + #[\Override] public function executeStatement(?IDBConnection $connection = null): int { if ($this->getType() === \Doctrine\DBAL\Query\QueryBuilder::SELECT) { throw new RuntimeException('Invalid query type, expected INSERT, DELETE or UPDATE statement'); @@ -288,6 +296,7 @@ class QueryBuilder extends TypedQueryBuilder { * * @return string The SQL query string. */ + #[\Override] public function getSQL() { return $this->queryBuilder->getSQL(); } @@ -309,6 +318,7 @@ class QueryBuilder extends TypedQueryBuilder { * * @return $this This QueryBuilder instance. */ + #[\Override] public function setParameter($key, $value, $type = null) { $this->queryBuilder->setParameter($key, $value, $type); @@ -334,6 +344,7 @@ class QueryBuilder extends TypedQueryBuilder { * * @return $this This QueryBuilder instance. */ + #[\Override] public function setParameters(array $params, array $types = []) { $this->queryBuilder->setParameters($params, $types); @@ -345,6 +356,7 @@ class QueryBuilder extends TypedQueryBuilder { * * @return array The currently defined query parameters indexed by parameter index or name. */ + #[\Override] public function getParameters() { return $this->queryBuilder->getParameters(); } @@ -356,6 +368,7 @@ class QueryBuilder extends TypedQueryBuilder { * * @return mixed The value of the bound parameter. */ + #[\Override] public function getParameter($key) { return $this->queryBuilder->getParameter($key); } @@ -365,6 +378,7 @@ class QueryBuilder extends TypedQueryBuilder { * * @return array The currently defined query parameter types indexed by parameter index or name. */ + #[\Override] public function getParameterTypes() { return $this->queryBuilder->getParameterTypes(); } @@ -376,6 +390,7 @@ class QueryBuilder extends TypedQueryBuilder { * * @return mixed The value of the bound parameter type. */ + #[\Override] public function getParameterType($key) { return $this->queryBuilder->getParameterType($key); } @@ -387,6 +402,7 @@ class QueryBuilder extends TypedQueryBuilder { * * @return $this This QueryBuilder instance. */ + #[\Override] public function setFirstResult($firstResult) { $this->queryBuilder->setFirstResult((int)$firstResult); @@ -399,6 +415,7 @@ class QueryBuilder extends TypedQueryBuilder { * * @return int The position of the first result. */ + #[\Override] public function getFirstResult() { return $this->queryBuilder->getFirstResult(); } @@ -414,6 +431,7 @@ class QueryBuilder extends TypedQueryBuilder { * * @return $this This QueryBuilder instance. */ + #[\Override] public function setMaxResults($maxResults) { if ($maxResults === null) { $this->queryBuilder->setMaxResults($maxResults); @@ -430,6 +448,7 @@ class QueryBuilder extends TypedQueryBuilder { * * @return int|null The maximum number of results. */ + #[\Override] public function getMaxResults() { return $this->queryBuilder->getMaxResults(); } @@ -449,6 +468,7 @@ class QueryBuilder extends TypedQueryBuilder { * * '@return $this This QueryBuilder instance. */ + #[\Override] public function select(...$selects) { if (count($selects) === 1 && is_array($selects[0])) { $selects = $selects[0]; @@ -477,6 +497,7 @@ class QueryBuilder extends TypedQueryBuilder { * * @return $this This QueryBuilder instance. */ + #[\Override] public function selectAlias($select, $alias): self { $this->queryBuilder->addSelect( $this->helper->quoteColumnName($select) . ' AS ' . $this->helper->quoteColumnName($alias) @@ -499,6 +520,7 @@ class QueryBuilder extends TypedQueryBuilder { * * @return $this This QueryBuilder instance. */ + #[\Override] public function selectDistinct($select) { if (!is_array($select)) { $select = [$select]; @@ -529,6 +551,7 @@ class QueryBuilder extends TypedQueryBuilder { * * @return $this This QueryBuilder instance. */ + #[\Override] public function addSelect(...$select) { if (count($select) === 1 && is_array($select[0])) { $select = $select[0]; @@ -558,6 +581,7 @@ class QueryBuilder extends TypedQueryBuilder { } } + #[\Override] public function getOutputColumns(): array { return array_unique($this->selectedColumns); } @@ -579,6 +603,7 @@ class QueryBuilder extends TypedQueryBuilder { * @return $this This QueryBuilder instance. * @since 30.0.0 Alias is deprecated and will no longer be used with the next Doctrine/DBAL update */ + #[\Override] public function delete($delete = null, $alias = null) { if ($alias !== null) { $this->logger->debug('DELETE queries with alias are no longer supported and the provided alias is ignored', ['exception' => new \InvalidArgumentException('Table alias provided for DELETE query')]); @@ -609,6 +634,7 @@ class QueryBuilder extends TypedQueryBuilder { * @return $this This QueryBuilder instance. * @since 30.0.0 Alias is deprecated and will no longer be used with the next Doctrine/DBAL update */ + #[\Override] public function update($update = null, $alias = null) { if ($alias !== null) { $this->logger->debug('UPDATE queries with alias are no longer supported and the provided alias is ignored', ['exception' => new \InvalidArgumentException('Table alias provided for UPDATE query')]); @@ -641,6 +667,7 @@ class QueryBuilder extends TypedQueryBuilder { * * @return $this This QueryBuilder instance. */ + #[\Override] public function insert($insert = null) { $this->queryBuilder->insert( $this->getTableName($insert) @@ -666,6 +693,7 @@ class QueryBuilder extends TypedQueryBuilder { * * @return $this This QueryBuilder instance. */ + #[\Override] public function from($from, $alias = null) { $this->queryBuilder->from( $this->getTableName($from), @@ -692,6 +720,7 @@ class QueryBuilder extends TypedQueryBuilder { * * @return $this This QueryBuilder instance. */ + #[\Override] public function join($fromAlias, $join, $alias, $condition = null) { $this->queryBuilder->join( $this->quoteAlias($fromAlias), @@ -720,6 +749,7 @@ class QueryBuilder extends TypedQueryBuilder { * * @return $this This QueryBuilder instance. */ + #[\Override] public function innerJoin($fromAlias, $join, $alias, $condition = null) { $this->queryBuilder->innerJoin( $this->quoteAlias($fromAlias), @@ -748,6 +778,7 @@ class QueryBuilder extends TypedQueryBuilder { * * @return $this This QueryBuilder instance. */ + #[\Override] public function leftJoin($fromAlias, $join, $alias, $condition = null) { $this->queryBuilder->leftJoin( $this->quoteAlias($fromAlias), @@ -776,6 +807,7 @@ class QueryBuilder extends TypedQueryBuilder { * * @return $this This QueryBuilder instance. */ + #[\Override] public function rightJoin($fromAlias, $join, $alias, $condition = null) { $this->queryBuilder->rightJoin( $this->quoteAlias($fromAlias), @@ -802,6 +834,7 @@ class QueryBuilder extends TypedQueryBuilder { * * @return $this This QueryBuilder instance. */ + #[\Override] public function set($key, $value) { $this->queryBuilder->set( $this->helper->quoteColumnName($key), @@ -838,6 +871,7 @@ class QueryBuilder extends TypedQueryBuilder { * * @return $this This QueryBuilder instance. */ + #[\Override] public function where(...$predicates) { if ($this->nonEmptyWhere && $this->systemConfig->getValue('debug', false)) { // Only logging a warning, not throwing for now. @@ -873,6 +907,7 @@ class QueryBuilder extends TypedQueryBuilder { * * @see where() */ + #[\Override] public function andWhere(...$where) { $this->nonEmptyWhere = true; call_user_func_array( @@ -901,6 +936,7 @@ class QueryBuilder extends TypedQueryBuilder { * * @see where() */ + #[\Override] public function orWhere(...$where) { $this->nonEmptyWhere = true; call_user_func_array( @@ -926,6 +962,7 @@ class QueryBuilder extends TypedQueryBuilder { * * @return $this This QueryBuilder instance. */ + #[\Override] public function groupBy(...$groupBys) { if (count($groupBys) === 1 && is_array($groupBys[0])) { $groupBys = $groupBys[0]; @@ -954,6 +991,7 @@ class QueryBuilder extends TypedQueryBuilder { * * @return $this This QueryBuilder instance. */ + #[\Override] public function addGroupBy(...$groupBy) { call_user_func_array( [$this->queryBuilder, 'addGroupBy'], @@ -982,6 +1020,7 @@ class QueryBuilder extends TypedQueryBuilder { * * @return $this This QueryBuilder instance. */ + #[\Override] public function setValue($column, $value) { $this->queryBuilder->setValue( $this->helper->quoteColumnName($column), @@ -1010,6 +1049,7 @@ class QueryBuilder extends TypedQueryBuilder { * * @return $this This QueryBuilder instance. */ + #[\Override] public function values(array $values) { $quotedValues = []; foreach ($values as $key => $value) { @@ -1029,6 +1069,7 @@ class QueryBuilder extends TypedQueryBuilder { * * @return $this This QueryBuilder instance. */ + #[\Override] public function having(...$having) { call_user_func_array( [$this->queryBuilder, 'having'], @@ -1046,6 +1087,7 @@ class QueryBuilder extends TypedQueryBuilder { * * @return $this This QueryBuilder instance. */ + #[\Override] public function andHaving(...$having) { call_user_func_array( [$this->queryBuilder, 'andHaving'], @@ -1063,6 +1105,7 @@ class QueryBuilder extends TypedQueryBuilder { * * @return $this This QueryBuilder instance. */ + #[\Override] public function orHaving(...$having) { call_user_func_array( [$this->queryBuilder, 'orHaving'], @@ -1081,6 +1124,7 @@ class QueryBuilder extends TypedQueryBuilder { * * @return $this This QueryBuilder instance. */ + #[\Override] public function orderBy($sort, $order = null) { if ($order !== null && !in_array(strtoupper((string)$order), ['ASC', 'DESC'], true)) { $order = null; @@ -1102,6 +1146,7 @@ class QueryBuilder extends TypedQueryBuilder { * * @return $this This QueryBuilder instance. */ + #[\Override] public function addOrderBy($sort, $order = null) { if ($order !== null && !in_array(strtoupper((string)$order), ['ASC', 'DESC'], true)) { $order = null; @@ -1124,6 +1169,7 @@ class QueryBuilder extends TypedQueryBuilder { * @deprecated 30.0.0 This function is going to be removed with the next Doctrine/DBAL update * and we can not fix this in our wrapper. Please track the details you need, outside the object. */ + #[\Override] public function getQueryPart($queryPartName) { $this->logger->debug(IQueryBuilder::class . '::' . __FUNCTION__ . ' is deprecated and will be removed soon.', ['exception' => new \Exception('Deprecated call to ' . __METHOD__)]); return $this->queryBuilder->getQueryPart($queryPartName); @@ -1136,6 +1182,7 @@ class QueryBuilder extends TypedQueryBuilder { * @deprecated 30.0.0 This function is going to be removed with the next Doctrine/DBAL update * and we can not fix this in our wrapper. Please track the details you need, outside the object. */ + #[\Override] public function getQueryParts() { $this->logger->debug(IQueryBuilder::class . '::' . __FUNCTION__ . ' is deprecated and will be removed soon.', ['exception' => new \Exception('Deprecated call to ' . __METHOD__)]); return $this->queryBuilder->getQueryParts(); @@ -1150,6 +1197,7 @@ class QueryBuilder extends TypedQueryBuilder { * @deprecated 30.0.0 This function is going to be removed with the next Doctrine/DBAL update * and we can not fix this in our wrapper. Please create a new IQueryBuilder instead. */ + #[\Override] public function resetQueryParts($queryPartNames = null) { $this->logger->debug(IQueryBuilder::class . '::' . __FUNCTION__ . ' is deprecated and will be removed soon.', ['exception' => new \Exception('Deprecated call to ' . __METHOD__)]); $this->queryBuilder->resetQueryParts($queryPartNames); @@ -1166,6 +1214,7 @@ class QueryBuilder extends TypedQueryBuilder { * @deprecated 30.0.0 This function is going to be removed with the next Doctrine/DBAL update * and we can not fix this in our wrapper. Please create a new IQueryBuilder instead. */ + #[\Override] public function resetQueryPart($queryPartName) { $this->logger->debug(IQueryBuilder::class . '::' . __FUNCTION__ . ' is deprecated and will be removed soon.', ['exception' => new \Exception('Deprecated call to ' . __METHOD__)]); $this->queryBuilder->resetQueryPart($queryPartName); @@ -1202,6 +1251,7 @@ class QueryBuilder extends TypedQueryBuilder { * * @return IParameter the placeholder name used. */ + #[\Override] public function createNamedParameter($value, $type = IQueryBuilder::PARAM_STR, $placeHolder = null) { return new Parameter($this->queryBuilder->createNamedParameter($value, $type, $placeHolder)); } @@ -1228,6 +1278,7 @@ class QueryBuilder extends TypedQueryBuilder { * * @return IParameter */ + #[\Override] public function createPositionalParameter($value, $type = IQueryBuilder::PARAM_STR) { return new Parameter($this->queryBuilder->createPositionalParameter($value, $type)); } @@ -1248,6 +1299,7 @@ class QueryBuilder extends TypedQueryBuilder { * * @return IParameter */ + #[\Override] public function createParameter($name) { return new Parameter(':' . $name); } @@ -1275,6 +1327,7 @@ class QueryBuilder extends TypedQueryBuilder { * * @return IQueryFunction */ + #[\Override] public function createFunction($call) { return new QueryFunction($call); } @@ -1284,6 +1337,7 @@ class QueryBuilder extends TypedQueryBuilder { * @return int * @throws \BadMethodCallException When being called before an insert query has been run. */ + #[\Override] public function getLastInsertId(): int { if ($this->getType() === \Doctrine\DBAL\Query\QueryBuilder::INSERT && $this->lastInsertedTable) { // lastInsertId() needs the prefix but no quotes @@ -1300,6 +1354,7 @@ class QueryBuilder extends TypedQueryBuilder { * @param string|IQueryFunction $table * @return string */ + #[\Override] public function getTableName($table) { if ($table instanceof IQueryFunction) { return (string)$table; @@ -1317,6 +1372,7 @@ class QueryBuilder extends TypedQueryBuilder { * @param string $table * @return string */ + #[\Override] public function prefixTableName(string $table): string { if ($this->automaticTablePrefix === false || str_starts_with($table, '*PREFIX*')) { return $table; @@ -1332,6 +1388,7 @@ class QueryBuilder extends TypedQueryBuilder { * @param string $tableAlias * @return string */ + #[\Override] public function getColumnName($column, $tableAlias = '') { if ($tableAlias !== '') { $tableAlias .= '.'; @@ -1358,10 +1415,12 @@ class QueryBuilder extends TypedQueryBuilder { return $this->connection->escapeLikeParameter($parameter); } + #[\Override] public function hintShardKey(string $column, mixed $value, bool $overwrite = false): self { return $this; } + #[\Override] public function runAcrossAllShards(): self { // noop return $this; diff --git a/lib/private/DB/QueryBuilder/Sharded/HashShardMapper.php b/lib/private/DB/QueryBuilder/Sharded/HashShardMapper.php index af778489a2d..dfa230f1473 100644 --- a/lib/private/DB/QueryBuilder/Sharded/HashShardMapper.php +++ b/lib/private/DB/QueryBuilder/Sharded/HashShardMapper.php @@ -14,6 +14,7 @@ use OCP\DB\QueryBuilder\Sharded\IShardMapper; * Map string key to an int-range by hashing the key */ class HashShardMapper implements IShardMapper { + #[\Override] public function getShardForKey(int $key, int $count): int { $int = unpack('L', substr(md5((string)$key, true), 0, 4))[1]; return $int % $count; diff --git a/lib/private/DB/QueryBuilder/Sharded/RoundRobinShardMapper.php b/lib/private/DB/QueryBuilder/Sharded/RoundRobinShardMapper.php index a5694b06507..3f63dd8fbb4 100644 --- a/lib/private/DB/QueryBuilder/Sharded/RoundRobinShardMapper.php +++ b/lib/private/DB/QueryBuilder/Sharded/RoundRobinShardMapper.php @@ -14,6 +14,7 @@ use OCP\DB\QueryBuilder\Sharded\IShardMapper; * Map string key to an int-range by hashing the key */ class RoundRobinShardMapper implements IShardMapper { + #[\Override] public function getShardForKey(int $key, int $count): int { return $key % $count; } diff --git a/lib/private/DB/QueryBuilder/Sharded/ShardedQueryBuilder.php b/lib/private/DB/QueryBuilder/Sharded/ShardedQueryBuilder.php index 2694a116af4..034abd3ce20 100644 --- a/lib/private/DB/QueryBuilder/Sharded/ShardedQueryBuilder.php +++ b/lib/private/DB/QueryBuilder/Sharded/ShardedQueryBuilder.php @@ -83,10 +83,12 @@ class ShardedQueryBuilder extends ExtendedQueryBuilder { } } + #[\Override] public function where(...$predicates) { return $this->andWhere(...$predicates); } + #[\Override] public function andWhere(...$where) { if ($where) { foreach ($where as $predicate) { @@ -158,6 +160,7 @@ class ShardedQueryBuilder extends ExtendedQueryBuilder { return []; } + #[\Override] public function set($key, $value) { if ($this->shardDefinition && $key === $this->shardDefinition->shardKey) { $updateShardKey = $value; @@ -165,6 +168,7 @@ class ShardedQueryBuilder extends ExtendedQueryBuilder { return parent::set($key, $value); } + #[\Override] public function setValue($column, $value) { if ($this->shardDefinition) { if ($this->shardDefinition->isKey($column)) { @@ -177,6 +181,7 @@ class ShardedQueryBuilder extends ExtendedQueryBuilder { return parent::setValue($column, $value); } + #[\Override] public function values(array $values) { foreach ($values as $column => $value) { $this->setValue($column, $value); @@ -193,6 +198,7 @@ class ShardedQueryBuilder extends ExtendedQueryBuilder { } } + #[\Override] public function from($from, $alias = null) { if (is_string($from) && $from) { $this->actOnTable($from); @@ -200,6 +206,7 @@ class ShardedQueryBuilder extends ExtendedQueryBuilder { return parent::from($from, $alias); } + #[\Override] public function update($update = null, $alias = null) { if (is_string($update) && $update) { $this->actOnTable($update); @@ -207,6 +214,7 @@ class ShardedQueryBuilder extends ExtendedQueryBuilder { return parent::update($update, $alias); } + #[\Override] public function insert($insert = null) { if (is_string($insert) && $insert) { $this->insertTable = $insert; @@ -215,6 +223,7 @@ class ShardedQueryBuilder extends ExtendedQueryBuilder { return parent::insert($insert); } + #[\Override] public function delete($delete = null, $alias = null) { if (is_string($delete) && $delete) { $this->actOnTable($delete); @@ -235,6 +244,7 @@ class ShardedQueryBuilder extends ExtendedQueryBuilder { } } + #[\Override] public function innerJoin($fromAlias, $join, $alias, $condition = null) { if (is_string($join)) { $this->checkJoin($join); @@ -242,6 +252,7 @@ class ShardedQueryBuilder extends ExtendedQueryBuilder { return parent::innerJoin($fromAlias, $join, $alias, $condition); } + #[\Override] public function leftJoin($fromAlias, $join, $alias, $condition = null) { if (is_string($join)) { $this->checkJoin($join); @@ -249,6 +260,7 @@ class ShardedQueryBuilder extends ExtendedQueryBuilder { return parent::leftJoin($fromAlias, $join, $alias, $condition); } + #[\Override] public function rightJoin($fromAlias, $join, $alias, $condition = null) { if ($this->shardDefinition) { throw new InvalidShardedQueryException("Sharded query on {$this->shardDefinition->table} isn't allowed to right join"); @@ -256,10 +268,12 @@ class ShardedQueryBuilder extends ExtendedQueryBuilder { return parent::rightJoin($fromAlias, $join, $alias, $condition); } + #[\Override] public function join($fromAlias, $join, $alias, $condition = null) { return $this->innerJoin($fromAlias, $join, $alias, $condition); } + #[\Override] public function setMaxResults($maxResults) { if ($maxResults > 0) { $this->limit = (int)$maxResults; @@ -267,6 +281,7 @@ class ShardedQueryBuilder extends ExtendedQueryBuilder { return parent::setMaxResults($maxResults); } + #[\Override] public function setFirstResult($firstResult) { if ($firstResult > 0) { $this->offset = (int)$firstResult; @@ -279,6 +294,7 @@ class ShardedQueryBuilder extends ExtendedQueryBuilder { } } + #[\Override] public function addOrderBy($sort, $order = null) { if ($order !== null && !in_array(strtoupper((string)$order), ['ASC', 'DESC'], true)) { $order = null; @@ -288,6 +304,7 @@ class ShardedQueryBuilder extends ExtendedQueryBuilder { return parent::addOrderBy($sort, $order); } + #[\Override] public function orderBy($sort, $order = null) { if ($order !== null && !in_array(strtoupper((string)$order), ['ASC', 'DESC'], true)) { $order = null; @@ -308,6 +325,7 @@ class ShardedQueryBuilder extends ExtendedQueryBuilder { ]; } + #[\Override] public function hintShardKey(string $column, mixed $value, bool $overwrite = false): self { if ($overwrite) { $this->primaryKeys = []; @@ -322,6 +340,7 @@ class ShardedQueryBuilder extends ExtendedQueryBuilder { return $this; } + #[\Override] public function runAcrossAllShards(): self { $this->allShards = true; return $this; @@ -364,6 +383,7 @@ class ShardedQueryBuilder extends ExtendedQueryBuilder { } } + #[\Override] public function executeQuery(?IDBConnection $connection = null): IResult { $this->validate(); if ($this->shardDefinition) { @@ -373,6 +393,7 @@ class ShardedQueryBuilder extends ExtendedQueryBuilder { return parent::executeQuery($connection); } + #[\Override] public function executeStatement(?IDBConnection $connection = null): int { $this->validate(); if ($this->shardDefinition) { @@ -403,6 +424,7 @@ class ShardedQueryBuilder extends ExtendedQueryBuilder { return parent::executeStatement($connection); } + #[\Override] public function getLastInsertId(): int { if ($this->lastInsertId) { return $this->lastInsertId; diff --git a/lib/private/DB/QueryBuilder/TypedQueryBuilder.php b/lib/private/DB/QueryBuilder/TypedQueryBuilder.php index cd6a060fbab..eb3a81a0c23 100644 --- a/lib/private/DB/QueryBuilder/TypedQueryBuilder.php +++ b/lib/private/DB/QueryBuilder/TypedQueryBuilder.php @@ -22,6 +22,7 @@ abstract class TypedQueryBuilder implements ITypedQueryBuilder { } } + #[\Override] public function selectColumns(string ...$columns): static { foreach ($columns as $column) { $this->validateColumn($column); @@ -30,6 +31,7 @@ abstract class TypedQueryBuilder implements ITypedQueryBuilder { return $this->select(...$columns); } + #[\Override] public function selectColumnsDistinct(string ...$columns): static { foreach ($columns as $column) { $this->validateColumn($column); diff --git a/lib/private/DB/SQLiteMigrator.php b/lib/private/DB/SQLiteMigrator.php index 160a0d6ccd7..0d178506d08 100644 --- a/lib/private/DB/SQLiteMigrator.php +++ b/lib/private/DB/SQLiteMigrator.php @@ -13,6 +13,7 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\SchemaDiff; class SQLiteMigrator extends Migrator { + #[\Override] protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection): SchemaDiff { foreach ($targetSchema->getTables() as $table) { foreach ($table->getColumns() as $column) { diff --git a/lib/private/DB/SQLiteSessionInit.php b/lib/private/DB/SQLiteSessionInit.php index be6daf87b6c..ed3392e9678 100644 --- a/lib/private/DB/SQLiteSessionInit.php +++ b/lib/private/DB/SQLiteSessionInit.php @@ -35,6 +35,7 @@ class SQLiteSessionInit implements EventSubscriber { } } + #[\Override] public function getSubscribedEvents(): array { return [Events::postConnect]; } diff --git a/lib/private/DB/SchemaWrapper.php b/lib/private/DB/SchemaWrapper.php index 57f0caecb8d..342a246ccb2 100644 --- a/lib/private/DB/SchemaWrapper.php +++ b/lib/private/DB/SchemaWrapper.php @@ -50,6 +50,7 @@ class SchemaWrapper implements ISchemaWrapper { * * @return array */ + #[\Override] public function getTableNamesWithoutPrefix() { $tableNames = $this->schema->getTableNames(); return array_map(function ($tableName) { @@ -66,6 +67,7 @@ class SchemaWrapper implements ISchemaWrapper { /** * @return array */ + #[\Override] public function getTableNames() { return $this->schema->getTableNames(); } @@ -76,6 +78,7 @@ class SchemaWrapper implements ISchemaWrapper { * @return \Doctrine\DBAL\Schema\Table * @throws \Doctrine\DBAL\Schema\SchemaException */ + #[\Override] public function getTable($tableName) { return $this->schema->getTable($this->connection->getPrefix() . $tableName); } @@ -87,6 +90,7 @@ class SchemaWrapper implements ISchemaWrapper { * * @return boolean */ + #[\Override] public function hasTable($tableName) { return $this->schema->hasTable($this->connection->getPrefix() . $tableName); } @@ -97,6 +101,7 @@ class SchemaWrapper implements ISchemaWrapper { * @param string $tableName * @return \Doctrine\DBAL\Schema\Table */ + #[\Override] public function createTable($tableName) { unset($this->tablesToDelete[$tableName]); return $this->schema->createTable($this->connection->getPrefix() . $tableName); @@ -108,6 +113,7 @@ class SchemaWrapper implements ISchemaWrapper { * @param string $tableName * @return \Doctrine\DBAL\Schema\Schema */ + #[\Override] public function dropTable($tableName) { $this->tablesToDelete[$tableName] = true; return $this->schema->dropTable($this->connection->getPrefix() . $tableName); @@ -118,6 +124,7 @@ class SchemaWrapper implements ISchemaWrapper { * * @return \Doctrine\DBAL\Schema\Table[] */ + #[\Override] public function getTables() { return $this->schema->getTables(); } @@ -129,10 +136,12 @@ class SchemaWrapper implements ISchemaWrapper { * * @throws Exception */ + #[\Override] public function getDatabasePlatform() { return $this->connection->getDatabasePlatform(); } + #[\Override] public function dropAutoincrementColumn(string $table, string $column): void { $tableObj = $this->schema->getTable($this->connection->getPrefix() . $table); $tableObj->modifyColumn('id', ['autoincrement' => false]); diff --git a/lib/private/DB/SetTransactionIsolationLevel.php b/lib/private/DB/SetTransactionIsolationLevel.php index cd18c4255e3..5e43a32c3bb 100644 --- a/lib/private/DB/SetTransactionIsolationLevel.php +++ b/lib/private/DB/SetTransactionIsolationLevel.php @@ -30,6 +30,7 @@ class SetTransactionIsolationLevel implements EventSubscriber { } } + #[\Override] public function getSubscribedEvents() { return [Events::postConnect]; } diff --git a/lib/private/Dashboard/Manager.php b/lib/private/Dashboard/Manager.php index d6ced08e1bb..4619a4ee5c1 100644 --- a/lib/private/Dashboard/Manager.php +++ b/lib/private/Dashboard/Manager.php @@ -46,6 +46,7 @@ class Manager implements IManager { $this->widgets[$widget->getId()] = $widget; } + #[\Override] public function lazyRegisterWidget(string $widgetClass, string $appId): void { $this->lazyWidgets[] = ['class' => $widgetClass, 'appId' => $appId]; } @@ -125,6 +126,7 @@ class Manager implements IManager { /** * @return array */ + #[\Override] public function getWidgets(): array { $this->loadLazyPanels(); return $this->widgets; diff --git a/lib/private/DateTimeFormatter.php b/lib/private/DateTimeFormatter.php index 2a20c65ada3..91c84baee27 100644 --- a/lib/private/DateTimeFormatter.php +++ b/lib/private/DateTimeFormatter.php @@ -86,6 +86,7 @@ class DateTimeFormatter implements IDateTimeFormatter { * @param IL10N $l The locale to use * @return string Formatted date string */ + #[\Override] public function formatDate($timestamp, $format = 'long', ?\DateTimeZone $timeZone = null, ?IL10N $l = null) { return $this->format($timestamp, 'date', $format, $timeZone, $l); } @@ -105,6 +106,7 @@ class DateTimeFormatter implements IDateTimeFormatter { * @param IL10N $l The locale to use * @return string Formatted relative date string */ + #[\Override] public function formatDateRelativeDay($timestamp, $format = 'long', ?\DateTimeZone $timeZone = null, ?IL10N $l = null) { if (!str_ends_with($format, '^') && !str_ends_with($format, '*')) { $format .= '^'; @@ -125,6 +127,7 @@ class DateTimeFormatter implements IDateTimeFormatter { * < 13 month => last month, n months ago * >= 13 month => last year, n years ago */ + #[\Override] public function formatDateSpan($timestamp, $baseTimestamp = null, ?IL10N $l = null) { $l = $this->getLocale($l); $timestamp = $this->getDateTime($timestamp); @@ -191,6 +194,7 @@ class DateTimeFormatter implements IDateTimeFormatter { * @param IL10N $l The locale to use * @return string Formatted time string */ + #[\Override] public function formatTime($timestamp, $format = 'medium', ?\DateTimeZone $timeZone = null, ?IL10N $l = null) { return $this->format($timestamp, 'time', $format, $timeZone, $l); } @@ -209,6 +213,7 @@ class DateTimeFormatter implements IDateTimeFormatter { * < 13 month => last month, n months ago * >= 13 month => last year, n years ago */ + #[\Override] public function formatTimeSpan($timestamp, $baseTimestamp = null, ?IL10N $l = null) { $l = $this->getLocale($l); $timestamp = $this->getDateTime($timestamp); @@ -252,6 +257,7 @@ class DateTimeFormatter implements IDateTimeFormatter { * @param IL10N $l The locale to use * @return string Formatted date and time string */ + #[\Override] public function formatDateTime($timestamp, $formatDate = 'long', $formatTime = 'medium', ?\DateTimeZone $timeZone = null, ?IL10N $l = null) { return $this->format($timestamp, 'datetime', $formatDate . '|' . $formatTime, $timeZone, $l); } @@ -267,6 +273,7 @@ class DateTimeFormatter implements IDateTimeFormatter { * @param IL10N $l The locale to use * @return string Formatted relative date and time string */ + #[\Override] public function formatDateTimeRelativeDay($timestamp, $formatDate = 'long', $formatTime = 'medium', ?\DateTimeZone $timeZone = null, ?IL10N $l = null) { if (!str_ends_with($formatDate, '^') && !str_ends_with($formatDate, '*')) { $formatDate .= '^'; diff --git a/lib/private/DateTimeZone.php b/lib/private/DateTimeZone.php index 589d2e0a6a9..2c5e1dbab3e 100644 --- a/lib/private/DateTimeZone.php +++ b/lib/private/DateTimeZone.php @@ -23,6 +23,7 @@ class DateTimeZone implements IDateTimeZone { /** * @inheritdoc */ + #[\Override] public function getTimeZone(int|false $timestamp = false, ?string $userId = null): \DateTimeZone { $uid = $userId ?? $this->session->get('user_id'); $timezoneName = $this->config->getUserValue($uid, 'core', 'timezone', ''); @@ -41,6 +42,7 @@ class DateTimeZone implements IDateTimeZone { } } + #[\Override] public function getDefaultTimeZone(): \DateTimeZone { /** @var non-empty-string */ $timezone = $this->config->getSystemValueString('default_timezone', 'UTC'); diff --git a/lib/private/Diagnostics/Event.php b/lib/private/Diagnostics/Event.php index 956d86b2693..c322f99e306 100644 --- a/lib/private/Diagnostics/Event.php +++ b/lib/private/Diagnostics/Event.php @@ -23,22 +23,27 @@ class Event implements IEvent { $this->end = $time; } + #[\Override] public function getStart(): float { return $this->start; } + #[\Override] public function getId(): string { return $this->id; } + #[\Override] public function getDescription(): string { return $this->description; } + #[\Override] public function getEnd(): float { return $this->end ?? -1; } + #[\Override] public function getDuration(): float { if (!$this->end) { $this->end = microtime(true); diff --git a/lib/private/Diagnostics/EventLogger.php b/lib/private/Diagnostics/EventLogger.php index f61b470e836..996f7165f96 100644 --- a/lib/private/Diagnostics/EventLogger.php +++ b/lib/private/Diagnostics/EventLogger.php @@ -47,6 +47,7 @@ class EventLogger implements IEventLogger { /** * @inheritdoc */ + #[\Override] public function start($id, $description = '') { if ($this->activated) { $this->events[$id] = new Event($id, $description, microtime(true)); @@ -57,6 +58,7 @@ class EventLogger implements IEventLogger { /** * @inheritdoc */ + #[\Override] public function end($id) { if ($this->activated && isset($this->events[$id])) { $timing = $this->events[$id]; @@ -68,6 +70,7 @@ class EventLogger implements IEventLogger { /** * @inheritdoc */ + #[\Override] public function log($id, $description, $start, $end) { if ($this->activated) { $this->events[$id] = new Event($id, $description, $start); @@ -79,6 +82,7 @@ class EventLogger implements IEventLogger { /** * @inheritdoc */ + #[\Override] public function getEvents() { return $this->events; } @@ -86,6 +90,7 @@ class EventLogger implements IEventLogger { /** * @inheritdoc */ + #[\Override] public function activate() { $this->activated = true; } diff --git a/lib/private/Diagnostics/Query.php b/lib/private/Diagnostics/Query.php index fd14b946883..5b687de935f 100644 --- a/lib/private/Diagnostics/Query.php +++ b/lib/private/Diagnostics/Query.php @@ -24,26 +24,32 @@ class Query implements IQuery { $this->end = $time; } + #[\Override] public function getParams(): array { return $this->params; } + #[\Override] public function getSql(): string { return $this->sql; } + #[\Override] public function getStart(): float { return $this->start; } + #[\Override] public function getDuration(): float { return $this->end - $this->start; } + #[\Override] public function getStartTime(): float { return $this->start; } + #[\Override] public function getStacktrace(): array { return $this->stack; } diff --git a/lib/private/Diagnostics/QueryLogger.php b/lib/private/Diagnostics/QueryLogger.php index 5efe99d1a74..ea378d15d11 100644 --- a/lib/private/Diagnostics/QueryLogger.php +++ b/lib/private/Diagnostics/QueryLogger.php @@ -32,6 +32,7 @@ class QueryLogger implements IQueryLogger { /** * @inheritdoc */ + #[\Override] public function startQuery($sql, ?array $params = null, ?array $types = null) { if ($this->activated) { $this->activeQuery = new Query($sql, $params, microtime(true), $this->getStack()); @@ -49,6 +50,7 @@ class QueryLogger implements IQueryLogger { /** * @inheritdoc */ + #[\Override] public function stopQuery() { if ($this->activated && $this->activeQuery) { $this->activeQuery->end(microtime(true)); @@ -61,6 +63,7 @@ class QueryLogger implements IQueryLogger { /** * @inheritdoc */ + #[\Override] public function getQueries() { return $this->queries->getData(); } @@ -68,6 +71,7 @@ class QueryLogger implements IQueryLogger { /** * @inheritdoc */ + #[\Override] public function activate() { $this->activated = true; } diff --git a/lib/private/DirectEditing/Manager.php b/lib/private/DirectEditing/Manager.php index bcb69163dbb..f3a62fc201f 100644 --- a/lib/private/DirectEditing/Manager.php +++ b/lib/private/DirectEditing/Manager.php @@ -58,10 +58,12 @@ class Manager implements IManager { $this->l10n = $l10nFactory->get('lib'); } + #[\Override] public function registerDirectEditor(IEditor $directEditor): void { $this->editors[$directEditor->getId()] = $directEditor; } + #[\Override] public function getEditors(): array { return $this->editors; } @@ -97,6 +99,7 @@ class Manager implements IManager { return $return; } + #[\Override] public function create(string $path, string $editorId, string $creatorId, $templateId = null): string { $userFolder = $this->rootFolder->getUserFolder($this->userId); if ($userFolder->nodeExists($path)) { @@ -160,6 +163,7 @@ class Manager implements IManager { throw new \RuntimeException('No default editor found for files mimetype'); } + #[\Override] public function edit(string $token): Response { try { /** @var IEditor $editor */ @@ -193,6 +197,7 @@ class Manager implements IManager { return $this->editors[$editorId]; } + #[\Override] public function getToken(string $token): IToken { $query = $this->connection->getQueryBuilder(); $query->select('*')->from(self::TABLE_TOKENS) @@ -204,6 +209,7 @@ class Manager implements IManager { throw new \RuntimeException('Failed to validate the token'); } + #[\Override] public function cleanup(): int { $query = $this->connection->getQueryBuilder(); $query->delete(self::TABLE_TOKENS) @@ -282,6 +288,7 @@ class Manager implements IManager { return $file; } + #[\Override] public function isEnabled(): bool { if (!$this->encryptionManager->isEnabled()) { return true; diff --git a/lib/private/DirectEditing/Token.php b/lib/private/DirectEditing/Token.php index a816bf18dcc..ece88c293aa 100644 --- a/lib/private/DirectEditing/Token.php +++ b/lib/private/DirectEditing/Token.php @@ -16,14 +16,17 @@ class Token implements IToken { ) { } + #[\Override] public function extend(): void { $this->manager->refreshToken($this->data['token']); } + #[\Override] public function invalidate(): void { $this->manager->invalidateToken($this->data['token']); } + #[\Override] public function getFile(): File { if ($this->data['share_id'] !== null) { return $this->manager->getShareForToken($this->data['share_id']); @@ -35,18 +38,22 @@ class Token implements IToken { return $this->data['token']; } + #[\Override] public function useTokenScope(): void { $this->manager->invokeTokenScope($this->data['user_id']); } + #[\Override] public function hasBeenAccessed(): bool { return (bool)$this->data['accessed']; } + #[\Override] public function getEditor(): string { return $this->data['editor_id']; } + #[\Override] public function getUser(): string { return $this->data['user_id']; } diff --git a/lib/private/EmojiHelper.php b/lib/private/EmojiHelper.php index d305fc24799..7f1046d6f2d 100644 --- a/lib/private/EmojiHelper.php +++ b/lib/private/EmojiHelper.php @@ -17,11 +17,13 @@ class EmojiHelper implements IEmojiHelper { ) { } + #[\Override] public function doesPlatformSupportEmoji(): bool { return $this->db->supports4ByteText() && \class_exists(\IntlBreakIterator::class); } + #[\Override] public function isValidSingleEmoji(string $emoji): bool { $intlBreakIterator = \IntlBreakIterator::createCharacterInstance(); $intlBreakIterator->setText($emoji); diff --git a/lib/private/Encryption/EncryptionEventListener.php b/lib/private/Encryption/EncryptionEventListener.php index ddd0eaa475c..d60a651a91f 100644 --- a/lib/private/Encryption/EncryptionEventListener.php +++ b/lib/private/Encryption/EncryptionEventListener.php @@ -48,6 +48,7 @@ class EncryptionEventListener implements IEventListener { $dispatcher->addServiceListener(NodeRestoredEvent::class, static::class); } + #[\Override] public function handle(Event $event): void { if (!$this->encryptionManager->isEnabled()) { return; diff --git a/lib/private/Encryption/File.php b/lib/private/Encryption/File.php index 8da0bcfcc0d..6b4b7528bf3 100644 --- a/lib/private/Encryption/File.php +++ b/lib/private/Encryption/File.php @@ -47,6 +47,7 @@ class File implements IFile { * @param string $path to the file * @return array{users: string[], public: bool} */ + #[\Override] public function getAccessList($path) { // Make sure that a share key is generated for the owner too [$owner, $ownerPath] = $this->util->getUidAndFilename($path); diff --git a/lib/private/Encryption/Keys/Storage.php b/lib/private/Encryption/Keys/Storage.php index d1d225cd573..48a5bc1bdc3 100644 --- a/lib/private/Encryption/Keys/Storage.php +++ b/lib/private/Encryption/Keys/Storage.php @@ -42,6 +42,7 @@ class Storage implements IStorage { /** * @inheritdoc */ + #[\Override] public function getUserKey($uid, $keyId, $encryptionModuleId) { $path = $this->constructUserKeyPath($encryptionModuleId, $keyId, $uid); return base64_decode($this->getKeyWithUid($path, $uid)); @@ -50,6 +51,7 @@ class Storage implements IStorage { /** * @inheritdoc */ + #[\Override] public function getFileKey($path, $keyId, $encryptionModuleId) { $realFile = $this->util->stripPartialFileExtension($path); $keyDir = $this->util->getFileKeyDir($encryptionModuleId, $realFile); @@ -69,6 +71,7 @@ class Storage implements IStorage { /** * @inheritdoc */ + #[\Override] public function getSystemUserKey($keyId, $encryptionModuleId) { $path = $this->constructUserKeyPath($encryptionModuleId, $keyId, null); return base64_decode($this->getKeyWithUid($path, null)); @@ -77,6 +80,7 @@ class Storage implements IStorage { /** * @inheritdoc */ + #[\Override] public function setUserKey($uid, $keyId, $key, $encryptionModuleId) { $path = $this->constructUserKeyPath($encryptionModuleId, $keyId, $uid); return $this->setKey($path, [ @@ -88,6 +92,7 @@ class Storage implements IStorage { /** * @inheritdoc */ + #[\Override] public function setFileKey($path, $keyId, $key, $encryptionModuleId) { $keyDir = $this->util->getFileKeyDir($encryptionModuleId, $path); return $this->setKey($keyDir . $keyId, [ @@ -98,6 +103,7 @@ class Storage implements IStorage { /** * @inheritdoc */ + #[\Override] public function setSystemUserKey($keyId, $key, $encryptionModuleId) { $path = $this->constructUserKeyPath($encryptionModuleId, $keyId, null); return $this->setKey($path, [ @@ -109,6 +115,7 @@ class Storage implements IStorage { /** * @inheritdoc */ + #[\Override] public function deleteUserKey($uid, $keyId, $encryptionModuleId) { try { $path = $this->constructUserKeyPath($encryptionModuleId, $keyId, $uid); @@ -130,6 +137,7 @@ class Storage implements IStorage { /** * @inheritdoc */ + #[\Override] public function deleteFileKey($path, $keyId, $encryptionModuleId) { $keyDir = $this->util->getFileKeyDir($encryptionModuleId, $path); return !$this->view->file_exists($keyDir . $keyId) || $this->view->unlink($keyDir . $keyId); @@ -138,6 +146,7 @@ class Storage implements IStorage { /** * @inheritdoc */ + #[\Override] public function deleteAllFileKeys($path) { $keyDir = $this->util->getFileKeyDir('', $path); return !$this->view->file_exists($keyDir) || $this->view->deleteAll($keyDir); @@ -146,6 +155,7 @@ class Storage implements IStorage { /** * @inheritdoc */ + #[\Override] public function deleteSystemUserKey($keyId, $encryptionModuleId) { $path = $this->constructUserKeyPath($encryptionModuleId, $keyId, null); return !$this->view->file_exists($path) || $this->view->unlink($path); @@ -316,6 +326,7 @@ class Storage implements IStorage { * @param string $target * @return boolean */ + #[\Override] public function renameKeys($source, $target) { $sourcePath = $this->getPathToKeys($source); $targetPath = $this->getPathToKeys($target); @@ -338,6 +349,7 @@ class Storage implements IStorage { * @param string $target * @return boolean */ + #[\Override] public function copyKeys($source, $target) { $sourcePath = $this->getPathToKeys($source); $targetPath = $this->getPathToKeys($target); @@ -360,6 +372,7 @@ class Storage implements IStorage { * @return bool * @since 12.0.0 */ + #[\Override] public function backupUserKeys($encryptionModuleId, $purpose, $uid) { $source = $uid . $this->encryption_base_dir . '/' . $encryptionModuleId; $backupDir = $uid . $this->backup_base_dir; diff --git a/lib/private/Encryption/Manager.php b/lib/private/Encryption/Manager.php index a357ae0a150..ac27f0911b8 100644 --- a/lib/private/Encryption/Manager.php +++ b/lib/private/Encryption/Manager.php @@ -41,6 +41,7 @@ class Manager implements IManager { * * @return bool true if enabled, false if not */ + #[\Override] public function isEnabled() { $installed = $this->config->getSystemValueBool('installed', false); if (!$installed) { @@ -92,6 +93,7 @@ class Manager implements IManager { * @param callable $callback * @throws Exceptions\ModuleAlreadyExistsException */ + #[\Override] public function registerEncryptionModule($id, $displayName, callable $callback) { if (isset($this->encryptionModules[$id])) { throw new ModuleAlreadyExistsException($id, $displayName); @@ -115,6 +117,7 @@ class Manager implements IManager { * * @param string $moduleId */ + #[\Override] public function unregisterEncryptionModule($moduleId) { unset($this->encryptionModules[$moduleId]); } @@ -124,6 +127,7 @@ class Manager implements IManager { * * @return array [id => ['id' => $id, 'displayName' => $displayName, 'callback' => callback]] */ + #[\Override] public function getEncryptionModules() { return $this->encryptionModules; } @@ -135,6 +139,7 @@ class Manager implements IManager { * @return IEncryptionModule * @throws Exceptions\ModuleDoesNotExistsException */ + #[\Override] public function getEncryptionModule($moduleId = '') { if (empty($moduleId)) { return $this->getDefaultEncryptionModule(); @@ -172,6 +177,7 @@ class Manager implements IManager { * @param string $moduleId * @return bool */ + #[\Override] public function setDefaultEncryptionModule($moduleId) { try { $this->getEncryptionModule($moduleId); @@ -188,6 +194,7 @@ class Manager implements IManager { * * @return string */ + #[\Override] public function getDefaultEncryptionModuleId() { return $this->config->getAppValue('core', 'default_encryption_module'); } diff --git a/lib/private/EventDispatcher/EventDispatcher.php b/lib/private/EventDispatcher/EventDispatcher.php index 4c87271009a..5bba7747c8a 100644 --- a/lib/private/EventDispatcher/EventDispatcher.php +++ b/lib/private/EventDispatcher/EventDispatcher.php @@ -33,17 +33,20 @@ class EventDispatcher implements IEventDispatcher { } } + #[\Override] public function addListener(string $eventName, callable $listener, int $priority = 0): void { $this->dispatcher->addListener($eventName, $listener, $priority); } + #[\Override] public function removeListener(string $eventName, callable $listener): void { $this->dispatcher->removeListener($eventName, $listener); } + #[\Override] public function addServiceListener(string $eventName, string $className, int $priority = 0): void { @@ -56,6 +59,7 @@ class EventDispatcher implements IEventDispatcher { $this->addListener($eventName, $listener, $priority); } + #[\Override] public function hasListeners(string $eventName): bool { return $this->dispatcher->hasListeners($eventName); } @@ -63,6 +67,7 @@ class EventDispatcher implements IEventDispatcher { /** * @deprecated */ + #[\Override] public function dispatch(string $eventName, Event $event): void { $this->dispatcher->dispatch($event, $eventName); @@ -76,6 +81,7 @@ class EventDispatcher implements IEventDispatcher { } } + #[\Override] public function dispatchTyped(Event $event): void { $this->dispatch(get_class($event), $event); } diff --git a/lib/private/EventSource.php b/lib/private/EventSource.php index 214de5ca6fe..0876a440465 100644 --- a/lib/private/EventSource.php +++ b/lib/private/EventSource.php @@ -46,6 +46,7 @@ class EventSource implements IEventSource { * @throws \BadMethodCallException * @suppress PhanDeprecatedFunction */ + #[\Override] public function send(string $type, mixed $data = null): void { if ($data && !preg_match('/^[A-Za-z0-9_]+$/', $type)) { throw new \BadMethodCallException('Type needs to be alphanumeric (' . $type . ')'); @@ -63,6 +64,7 @@ class EventSource implements IEventSource { flush(); } + #[\Override] public function close(): void { $this->send('__internal__', 'close'); //server side closing can be an issue, let the client do it } diff --git a/lib/private/EventSourceFactory.php b/lib/private/EventSourceFactory.php index 57888b1be4c..2f23466be68 100644 --- a/lib/private/EventSourceFactory.php +++ b/lib/private/EventSourceFactory.php @@ -19,6 +19,7 @@ class EventSourceFactory implements IEventSourceFactory { ) { } + #[\Override] public function create(): IEventSource { return new EventSource($this->request); } diff --git a/lib/private/Federation/CloudFederationFactory.php b/lib/private/Federation/CloudFederationFactory.php index d06de0f2f58..f183fa3e87d 100644 --- a/lib/private/Federation/CloudFederationFactory.php +++ b/lib/private/Federation/CloudFederationFactory.php @@ -29,6 +29,7 @@ class CloudFederationFactory implements ICloudFederationFactory { * * @since 14.0.0 */ + #[\Override] public function getCloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $sharedSecret, $shareType, $resourceType) { return new CloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $shareType, $resourceType, $sharedSecret); } @@ -41,6 +42,7 @@ class CloudFederationFactory implements ICloudFederationFactory { * * @since 14.0.0 */ + #[\Override] public function getCloudFederationNotification() { return new CloudFederationNotification(); } diff --git a/lib/private/Federation/CloudFederationNotification.php b/lib/private/Federation/CloudFederationNotification.php index e0694c184af..b5ecd468814 100644 --- a/lib/private/Federation/CloudFederationNotification.php +++ b/lib/private/Federation/CloudFederationNotification.php @@ -30,6 +30,7 @@ class CloudFederationNotification implements ICloudFederationNotification { * * @since 14.0.0 */ + #[\Override] public function setMessage($notificationType, $resourceType, $providerId, array $notification) { $this->message = [ 'notificationType' => $notificationType, @@ -46,6 +47,7 @@ class CloudFederationNotification implements ICloudFederationNotification { * * @since 14.0.0 */ + #[\Override] public function getMessage() { return $this->message; } diff --git a/lib/private/Federation/CloudFederationProviderManager.php b/lib/private/Federation/CloudFederationProviderManager.php index f0dcf8ce411..77d225a49b3 100644 --- a/lib/private/Federation/CloudFederationProviderManager.php +++ b/lib/private/Federation/CloudFederationProviderManager.php @@ -60,6 +60,7 @@ class CloudFederationProviderManager implements ICloudFederationProviderManager * @param string $displayName user facing name of the federated share provider * @param callable $callback */ + #[\Override] public function addCloudFederationProvider($resourceType, $displayName, callable $callback) { $this->cloudFederationProvider[$resourceType] = [ 'resourceType' => $resourceType, @@ -73,6 +74,7 @@ class CloudFederationProviderManager implements ICloudFederationProviderManager * * @param string $providerId */ + #[\Override] public function removeCloudFederationProvider($providerId) { unset($this->cloudFederationProvider[$providerId]); } @@ -82,6 +84,7 @@ class CloudFederationProviderManager implements ICloudFederationProviderManager * * @return array [resourceType => ['resourceType' => $resourceType, 'displayName' => $displayName, 'callback' => callback]] */ + #[\Override] public function getAllCloudFederationProviders() { return $this->cloudFederationProvider; } @@ -93,6 +96,7 @@ class CloudFederationProviderManager implements ICloudFederationProviderManager * @return ICloudFederationProvider * @throws ProviderDoesNotExistsException */ + #[\Override] public function getCloudFederationProvider($resourceType) { if (isset($this->cloudFederationProvider[$resourceType])) { return call_user_func($this->cloudFederationProvider[$resourceType]['callback']); @@ -104,6 +108,7 @@ class CloudFederationProviderManager implements ICloudFederationProviderManager /** * @deprecated 29.0.0 - Use {@see sendCloudShare()} instead and handle errors manually */ + #[\Override] public function sendShare(ICloudFederationShare $share) { $cloudID = $this->cloudIdManager->resolveCloudId($share->getShareWith()); try { @@ -135,6 +140,7 @@ class CloudFederationProviderManager implements ICloudFederationProviderManager * @return IResponse * @throws OCMProviderException */ + #[\Override] public function sendCloudShare(ICloudFederationShare $share): IResponse { $cloudID = $this->cloudIdManager->resolveCloudId($share->getShareWith()); $client = $this->httpClientService->newClient(); @@ -156,6 +162,7 @@ class CloudFederationProviderManager implements ICloudFederationProviderManager * @return array|false * @deprecated 29.0.0 - Use {@see sendCloudNotification()} instead and handle errors manually */ + #[\Override] public function sendNotification($url, ICloudFederationNotification $notification) { try { try { @@ -181,6 +188,7 @@ class CloudFederationProviderManager implements ICloudFederationProviderManager * @return IResponse * @throws OCMProviderException */ + #[\Override] public function sendCloudNotification(string $url, ICloudFederationNotification $notification): IResponse { $client = $this->httpClientService->newClient(); try { @@ -200,6 +208,7 @@ class CloudFederationProviderManager implements ICloudFederationProviderManager * * @return bool */ + #[\Override] public function isReady() { return $this->appManager->isEnabledForUser('cloud_federation_api'); } diff --git a/lib/private/Federation/CloudFederationShare.php b/lib/private/Federation/CloudFederationShare.php index 6bd35cea763..311a0ee7f5b 100644 --- a/lib/private/Federation/CloudFederationShare.php +++ b/lib/private/Federation/CloudFederationShare.php @@ -79,6 +79,7 @@ class CloudFederationShare implements ICloudFederationShare { * * @since 14.0.0 */ + #[\Override] public function setShareWith($user) { $this->share['shareWith'] = $user; } @@ -90,6 +91,7 @@ class CloudFederationShare implements ICloudFederationShare { * * @since 14.0.0 */ + #[\Override] public function setResourceName($name) { $this->share['name'] = $name; } @@ -101,6 +103,7 @@ class CloudFederationShare implements ICloudFederationShare { * * @since 14.0.0 */ + #[\Override] public function setResourceType($resourceType) { $this->share['resourceType'] = $resourceType; } @@ -112,6 +115,7 @@ class CloudFederationShare implements ICloudFederationShare { * * @since 14.0.0 */ + #[\Override] public function setDescription($description) { $this->share['description'] = $description; } @@ -123,6 +127,7 @@ class CloudFederationShare implements ICloudFederationShare { * * @since 14.0.0 */ + #[\Override] public function setProviderId($providerId) { $this->share['providerId'] = (string)$providerId; } @@ -134,6 +139,7 @@ class CloudFederationShare implements ICloudFederationShare { * * @since 14.0.0 */ + #[\Override] public function setOwner($owner) { $this->share['owner'] = $owner; } @@ -145,6 +151,7 @@ class CloudFederationShare implements ICloudFederationShare { * * @since 14.0.0 */ + #[\Override] public function setOwnerDisplayName($ownerDisplayName) { $this->share['ownerDisplayName'] = $ownerDisplayName; } @@ -156,6 +163,7 @@ class CloudFederationShare implements ICloudFederationShare { * * @since 14.0.0 */ + #[\Override] public function setSharedBy($sharedBy) { $this->share['sharedBy'] = $sharedBy; $this->share['sender'] = $sharedBy; @@ -168,6 +176,7 @@ class CloudFederationShare implements ICloudFederationShare { * * @since 14.0.0 */ + #[\Override] public function setSharedByDisplayName($sharedByDisplayName) { $this->share['sharedByDisplayName'] = $sharedByDisplayName; $this->share['senderDisplayName'] = $sharedByDisplayName; @@ -180,6 +189,7 @@ class CloudFederationShare implements ICloudFederationShare { * * @since 14.0.0 */ + #[\Override] public function setProtocol(array $protocol) { $this->share['protocol'] = $protocol; } @@ -191,6 +201,7 @@ class CloudFederationShare implements ICloudFederationShare { * * @since 14.0.0 */ + #[\Override] public function setShareType($shareType) { if ($shareType === 'group' || $shareType === IShare::TYPE_REMOTE_GROUP) { $this->share['shareType'] = 'group'; @@ -206,6 +217,7 @@ class CloudFederationShare implements ICloudFederationShare { * * @since 14.0.0 */ + #[\Override] public function getShare() { return $this->share; } @@ -217,6 +229,7 @@ class CloudFederationShare implements ICloudFederationShare { * * @since 14.0.0 */ + #[\Override] public function getShareWith() { return $this->share['shareWith']; } @@ -228,6 +241,7 @@ class CloudFederationShare implements ICloudFederationShare { * * @since 14.0.0 */ + #[\Override] public function getResourceName() { return $this->share['name']; } @@ -239,6 +253,7 @@ class CloudFederationShare implements ICloudFederationShare { * * @since 14.0.0 */ + #[\Override] public function getResourceType() { return $this->share['resourceType']; } @@ -250,6 +265,7 @@ class CloudFederationShare implements ICloudFederationShare { * * @since 14.0.0 */ + #[\Override] public function getDescription() { return $this->share['description']; } @@ -261,6 +277,7 @@ class CloudFederationShare implements ICloudFederationShare { * * @since 14.0.0 */ + #[\Override] public function getProviderId() { return $this->share['providerId']; } @@ -272,6 +289,7 @@ class CloudFederationShare implements ICloudFederationShare { * * @since 14.0.0 */ + #[\Override] public function getOwner() { return $this->share['owner']; } @@ -283,6 +301,7 @@ class CloudFederationShare implements ICloudFederationShare { * * @since 14.0.0 */ + #[\Override] public function getOwnerDisplayName() { return $this->share['ownerDisplayName']; } @@ -294,6 +313,7 @@ class CloudFederationShare implements ICloudFederationShare { * * @since 14.0.0 */ + #[\Override] public function getSharedBy() { return $this->share['sharedBy']; } @@ -305,6 +325,7 @@ class CloudFederationShare implements ICloudFederationShare { * * @since 14.0.0 */ + #[\Override] public function getSharedByDisplayName() { return $this->share['sharedByDisplayName']; } @@ -316,6 +337,7 @@ class CloudFederationShare implements ICloudFederationShare { * * @since 14.0.0 */ + #[\Override] public function getShareType() { return $this->share['shareType']; } @@ -327,6 +349,7 @@ class CloudFederationShare implements ICloudFederationShare { * * @since 14.0.0 */ + #[\Override] public function getShareSecret() { return $this->share['protocol']['options']['sharedSecret']; } @@ -338,6 +361,7 @@ class CloudFederationShare implements ICloudFederationShare { * * @since 14.0.0 */ + #[\Override] public function getProtocol() { return $this->share['protocol']; } diff --git a/lib/private/Federation/CloudId.php b/lib/private/Federation/CloudId.php index 643524b3acd..9150d89d4d9 100644 --- a/lib/private/Federation/CloudId.php +++ b/lib/private/Federation/CloudId.php @@ -26,10 +26,12 @@ class CloudId implements ICloudId { * * @return string */ + #[\Override] public function getId(): string { return $this->id; } + #[\Override] public function getDisplayId(): string { if ($this->displayName === null) { /** @var CloudIdManager $cloudIdManager */ @@ -50,6 +52,7 @@ class CloudId implements ICloudId { * * @return string */ + #[\Override] public function getUser(): string { return $this->user; } @@ -59,6 +62,7 @@ class CloudId implements ICloudId { * * @return string */ + #[\Override] public function getRemote(): string { return $this->remote; } diff --git a/lib/private/Federation/CloudIdManager.php b/lib/private/Federation/CloudIdManager.php index b0996d5179c..57217af524e 100644 --- a/lib/private/Federation/CloudIdManager.php +++ b/lib/private/Federation/CloudIdManager.php @@ -71,6 +71,7 @@ class CloudIdManager implements ICloudIdManager { * @return ICloudId * @throws \InvalidArgumentException */ + #[\Override] public function resolveCloudId(string $cloudId): ICloudId { // TODO magic here to get the url and user instead of just splitting on @ @@ -189,6 +190,7 @@ class CloudIdManager implements ICloudIdManager { * @param string|null $remote * @return CloudId */ + #[\Override] public function getCloudId(string $user, ?string $remote): ICloudId { $isLocal = $remote === null; if ($isLocal) { @@ -234,6 +236,7 @@ class CloudIdManager implements ICloudIdManager { * @param string $url * @return string */ + #[\Override] public function removeProtocolFromUrl(string $url, bool $httpsOnly = false): string { if (str_starts_with($url, 'https://')) { return substr($url, 8); @@ -279,6 +282,7 @@ class CloudIdManager implements ICloudIdManager { * @param string $cloudId * @return bool */ + #[\Override] public function isValidCloudId(string $cloudId): bool { foreach ($this->cloudIdResolvers as $resolver) { if ($resolver->isValidCloudId($cloudId)) { @@ -289,14 +293,17 @@ class CloudIdManager implements ICloudIdManager { return strpos($cloudId, '@') !== false; } + #[\Override] public function createCloudId(string $id, string $user, string $remote, ?string $displayName = null): ICloudId { return new CloudId($id, $user, $remote, $displayName); } + #[\Override] public function registerCloudIdResolver(ICloudIdResolver $resolver): void { array_unshift($this->cloudIdResolvers, $resolver); } + #[\Override] public function unregisterCloudIdResolver(ICloudIdResolver $resolver): void { if (($key = array_search($resolver, $this->cloudIdResolvers)) !== false) { array_splice($this->cloudIdResolvers, $key, 1); diff --git a/lib/private/Files/AppData/AppData.php b/lib/private/Files/AppData/AppData.php index 5bea7ec470c..b4e8d51d438 100644 --- a/lib/private/Files/AppData/AppData.php +++ b/lib/private/Files/AppData/AppData.php @@ -85,6 +85,7 @@ class AppData implements IAppData { return $this->folder; } + #[\Override] public function getFolder(string $name): ISimpleFolder { $key = $this->appId . '/' . $name; if ($cachedFolder = $this->folders->get($key)) { @@ -113,6 +114,7 @@ class AppData implements IAppData { return $folder; } + #[\Override] public function newFolder(string $name): ISimpleFolder { $key = $this->appId . '/' . $name; $folder = $this->getAppDataFolder()->newFolder($name); @@ -122,6 +124,7 @@ class AppData implements IAppData { return $simpleFolder; } + #[\Override] public function getDirectoryListing(): array { $listing = $this->getAppDataFolder()->getDirectoryListing(); diff --git a/lib/private/Files/AppData/Factory.php b/lib/private/Files/AppData/Factory.php index 75d20e454e5..cf436b54ea3 100644 --- a/lib/private/Files/AppData/Factory.php +++ b/lib/private/Files/AppData/Factory.php @@ -23,6 +23,7 @@ class Factory implements IAppDataFactory { ) { } + #[\Override] public function get(string $appId): IAppData { if (!isset($this->folders[$appId])) { $this->folders[$appId] = new AppData($this->rootFolder, $this->config, $appId); diff --git a/lib/private/Files/Cache/Cache.php b/lib/private/Files/Cache/Cache.php index 96b0c413e4d..6676d93a5f8 100644 --- a/lib/private/Files/Cache/Cache.php +++ b/lib/private/Files/Cache/Cache.php @@ -110,6 +110,7 @@ class Cache implements ICache { * * @return int */ + #[\Override] public function getNumericStorageId() { return $this->storageCache->getNumericId(); } @@ -120,6 +121,7 @@ class Cache implements ICache { * @param string|int $file either the path of a file or folder or the file id for a file or folder * @return ICacheEntry|false the cache entry as array or false if the file is not found in the cache */ + #[\Override] public function get($file) { $query = $this->getQueryBuilder(); $query->selectFileCache(); @@ -251,6 +253,7 @@ class Cache implements ICache { * @return int file id * @throws \RuntimeException */ + #[\Override] public function put($file, array $data) { // do not carry over creation_time to file versions, as each new version would otherwise // create a filecache_extended entry with the same creation_time as the original file @@ -275,6 +278,7 @@ class Cache implements ICache { * @return int file id * @throws \RuntimeException|Exception */ + #[\Override] public function insert($file, array $data) { // normalize file $file = $this->normalize($file); @@ -360,6 +364,7 @@ class Cache implements ICache { * @param int $id the fileid of the existing file or folder * @param array $data [$key => $value] the metadata to update, only the fields provided in the array will be updated, non-provided values will remain unchanged */ + #[\Override] public function update($id, array $data) { if (isset($data['path'])) { // normalize path @@ -496,6 +501,7 @@ class Cache implements ICache { * @param string $file * @return int */ + #[\Override] public function getId($file) { // normalize file $file = $this->normalize($file); @@ -519,6 +525,7 @@ class Cache implements ICache { * @param string $file * @return int */ + #[\Override] public function getParentId($file) { if ($file === '') { return -1; @@ -542,6 +549,7 @@ class Cache implements ICache { * @param string $file * @return bool */ + #[\Override] public function inCache($file) { return $this->getId($file) != -1; } @@ -553,6 +561,7 @@ class Cache implements ICache { * * @param string $file */ + #[\Override] public function remove($file) { $entry = $this->get($file); @@ -679,6 +688,7 @@ class Cache implements ICache { * @param string $source * @param string $target */ + #[\Override] public function move($source, $target) { $this->moveFromCache($this, $source, $target); } @@ -713,6 +723,7 @@ class Cache implements ICache { * @throws DatabaseException * @throws \Exception if the given storages have an invalid id */ + #[\Override] public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) { if ($sourceCache instanceof Cache) { // normalize source and target @@ -888,6 +899,7 @@ class Cache implements ICache { * * @return int Cache::NOT_FOUND, Cache::PARTIAL, Cache::SHALLOW or Cache::COMPLETE */ + #[\Override] public function getStatus($file) { // normalize file $file = $this->normalize($file); @@ -923,6 +935,7 @@ class Cache implements ICache { * @param string $pattern the search pattern using SQL search syntax (e.g. '%searchstring%') * @return ICacheEntry[] an array of cache entries where the name matches the search pattern */ + #[\Override] public function search($pattern) { $operator = new SearchComparison(ISearchComparison::COMPARE_LIKE, 'name', $pattern); return $this->searchQuery(new SearchQuery($operator, 0, 0, [], null)); @@ -935,6 +948,7 @@ class Cache implements ICache { * where it will search for all mimetypes in the group ('image/*') * @return ICacheEntry[] an array of cache entries where the mimetype matches the search */ + #[\Override] public function searchByMime($mimetype) { if (!str_contains($mimetype, '/')) { $operator = new SearchComparison(ISearchComparison::COMPARE_LIKE, 'mimetype', $mimetype . '/%'); @@ -944,6 +958,7 @@ class Cache implements ICache { return $this->searchQuery(new SearchQuery($operator, 0, 0, [], null)); } + #[\Override] public function searchQuery(ISearchQuery $query) { return current($this->querySearchHelper->searchInCaches($query, [$this])); } @@ -1129,6 +1144,7 @@ class Cache implements ICache { * * @return string|false the path of the folder or false when no folder matched */ + #[\Override] public function getIncomplete() { $query = $this->getQueryBuilder(); $query->select('path') @@ -1151,6 +1167,7 @@ class Cache implements ICache { * @param int $id the file id of the file or folder to search * @return string|null the path of the file (relative to the storage) or null if a file with the given id does not exists within this cache */ + #[\Override] public function getPathById($id) { $query = $this->getQueryBuilder(); $query->select('path') @@ -1208,6 +1225,7 @@ class Cache implements ICache { * @param string $path * @return string */ + #[\Override] public function normalize($path) { return trim(\OC_Util::normalizeUnicode($path), '/'); } @@ -1220,6 +1238,7 @@ class Cache implements ICache { * @param string $targetPath * @return int fileId of copied entry */ + #[\Override] public function copyFromCache(ICache $sourceCache, ICacheEntry $sourceEntry, string $targetPath): int { if ($sourceEntry->getId() < 0) { throw new \RuntimeException('Invalid source cache entry on copyFromCache'); @@ -1273,10 +1292,12 @@ class Cache implements ICache { return $data; } + #[\Override] public function getQueryFilterForStorage(): ISearchOperator { return new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', $this->getNumericStorageId()); } + #[\Override] public function getCacheEntryFromSearchResult(ICacheEntry $rawEntry): ?ICacheEntry { if ($rawEntry->getStorageId() === $this->getNumericStorageId()) { return $rawEntry; diff --git a/lib/private/Files/Cache/CacheEntry.php b/lib/private/Files/Cache/CacheEntry.php index 943f328e845..74af7d0a598 100644 --- a/lib/private/Files/Cache/CacheEntry.php +++ b/lib/private/Files/Cache/CacheEntry.php @@ -18,14 +18,17 @@ class CacheEntry implements ICacheEntry { ) { } + #[\Override] public function offsetSet($offset, $value): void { $this->data[$offset] = $value; } + #[\Override] public function offsetExists($offset): bool { return isset($this->data[$offset]); } + #[\Override] public function offsetUnset($offset): void { unset($this->data[$offset]); } @@ -33,6 +36,7 @@ class CacheEntry implements ICacheEntry { /** * @return mixed */ + #[\Override] #[\ReturnTypeWillChange] public function offsetGet($offset) { if (isset($this->data[$offset])) { @@ -42,70 +46,86 @@ class CacheEntry implements ICacheEntry { } } + #[\Override] public function getId() { return (int)$this->data['fileid']; } + #[\Override] public function getStorageId() { return $this->data['storage']; } + #[\Override] public function getPath() { return (string)$this->data['path']; } + #[\Override] public function getName() { return $this->data['name']; } + #[\Override] public function getMimeType(): string { return $this->data['mimetype'] ?? 'application/octet-stream'; } + #[\Override] public function getMimePart() { return $this->data['mimepart']; } + #[\Override] public function getSize() { return $this->data['size']; } + #[\Override] public function getMTime() { return $this->data['mtime']; } + #[\Override] public function getStorageMTime() { return $this->data['storage_mtime']; } + #[\Override] public function getEtag() { return $this->data['etag']; } + #[\Override] public function getPermissions(): int { return $this->data['permissions']; } + #[\Override] public function isEncrypted() { return isset($this->data['encrypted']) && $this->data['encrypted']; } + #[\Override] public function getMetadataEtag(): ?string { return $this->data['metadata_etag'] ?? null; } + #[\Override] public function getCreationTime(): ?int { return $this->data['creation_time'] ?? null; } + #[\Override] public function getUploadTime(): ?int { return $this->data['upload_time'] ?? null; } + #[\Override] public function getParentId(): int { return $this->data['parent']; } @@ -118,6 +138,7 @@ class CacheEntry implements ICacheEntry { $this->data = array_merge([], $this->data); } + #[\Override] public function getUnencryptedSize(): int { if ($this->data['encrypted'] && isset($this->data['unencrypted_size']) && $this->data['unencrypted_size'] > 0) { return $this->data['unencrypted_size']; diff --git a/lib/private/Files/Cache/FailedCache.php b/lib/private/Files/Cache/FailedCache.php index 82d2dbbd8cf..7db87accc32 100644 --- a/lib/private/Files/Cache/FailedCache.php +++ b/lib/private/Files/Cache/FailedCache.php @@ -26,10 +26,12 @@ class FailedCache implements ICache { ) { } + #[\Override] public function getNumericStorageId(): int { return -1; } + #[\Override] public function get($file): false|ICacheEntry { if ($file === '') { return new CacheEntry([ @@ -45,59 +47,74 @@ class FailedCache implements ICache { } } + #[\Override] public function getFolderContents(string $folder, ?string $mimeTypeFilter = null): array { return []; } + #[\Override] public function getFolderContentsById(int $fileId, ?string $mimeTypeFilter = null): array { return []; } + #[\Override] public function put($file, array $data) { } + #[\Override] public function insert($file, array $data) { } + #[\Override] public function update($id, array $data) { } + #[\Override] public function getId($file): int { return -1; } + #[\Override] public function getParentId($file): int { return -1; } + #[\Override] public function inCache($file): bool { return false; } + #[\Override] public function remove($file) { } + #[\Override] public function move($source, $target) { } + #[\Override] public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) { } public function clear() { } + #[\Override] public function getStatus($file) { return ICache::NOT_FOUND; } + #[\Override] public function search($pattern) { return []; } + #[\Override] public function searchByMime($mimetype) { return []; } + #[\Override] public function searchQuery(ISearchQuery $query) { return []; } @@ -106,26 +123,32 @@ class FailedCache implements ICache { return []; } + #[\Override] public function getIncomplete() { return []; } + #[\Override] public function getPathById($id) { return null; } + #[\Override] public function normalize($path) { return $path; } + #[\Override] public function copyFromCache(ICache $sourceCache, ICacheEntry $sourceEntry, string $targetPath): int { throw new \Exception('Invalid cache'); } + #[\Override] public function getQueryFilterForStorage(): ISearchOperator { return new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', -1); } + #[\Override] public function getCacheEntryFromSearchResult(ICacheEntry $rawEntry): ?ICacheEntry { return null; } diff --git a/lib/private/Files/Cache/FileAccess.php b/lib/private/Files/Cache/FileAccess.php index ee92c4fdc7a..b7357dfe0bc 100644 --- a/lib/private/Files/Cache/FileAccess.php +++ b/lib/private/Files/Cache/FileAccess.php @@ -39,11 +39,13 @@ class FileAccess implements IFileAccess { ); } + #[\Override] public function getByFileIdInStorage(int $fileId, int $storageId): ?CacheEntry { $items = array_values($this->getByFileIdsInStorage([$fileId], $storageId)); return $items[0] ?? null; } + #[\Override] public function getByPathInStorage(string $path, int $storageId): ?CacheEntry { $query = $this->getQuery()->selectFileCache(); $query->andWhere($query->expr()->eq('filecache.path_hash', $query->createNamedParameter(md5($path)))); @@ -53,6 +55,7 @@ class FileAccess implements IFileAccess { return $row ? Cache::cacheEntryFromData($row, $this->mimeTypeLoader) : null; } + #[\Override] public function getByFileId(int $fileId): ?CacheEntry { $items = array_values($this->getByFileIds([$fileId])); return $items[0] ?? null; @@ -75,6 +78,7 @@ class FileAccess implements IFileAccess { * @param int[] $fileIds * @return array */ + #[\Override] public function getByFileIds(array $fileIds): array { $query = $this->getQuery()->selectFileCache(); $query->andWhere($query->expr()->in('filecache.fileid', $query->createNamedParameter($fileIds, IQueryBuilder::PARAM_INT_ARRAY))); @@ -88,6 +92,7 @@ class FileAccess implements IFileAccess { * @param int $storageId * @return array */ + #[\Override] public function getByFileIdsInStorage(array $fileIds, int $storageId): array { $fileIds = array_values($fileIds); $query = $this->getQuery()->selectFileCache(); @@ -98,6 +103,7 @@ class FileAccess implements IFileAccess { return $this->rowsToEntries($rows); } + #[\Override] public function getByAncestorInStorage(int $storageId, int $folderId, int $fileIdCursor = 0, int $maxResults = 100, array $mimeTypeIds = [], bool $endToEndEncrypted = true, bool $serverSideEncrypted = true): \Generator { $qb = $this->getQuery(); $qb->select('path') @@ -189,6 +195,7 @@ class FileAccess implements IFileAccess { $files->closeCursor(); } + #[\Override] public function getDistinctMounts(array $mountProviders = [], bool $onlyUserFilesMounts = true): \Generator { $qb = $this->connection->getQueryBuilder(); $qb->selectDistinct(['root_id', 'storage_id', 'mount_provider_class']) diff --git a/lib/private/Files/Cache/HomeCache.php b/lib/private/Files/Cache/HomeCache.php index 0fad90c60db..a0b4754ff97 100644 --- a/lib/private/Files/Cache/HomeCache.php +++ b/lib/private/Files/Cache/HomeCache.php @@ -17,6 +17,7 @@ class HomeCache extends Cache { * @param array|null|ICacheEntry $entry (optional) meta data of the folder * @return int|float */ + #[\Override] public function calculateFolderSize($path, $entry = null) { if ($path !== '/' && $path !== '' && $path !== 'files' && $path !== 'files_trashbin' && $path !== 'files_versions') { return parent::calculateFolderSize($path, $entry); @@ -32,6 +33,7 @@ class HomeCache extends Cache { * @param string $file * @return ICacheEntry */ + #[\Override] public function get($file) { $data = parent::get($file); if ($file === '' || $file === '/') { diff --git a/lib/private/Files/Cache/NullWatcher.php b/lib/private/Files/Cache/NullWatcher.php index e3659214849..e6973e8d266 100644 --- a/lib/private/Files/Cache/NullWatcher.php +++ b/lib/private/Files/Cache/NullWatcher.php @@ -14,25 +14,31 @@ class NullWatcher extends Watcher { public function __construct() { } + #[\Override] public function setPolicy($policy) { $this->policy = $policy; } + #[\Override] public function getPolicy() { return $this->policy; } + #[\Override] public function checkUpdate($path, $cachedEntry = null) { return false; } + #[\Override] public function update($path, $cachedData) { } + #[\Override] public function needsUpdate($path, $cachedData) { return false; } + #[\Override] public function cleanFolder($path) { } } diff --git a/lib/private/Files/Cache/Scanner.php b/lib/private/Files/Cache/Scanner.php index 140f840ba1f..36c8c02a8bf 100644 --- a/lib/private/Files/Cache/Scanner.php +++ b/lib/private/Files/Cache/Scanner.php @@ -99,6 +99,7 @@ class Scanner extends BasicEmitter implements IScanner { * @return array|null an array of metadata of the scanned file * @throws LockedException */ + #[\Override] public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null, $lock = true, $data = null) { if ($file !== '') { try { @@ -291,6 +292,7 @@ class Scanner extends BasicEmitter implements IScanner { * @param bool $lock set to false to disable getting an additional read lock during scanning * @return array|null an array of the meta data of the scanned file or folder */ + #[\Override] public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $lock = true) { if ($reuse === -1) { $reuse = ($recursive === self::SCAN_SHALLOW) ? self::REUSE_ETAG | self::REUSE_SIZE : self::REUSE_ETAG; @@ -536,6 +538,7 @@ class Scanner extends BasicEmitter implements IScanner { * @param string $file * @return boolean */ + #[\Override] public static function isPartialFile($file) { if (pathinfo($file, PATHINFO_EXTENSION) === 'part') { return true; @@ -550,6 +553,7 @@ class Scanner extends BasicEmitter implements IScanner { /** * walk over any folders that are not fully scanned yet and scan them */ + #[\Override] public function backgroundScan() { if ($this->storage->instanceOfStorage(Jail::class)) { // for jail storage wrappers (shares, groupfolders) we run the background scan on the source storage diff --git a/lib/private/Files/Cache/Watcher.php b/lib/private/Files/Cache/Watcher.php index c4734bce0d9..48c5e323514 100644 --- a/lib/private/Files/Cache/Watcher.php +++ b/lib/private/Files/Cache/Watcher.php @@ -37,10 +37,12 @@ class Watcher implements IWatcher { /** * @param int $policy either \OC\Files\Cache\Watcher::CHECK_NEVER, \OC\Files\Cache\Watcher::CHECK_ONCE, \OC\Files\Cache\Watcher::CHECK_ALWAYS */ + #[\Override] public function setPolicy($policy) { $this->watchPolicy = $policy; } + #[\Override] public function setCheckFilter(?string $filter): void { $this->checkFilter = $filter; } @@ -48,6 +50,7 @@ class Watcher implements IWatcher { /** * @return int either \OC\Files\Cache\Watcher::CHECK_NEVER, \OC\Files\Cache\Watcher::CHECK_ONCE, \OC\Files\Cache\Watcher::CHECK_ALWAYS */ + #[\Override] public function getPolicy() { return $this->watchPolicy; } @@ -59,6 +62,7 @@ class Watcher implements IWatcher { * @param ICacheEntry|null $cachedEntry * @return boolean true if path was updated */ + #[\Override] public function checkUpdate($path, $cachedEntry = null) { if (is_null($cachedEntry)) { $cachedEntry = $this->cache->get($path); @@ -84,6 +88,7 @@ class Watcher implements IWatcher { * @param string $path * @param ICacheEntry $cachedData */ + #[\Override] public function update($path, $cachedData) { if ($this->storage->is_dir($path)) { $this->scanner->scan($path, Scanner::SCAN_SHALLOW); @@ -108,6 +113,7 @@ class Watcher implements IWatcher { * @param ICacheEntry $cachedData * @return bool */ + #[\Override] public function needsUpdate($path, $cachedData) { if ($this->checkFilter !== null) { if (!preg_match($this->checkFilter, $path)) { @@ -127,6 +133,7 @@ class Watcher implements IWatcher { * * @param string $path */ + #[\Override] public function cleanFolder($path) { $cachedContent = $this->cache->getFolderContents($path); foreach ($cachedContent as $entry) { @@ -139,6 +146,7 @@ class Watcher implements IWatcher { /** * register a callback to be called whenever the watcher triggers and update */ + #[\Override] public function onUpdate(callable $callback): void { $this->onUpdate[] = $callback; } diff --git a/lib/private/Files/Cache/Wrapper/CacheDirPermissionsMask.php b/lib/private/Files/Cache/Wrapper/CacheDirPermissionsMask.php index 38fe5a88c41..e5a1b648a2f 100644 --- a/lib/private/Files/Cache/Wrapper/CacheDirPermissionsMask.php +++ b/lib/private/Files/Cache/Wrapper/CacheDirPermissionsMask.php @@ -25,6 +25,7 @@ class CacheDirPermissionsMask extends CachePermissionsMask { parent::__construct($cache, $mask); } + #[\Override] protected function formatCacheEntry($entry): ICacheEntry|false { $checkPath = $this->checkPath; if ($checkPath($entry['path'])) { diff --git a/lib/private/Files/Cache/Wrapper/CacheJail.php b/lib/private/Files/Cache/Wrapper/CacheJail.php index 59d0faf0078..477d85c6933 100644 --- a/lib/private/Files/Cache/Wrapper/CacheJail.php +++ b/lib/private/Files/Cache/Wrapper/CacheJail.php @@ -98,6 +98,7 @@ class CacheJail extends CacheWrapper { } } + #[\Override] protected function formatCacheEntry($entry) { if (isset($entry['path'])) { $entry['path'] = $this->getJailedPath($entry['path']); @@ -111,6 +112,7 @@ class CacheJail extends CacheWrapper { * @param string|int $file * @return ICacheEntry|false */ + #[\Override] public function get($file) { if (is_string($file) || $file === '') { $file = $this->getSourcePath($file); @@ -127,6 +129,7 @@ class CacheJail extends CacheWrapper { * @return int file id * @throws \RuntimeException */ + #[\Override] public function insert($file, array $data) { return $this->getCache()->insert($this->getSourcePath($file), $data); } @@ -137,6 +140,7 @@ class CacheJail extends CacheWrapper { * @param int $id * @param array $data */ + #[\Override] public function update($id, array $data) { $this->getCache()->update($id, $data); } @@ -147,6 +151,7 @@ class CacheJail extends CacheWrapper { * @param string $file * @return int */ + #[\Override] public function getId($file) { return $this->getCache()->getId($this->getSourcePath($file)); } @@ -157,6 +162,7 @@ class CacheJail extends CacheWrapper { * @param string $file * @return int */ + #[\Override] public function getParentId($file) { return $this->getCache()->getParentId($this->getSourcePath($file)); } @@ -167,6 +173,7 @@ class CacheJail extends CacheWrapper { * @param string $file * @return bool */ + #[\Override] public function inCache($file) { return $this->getCache()->inCache($this->getSourcePath($file)); } @@ -176,6 +183,7 @@ class CacheJail extends CacheWrapper { * * @param string $file */ + #[\Override] public function remove($file) { $this->getCache()->remove($this->getSourcePath($file)); } @@ -186,6 +194,7 @@ class CacheJail extends CacheWrapper { * @param string $source * @param string $target */ + #[\Override] public function move($source, $target) { $this->getCache()->move($this->getSourcePath($source), $this->getSourcePath($target)); } @@ -196,6 +205,7 @@ class CacheJail extends CacheWrapper { * @param string $path * @return array [$storageId, $internalPath] */ + #[\Override] protected function getMoveInfo($path) { return [$this->getNumericStorageId(), $this->getUnjailedSourcePath($path)]; } @@ -203,6 +213,7 @@ class CacheJail extends CacheWrapper { /** * remove all entries for files that are stored on the storage from the cache */ + #[\Override] public function clear() { $this->getCache()->remove($this->getRoot()); } @@ -212,6 +223,7 @@ class CacheJail extends CacheWrapper { * * @return int Cache::NOT_FOUND, Cache::PARTIAL, Cache::SHALLOW or Cache::COMPLETE */ + #[\Override] public function getStatus($file) { return $this->getCache()->getStatus($this->getSourcePath($file)); } @@ -221,6 +233,7 @@ class CacheJail extends CacheWrapper { * * @param array|ICacheEntry|null $data (optional) meta data of the folder */ + #[\Override] public function correctFolderSize(string $path, $data = null, bool $isBackgroundScan = false): void { $cache = $this->getCache(); if ($cache instanceof Cache) { @@ -235,6 +248,7 @@ class CacheJail extends CacheWrapper { * @param array|null|ICacheEntry $entry (optional) meta data of the folder * @return int|float */ + #[\Override] public function calculateFolderSize($path, $entry = null) { $cache = $this->getCache(); if ($cache instanceof Cache) { @@ -249,6 +263,7 @@ class CacheJail extends CacheWrapper { * * @return int[] */ + #[\Override] public function getAll() { // not supported return []; @@ -263,6 +278,7 @@ class CacheJail extends CacheWrapper { * * @return string|false the path of the folder or false when no folder matched */ + #[\Override] public function getIncomplete() { // not supported return false; @@ -274,6 +290,7 @@ class CacheJail extends CacheWrapper { * @param int $id * @return string|null */ + #[\Override] public function getPathById($id) { $path = $this->getCache()->getPathById($id); if ($path === null) { @@ -291,6 +308,7 @@ class CacheJail extends CacheWrapper { * @param string $sourcePath * @param string $targetPath */ + #[\Override] public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) { if ($sourceCache === $this) { return $this->move($sourcePath, $targetPath); @@ -298,6 +316,7 @@ class CacheJail extends CacheWrapper { return $this->getCache()->moveFromCache($sourceCache, $sourcePath, $this->getSourcePath($targetPath)); } + #[\Override] public function getQueryFilterForStorage(): ISearchOperator { return $this->addJailFilterQuery($this->getCache()->getQueryFilterForStorage()); } @@ -320,6 +339,7 @@ class CacheJail extends CacheWrapper { } } + #[\Override] public function getCacheEntryFromSearchResult(ICacheEntry $rawEntry): ?ICacheEntry { if ($this->getGetUnjailedRoot() === '' || str_starts_with($rawEntry->getPath(), $this->getGetUnjailedRoot())) { $rawEntry = $this->getCache()->getCacheEntryFromSearchResult($rawEntry); diff --git a/lib/private/Files/Cache/Wrapper/CachePermissionsMask.php b/lib/private/Files/Cache/Wrapper/CachePermissionsMask.php index 905b418cdf4..56e661b3c02 100644 --- a/lib/private/Files/Cache/Wrapper/CachePermissionsMask.php +++ b/lib/private/Files/Cache/Wrapper/CachePermissionsMask.php @@ -19,6 +19,7 @@ class CachePermissionsMask extends CacheWrapper { parent::__construct($cache); } + #[\Override] protected function formatCacheEntry($entry) { if (isset($entry['permissions'])) { $entry['scan_permissions'] ??= $entry['permissions']; diff --git a/lib/private/Files/Cache/Wrapper/CacheWrapper.php b/lib/private/Files/Cache/Wrapper/CacheWrapper.php index 38becfeefce..c08a703a08a 100644 --- a/lib/private/Files/Cache/Wrapper/CacheWrapper.php +++ b/lib/private/Files/Cache/Wrapper/CacheWrapper.php @@ -41,6 +41,7 @@ class CacheWrapper extends Cache { return $this->cache; } + #[\Override] protected function hasEncryptionWrapper(): bool { $cache = $this->getCache(); if ($cache instanceof Cache) { @@ -50,6 +51,7 @@ class CacheWrapper extends Cache { } } + #[\Override] protected function shouldEncrypt(string $targetPath): bool { $cache = $this->getCache(); if ($cache instanceof Cache) { @@ -75,6 +77,7 @@ class CacheWrapper extends Cache { * @param string|int $file * @return ICacheEntry|false */ + #[\Override] public function get($file) { $result = $this->getCache()->get($file); if ($result instanceof ICacheEntry) { @@ -89,6 +92,7 @@ class CacheWrapper extends Cache { * @param string $folder * @return ICacheEntry[] */ + #[\Override] public function getFolderContents(string $folder, ?string $mimeTypeFilter = null): array { // can't do a simple $this->getCache()->.... call here since getFolderContentsById needs to be called on this // and not the wrapped cache @@ -102,6 +106,7 @@ class CacheWrapper extends Cache { * @param int $fileId the file id of the folder * @return ICacheEntry[] */ + #[\Override] public function getFolderContentsById(int $fileId, ?string $mimeTypeFilter = null) { $results = $this->getCache()->getFolderContentsById($fileId, $mimeTypeFilter); return array_filter(array_map($this->formatCacheEntry(...), $results)); @@ -116,6 +121,7 @@ class CacheWrapper extends Cache { * @return int file id * @throws \RuntimeException */ + #[\Override] public function put($file, array $data) { if (($id = $this->getId($file)) > -1) { $this->update($id, $data); @@ -134,6 +140,7 @@ class CacheWrapper extends Cache { * @return int file id * @throws \RuntimeException */ + #[\Override] public function insert($file, array $data) { return $this->getCache()->insert($file, $data); } @@ -144,6 +151,7 @@ class CacheWrapper extends Cache { * @param int $id * @param array $data */ + #[\Override] public function update($id, array $data) { $this->getCache()->update($id, $data); } @@ -154,6 +162,7 @@ class CacheWrapper extends Cache { * @param string $file * @return int */ + #[\Override] public function getId($file) { return $this->getCache()->getId($file); } @@ -164,6 +173,7 @@ class CacheWrapper extends Cache { * @param string $file * @return int */ + #[\Override] public function getParentId($file) { return $this->getCache()->getParentId($file); } @@ -174,6 +184,7 @@ class CacheWrapper extends Cache { * @param string $file * @return bool */ + #[\Override] public function inCache($file) { return $this->getCache()->inCache($file); } @@ -183,6 +194,7 @@ class CacheWrapper extends Cache { * * @param string $file */ + #[\Override] public function remove($file) { $this->getCache()->remove($file); } @@ -193,16 +205,19 @@ class CacheWrapper extends Cache { * @param string $source * @param string $target */ + #[\Override] public function move($source, $target) { $this->getCache()->move($source, $target); } + #[\Override] protected function getMoveInfo($path) { /** @var Cache|CacheJail $cache */ $cache = $this->getCache(); return $cache->getMoveInfo($path); } + #[\Override] public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) { $this->getCache()->moveFromCache($sourceCache, $sourcePath, $targetPath); } @@ -210,6 +225,7 @@ class CacheWrapper extends Cache { /** * remove all entries for files that are stored on the storage from the cache */ + #[\Override] public function clear() { $cache = $this->getCache(); if ($cache instanceof Cache) { @@ -224,10 +240,12 @@ class CacheWrapper extends Cache { * * @return int Cache::NOT_FOUND, Cache::PARTIAL, Cache::SHALLOW or Cache::COMPLETE */ + #[\Override] public function getStatus($file) { return $this->getCache()->getStatus($file); } + #[\Override] public function searchQuery(ISearchQuery $query) { return current($this->querySearchHelper->searchInCaches($query, [$this])); } @@ -237,6 +255,7 @@ class CacheWrapper extends Cache { * * @param array|ICacheEntry|null $data (optional) meta data of the folder */ + #[\Override] public function correctFolderSize(string $path, $data = null, bool $isBackgroundScan = false): void { $cache = $this->getCache(); if ($cache instanceof Cache) { @@ -251,6 +270,7 @@ class CacheWrapper extends Cache { * @param array|null|ICacheEntry $entry (optional) meta data of the folder * @return int|float */ + #[\Override] public function calculateFolderSize($path, $entry = null) { $cache = $this->getCache(); if ($cache instanceof Cache) { @@ -265,6 +285,7 @@ class CacheWrapper extends Cache { * * @return int[] */ + #[\Override] public function getAll() { /** @var Cache $cache */ $cache = $this->getCache(); @@ -280,6 +301,7 @@ class CacheWrapper extends Cache { * * @return string|false the path of the folder or false when no folder matched */ + #[\Override] public function getIncomplete() { return $this->getCache()->getIncomplete(); } @@ -290,6 +312,7 @@ class CacheWrapper extends Cache { * @param int $id * @return string|null */ + #[\Override] public function getPathById($id) { return $this->getCache()->getPathById($id); } @@ -299,6 +322,7 @@ class CacheWrapper extends Cache { * * @return int */ + #[\Override] public function getNumericStorageId() { return $this->getCache()->getNumericStorageId(); } @@ -311,14 +335,17 @@ class CacheWrapper extends Cache { * @param int $id * @return array first element holding the storage id, second the path */ + #[\Override] public static function getById($id) { return parent::getById($id); } + #[\Override] public function getQueryFilterForStorage(): ISearchOperator { return $this->getCache()->getQueryFilterForStorage(); } + #[\Override] public function getCacheEntryFromSearchResult(ICacheEntry $rawEntry): ?ICacheEntry { $rawEntry = $this->getCache()->getCacheEntryFromSearchResult($rawEntry); if ($rawEntry) { diff --git a/lib/private/Files/Cache/Wrapper/JailWatcher.php b/lib/private/Files/Cache/Wrapper/JailWatcher.php index 18a1c22495c..d066d069d15 100644 --- a/lib/private/Files/Cache/Wrapper/JailWatcher.php +++ b/lib/private/Files/Cache/Wrapper/JailWatcher.php @@ -28,31 +28,38 @@ class JailWatcher extends Watcher { } } + #[\Override] public function setPolicy($policy) { $this->watcher->setPolicy($policy); } + #[\Override] public function getPolicy() { return $this->watcher->getPolicy(); } + #[\Override] public function checkUpdate($path, $cachedEntry = null) { return $this->watcher->checkUpdate($this->getSourcePath($path), $cachedEntry); } + #[\Override] public function update($path, $cachedData) { $this->watcher->update($this->getSourcePath($path), $cachedData); } + #[\Override] public function needsUpdate($path, $cachedData) { return $this->watcher->needsUpdate($this->getSourcePath($path), $cachedData); } + #[\Override] public function cleanFolder($path) { $this->watcher->cleanFolder($this->getSourcePath($path)); } + #[\Override] public function onUpdate(callable $callback): void { $this->watcher->onUpdate($callback); } diff --git a/lib/private/Files/Config/CachedMountFileInfo.php b/lib/private/Files/Config/CachedMountFileInfo.php index ae27b1e762d..29636e5c665 100644 --- a/lib/private/Files/Config/CachedMountFileInfo.php +++ b/lib/private/Files/Config/CachedMountFileInfo.php @@ -25,6 +25,7 @@ class CachedMountFileInfo extends CachedMountInfo implements ICachedMountFileInf parent::__construct($user, $storageId, $rootId, $mountPoint, $mountProvider, $mountId, $rootInternalPath); } + #[\Override] public function getInternalPath(): string { if ($this->getRootInternalPath()) { return substr($this->internalPath, strlen($this->getRootInternalPath()) + 1); @@ -33,6 +34,7 @@ class CachedMountFileInfo extends CachedMountInfo implements ICachedMountFileInf } } + #[\Override] public function getPath(): string { return $this->getMountPoint() . $this->getInternalPath(); } diff --git a/lib/private/Files/Config/CachedMountInfo.php b/lib/private/Files/Config/CachedMountInfo.php index 7d67f38421e..ffe06c25b16 100644 --- a/lib/private/Files/Config/CachedMountInfo.php +++ b/lib/private/Files/Config/CachedMountInfo.php @@ -30,6 +30,7 @@ class CachedMountInfo implements ICachedMountInfo { $this->key = $this->rootId . '::' . $this->mountPoint; } + #[\Override] public function getUser(): IUser { return $this->user; } @@ -37,6 +38,7 @@ class CachedMountInfo implements ICachedMountInfo { /** * @return int the numeric storage id of the mount */ + #[\Override] public function getStorageId(): int { return $this->storageId; } @@ -44,6 +46,7 @@ class CachedMountInfo implements ICachedMountInfo { /** * @return int the fileid of the root of the mount */ + #[\Override] public function getRootId(): int { return $this->rootId; } @@ -51,6 +54,7 @@ class CachedMountInfo implements ICachedMountInfo { /** * @return Node|null the root node of the mount */ + #[\Override] public function getMountPointNode(): ?Node { // TODO injection etc Filesystem::initMountPoints($this->getUser()->getUID()); @@ -61,6 +65,7 @@ class CachedMountInfo implements ICachedMountInfo { /** * @return string the mount point of the mount for the user */ + #[\Override] public function getMountPoint(): string { return $this->mountPoint; } @@ -71,6 +76,7 @@ class CachedMountInfo implements ICachedMountInfo { * @return int|null mount id or null if not applicable * @since 9.1.0 */ + #[\Override] public function getMountId(): ?int { return $this->mountId; } @@ -80,14 +86,17 @@ class CachedMountInfo implements ICachedMountInfo { * * @return string */ + #[\Override] public function getRootInternalPath(): string { return $this->rootInternalPath; } + #[\Override] public function getMountProvider(): string { return $this->mountProvider; } + #[\Override] public function getKey(): string { return $this->key; } diff --git a/lib/private/Files/Config/LazyPathCachedMountInfo.php b/lib/private/Files/Config/LazyPathCachedMountInfo.php index d2396109b1a..699f3e4bd55 100644 --- a/lib/private/Files/Config/LazyPathCachedMountInfo.php +++ b/lib/private/Files/Config/LazyPathCachedMountInfo.php @@ -39,6 +39,7 @@ class LazyPathCachedMountInfo extends CachedMountInfo { $this->rootInternalPathCallback = $rootInternalPathCallback; } + #[\Override] public function getRootInternalPath(): string { if ($this->rootInternalPath === self::PATH_PLACEHOLDER) { $this->rootInternalPath = ($this->rootInternalPathCallback)($this); diff --git a/lib/private/Files/Config/LazyStorageMountInfo.php b/lib/private/Files/Config/LazyStorageMountInfo.php index 186e354aa34..8c992f7a162 100644 --- a/lib/private/Files/Config/LazyStorageMountInfo.php +++ b/lib/private/Files/Config/LazyStorageMountInfo.php @@ -22,6 +22,7 @@ class LazyStorageMountInfo extends CachedMountInfo { /** * @return int the numeric storage id of the mount */ + #[\Override] public function getStorageId(): int { if (!$this->storageId) { $this->storageId = $this->mount->getNumericStorageId(); @@ -32,6 +33,7 @@ class LazyStorageMountInfo extends CachedMountInfo { /** * @return int the fileid of the root of the mount */ + #[\Override] public function getRootId(): int { if (!$this->rootId) { $this->rootId = $this->mount->getStorageRootId(); @@ -42,6 +44,7 @@ class LazyStorageMountInfo extends CachedMountInfo { /** * @return string the mount point of the mount for the user */ + #[\Override] public function getMountPoint(): string { if (!$this->mountPoint) { $this->mountPoint = $this->mount->getMountPoint(); @@ -49,6 +52,7 @@ class LazyStorageMountInfo extends CachedMountInfo { return parent::getMountPoint(); } + #[\Override] public function getMountId(): ?int { return $this->mount->getMountId(); } @@ -58,14 +62,17 @@ class LazyStorageMountInfo extends CachedMountInfo { * * @return string */ + #[\Override] public function getRootInternalPath(): string { return $this->mount->getInternalPath($this->mount->getMountPoint()); } + #[\Override] public function getMountProvider(): string { return $this->mount->getMountProvider(); } + #[\Override] public function getKey(): string { if (!$this->key) { $this->key = $this->getRootId() . '::' . $this->getMountPoint(); diff --git a/lib/private/Files/Config/MountProviderCollection.php b/lib/private/Files/Config/MountProviderCollection.php index 338c26350ea..d6a33e675b3 100644 --- a/lib/private/Files/Config/MountProviderCollection.php +++ b/lib/private/Files/Config/MountProviderCollection.php @@ -79,6 +79,7 @@ class MountProviderCollection implements IMountProviderCollection, Emitter { /** * @return list */ + #[\Override] public function getMountsForUser(IUser $user): array { return $this->getUserMountsForProviders($user, array_values($this->providers)); } @@ -138,6 +139,7 @@ class MountProviderCollection implements IMountProviderCollection, Emitter { * * @return list */ + #[\Override] public function getUserMountsForProviderClasses(IUser $user, array $mountProviderClasses): array { $providers = array_filter( $this->providers, @@ -196,6 +198,7 @@ class MountProviderCollection implements IMountProviderCollection, Emitter { * * @since 9.1.0 */ + #[\Override] public function getHomeMountForUser(IUser $user): IMountPoint { $providers = array_reverse($this->homeProviders); // call the latest registered provider first to give apps an opportunity to overwrite builtin foreach ($providers as $homeProvider) { @@ -210,12 +213,14 @@ class MountProviderCollection implements IMountProviderCollection, Emitter { /** * Add a provider for mount points */ + #[\Override] public function registerProvider(IMountProvider $provider): void { $this->providers[get_class($provider)] = $provider; $this->emit('\OC\Files\Config', 'registerMountProvider', [$provider]); } + #[\Override] public function registerMountFilter(callable $filter): void { $this->mountFilters[] = $filter; } @@ -241,6 +246,7 @@ class MountProviderCollection implements IMountProviderCollection, Emitter { * @param IHomeMountProvider $provider * @since 9.1.0 */ + #[\Override] public function registerHomeProvider(IHomeMountProvider $provider) { $this->homeProviders[] = $provider; $this->emit('\OC\Files\Config', 'registerHomeMountProvider', [$provider]); @@ -249,6 +255,7 @@ class MountProviderCollection implements IMountProviderCollection, Emitter { /** * Get the mount cache which can be used to search for mounts without setting up the filesystem */ + #[\Override] public function getMountCache(): IUserMountCache { return $this->mountCache; } @@ -263,6 +270,7 @@ class MountProviderCollection implements IMountProviderCollection, Emitter { * @return list * @since 20.0.0 */ + #[\Override] public function getRootMounts(): array { $loader = $this->loader; $mounts = array_map(function (IRootMountProvider $provider) use ($loader) { diff --git a/lib/private/Files/Config/UserMountCache.php b/lib/private/Files/Config/UserMountCache.php index 5e0653b1c63..c2a1d88ef12 100644 --- a/lib/private/Files/Config/UserMountCache.php +++ b/lib/private/Files/Config/UserMountCache.php @@ -62,6 +62,7 @@ class UserMountCache implements IUserMountCache { $this->mountsForUsers = new CappedMemoryCache(); } + #[\Override] public function registerMounts(IUser $user, array $mounts, ?array $mountProviderClasses = null) { $this->eventLogger->start('fs:setup:user:register', 'Registering mounts for user'); /** @var array $newMounts */ @@ -249,6 +250,7 @@ class UserMountCache implements IUserMountCache { * @param IUser $user * @return ICachedMountInfo[] */ + #[\Override] public function getMountsForUser(IUser $user) { $userUID = $user->getUID(); if (!$this->userManager->userExists($userUID)) { @@ -294,6 +296,7 @@ class UserMountCache implements IUserMountCache { * @param string|null $user limit the results to a single user * @return CachedMountInfo[] */ + #[\Override] public function getMountsForStorageId($numericStorageId, $user = null) { $builder = $this->connection->getQueryBuilder(); $query = $builder->select('storage_id', 'root_id', 'user_id', 'mount_point', 'mount_id', 'f.path', 'mount_provider_class') @@ -316,6 +319,7 @@ class UserMountCache implements IUserMountCache { * @param int $rootFileId * @return CachedMountInfo[] */ + #[\Override] public function getMountsForRootId($rootFileId) { $builder = $this->connection->getQueryBuilder(); $query = $builder->select('storage_id', 'root_id', 'user_id', 'mount_point', 'mount_id', 'f.path', 'mount_provider_class') @@ -365,6 +369,7 @@ class UserMountCache implements IUserMountCache { * @return ICachedMountFileInfo[] * @since 9.0.0 */ + #[\Override] public function getMountsForFileId($fileId, $user = null) { try { [$storageId, $internalPath] = $this->getCacheInfoFromFileId($fileId); @@ -427,6 +432,7 @@ class UserMountCache implements IUserMountCache { * * @param IUser $user */ + #[\Override] public function removeUserMounts(IUser $user) { $builder = $this->connection->getQueryBuilder(); @@ -435,6 +441,7 @@ class UserMountCache implements IUserMountCache { $query->executeStatement(); } + #[\Override] public function removeUserStorageMount($storageId, $userId) { $builder = $this->connection->getQueryBuilder(); @@ -444,6 +451,7 @@ class UserMountCache implements IUserMountCache { $query->executeStatement(); } + #[\Override] public function remoteStorageMounts($storageId) { $builder = $this->connection->getQueryBuilder(); @@ -456,6 +464,7 @@ class UserMountCache implements IUserMountCache { * @param array $users * @return array */ + #[\Override] public function getUsedSpaceForUsers(array $users) { $builder = $this->connection->getQueryBuilder(); @@ -482,11 +491,13 @@ class UserMountCache implements IUserMountCache { return $results; } + #[\Override] public function clear(): void { $this->cacheInfoCache = new CappedMemoryCache(); $this->mountsForUsers = new CappedMemoryCache(); } + #[\Override] public function getMountForPath(IUser $user, string $path): ICachedMountInfo { $searchPaths = []; $current = rtrim($path, '/'); @@ -533,6 +544,7 @@ class UserMountCache implements IUserMountCache { throw new NotFoundException('No cached mount for path ' . $path); } + #[\Override] public function getMountsInPath(IUser $user, string $path): array { $path = rtrim($path, '/') . '/'; $result = []; @@ -545,6 +557,7 @@ class UserMountCache implements IUserMountCache { return $result; } + #[\Override] public function removeMount(string $mountPoint, ?IUser $user = null): void { $query = $this->connection->getQueryBuilder(); $query->delete('mounts') @@ -561,6 +574,7 @@ class UserMountCache implements IUserMountCache { } } + #[\Override] public function addMount( IUser $user, string $mountPoint, @@ -599,6 +613,7 @@ class UserMountCache implements IUserMountCache { $this->mountsForUsers = new CappedMemoryCache(); } + #[\Override] public function getMountAtPath(IUser $user, string $mountPoint): ?ICachedMountInfo { if (isset($this->mountsForUsers[$user->getUID()])) { foreach ($this->mountsForUsers[$user->getUID()] as $mount) { diff --git a/lib/private/Files/Conversion/ConversionManager.php b/lib/private/Files/Conversion/ConversionManager.php index 2c98a4c6404..24a4b8cb635 100644 --- a/lib/private/Files/Conversion/ConversionManager.php +++ b/lib/private/Files/Conversion/ConversionManager.php @@ -53,11 +53,13 @@ class ConversionManager implements IConversionManager { $this->l10n = $l10nFactory->get('files'); } + #[\Override] public function hasProviders(): bool { $context = $this->coordinator->getRegistrationContext(); return !empty($context->getFileConversionProviders()); } + #[\Override] public function getProviders(): array { $providers = []; foreach ($this->getRegisteredProviders() as $provider) { @@ -66,6 +68,7 @@ class ConversionManager implements IConversionManager { return $providers; } + #[\Override] public function convert(File $file, string $targetMimeType, ?string $destination = null): string { if (!$this->hasProviders()) { throw new PreConditionNotMetException($this->l10n->t('No file conversion providers available')); diff --git a/lib/private/Files/FileInfo.php b/lib/private/Files/FileInfo.php index 81e56345e3b..65280b0f315 100644 --- a/lib/private/Files/FileInfo.php +++ b/lib/private/Files/FileInfo.php @@ -65,6 +65,7 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess { } } + #[\Override] public function offsetSet($offset, $value): void { if (is_null($offset)) { throw new \TypeError('Null offset not supported'); @@ -72,14 +73,17 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess { $this->data[$offset] = $value; } + #[\Override] public function offsetExists($offset): bool { return isset($this->data[$offset]); } + #[\Override] public function offsetUnset($offset): void { unset($this->data[$offset]); } + #[\Override] public function offsetGet(mixed $offset): mixed { return match ($offset) { 'path' => $this->getPath(), @@ -95,10 +99,12 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess { /** * @return string */ + #[\Override] public function getPath() { return $this->path; } + #[\Override] public function getStorage() { return $this->storage; } @@ -106,6 +112,7 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess { /** * @return string */ + #[\Override] public function getInternalPath() { return $this->internalPath; } @@ -115,10 +122,12 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess { * * @return int|null */ + #[\Override] public function getId() { return isset($this->data['fileid']) ? (int)$this->data['fileid'] : null; } + #[\Override] public function getMimetype(): string { return $this->data['mimetype'] ?? 'application/octet-stream'; } @@ -126,6 +135,7 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess { /** * @return string */ + #[\Override] public function getMimePart() { return $this->data['mimepart']; } @@ -133,6 +143,7 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess { /** * @return string */ + #[\Override] public function getName() { return empty($this->data['name']) ? basename($this->getPath()) @@ -142,6 +153,7 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess { /** * @return string */ + #[\Override] public function getEtag() { $this->updateEntryFromSubMounts(); if (count($this->childEtags) > 0) { @@ -156,6 +168,7 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess { * @param bool $includeMounts * @return int|float */ + #[\Override] public function getSize($includeMounts = true) { if ($includeMounts) { $this->updateEntryFromSubMounts(); @@ -173,6 +186,7 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess { /** * @return int */ + #[\Override] public function getMTime() { $this->updateEntryFromSubMounts(); return (int)$this->data['mtime']; @@ -181,6 +195,7 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess { /** * @return bool */ + #[\Override] public function isEncrypted() { return $this->data['encrypted'] ?? false; } @@ -195,6 +210,7 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess { /** * @return int */ + #[\Override] public function getPermissions() { return (int)$this->data['permissions']; } @@ -202,6 +218,7 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess { /** * @return string \OCP\Files\FileInfo::TYPE_FILE|\OCP\Files\FileInfo::TYPE_FOLDER */ + #[\Override] public function getType() { if (!isset($this->data['type'])) { $this->data['type'] = ($this->getMimetype() === self::MIMETYPE_FOLDER) ? self::TYPE_FOLDER : self::TYPE_FILE; @@ -209,6 +226,7 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess { return $this->data['type']; } + #[\Override] public function getData(): ICacheEntry { if ($this->data instanceof ICacheEntry) { return $this->data; @@ -228,6 +246,7 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess { /** * @return bool */ + #[\Override] public function isReadable() { return $this->checkPermissions(Constants::PERMISSION_READ); } @@ -235,6 +254,7 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess { /** * @return bool */ + #[\Override] public function isUpdateable() { return $this->checkPermissions(Constants::PERMISSION_UPDATE); } @@ -244,6 +264,7 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess { * * @return bool */ + #[\Override] public function isCreatable() { return $this->checkPermissions(Constants::PERMISSION_CREATE); } @@ -251,6 +272,7 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess { /** * @return bool */ + #[\Override] public function isDeletable() { return $this->checkPermissions(Constants::PERMISSION_DELETE); } @@ -258,6 +280,7 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess { /** * @return bool */ + #[\Override] public function isShareable() { return $this->checkPermissions(Constants::PERMISSION_SHARE); } @@ -267,10 +290,12 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess { * * @return bool */ + #[\Override] public function isShared() { return $this->mount instanceof ISharedMountPoint; } + #[\Override] public function isMounted() { $isHome = $this->mount instanceof HomeMountPoint; return !$isHome && !$this->isShared(); @@ -281,6 +306,7 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess { * * @return \OCP\Files\Mount\IMountPoint */ + #[\Override] public function getMountPoint() { return $this->mount; } @@ -290,6 +316,7 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess { * * @return ?IUser */ + #[\Override] public function getOwner() { return $this->owner; } @@ -353,26 +380,32 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess { /** * @inheritdoc */ + #[\Override] public function getChecksum() { return $this->data['checksum']; } + #[\Override] public function getExtension(): string { return pathinfo($this->getName(), PATHINFO_EXTENSION); } + #[\Override] public function getCreationTime(): int { return (int)$this->data['creation_time']; } + #[\Override] public function getUploadTime(): int { return (int)$this->data['upload_time']; } + #[\Override] public function getLastActivity(): int { return max($this->getUploadTime(), $this->getMTime()); } + #[\Override] public function getParentId(): int { return $this->data['parent'] ?? -1; } @@ -381,6 +414,7 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess { * @inheritDoc * @return array */ + #[\Override] public function getMetadata(): array { return $this->data['metadata'] ?? []; } diff --git a/lib/private/Files/FilenameValidator.php b/lib/private/Files/FilenameValidator.php index 987575292d7..1610b09da22 100644 --- a/lib/private/Files/FilenameValidator.php +++ b/lib/private/Files/FilenameValidator.php @@ -157,6 +157,7 @@ class FilenameValidator implements IFilenameValidator { /** * @inheritdoc */ + #[\Override] public function isFilenameValid(string $filename): bool { try { $this->validateFilename($filename); @@ -169,6 +170,7 @@ class FilenameValidator implements IFilenameValidator { /** * @inheritdoc */ + #[\Override] public function validateFilename(string $filename): void { $trimmed = trim($filename); if ($trimmed === '') { @@ -229,6 +231,7 @@ class FilenameValidator implements IFilenameValidator { return false; } + #[\Override] public function sanitizeFilename(string $name, ?string $charReplacement = null): string { $forbiddenCharacters = $this->getForbiddenCharacters(); diff --git a/lib/private/Files/Lock/LockManager.php b/lib/private/Files/Lock/LockManager.php index 4c7e1427d02..ae2613fc9dd 100644 --- a/lib/private/Files/Lock/LockManager.php +++ b/lib/private/Files/Lock/LockManager.php @@ -20,6 +20,7 @@ class LockManager implements ILockManager { private ?ILockProvider $lockProvider = null; private ?LockContext $lockInScope = null; + #[\Override] public function registerLockProvider(ILockProvider $lockProvider): void { if ($this->lockProvider) { throw new PreConditionNotMetException('There is already a registered lock provider'); @@ -28,6 +29,7 @@ class LockManager implements ILockManager { $this->lockProvider = $lockProvider; } + #[\Override] public function registerLazyLockProvider(string $lockProviderClass): void { if ($this->lockProviderClass || $this->lockProvider) { throw new PreConditionNotMetException('There is already a registered lock provider'); @@ -50,10 +52,12 @@ class LockManager implements ILockManager { return $this->lockProvider; } + #[\Override] public function isLockProviderAvailable(): bool { return $this->getLockProvider() !== null; } + #[\Override] public function runInScope(LockContext $lock, callable $callback): void { if (!$this->getLockProvider()) { $callback(); @@ -72,10 +76,12 @@ class LockManager implements ILockManager { } } + #[\Override] public function getLockInScope(): ?LockContext { return $this->lockInScope; } + #[\Override] public function getLocks(int $fileId): array { if (!$this->getLockProvider()) { throw new PreConditionNotMetException('No lock provider available'); @@ -84,6 +90,7 @@ class LockManager implements ILockManager { return $this->getLockProvider()->getLocks($fileId); } + #[\Override] public function lock(LockContext $lockInfo): ILock { if (!$this->getLockProvider()) { throw new PreConditionNotMetException('No lock provider available'); @@ -92,6 +99,7 @@ class LockManager implements ILockManager { return $this->getLockProvider()->lock($lockInfo); } + #[\Override] public function unlock(LockContext $lockInfo): void { if (!$this->getLockProvider()) { throw new PreConditionNotMetException('No lock provider available'); diff --git a/lib/private/Files/Mount/LocalHomeMountProvider.php b/lib/private/Files/Mount/LocalHomeMountProvider.php index 92b44eac151..0b867436300 100644 --- a/lib/private/Files/Mount/LocalHomeMountProvider.php +++ b/lib/private/Files/Mount/LocalHomeMountProvider.php @@ -25,6 +25,7 @@ class LocalHomeMountProvider implements IHomeMountProvider { * @param IStorageFactory $loader * @return IMountPoint|null */ + #[\Override] public function getHomeMountForUser(IUser $user, IStorageFactory $loader) { $arguments = ['user' => $user]; return new HomeMountPoint($user, '\OC\Files\Storage\Home', '/' . $user->getUID(), $arguments, $loader, null, null, self::class); diff --git a/lib/private/Files/Mount/Manager.php b/lib/private/Files/Mount/Manager.php index 9a29752229d..3ec0fa5d125 100644 --- a/lib/private/Files/Mount/Manager.php +++ b/lib/private/Files/Mount/Manager.php @@ -36,6 +36,7 @@ class Manager implements IMountManager { $this->setupManager = $setupManagerFactory->create($this); } + #[\Override] public function addMount(IMountPoint $mount): void { $mountPoint = $mount->getMountPoint(); $mountProvider = $mount->getMountProvider(); @@ -47,6 +48,7 @@ class Manager implements IMountManager { $this->areMountsSorted = false; } + #[\Override] public function removeMount(string $mountPoint): void { $mountPoint = Filesystem::normalizePath($mountPoint); if (\strlen($mountPoint) > 1) { @@ -58,6 +60,7 @@ class Manager implements IMountManager { $this->areMountsSorted = false; } + #[\Override] public function moveMount(string $mountPoint, string $target): void { if ($mountPoint !== $target) { $this->mounts[$target] = $this->mounts[$mountPoint]; @@ -72,6 +75,7 @@ class Manager implements IMountManager { /** * Find the mount for $path */ + #[\Override] public function find(string $path): IMountPoint { $this->setupManager->setupForPath($path); $path = Filesystem::normalizePath($path); @@ -111,6 +115,7 @@ class Manager implements IMountManager { * * @return IMountPoint[] */ + #[\Override] public function findIn(string $path): array { $this->setupManager->setupForPath($path, true); $path = $this->formatPath($path); @@ -173,6 +178,7 @@ class Manager implements IMountManager { return $result; } + #[\Override] public function clear(): void { $this->mounts = []; $this->mountsByProvider = []; @@ -186,6 +192,7 @@ class Manager implements IMountManager { * @param string $id * @return IMountPoint[] */ + #[\Override] public function findByStorageId(string $id): array { if (\strlen($id) > 64) { $id = md5($id); @@ -202,6 +209,7 @@ class Manager implements IMountManager { /** * @return IMountPoint[] */ + #[\Override] public function getAll(): array { return $this->mounts; } @@ -212,6 +220,7 @@ class Manager implements IMountManager { * @param int $id * @return IMountPoint[] */ + #[\Override] public function findByNumericId(int $id): array { $result = []; foreach ($this->mounts as $mount) { @@ -266,6 +275,7 @@ class Manager implements IMountManager { * * @return IMountPoint|null */ + #[\Override] public function getMountFromMountInfo(ICachedMountInfo $info): ?IMountPoint { $this->setupManager->setupForPath($info->getMountPoint()); foreach ($this->mounts as $mount) { diff --git a/lib/private/Files/Mount/MountPoint.php b/lib/private/Files/Mount/MountPoint.php index 3538a1386c5..96009d58d09 100644 --- a/lib/private/Files/Mount/MountPoint.php +++ b/lib/private/Files/Mount/MountPoint.php @@ -99,6 +99,7 @@ class MountPoint implements IMountPoint { * * @return string */ + #[\Override] public function getMountPoint() { return $this->mountPoint; } @@ -108,6 +109,7 @@ class MountPoint implements IMountPoint { * * @param string $mountPoint new mount point */ + #[\Override] public function setMountPoint($mountPoint) { $this->mountPoint = $this->formatPath($mountPoint); } @@ -147,6 +149,7 @@ class MountPoint implements IMountPoint { /** * @return IStorage|null */ + #[\Override] public function getStorage() { if (is_null($this->storage)) { $this->createStorage(); @@ -157,6 +160,7 @@ class MountPoint implements IMountPoint { /** * @return string|null */ + #[\Override] public function getStorageId() { if (!$this->storageId) { $storage = $this->getStorage(); @@ -174,6 +178,7 @@ class MountPoint implements IMountPoint { /** * @return int */ + #[\Override] public function getNumericStorageId() { if (is_null($this->numericStorageId)) { $storage = $this->getStorage(); @@ -189,6 +194,7 @@ class MountPoint implements IMountPoint { * @param string $path * @return string */ + #[\Override] public function getInternalPath($path) { $path = Filesystem::normalizePath($path, true, false, true); if ($this->mountPoint === $path || $this->mountPoint . '/' === $path) { @@ -215,6 +221,7 @@ class MountPoint implements IMountPoint { /** * @param callable $wrapper */ + #[\Override] public function wrapStorage($wrapper) { $storage = $this->getStorage(); // storage can be null if it couldn't be initialized @@ -230,6 +237,7 @@ class MountPoint implements IMountPoint { * @param mixed $default Default value for the mount option * @return mixed */ + #[\Override] public function getOption($name, $default) { return $this->mountOptions[$name] ?? $default; } @@ -239,6 +247,7 @@ class MountPoint implements IMountPoint { * * @return array */ + #[\Override] public function getOptions() { return $this->mountOptions; } @@ -248,6 +257,7 @@ class MountPoint implements IMountPoint { * * @return int */ + #[\Override] public function getStorageRootId() { if (is_null($this->rootId) || $this->rootId === -1) { $storage = $this->getStorage(); @@ -261,14 +271,17 @@ class MountPoint implements IMountPoint { return $this->rootId; } + #[\Override] public function getMountId() { return $this->mountId; } + #[\Override] public function getMountType() { return ''; } + #[\Override] public function getMountProvider(): string { return $this->mountProvider; } diff --git a/lib/private/Files/Mount/ObjectHomeMountProvider.php b/lib/private/Files/Mount/ObjectHomeMountProvider.php index 4b088f2c808..574a5594f87 100644 --- a/lib/private/Files/Mount/ObjectHomeMountProvider.php +++ b/lib/private/Files/Mount/ObjectHomeMountProvider.php @@ -30,6 +30,7 @@ class ObjectHomeMountProvider implements IHomeMountProvider { * @param IStorageFactory $loader * @return ?IMountPoint */ + #[\Override] public function getHomeMountForUser(IUser $user, IStorageFactory $loader): ?IMountPoint { $objectStoreConfig = $this->objectStoreConfig->getObjectStoreConfigForUser($user); if ($objectStoreConfig === null) { diff --git a/lib/private/Files/Mount/RootMountProvider.php b/lib/private/Files/Mount/RootMountProvider.php index a1ab474ba28..83d0ebef0a0 100644 --- a/lib/private/Files/Mount/RootMountProvider.php +++ b/lib/private/Files/Mount/RootMountProvider.php @@ -23,6 +23,7 @@ class RootMountProvider implements IRootMountProvider { ) { } + #[\Override] public function getRootMounts(IStorageFactory $loader): array { $objectStoreConfig = $this->objectStoreConfig->getObjectStoreConfigForRoot(); diff --git a/lib/private/Files/Node/File.php b/lib/private/Files/Node/File.php index 4e8aad1cfb1..de22ccc9f75 100644 --- a/lib/private/Files/Node/File.php +++ b/lib/private/Files/Node/File.php @@ -19,6 +19,7 @@ class File extends Node implements \OCP\Files\File { * @param string $path path * @return NonExistingFile non-existing node */ + #[\Override] protected function createNonExistingNode($path) { return new NonExistingFile($this->root, $this->view, $path); } @@ -29,6 +30,7 @@ class File extends Node implements \OCP\Files\File { * @throws GenericFileException * @throws LockedException */ + #[\Override] public function getContent() { if ($this->checkPermissions(Constants::PERMISSION_READ)) { $content = $this->view->file_get_contents($this->path); @@ -47,6 +49,7 @@ class File extends Node implements \OCP\Files\File { * @throws GenericFileException * @throws LockedException */ + #[\Override] public function putContent($data) { if ($this->checkPermissions(Constants::PERMISSION_UPDATE)) { $this->sendHooks(['preWrite']); @@ -66,6 +69,7 @@ class File extends Node implements \OCP\Files\File { * @throws NotPermittedException * @throws LockedException */ + #[\Override] public function fopen($mode) { $preHooks = []; $postHooks = []; @@ -106,6 +110,7 @@ class File extends Node implements \OCP\Files\File { * @throws \OCP\Files\InvalidPathException * @throws \OCP\Files\NotFoundException */ + #[\Override] public function delete() { if ($this->checkPermissions(Constants::PERMISSION_DELETE)) { $this->sendHooks(['preDelete']); @@ -124,6 +129,7 @@ class File extends Node implements \OCP\Files\File { * @param bool $raw * @return string */ + #[\Override] public function hash($type, $raw = false) { return $this->view->hash($type, $this->path, $raw); } @@ -131,10 +137,12 @@ class File extends Node implements \OCP\Files\File { /** * @inheritdoc */ + #[\Override] public function getChecksum() { return $this->getFileInfo()->getChecksum(); } + #[\Override] public function getExtension(): string { return $this->getFileInfo()->getExtension(); } diff --git a/lib/private/Files/Node/Folder.php b/lib/private/Files/Node/Folder.php index f103a34c9e9..37de7abfbe5 100644 --- a/lib/private/Files/Node/Folder.php +++ b/lib/private/Files/Node/Folder.php @@ -44,6 +44,7 @@ class Folder extends Node implements IFolder { * @param string $path path * @return NonExistingFolder non-existing node */ + #[\Override] protected function createNonExistingNode($path) { return new NonExistingFolder($this->root, $this->view, $path); } @@ -53,6 +54,7 @@ class Folder extends Node implements IFolder { * @return string * @throws \OCP\Files\NotPermittedException */ + #[\Override] public function getFullPath($path) { $path = $this->normalizePath($path); if (!$this->isValidPath($path)) { @@ -65,6 +67,7 @@ class Folder extends Node implements IFolder { * @param string $path * @return string|null */ + #[\Override] public function getRelativePath($path) { return PathHelper::getRelativePath($this->getPath(), $path); } @@ -75,6 +78,7 @@ class Folder extends Node implements IFolder { * @param \OC\Files\Node\Node $node * @return bool */ + #[\Override] public function isSubNode($node) { return str_starts_with($node->getPath(), $this->path . '/'); } @@ -106,10 +110,12 @@ class Folder extends Node implements IFolder { } } + #[\Override] public function get($path) { return $this->root->get($this->getFullPath($path)); } + #[\Override] public function nodeExists($path) { try { $this->get($path); @@ -124,6 +130,7 @@ class Folder extends Node implements IFolder { * @return \OC\Files\Node\Folder * @throws \OCP\Files\NotPermittedException */ + #[\Override] public function newFolder($path) { if ($this->checkPermissions(Constants::PERMISSION_CREATE)) { $fullPath = $this->getFullPath($path); @@ -160,6 +167,7 @@ class Folder extends Node implements IFolder { * @return File * @throws \OCP\Files\NotPermittedException */ + #[\Override] public function newFile($path, $content = null) { if ($path === '') { throw new NotPermittedException('Could not create as provided path is empty'); @@ -202,6 +210,7 @@ class Folder extends Node implements IFolder { * @param string|ISearchQuery $query * @return \OC\Files\Node\Node[] */ + #[\Override] public function search($query) { if (is_string($query)) { $query = $this->queryFromOperator(new SearchComparison(ISearchComparison::COMPARE_LIKE, 'name', '%' . $query . '%')); @@ -284,6 +293,7 @@ class Folder extends Node implements IFolder { * @param string $mimetype * @return Node[] */ + #[\Override] public function searchByMime($mimetype) { if (!str_contains($mimetype, '/')) { $query = $this->queryFromOperator(new SearchComparison(ISearchComparison::COMPARE_LIKE, 'mimetype', $mimetype . '/%')); @@ -300,11 +310,13 @@ class Folder extends Node implements IFolder { * @param string $userId owner of the tags * @return Node[] */ + #[\Override] public function searchByTag($tag, $userId) { $query = $this->queryFromOperator(new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'tagname', $tag), $userId); return $this->search($query); } + #[\Override] public function searchBySystemTag(string $tagName, string $userId, int $limit = 0, int $offset = 0): array { $query = $this->queryFromOperator(new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'systemtag', $tagName), $userId, $limit, $offset); return $this->search($query); @@ -314,10 +326,12 @@ class Folder extends Node implements IFolder { * @param int $id * @return \OCP\Files\Node[] */ + #[\Override] public function getById($id) { return $this->root->getByIdInPath((int)$id, $this->getPath()); } + #[\Override] public function getFirstNodeById(int $id): ?INode { return $this->root->getFirstNodeByIdInPath($id, $this->getPath()); } @@ -370,10 +384,12 @@ class Folder extends Node implements IFolder { ))]; } + #[\Override] public function getFreeSpace() { return $this->view->free_space($this->path); } + #[\Override] public function delete() { if ($this->checkPermissions(Constants::PERMISSION_DELETE)) { $this->sendHooks(['preDelete']); @@ -394,6 +410,7 @@ class Folder extends Node implements IFolder { * @return string * @throws NotPermittedException */ + #[\Override] public function getNonExistingName($filename) { $path = $this->getPath(); if ($path === '/') { @@ -441,6 +458,7 @@ class Folder extends Node implements IFolder { * @param int $offset * @return INode[] */ + #[\Override] public function getRecent($limit, $offset = 0) { $filterOutNonEmptyFolder = new SearchBinaryOperator( // filter out non empty folders @@ -504,6 +522,7 @@ class Folder extends Node implements IFolder { return $this->search($query); } + #[\Override] public function verifyPath($fileName, $readonly = false): void { $this->view->verifyPath( $this->getPath(), diff --git a/lib/private/Files/Node/LazyFolder.php b/lib/private/Files/Node/LazyFolder.php index 1bc663f76b6..cd67de7c33a 100644 --- a/lib/private/Files/Node/LazyFolder.php +++ b/lib/private/Files/Node/LazyFolder.php @@ -136,6 +136,7 @@ class LazyFolder implements Folder { $this->__call(__FUNCTION__, func_get_args()); } + #[\Override] public function get($path) { return $this->getRootFolder()->get($this->getFullPath($path)); } @@ -155,6 +156,7 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function delete() { return $this->__call(__FUNCTION__, func_get_args()); } @@ -162,6 +164,7 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function copy($targetPath) { return $this->__call(__FUNCTION__, func_get_args()); } @@ -169,6 +172,7 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function touch($mtime = null) { $this->__call(__FUNCTION__, func_get_args()); } @@ -176,6 +180,7 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function getStorage() { return $this->__call(__FUNCTION__, func_get_args()); } @@ -183,6 +188,7 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function getPath() { if (isset($this->data['path'])) { return $this->data['path']; @@ -193,6 +199,7 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function getInternalPath() { return $this->__call(__FUNCTION__, func_get_args()); } @@ -200,6 +207,7 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function getId() { if (isset($this->data['fileid'])) { return $this->data['fileid']; @@ -210,6 +218,7 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function stat() { return $this->__call(__FUNCTION__, func_get_args()); } @@ -217,6 +226,7 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function getMTime() { if (isset($this->data['mtime'])) { return $this->data['mtime']; @@ -227,6 +237,7 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function getSize($includeMounts = true): int|float { if (isset($this->data['size'])) { return $this->data['size']; @@ -237,6 +248,7 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function getEtag() { if (isset($this->data['etag'])) { return $this->data['etag']; @@ -247,6 +259,7 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function getPermissions() { if (isset($this->data['permissions'])) { return $this->data['permissions']; @@ -257,6 +270,7 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function isReadable() { if (isset($this->data['permissions'])) { return ($this->data['permissions'] & Constants::PERMISSION_READ) === Constants::PERMISSION_READ; @@ -267,6 +281,7 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function isUpdateable() { if (isset($this->data['permissions'])) { return ($this->data['permissions'] & Constants::PERMISSION_UPDATE) === Constants::PERMISSION_UPDATE; @@ -277,6 +292,7 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function isDeletable() { if (isset($this->data['permissions'])) { return ($this->data['permissions'] & Constants::PERMISSION_DELETE) === Constants::PERMISSION_DELETE; @@ -287,6 +303,7 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function isShareable() { if (isset($this->data['permissions'])) { return ($this->data['permissions'] & Constants::PERMISSION_SHARE) === Constants::PERMISSION_SHARE; @@ -297,6 +314,7 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function getParent() { return $this->__call(__FUNCTION__, func_get_args()); } @@ -304,6 +322,7 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function getName() { if (isset($this->data['path'])) { return basename($this->data['path']); @@ -321,6 +340,7 @@ class LazyFolder implements Folder { return $this->__call(__FUNCTION__, func_get_args()); } + #[\Override] public function getMimetype(): string { if (isset($this->data['mimetype'])) { return $this->data['mimetype']; @@ -331,6 +351,7 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function getMimePart() { if (isset($this->data['mimetype'])) { [$part,] = explode('/', $this->data['mimetype']); @@ -342,6 +363,7 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function isEncrypted() { return $this->__call(__FUNCTION__, func_get_args()); } @@ -349,6 +371,7 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function getType() { if (isset($this->data['type'])) { return $this->data['type']; @@ -359,6 +382,7 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function isShared() { return $this->__call(__FUNCTION__, func_get_args()); } @@ -366,6 +390,7 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function isMounted() { return $this->__call(__FUNCTION__, func_get_args()); } @@ -373,6 +398,7 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function getMountPoint() { return $this->__call(__FUNCTION__, func_get_args()); } @@ -380,6 +406,7 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function getOwner() { return $this->__call(__FUNCTION__, func_get_args()); } @@ -387,10 +414,12 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function getChecksum() { return $this->__call(__FUNCTION__, func_get_args()); } + #[\Override] public function getExtension(): string { return $this->__call(__FUNCTION__, func_get_args()); } @@ -398,6 +427,7 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function getFullPath($path) { if (isset($this->data['path'])) { $path = PathHelper::normalizePath($path); @@ -412,6 +442,7 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function isSubNode($node) { return $this->__call(__FUNCTION__, func_get_args()); } @@ -421,6 +452,7 @@ class LazyFolder implements Folder { return $this->__call(__FUNCTION__, func_get_args()); } + #[\Override] public function nodeExists($path) { return $this->__call(__FUNCTION__, func_get_args()); } @@ -428,6 +460,7 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function newFolder($path) { return $this->__call(__FUNCTION__, func_get_args()); } @@ -435,6 +468,7 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function newFile($path, $content = null) { return $this->__call(__FUNCTION__, func_get_args()); } @@ -442,6 +476,7 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function search($query) { return $this->__call(__FUNCTION__, func_get_args()); } @@ -449,6 +484,7 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function searchByMime($mimetype) { return $this->__call(__FUNCTION__, func_get_args()); } @@ -456,10 +492,12 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function searchByTag($tag, $userId) { return $this->__call(__FUNCTION__, func_get_args()); } + #[\Override] public function searchBySystemTag(string $tagName, string $userId, int $limit = 0, int $offset = 0) { return $this->__call(__FUNCTION__, func_get_args()); } @@ -467,10 +505,12 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function getById($id) { return $this->getRootFolder()->getByIdInPath((int)$id, $this->getPath()); } + #[\Override] public function getFirstNodeById(int $id): ?Node { return $this->getRootFolder()->getFirstNodeByIdInPath($id, $this->getPath()); } @@ -478,6 +518,7 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function getFreeSpace() { return $this->__call(__FUNCTION__, func_get_args()); } @@ -485,6 +526,7 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function isCreatable() { return $this->__call(__FUNCTION__, func_get_args()); } @@ -492,6 +534,7 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function getNonExistingName($filename) { return $this->__call(__FUNCTION__, func_get_args()); } @@ -499,6 +542,7 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function move($targetPath) { return $this->__call(__FUNCTION__, func_get_args()); } @@ -506,6 +550,7 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function lock($type) { return $this->__call(__FUNCTION__, func_get_args()); } @@ -513,6 +558,7 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function changeLock($targetType) { return $this->__call(__FUNCTION__, func_get_args()); } @@ -520,6 +566,7 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function unlock($type) { return $this->__call(__FUNCTION__, func_get_args()); } @@ -527,6 +574,7 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function getRecent($limit, $offset = 0) { return $this->__call(__FUNCTION__, func_get_args()); } @@ -534,6 +582,7 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function getCreationTime(): int { return $this->__call(__FUNCTION__, func_get_args()); } @@ -541,6 +590,7 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function getUploadTime(): int { return $this->__call(__FUNCTION__, func_get_args()); } @@ -548,14 +598,17 @@ class LazyFolder implements Folder { /** * @inheritDoc */ + #[\Override] public function getLastActivity(): int { return $this->__call(__FUNCTION__, func_get_args()); } + #[\Override] public function getRelativePath($path) { return PathHelper::getRelativePath($this->getPath(), $path); } + #[\Override] public function getParentId(): int { if (isset($this->data['parent'])) { return $this->data['parent']; @@ -567,14 +620,17 @@ class LazyFolder implements Folder { * @inheritDoc * @return array */ + #[\Override] public function getMetadata(): array { return $this->data['metadata'] ?? $this->__call(__FUNCTION__, func_get_args()); } + #[\Override] public function getData(): ICacheEntry { return $this->__call(__FUNCTION__, func_get_args()); } + #[\Override] public function verifyPath($fileName, $readonly = false): void { $this->__call(__FUNCTION__, func_get_args()); } diff --git a/lib/private/Files/Node/LazyRoot.php b/lib/private/Files/Node/LazyRoot.php index 8920a2f68f6..cf1cd90245b 100644 --- a/lib/private/Files/Node/LazyRoot.php +++ b/lib/private/Files/Node/LazyRoot.php @@ -25,6 +25,7 @@ class LazyRoot extends LazyFolder implements IRootFolder { parent::__construct($this, $folderClosure, $data); } + #[\Override] protected function getRootFolder(): IRootFolder { $folder = $this->getRealFolder(); if (!$folder instanceof IRootFolder) { @@ -33,22 +34,27 @@ class LazyRoot extends LazyFolder implements IRootFolder { return $folder; } + #[\Override] public function getUserFolder($userId) { return $this->__call(__FUNCTION__, func_get_args()); } + #[\Override] public function getByIdInPath(int $id, string $path) { return $this->__call(__FUNCTION__, func_get_args()); } + #[\Override] public function getFirstNodeByIdInPath(int $id, string $path): ?INode { return $this->__call(__FUNCTION__, func_get_args()); } + #[\Override] public function getNodeFromCacheEntryAndMount(ICacheEntry $cacheEntry, IMountPoint $mountPoint): INode { return $this->getRootFolder()->getNodeFromCacheEntryAndMount($cacheEntry, $mountPoint); } + #[\Override] public function getAppDataDirectoryName(): string { return $this->__call(__FUNCTION__, func_get_args()); } diff --git a/lib/private/Files/Node/LazyUserFolder.php b/lib/private/Files/Node/LazyUserFolder.php index a75dd24391a..496d2be81a7 100644 --- a/lib/private/Files/Node/LazyUserFolder.php +++ b/lib/private/Files/Node/LazyUserFolder.php @@ -66,6 +66,7 @@ class LazyUserFolder extends LazyFolder { ); } + #[\Override] public function getMountPoint() { if ($this->folder !== null) { return $this->folder->getMountPoint(); diff --git a/lib/private/Files/Node/Node.php b/lib/private/Files/Node/Node.php index 72050e97872..63e275d1f47 100644 --- a/lib/private/Files/Node/Node.php +++ b/lib/private/Files/Node/Node.php @@ -126,6 +126,7 @@ class Node implements INode { return ($this->getPermissions() & $permissions) === $permissions; } + #[\Override] public function delete() { } @@ -135,6 +136,7 @@ class Node implements INode { * @throws NotFoundException * @throws NotPermittedException */ + #[\Override] public function touch($mtime = null) { if ($this->checkPermissions(Constants::PERMISSION_UPDATE)) { $this->sendHooks(['preTouch']); @@ -151,6 +153,7 @@ class Node implements INode { } } + #[\Override] public function getStorage() { $storage = $this->getMountPoint()->getStorage(); if (!$storage) { @@ -162,6 +165,7 @@ class Node implements INode { /** * @return string */ + #[\Override] public function getPath() { return $this->path; } @@ -169,6 +173,7 @@ class Node implements INode { /** * @return string */ + #[\Override] public function getInternalPath() { return $this->getFileInfo(false)->getInternalPath(); } @@ -178,6 +183,7 @@ class Node implements INode { * @throws InvalidPathException * @throws NotFoundException */ + #[\Override] public function getId() { return $this->getFileInfo(false)->getId() ?? -1; } @@ -185,6 +191,7 @@ class Node implements INode { /** * @return array */ + #[\Override] public function stat() { return $this->view->stat($this->path); } @@ -194,6 +201,7 @@ class Node implements INode { * @throws InvalidPathException * @throws NotFoundException */ + #[\Override] public function getMTime() { return $this->getFileInfo()->getMTime(); } @@ -204,6 +212,7 @@ class Node implements INode { * @throws InvalidPathException * @throws NotFoundException */ + #[\Override] public function getSize($includeMounts = true): int|float { return $this->getFileInfo()->getSize($includeMounts); } @@ -213,6 +222,7 @@ class Node implements INode { * @throws InvalidPathException * @throws NotFoundException */ + #[\Override] public function getEtag() { return $this->getFileInfo()->getEtag(); } @@ -222,6 +232,7 @@ class Node implements INode { * @throws InvalidPathException * @throws NotFoundException */ + #[\Override] public function getPermissions() { return $this->getFileInfo(false)->getPermissions(); } @@ -231,6 +242,7 @@ class Node implements INode { * @throws InvalidPathException * @throws NotFoundException */ + #[\Override] public function isReadable() { return $this->getFileInfo(false)->isReadable(); } @@ -240,6 +252,7 @@ class Node implements INode { * @throws InvalidPathException * @throws NotFoundException */ + #[\Override] public function isUpdateable() { return $this->getFileInfo(false)->isUpdateable(); } @@ -249,6 +262,7 @@ class Node implements INode { * @throws InvalidPathException * @throws NotFoundException */ + #[\Override] public function isDeletable() { return $this->getFileInfo(false)->isDeletable(); } @@ -258,6 +272,7 @@ class Node implements INode { * @throws InvalidPathException * @throws NotFoundException */ + #[\Override] public function isShareable() { return $this->getFileInfo(false)->isShareable(); } @@ -267,10 +282,12 @@ class Node implements INode { * @throws InvalidPathException * @throws NotFoundException */ + #[\Override] public function isCreatable() { return $this->getFileInfo(false)->isCreatable(); } + #[\Override] public function getParent(): INode|IRootFolder { if ($this->parent === null) { $newPath = dirname($this->path); @@ -305,6 +322,7 @@ class Node implements INode { /** * @return string */ + #[\Override] public function getName() { return basename($this->path); } @@ -327,41 +345,51 @@ class Node implements INode { return Filesystem::isValidPath($path); } + #[\Override] public function isMounted() { return $this->getFileInfo(false)->isMounted(); } + #[\Override] public function isShared() { return $this->getFileInfo(false)->isShared(); } + #[\Override] public function getMimeType(): string { return $this->getFileInfo(false)->getMimetype(); } + #[\Override] public function getMimePart() { return $this->getFileInfo(false)->getMimePart(); } + #[\Override] public function getType() { return $this->getFileInfo(false)->getType(); } + #[\Override] public function isEncrypted() { return $this->getFileInfo(false)->isEncrypted(); } + #[\Override] public function getMountPoint() { return $this->getFileInfo(false)->getMountPoint(); } + #[\Override] public function getOwner() { return $this->getFileInfo(false)->getOwner(); } + #[\Override] public function getChecksum() { } + #[\Override] public function getExtension(): string { return $this->getFileInfo(false)->getExtension(); } @@ -370,6 +398,7 @@ class Node implements INode { * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE * @throws LockedException */ + #[\Override] public function lock($type) { $this->view->lockFile($this->path, $type); } @@ -378,6 +407,7 @@ class Node implements INode { * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE * @throws LockedException */ + #[\Override] public function changeLock($type) { $this->view->changeLock($this->path, $type); } @@ -386,6 +416,7 @@ class Node implements INode { * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE * @throws LockedException */ + #[\Override] public function unlock($type) { $this->view->unlockFile($this->path, $type); } @@ -397,6 +428,7 @@ class Node implements INode { * @throws NotFoundException * @throws NotPermittedException if copy not allowed or failed */ + #[\Override] public function copy($targetPath) { $targetPath = $this->normalizePath($targetPath); $parent = $this->root->get(dirname($targetPath)); @@ -424,6 +456,7 @@ class Node implements INode { * @throws NotPermittedException if move not allowed or failed * @throws LockedException */ + #[\Override] public function move($targetPath) { $targetPath = $this->normalizePath($targetPath); $parent = $this->root->get(dirname($targetPath)); @@ -463,18 +496,22 @@ class Node implements INode { } } + #[\Override] public function getCreationTime(): int { return $this->getFileInfo()->getCreationTime(); } + #[\Override] public function getUploadTime(): int { return $this->getFileInfo()->getUploadTime(); } + #[\Override] public function getLastActivity(): int { return $this->getFileInfo()->getLastActivity(); } + #[\Override] public function getParentId(): int { return $this->fileInfo->getParentId(); } @@ -483,10 +520,12 @@ class Node implements INode { * @inheritDoc * @return array */ + #[\Override] public function getMetadata(): array { return $this->fileInfo->getMetadata(); } + #[\Override] public function getData(): ICacheEntry { return $this->fileInfo->getData(); } diff --git a/lib/private/Files/Node/NonExistingFile.php b/lib/private/Files/Node/NonExistingFile.php index 7fb375b941a..356ba5e4785 100644 --- a/lib/private/Files/Node/NonExistingFile.php +++ b/lib/private/Files/Node/NonExistingFile.php @@ -18,18 +18,22 @@ class NonExistingFile extends File { throw new NotFoundException(); } + #[\Override] public function delete() { throw new NotFoundException(); } + #[\Override] public function copy($targetPath) { throw new NotFoundException(); } + #[\Override] public function touch($mtime = null) { throw new NotFoundException(); } + #[\Override] public function getId() { if ($this->fileInfo) { return parent::getId(); @@ -38,6 +42,7 @@ class NonExistingFile extends File { } } + #[\Override] public function getInternalPath() { if ($this->fileInfo) { return parent::getInternalPath(); @@ -46,10 +51,12 @@ class NonExistingFile extends File { } } + #[\Override] public function stat() { throw new NotFoundException(); } + #[\Override] public function getMTime() { if ($this->fileInfo) { return parent::getMTime(); @@ -58,6 +65,7 @@ class NonExistingFile extends File { } } + #[\Override] public function getSize($includeMounts = true): int|float { if ($this->fileInfo) { return parent::getSize($includeMounts); @@ -66,6 +74,7 @@ class NonExistingFile extends File { } } + #[\Override] public function getEtag() { if ($this->fileInfo) { return parent::getEtag(); @@ -74,6 +83,7 @@ class NonExistingFile extends File { } } + #[\Override] public function getPermissions() { if ($this->fileInfo) { return parent::getPermissions(); @@ -82,6 +92,7 @@ class NonExistingFile extends File { } } + #[\Override] public function isReadable() { if ($this->fileInfo) { return parent::isReadable(); @@ -90,6 +101,7 @@ class NonExistingFile extends File { } } + #[\Override] public function isUpdateable() { if ($this->fileInfo) { return parent::isUpdateable(); @@ -98,6 +110,7 @@ class NonExistingFile extends File { } } + #[\Override] public function isDeletable() { if ($this->fileInfo) { return parent::isDeletable(); @@ -106,6 +119,7 @@ class NonExistingFile extends File { } } + #[\Override] public function isShareable() { if ($this->fileInfo) { return parent::isShareable(); @@ -114,14 +128,17 @@ class NonExistingFile extends File { } } + #[\Override] public function getContent() { throw new NotFoundException(); } + #[\Override] public function putContent($data) { throw new NotFoundException(); } + #[\Override] public function getMimeType(): string { if ($this->fileInfo) { return parent::getMimeType(); @@ -130,6 +147,7 @@ class NonExistingFile extends File { } } + #[\Override] public function fopen($mode) { throw new NotFoundException(); } diff --git a/lib/private/Files/Node/NonExistingFolder.php b/lib/private/Files/Node/NonExistingFolder.php index 9e6638376cd..487170c98fa 100644 --- a/lib/private/Files/Node/NonExistingFolder.php +++ b/lib/private/Files/Node/NonExistingFolder.php @@ -20,18 +20,22 @@ class NonExistingFolder extends Folder { throw new NotFoundException(); } + #[\Override] public function delete() { throw new NotFoundException(); } + #[\Override] public function copy($targetPath) { throw new NotFoundException(); } + #[\Override] public function touch($mtime = null) { throw new NotFoundException(); } + #[\Override] public function getId() { if ($this->fileInfo) { return parent::getId(); @@ -40,6 +44,7 @@ class NonExistingFolder extends Folder { } } + #[\Override] public function getInternalPath() { if ($this->fileInfo) { return parent::getInternalPath(); @@ -48,10 +53,12 @@ class NonExistingFolder extends Folder { } } + #[\Override] public function stat() { throw new NotFoundException(); } + #[\Override] public function getMTime() { if ($this->fileInfo) { return parent::getMTime(); @@ -60,6 +67,7 @@ class NonExistingFolder extends Folder { } } + #[\Override] public function getSize($includeMounts = true): int|float { if ($this->fileInfo) { return parent::getSize($includeMounts); @@ -68,6 +76,7 @@ class NonExistingFolder extends Folder { } } + #[\Override] public function getEtag() { if ($this->fileInfo) { return parent::getEtag(); @@ -76,6 +85,7 @@ class NonExistingFolder extends Folder { } } + #[\Override] public function getPermissions() { if ($this->fileInfo) { return parent::getPermissions(); @@ -84,6 +94,7 @@ class NonExistingFolder extends Folder { } } + #[\Override] public function isReadable() { if ($this->fileInfo) { return parent::isReadable(); @@ -92,6 +103,7 @@ class NonExistingFolder extends Folder { } } + #[\Override] public function isUpdateable() { if ($this->fileInfo) { return parent::isUpdateable(); @@ -100,6 +112,7 @@ class NonExistingFolder extends Folder { } } + #[\Override] public function isDeletable() { if ($this->fileInfo) { return parent::isDeletable(); @@ -108,6 +121,7 @@ class NonExistingFolder extends Folder { } } + #[\Override] public function isShareable() { if ($this->fileInfo) { return parent::isShareable(); @@ -116,6 +130,7 @@ class NonExistingFolder extends Folder { } } + #[\Override] public function get($path) { throw new NotFoundException(); } @@ -125,46 +140,57 @@ class NonExistingFolder extends Folder { throw new NotFoundException(); } + #[\Override] public function nodeExists($path) { return false; } + #[\Override] public function newFolder($path) { throw new NotFoundException(); } + #[\Override] public function newFile($path, $content = null) { throw new NotFoundException(); } + #[\Override] public function search($query) { throw new NotFoundException(); } + #[\Override] public function searchByMime($mimetype) { throw new NotFoundException(); } + #[\Override] public function searchByTag($tag, $userId) { throw new NotFoundException(); } + #[\Override] public function searchBySystemTag(string $tagName, string $userId, int $limit = 0, int $offset = 0): array { throw new NotFoundException(); } + #[\Override] public function getById($id) { throw new NotFoundException(); } + #[\Override] public function getFirstNodeById(int $id): ?Node { throw new NotFoundException(); } + #[\Override] public function getFreeSpace() { throw new NotFoundException(); } + #[\Override] public function isCreatable() { if ($this->fileInfo) { return parent::isCreatable(); diff --git a/lib/private/Files/Node/Root.php b/lib/private/Files/Node/Root.php index 0c121dc8b05..095db425ed6 100644 --- a/lib/private/Files/Node/Root.php +++ b/lib/private/Files/Node/Root.php @@ -97,6 +97,7 @@ class Root extends Folder implements IRootFolder { * @param string $method * @param callable $callback */ + #[\Override] public function listen($scope, $method, callable $callback) { $this->emitter->listen($scope, $method, $callback); } @@ -106,6 +107,7 @@ class Root extends Folder implements IRootFolder { * @param string $method optional * @param callable $callback optional */ + #[\Override] public function removeListener($scope = null, $method = null, ?callable $callback = null) { $this->emitter->removeListener($scope, $method, $callback); } @@ -129,6 +131,7 @@ class Root extends Folder implements IRootFolder { $this->mountManager->addMount($mount); } + #[\Override] public function getMount(string $mountPoint): IMountPoint { return $this->mountManager->find($mountPoint); } @@ -137,10 +140,12 @@ class Root extends Folder implements IRootFolder { * @param string $mountPoint * @return IMountPoint[] */ + #[\Override] public function getMountsIn(string $mountPoint): array { return $this->mountManager->findIn($mountPoint); } + #[\Override] public function get($path) { $path = $this->normalizePath($path); if ($this->isValidPath($path)) { @@ -167,6 +172,7 @@ class Root extends Folder implements IRootFolder { throw new NotPermittedException(); } + #[\Override] public function delete() { throw new NotPermittedException(); } @@ -176,6 +182,7 @@ class Root extends Folder implements IRootFolder { * @return Node * @throws \OCP\Files\NotPermittedException */ + #[\Override] public function copy($targetPath) { throw new NotPermittedException(); } @@ -184,6 +191,7 @@ class Root extends Folder implements IRootFolder { * @param int $mtime * @throws \OCP\Files\NotPermittedException */ + #[\Override] public function touch($mtime = null) { throw new NotPermittedException(); } @@ -192,6 +200,7 @@ class Root extends Folder implements IRootFolder { * @return Storage * @throws \OCP\Files\NotFoundException */ + #[\Override] public function getStorage() { throw new NotFoundException(); } @@ -199,6 +208,7 @@ class Root extends Folder implements IRootFolder { /** * @return string */ + #[\Override] public function getPath() { return '/'; } @@ -206,6 +216,7 @@ class Root extends Folder implements IRootFolder { /** * @return string */ + #[\Override] public function getInternalPath() { return ''; } @@ -213,6 +224,7 @@ class Root extends Folder implements IRootFolder { /** * @return int */ + #[\Override] public function getId() { return 0; } @@ -220,6 +232,7 @@ class Root extends Folder implements IRootFolder { /** * @return array */ + #[\Override] public function stat() { return []; } @@ -227,6 +240,7 @@ class Root extends Folder implements IRootFolder { /** * @return int */ + #[\Override] public function getMTime() { return 0; } @@ -235,6 +249,7 @@ class Root extends Folder implements IRootFolder { * @param bool $includeMounts * @return int|float */ + #[\Override] public function getSize($includeMounts = true): int|float { return 0; } @@ -242,6 +257,7 @@ class Root extends Folder implements IRootFolder { /** * @return string */ + #[\Override] public function getEtag() { return ''; } @@ -249,6 +265,7 @@ class Root extends Folder implements IRootFolder { /** * @return int */ + #[\Override] public function getPermissions() { return Constants::PERMISSION_CREATE; } @@ -256,6 +273,7 @@ class Root extends Folder implements IRootFolder { /** * @return bool */ + #[\Override] public function isReadable() { return false; } @@ -263,6 +281,7 @@ class Root extends Folder implements IRootFolder { /** * @return bool */ + #[\Override] public function isUpdateable() { return false; } @@ -270,6 +289,7 @@ class Root extends Folder implements IRootFolder { /** * @return bool */ + #[\Override] public function isDeletable() { return false; } @@ -277,6 +297,7 @@ class Root extends Folder implements IRootFolder { /** * @return bool */ + #[\Override] public function isShareable() { return false; } @@ -284,6 +305,7 @@ class Root extends Folder implements IRootFolder { /** * @throws \OCP\Files\NotFoundException */ + #[\Override] public function getParent(): INode|IRootFolder { throw new NotFoundException(); } @@ -291,6 +313,7 @@ class Root extends Folder implements IRootFolder { /** * @return string */ + #[\Override] public function getName() { return ''; } @@ -303,6 +326,7 @@ class Root extends Folder implements IRootFolder { * @throws NoUserException * @throws NotPermittedException */ + #[\Override] public function getUserFolder($userId) { $userObject = $this->userManager->get($userId); @@ -350,6 +374,7 @@ class Root extends Folder implements IRootFolder { return $this->userMountCache; } + #[\Override] public function getFirstNodeByIdInPath(int $id, string $path): ?INode { // scope the cache by user, so we don't return nodes for different users if ($this->user) { @@ -382,6 +407,7 @@ class Root extends Folder implements IRootFolder { /** * @return INode[] */ + #[\Override] public function getByIdInPath(int $id, string $path): array { $mountCache = $this->getUserMountCache(); $setupManager = $this->mountManager->getSetupManager(); @@ -492,6 +518,7 @@ class Root extends Folder implements IRootFolder { return $folders; } + #[\Override] public function getNodeFromCacheEntryAndMount(ICacheEntry $cacheEntry, IMountPoint $mountPoint): INode { $path = $cacheEntry->getPath(); $fullPath = $mountPoint->getMountPoint() . $path; diff --git a/lib/private/Files/Notify/Change.php b/lib/private/Files/Notify/Change.php index 445b978746a..422b39356e0 100644 --- a/lib/private/Files/Notify/Change.php +++ b/lib/private/Files/Notify/Change.php @@ -25,6 +25,7 @@ class Change implements IChange { * * @return IChange::ADDED|IChange::REMOVED|IChange::MODIFIED|IChange::RENAMED */ + #[\Override] public function getType(): int { return $this->type; } @@ -34,6 +35,7 @@ class Change implements IChange { * * Note, for rename changes this path is the old path for the file */ + #[\Override] public function getPath(): string { return $this->path; } diff --git a/lib/private/Files/Notify/RenameChange.php b/lib/private/Files/Notify/RenameChange.php index bb5c17d7cbc..d7dfde93118 100644 --- a/lib/private/Files/Notify/RenameChange.php +++ b/lib/private/Files/Notify/RenameChange.php @@ -26,6 +26,7 @@ class RenameChange extends Change implements IRenameChange { /** * Get the new path of the renamed file relative to the storage root */ + #[\Override] public function getTargetPath(): string { return $this->targetPath; } diff --git a/lib/private/Files/ObjectStore/AppdataPreviewObjectStoreStorage.php b/lib/private/Files/ObjectStore/AppdataPreviewObjectStoreStorage.php index aaaee044bac..090c81cfe62 100644 --- a/lib/private/Files/ObjectStore/AppdataPreviewObjectStoreStorage.php +++ b/lib/private/Files/ObjectStore/AppdataPreviewObjectStoreStorage.php @@ -23,6 +23,7 @@ class AppdataPreviewObjectStoreStorage extends ObjectStoreStorage { parent::__construct($parameters); } + #[\Override] public function getId(): string { return 'object::appdata::preview:' . $this->internalId; } diff --git a/lib/private/Files/ObjectStore/Azure.php b/lib/private/Files/ObjectStore/Azure.php index 4e7b0c51678..75add59f4ee 100644 --- a/lib/private/Files/ObjectStore/Azure.php +++ b/lib/private/Files/ObjectStore/Azure.php @@ -70,6 +70,7 @@ class Azure implements IObjectStore { /** * @return string the container or bucket name where objects are stored */ + #[\Override] public function getStorageId() { return 'azure::blob::' . $this->containerName; } @@ -79,11 +80,13 @@ class Azure implements IObjectStore { * @return resource stream with the read data * @throws \Exception when something goes wrong, message will be logged */ + #[\Override] public function readObject($urn) { $blob = $this->getBlobClient()->getBlob($this->containerName, $urn); return $blob->getContentStream(); } + #[\Override] public function writeObject($urn, $stream, ?string $mimetype = null) { $options = new CreateBlockBlobOptions(); if ($mimetype) { @@ -97,10 +100,12 @@ class Azure implements IObjectStore { * @return void * @throws \Exception when something goes wrong, message will be logged */ + #[\Override] public function deleteObject($urn) { $this->getBlobClient()->deleteBlob($this->containerName, $urn); } + #[\Override] public function objectExists($urn) { try { $this->getBlobClient()->getBlobMetadata($this->containerName, $urn); @@ -114,10 +119,12 @@ class Azure implements IObjectStore { } } + #[\Override] public function copyObject($from, $to) { $this->getBlobClient()->copyBlob($this->containerName, $to, $this->containerName, $from); } + #[\Override] public function preSignedUrl(string $urn, \DateTimeInterface $expiration): ?string { return null; } diff --git a/lib/private/Files/ObjectStore/HomeObjectStoreStorage.php b/lib/private/Files/ObjectStore/HomeObjectStoreStorage.php index 4e2d10705fe..d157f86f5ae 100644 --- a/lib/private/Files/ObjectStore/HomeObjectStoreStorage.php +++ b/lib/private/Files/ObjectStore/HomeObjectStoreStorage.php @@ -28,14 +28,17 @@ class HomeObjectStoreStorage extends ObjectStoreStorage implements IHomeStorage parent::__construct($parameters); } + #[\Override] public function getId(): string { return 'object::user:' . $this->user->getUID(); } + #[\Override] public function getOwner(string $path): string|false { return $this->user->getUID(); } + #[\Override] public function getUser(): IUser { return $this->user; } diff --git a/lib/private/Files/ObjectStore/ObjectStoreScanner.php b/lib/private/Files/ObjectStore/ObjectStoreScanner.php index a31947ec8ae..19ac35de3ce 100644 --- a/lib/private/Files/ObjectStore/ObjectStoreScanner.php +++ b/lib/private/Files/ObjectStore/ObjectStoreScanner.php @@ -12,18 +12,22 @@ use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\Files\FileInfo; class ObjectStoreScanner extends Scanner { + #[\Override] public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null, $lock = true, $data = null) { return null; } + #[\Override] public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $lock = true) { return null; } + #[\Override] protected function scanChildren(string $path, $recursive, int $reuse, int $folderId, bool $lock, int|float $oldSize, &$etagChanged = false) { return 0; } + #[\Override] public function backgroundScan() { $lastPath = null; // find any path marked as unscanned and run the scanner until no more paths are unscanned (or we get stuck) diff --git a/lib/private/Files/ObjectStore/ObjectStoreStorage.php b/lib/private/Files/ObjectStore/ObjectStoreStorage.php index 943e6d39ffb..bd69fa7926e 100644 --- a/lib/private/Files/ObjectStore/ObjectStoreStorage.php +++ b/lib/private/Files/ObjectStore/ObjectStoreStorage.php @@ -76,6 +76,7 @@ class ObjectStoreStorage extends Common implements IChunkedFileWrite { $this->logger = Server::get(LoggerInterface::class); } + #[\Override] public function mkdir(string $path, bool $force = false, array $metadata = []): bool { $path = $this->normalizePath($path); if (!$force && $this->file_exists($path)) { @@ -138,6 +139,7 @@ class ObjectStoreStorage extends Common implements IChunkedFileWrite { * Object Stores use a NoopScanner because metadata is directly stored in * the file cache and cannot really scan the filesystem. The storage passed in is not used anywhere. */ + #[\Override] public function getScanner(string $path = '', ?IStorage $storage = null): IScanner { if (!$storage) { $storage = $this; @@ -149,10 +151,12 @@ class ObjectStoreStorage extends Common implements IChunkedFileWrite { return $this->scanner; } + #[\Override] public function getId(): string { return $this->id; } + #[\Override] public function rmdir(string $path): bool { $path = $this->normalizePath($path); $entry = $this->getCache()->get($path); @@ -185,6 +189,7 @@ class ObjectStoreStorage extends Common implements IChunkedFileWrite { return true; } + #[\Override] public function unlink(string $path): bool { $path = $this->normalizePath($path); $entry = $this->getCache()->get($path); @@ -221,6 +226,7 @@ class ObjectStoreStorage extends Common implements IChunkedFileWrite { return true; } + #[\Override] public function stat(string $path): array|false { $path = $this->normalizePath($path); $cacheEntry = $this->getCache()->get($path); @@ -238,6 +244,7 @@ class ObjectStoreStorage extends Common implements IChunkedFileWrite { } } + #[\Override] public function getPermissions(string $path): int { $stat = $this->stat($path); @@ -259,6 +266,7 @@ class ObjectStoreStorage extends Common implements IChunkedFileWrite { return $this->objectPrefix . $fileId; } + #[\Override] public function opendir(string $path) { $path = $this->normalizePath($path); @@ -276,6 +284,7 @@ class ObjectStoreStorage extends Common implements IChunkedFileWrite { } } + #[\Override] public function filetype(string $path): string|false { $path = $this->normalizePath($path); $stat = $this->stat($path); @@ -289,6 +298,7 @@ class ObjectStoreStorage extends Common implements IChunkedFileWrite { } } + #[\Override] public function fopen(string $path, string $mode) { $path = $this->normalizePath($path); @@ -381,11 +391,13 @@ class ObjectStoreStorage extends Common implements IChunkedFileWrite { return false; } + #[\Override] public function file_exists(string $path): bool { $path = $this->normalizePath($path); return (bool)$this->stat($path); } + #[\Override] public function rename(string $source, string $target): bool { $source = $this->normalizePath($source); $target = $this->normalizePath($target); @@ -395,11 +407,13 @@ class ObjectStoreStorage extends Common implements IChunkedFileWrite { return true; } + #[\Override] public function getMimeType(string $path): string|false { $path = $this->normalizePath($path); return parent::getMimeType($path); } + #[\Override] public function touch(string $path, ?int $mtime = null): bool { if (is_null($mtime)) { $mtime = time(); @@ -441,14 +455,17 @@ class ObjectStoreStorage extends Common implements IChunkedFileWrite { $this->writeStream($path, fopen($tmpFile, 'r'), $size); } + #[\Override] public function hasUpdated(string $path, int $time): bool { return false; } + #[\Override] public function needsPartFile(): bool { return false; } + #[\Override] public function file_put_contents(string $path, mixed $data): int { $fh = fopen('php://temp', 'w+'); fwrite($fh, $data); @@ -456,6 +473,7 @@ class ObjectStoreStorage extends Common implements IChunkedFileWrite { return $this->writeStream($path, $fh, strlen($data)); } + #[\Override] public function writeStream(string $path, $stream, ?int $size = null): int { if ($size === null) { $stats = fstat($stream); @@ -575,6 +593,7 @@ class ObjectStoreStorage extends Common implements IChunkedFileWrite { return $this->objectStore; } + #[\Override] public function copyFromStorage( IStorage $sourceStorage, string $sourceInternalPath, @@ -601,6 +620,7 @@ class ObjectStoreStorage extends Common implements IChunkedFileWrite { return parent::copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); } + #[\Override] public function moveFromStorage(IStorage $sourceStorage, string $sourceInternalPath, string $targetInternalPath, ?ICacheEntry $sourceCacheEntry = null): bool { $sourceCache = $sourceStorage->getCache(); if ( @@ -684,6 +704,7 @@ class ObjectStoreStorage extends Common implements IChunkedFileWrite { } } + #[\Override] public function copy(string $source, string $target): bool { $source = $this->normalizePath($source); $target = $this->normalizePath($target); @@ -738,6 +759,7 @@ class ObjectStoreStorage extends Common implements IChunkedFileWrite { } } + #[\Override] public function startChunkedWrite(string $targetPath): string { if (!$this->objectStore instanceof IObjectStoreMultiPartUpload) { throw new GenericFileException('Object store does not support multipart upload'); @@ -750,6 +772,7 @@ class ObjectStoreStorage extends Common implements IChunkedFileWrite { /** * @throws GenericFileException */ + #[\Override] public function putChunkedWritePart( string $targetPath, string $writeToken, @@ -773,6 +796,7 @@ class ObjectStoreStorage extends Common implements IChunkedFileWrite { return $parts[$chunkId]; } + #[\Override] public function completeChunkedWrite(string $targetPath, string $writeToken): int { if (!$this->objectStore instanceof IObjectStoreMultiPartUpload) { throw new GenericFileException('Object store does not support multipart upload'); @@ -806,6 +830,7 @@ class ObjectStoreStorage extends Common implements IChunkedFileWrite { return $size; } + #[\Override] public function cancelChunkedWrite(string $targetPath, string $writeToken): void { if (!$this->objectStore instanceof IObjectStoreMultiPartUpload) { throw new GenericFileException('Object store does not support multipart upload'); @@ -819,6 +844,7 @@ class ObjectStoreStorage extends Common implements IChunkedFileWrite { $this->preserveCacheItemsOnDelete = $preserve; } + #[\Override] public function free_space(string $path): int|float|false { if ($this->totalSizeLimit === null) { return FileInfo::SPACE_UNLIMITED; diff --git a/lib/private/Files/ObjectStore/S3.php b/lib/private/Files/ObjectStore/S3.php index 80eee35f395..eeacfa3fca6 100644 --- a/lib/private/Files/ObjectStore/S3.php +++ b/lib/private/Files/ObjectStore/S3.php @@ -26,10 +26,12 @@ class S3 implements IObjectStore, IObjectStoreMultiPartUpload, IObjectStoreMetaD * @return string the container or bucket name where objects are stored * @since 7.0.0 */ + #[\Override] public function getStorageId() { return $this->id; } + #[\Override] public function initiateMultipartUpload(string $urn): string { $upload = $this->getConnection()->createMultipartUpload([ 'Bucket' => $this->bucket, @@ -42,6 +44,7 @@ class S3 implements IObjectStore, IObjectStoreMultiPartUpload, IObjectStoreMetaD return (string)$uploadId; } + #[\Override] public function uploadMultipartPart(string $urn, string $uploadId, int $partId, $stream, $size): Result { return $this->getConnection()->uploadPart([ 'Body' => $stream, @@ -53,6 +56,7 @@ class S3 implements IObjectStore, IObjectStoreMultiPartUpload, IObjectStoreMetaD ] + $this->getServerSideEncryptionParameters()); } + #[\Override] public function getMultipartUploads(string $urn, string $uploadId): array { $parts = []; $isTruncated = true; @@ -74,6 +78,7 @@ class S3 implements IObjectStore, IObjectStoreMultiPartUpload, IObjectStoreMetaD return $parts; } + #[\Override] public function completeMultipartUpload(string $urn, string $uploadId, array $result): int { $this->getConnection()->completeMultipartUpload([ 'Bucket' => $this->bucket, @@ -88,6 +93,7 @@ class S3 implements IObjectStore, IObjectStoreMultiPartUpload, IObjectStoreMetaD return (int)$stat->get('ContentLength'); } + #[\Override] public function abortMultipartUpload($urn, $uploadId): void { $this->getConnection()->abortMultipartUpload([ 'Bucket' => $this->bucket, @@ -109,6 +115,7 @@ class S3 implements IObjectStore, IObjectStoreMultiPartUpload, IObjectStoreMetaD return $result; } + #[\Override] public function getObjectMetaData(string $urn): array { $object = $this->getConnection()->headObject([ 'Bucket' => $this->bucket, @@ -121,6 +128,7 @@ class S3 implements IObjectStore, IObjectStoreMultiPartUpload, IObjectStoreMetaD ] + $this->parseS3Metadata($object['Metadata'] ?? []); } + #[\Override] public function listObjects(string $prefix = ''): \Iterator { $results = $this->getConnection()->getPaginator('ListObjectsV2', [ 'Bucket' => $this->bucket, diff --git a/lib/private/Files/ObjectStore/S3Signature.php b/lib/private/Files/ObjectStore/S3Signature.php index b80382ff67d..47b3cf8e7f5 100644 --- a/lib/private/Files/ObjectStore/S3Signature.php +++ b/lib/private/Files/ObjectStore/S3Signature.php @@ -40,6 +40,7 @@ class S3Signature implements SignatureInterface { sort($this->signableQueryString); } + #[\Override] public function signRequest( RequestInterface $request, CredentialsInterface $credentials, @@ -53,6 +54,7 @@ class S3Signature implements SignatureInterface { return $request->withHeader('Authorization', $auth); } + #[\Override] public function presign( RequestInterface $request, CredentialsInterface $credentials, diff --git a/lib/private/Files/ObjectStore/StorageObjectStore.php b/lib/private/Files/ObjectStore/StorageObjectStore.php index f170116a3a6..0e8b54a6843 100644 --- a/lib/private/Files/ObjectStore/StorageObjectStore.php +++ b/lib/private/Files/ObjectStore/StorageObjectStore.php @@ -23,6 +23,7 @@ class StorageObjectStore implements IObjectStore { * @return string the container or bucket name where objects are stored * @since 7.0.0 */ + #[\Override] public function getStorageId(): string { return $this->storage->getId(); } @@ -33,6 +34,7 @@ class StorageObjectStore implements IObjectStore { * @throws \Exception when something goes wrong, message will be logged * @since 7.0.0 */ + #[\Override] public function readObject($urn) { $handle = $this->storage->fopen($urn, 'r'); if (is_resource($handle)) { @@ -42,6 +44,7 @@ class StorageObjectStore implements IObjectStore { throw new \Exception(); } + #[\Override] public function writeObject($urn, $stream, ?string $mimetype = null) { $handle = $this->storage->fopen($urn, 'w'); if ($handle) { @@ -58,18 +61,22 @@ class StorageObjectStore implements IObjectStore { * @throws \Exception when something goes wrong, message will be logged * @since 7.0.0 */ + #[\Override] public function deleteObject($urn) { $this->storage->unlink($urn); } + #[\Override] public function objectExists($urn) { return $this->storage->file_exists($urn); } + #[\Override] public function copyObject($from, $to) { $this->storage->copy($from, $to); } + #[\Override] public function preSignedUrl(string $urn, \DateTimeInterface $expiration): ?string { return null; } diff --git a/lib/private/Files/ObjectStore/Swift.php b/lib/private/Files/ObjectStore/Swift.php index b1fb7e520db..288af35bbaf 100644 --- a/lib/private/Files/ObjectStore/Swift.php +++ b/lib/private/Files/ObjectStore/Swift.php @@ -52,6 +52,7 @@ class Swift implements IObjectStore { /** * @return string the container name where objects are stored */ + #[\Override] public function getStorageId() { if (isset($this->params['bucket'])) { return $this->params['bucket']; @@ -60,6 +61,7 @@ class Swift implements IObjectStore { return $this->params['container']; } + #[\Override] public function writeObject($urn, $stream, ?string $mimetype = null) { $tmpFile = Server::get(ITempManager::class)->getTemporaryFile('swiftwrite'); file_put_contents($tmpFile, $stream); @@ -87,6 +89,7 @@ class Swift implements IObjectStore { * @throws \Exception from openstack or GuzzleHttp libs when something goes wrong * @throws NotFoundException if file does not exist */ + #[\Override] public function readObject($urn) { try { $publicUri = $this->getContainer()->getObject($urn)->getPublicUri(); @@ -117,6 +120,7 @@ class Swift implements IObjectStore { * @return void * @throws \Exception from openstack lib when something goes wrong */ + #[\Override] public function deleteObject($urn) { $this->getContainer()->getObject($urn)->delete(); } @@ -129,15 +133,18 @@ class Swift implements IObjectStore { $this->getContainer()->delete(); } + #[\Override] public function objectExists($urn) { return $this->getContainer()->objectExists($urn); } + #[\Override] public function copyObject($from, $to) { $this->getContainer()->getObject($from)->copy([ 'destination' => $this->getContainer()->name . '/' . $to ]); } + #[\Override] public function preSignedUrl(string $urn, \DateTimeInterface $expiration): ?string { return null; } diff --git a/lib/private/Files/ObjectStore/SwiftV2CachingAuthService.php b/lib/private/Files/ObjectStore/SwiftV2CachingAuthService.php index 266781af142..7ffd728a922 100644 --- a/lib/private/Files/ObjectStore/SwiftV2CachingAuthService.php +++ b/lib/private/Files/ObjectStore/SwiftV2CachingAuthService.php @@ -12,6 +12,7 @@ use OpenStack\Common\Auth\Token; use OpenStack\Identity\v2\Service; class SwiftV2CachingAuthService extends Service { + #[\Override] public function authenticate(array $options = []): array { if (isset($options['v2cachedToken'], $options['v2serviceUrl']) && $options['v2cachedToken'] instanceof Token diff --git a/lib/private/Files/Search/QueryOptimizer/FlattenNestedBool.php b/lib/private/Files/Search/QueryOptimizer/FlattenNestedBool.php index bb7bef2ed63..b4f3258709f 100644 --- a/lib/private/Files/Search/QueryOptimizer/FlattenNestedBool.php +++ b/lib/private/Files/Search/QueryOptimizer/FlattenNestedBool.php @@ -11,6 +11,7 @@ use OCP\Files\Search\ISearchBinaryOperator; use OCP\Files\Search\ISearchOperator; class FlattenNestedBool extends QueryOptimizerStep { + #[\Override] public function processOperator(ISearchOperator &$operator) { if ( $operator instanceof SearchBinaryOperator && ( diff --git a/lib/private/Files/Search/QueryOptimizer/FlattenSingleArgumentBinaryOperation.php b/lib/private/Files/Search/QueryOptimizer/FlattenSingleArgumentBinaryOperation.php index 7e99c04f197..6c2e443f232 100644 --- a/lib/private/Files/Search/QueryOptimizer/FlattenSingleArgumentBinaryOperation.php +++ b/lib/private/Files/Search/QueryOptimizer/FlattenSingleArgumentBinaryOperation.php @@ -13,6 +13,7 @@ use OCP\Files\Search\ISearchOperator; * replace single argument AND and OR operations with their single argument */ class FlattenSingleArgumentBinaryOperation extends ReplacingOptimizerStep { + #[\Override] public function processOperator(ISearchOperator &$operator): bool { parent::processOperator($operator); if ( diff --git a/lib/private/Files/Search/QueryOptimizer/MergeDistributiveOperations.php b/lib/private/Files/Search/QueryOptimizer/MergeDistributiveOperations.php index 4949ca7396b..74ce9fea93a 100644 --- a/lib/private/Files/Search/QueryOptimizer/MergeDistributiveOperations.php +++ b/lib/private/Files/Search/QueryOptimizer/MergeDistributiveOperations.php @@ -21,6 +21,7 @@ use OCP\Files\Search\ISearchOperator; * [1]: https://en.wikipedia.org/wiki/Distributive_property */ class MergeDistributiveOperations extends ReplacingOptimizerStep { + #[\Override] public function processOperator(ISearchOperator &$operator): bool { if ($operator instanceof SearchBinaryOperator) { // either 'AND' or 'OR' diff --git a/lib/private/Files/Search/QueryOptimizer/OrEqualsToIn.php b/lib/private/Files/Search/QueryOptimizer/OrEqualsToIn.php index 6df35c9c9a2..6fbada1d5a1 100644 --- a/lib/private/Files/Search/QueryOptimizer/OrEqualsToIn.php +++ b/lib/private/Files/Search/QueryOptimizer/OrEqualsToIn.php @@ -16,6 +16,7 @@ use OCP\Files\Search\ISearchOperator; * transform (field == A OR field == B ...) into field IN (A, B, ...) */ class OrEqualsToIn extends ReplacingOptimizerStep { + #[\Override] public function processOperator(ISearchOperator &$operator): bool { if ( $operator instanceof ISearchBinaryOperator diff --git a/lib/private/Files/Search/QueryOptimizer/PathPrefixOptimizer.php b/lib/private/Files/Search/QueryOptimizer/PathPrefixOptimizer.php index 5e874aa159f..84022c2f71a 100644 --- a/lib/private/Files/Search/QueryOptimizer/PathPrefixOptimizer.php +++ b/lib/private/Files/Search/QueryOptimizer/PathPrefixOptimizer.php @@ -15,6 +15,7 @@ use OCP\Files\Search\ISearchOperator; class PathPrefixOptimizer extends QueryOptimizerStep { private bool $useHashEq = true; + #[\Override] public function inspectOperator(ISearchOperator $operator): void { // normally any `path = "$path"` search filter would be generated as an `path_hash = md5($path)` sql query // since the `path_hash` sql column usually provides much faster querying that selecting on the `path` sql column @@ -31,6 +32,7 @@ class PathPrefixOptimizer extends QueryOptimizerStep { parent::inspectOperator($operator); } + #[\Override] public function processOperator(ISearchOperator &$operator) { if (!$this->useHashEq && $operator instanceof ISearchComparison && !$operator->getExtra() && $operator->getField() === 'path' && $operator->getType() === ISearchComparison::COMPARE_EQUAL) { $operator->setQueryHint(ISearchComparison::HINT_PATH_EQ_HASH, false); diff --git a/lib/private/Files/Search/QueryOptimizer/ReplacingOptimizerStep.php b/lib/private/Files/Search/QueryOptimizer/ReplacingOptimizerStep.php index a9c9ba876bc..562ed4aa915 100644 --- a/lib/private/Files/Search/QueryOptimizer/ReplacingOptimizerStep.php +++ b/lib/private/Files/Search/QueryOptimizer/ReplacingOptimizerStep.php @@ -19,6 +19,7 @@ class ReplacingOptimizerStep extends QueryOptimizerStep { * * Returns true if the reference $operator points to a new value */ + #[\Override] public function processOperator(ISearchOperator &$operator): bool { if ($operator instanceof SearchBinaryOperator) { $modified = false; diff --git a/lib/private/Files/Search/QueryOptimizer/SplitLargeIn.php b/lib/private/Files/Search/QueryOptimizer/SplitLargeIn.php index 8aee1975708..660138f9d83 100644 --- a/lib/private/Files/Search/QueryOptimizer/SplitLargeIn.php +++ b/lib/private/Files/Search/QueryOptimizer/SplitLargeIn.php @@ -16,6 +16,7 @@ use OCP\Files\Search\ISearchOperator; * transform IN (1000+ element) into (IN (1000 elements) OR IN(...)) */ class SplitLargeIn extends ReplacingOptimizerStep { + #[\Override] public function processOperator(ISearchOperator &$operator): bool { if ( $operator instanceof ISearchComparison diff --git a/lib/private/Files/Search/SearchBinaryOperator.php b/lib/private/Files/Search/SearchBinaryOperator.php index ba8caa10cb8..95d222474d7 100644 --- a/lib/private/Files/Search/SearchBinaryOperator.php +++ b/lib/private/Files/Search/SearchBinaryOperator.php @@ -29,6 +29,7 @@ class SearchBinaryOperator implements ISearchBinaryOperator { /** * @return string */ + #[\Override] public function getType() { return $this->type; } @@ -36,6 +37,7 @@ class SearchBinaryOperator implements ISearchBinaryOperator { /** * @return ISearchOperator[] */ + #[\Override] public function getArguments() { return $this->arguments; } @@ -48,10 +50,12 @@ class SearchBinaryOperator implements ISearchBinaryOperator { $this->arguments = $arguments; } + #[\Override] public function getQueryHint(string $name, $default) { return $this->hints[$name] ?? $default; } + #[\Override] public function setQueryHint(string $name, $value): void { $this->hints[$name] = $value; } diff --git a/lib/private/Files/Search/SearchComparison.php b/lib/private/Files/Search/SearchComparison.php index c1f0176afd9..f3ebfa64858 100644 --- a/lib/private/Files/Search/SearchComparison.php +++ b/lib/private/Files/Search/SearchComparison.php @@ -27,6 +27,7 @@ class SearchComparison implements ISearchComparison { /** * @return string */ + #[\Override] public function getType(): string { return $this->type; } @@ -34,10 +35,12 @@ class SearchComparison implements ISearchComparison { /** * @return string */ + #[\Override] public function getField(): string { return $this->field; } + #[\Override] public function getValue(): string|int|bool|\DateTime|array { return $this->value; } @@ -46,14 +49,17 @@ class SearchComparison implements ISearchComparison { * @return string * @since 28.0.0 */ + #[\Override] public function getExtra(): string { return $this->extra; } + #[\Override] public function getQueryHint(string $name, $default) { return $this->hints[$name] ?? $default; } + #[\Override] public function setQueryHint(string $name, $value): void { $this->hints[$name] = $value; } diff --git a/lib/private/Files/Search/SearchOrder.php b/lib/private/Files/Search/SearchOrder.php index ce4a3211416..3c79e641512 100644 --- a/lib/private/Files/Search/SearchOrder.php +++ b/lib/private/Files/Search/SearchOrder.php @@ -22,6 +22,7 @@ class SearchOrder implements ISearchOrder { /** * @return string */ + #[\Override] public function getDirection(): string { return $this->direction; } @@ -29,6 +30,7 @@ class SearchOrder implements ISearchOrder { /** * @return string */ + #[\Override] public function getField(): string { return $this->field; } @@ -37,10 +39,12 @@ class SearchOrder implements ISearchOrder { * @return string * @since 28.0.0 */ + #[\Override] public function getExtra(): string { return $this->extra; } + #[\Override] public function sortFileInfo(FileInfo $a, FileInfo $b): int { $cmp = $this->sortFileInfoNoDirection($a, $b); return $cmp * ($this->direction === ISearchOrder::DIRECTION_ASCENDING ? 1 : -1); diff --git a/lib/private/Files/Search/SearchQuery.php b/lib/private/Files/Search/SearchQuery.php index 1c38c1ef162..ecefe02205a 100644 --- a/lib/private/Files/Search/SearchQuery.php +++ b/lib/private/Files/Search/SearchQuery.php @@ -27,14 +27,17 @@ class SearchQuery implements ISearchQuery { ) { } + #[\Override] public function getSearchOperation(): ISearchOperator { return $this->searchOperation; } + #[\Override] public function getLimit(): int { return $this->limit; } + #[\Override] public function getOffset(): int { return $this->offset; } @@ -42,14 +45,17 @@ class SearchQuery implements ISearchQuery { /** * @return ISearchOrder[] */ + #[\Override] public function getOrder(): array { return $this->order; } + #[\Override] public function getUser(): ?IUser { return $this->user; } + #[\Override] public function limitToHome(): bool { return $this->limitToHome; } diff --git a/lib/private/Files/SimpleFS/NewSimpleFile.php b/lib/private/Files/SimpleFS/NewSimpleFile.php index fbbe8a3902c..5f331e648d9 100644 --- a/lib/private/Files/SimpleFS/NewSimpleFile.php +++ b/lib/private/Files/SimpleFS/NewSimpleFile.php @@ -27,6 +27,7 @@ class NewSimpleFile implements ISimpleFile { /** * Get the name */ + #[\Override] public function getName(): string { return $this->name; } @@ -34,6 +35,7 @@ class NewSimpleFile implements ISimpleFile { /** * Get the size in bytes */ + #[\Override] public function getSize(): int|float { if ($this->file) { return $this->file->getSize(); @@ -45,6 +47,7 @@ class NewSimpleFile implements ISimpleFile { /** * Get the ETag */ + #[\Override] public function getETag(): string { if ($this->file) { return $this->file->getEtag(); @@ -56,6 +59,7 @@ class NewSimpleFile implements ISimpleFile { /** * Get the last modification time */ + #[\Override] public function getMTime(): int { if ($this->file) { return $this->file->getMTime(); @@ -70,6 +74,7 @@ class NewSimpleFile implements ISimpleFile { * @throws NotFoundException * @throws NotPermittedException */ + #[\Override] public function getContent(): string { if ($this->file) { $result = $this->file->getContent(); @@ -91,6 +96,7 @@ class NewSimpleFile implements ISimpleFile { * @throws NotPermittedException * @throws NotFoundException */ + #[\Override] public function putContent($data): void { try { if ($this->file) { @@ -141,6 +147,7 @@ class NewSimpleFile implements ISimpleFile { * * @throws NotPermittedException */ + #[\Override] public function delete(): void { if ($this->file) { $this->file->delete(); @@ -152,6 +159,7 @@ class NewSimpleFile implements ISimpleFile { * * @return string */ + #[\Override] public function getMimeType(): string { if ($this->file) { return $this->file->getMimeType(); @@ -163,6 +171,7 @@ class NewSimpleFile implements ISimpleFile { /** * {@inheritDoc} */ + #[\Override] public function getExtension(): string { if ($this->file) { return $this->file->getExtension(); @@ -178,6 +187,7 @@ class NewSimpleFile implements ISimpleFile { * @throws NotPermittedException * @since 14.0.0 */ + #[\Override] public function read() { if ($this->file) { return $this->file->fopen('r'); @@ -193,6 +203,7 @@ class NewSimpleFile implements ISimpleFile { * @throws NotPermittedException * @since 14.0.0 */ + #[\Override] public function write() { if ($this->file) { return $this->file->fopen('w'); diff --git a/lib/private/Files/SimpleFS/SimpleFile.php b/lib/private/Files/SimpleFS/SimpleFile.php index 4f9911a9ce9..b28a415f57e 100644 --- a/lib/private/Files/SimpleFS/SimpleFile.php +++ b/lib/private/Files/SimpleFS/SimpleFile.php @@ -22,6 +22,7 @@ class SimpleFile implements ISimpleFile { /** * Get the name */ + #[\Override] public function getName(): string { return $this->file->getName(); } @@ -29,6 +30,7 @@ class SimpleFile implements ISimpleFile { /** * Get the size in bytes */ + #[\Override] public function getSize(): int|float { return $this->file->getSize(); } @@ -36,6 +38,7 @@ class SimpleFile implements ISimpleFile { /** * Get the ETag */ + #[\Override] public function getETag(): string { return $this->file->getEtag(); } @@ -43,6 +46,7 @@ class SimpleFile implements ISimpleFile { /** * Get the last modification time */ + #[\Override] public function getMTime(): int { return $this->file->getMTime(); } @@ -55,6 +59,7 @@ class SimpleFile implements ISimpleFile { * @throws NotFoundException * @throws NotPermittedException */ + #[\Override] public function getContent(): string { $result = $this->file->getContent(); @@ -74,6 +79,7 @@ class SimpleFile implements ISimpleFile { * @throws NotFoundException * @throws NotPermittedException */ + #[\Override] public function putContent($data): void { try { $this->file->putContent($data); @@ -116,6 +122,7 @@ class SimpleFile implements ISimpleFile { * * @throws NotPermittedException */ + #[\Override] public function delete(): void { $this->file->delete(); } @@ -123,6 +130,7 @@ class SimpleFile implements ISimpleFile { /** * Get the MimeType */ + #[\Override] public function getMimeType(): string { return $this->file->getMimeType(); } @@ -130,6 +138,7 @@ class SimpleFile implements ISimpleFile { /** * {@inheritDoc} */ + #[\Override] public function getExtension(): string { return $this->file->getExtension(); } @@ -141,6 +150,7 @@ class SimpleFile implements ISimpleFile { * @throws NotPermittedException * @since 14.0.0 */ + #[\Override] public function read() { return $this->file->fopen('r'); } @@ -152,6 +162,7 @@ class SimpleFile implements ISimpleFile { * @throws NotPermittedException * @since 14.0.0 */ + #[\Override] public function write() { return $this->file->fopen('w'); } diff --git a/lib/private/Files/SimpleFS/SimpleFolder.php b/lib/private/Files/SimpleFS/SimpleFolder.php index 2f983700698..2124302823c 100644 --- a/lib/private/Files/SimpleFS/SimpleFolder.php +++ b/lib/private/Files/SimpleFS/SimpleFolder.php @@ -19,10 +19,12 @@ class SimpleFolder implements ISimpleFolder { ) { } + #[\Override] public function getName(): string { return $this->folder->getName(); } + #[\Override] public function getDirectoryListing(): array { $listing = $this->folder->getDirectoryListing(); @@ -38,14 +40,17 @@ class SimpleFolder implements ISimpleFolder { return array_values($fileListing); } + #[\Override] public function delete(): void { $this->folder->delete(); } + #[\Override] public function fileExists(string $name): bool { return $this->folder->nodeExists($name); } + #[\Override] public function getFile(string $name): ISimpleFile { $file = $this->folder->get($name); @@ -56,6 +61,7 @@ class SimpleFolder implements ISimpleFolder { return new SimpleFile($file); } + #[\Override] public function newFile(string $name, $content = null): ISimpleFile { if ($content === null) { // delay creating the file until it's written to @@ -66,6 +72,7 @@ class SimpleFolder implements ISimpleFolder { } } + #[\Override] public function getFolder(string $name): ISimpleFolder { $folder = $this->folder->get($name); @@ -76,6 +83,7 @@ class SimpleFolder implements ISimpleFolder { return new SimpleFolder($folder); } + #[\Override] public function newFolder(string $path): ISimpleFolder { $folder = $this->folder->newFolder($path); return new SimpleFolder($folder); diff --git a/lib/private/Files/Storage/Common.php b/lib/private/Files/Storage/Common.php index bb6848bc4fb..dbb98eda9b7 100644 --- a/lib/private/Files/Storage/Common.php +++ b/lib/private/Files/Storage/Common.php @@ -90,14 +90,17 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage, return false; } + #[\Override] public function is_dir(string $path): bool { return $this->filetype($path) === 'dir'; } + #[\Override] public function is_file(string $path): bool { return $this->filetype($path) === 'file'; } + #[\Override] public function filesize(string $path): int|float|false { $type = $this->filetype($path); if ($type === false) { @@ -111,12 +114,14 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage, } } + #[\Override] public function isReadable(string $path): bool { // at least check whether it exists // subclasses might want to implement this more thoroughly return $this->file_exists($path); } + #[\Override] public function isUpdatable(string $path): bool { // at least check whether it exists // subclasses might want to implement this more thoroughly @@ -124,6 +129,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage, return $this->file_exists($path); } + #[\Override] public function isCreatable(string $path): bool { if ($this->is_dir($path) && $this->isUpdatable($path)) { return true; @@ -131,6 +137,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage, return false; } + #[\Override] public function isDeletable(string $path): bool { if ($path === '' || $path === '/') { return $this->isUpdatable($path); @@ -139,10 +146,12 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage, return $this->isUpdatable($parent) && $this->isUpdatable($path); } + #[\Override] public function isSharable(string $path): bool { return $this->isReadable($path); } + #[\Override] public function getPermissions(string $path): int { $permissions = 0; if ($this->isCreatable($path)) { @@ -163,6 +172,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage, return $permissions; } + #[\Override] public function filemtime(string $path): int|false { $stat = $this->stat($path); if (isset($stat['mtime']) && $stat['mtime'] > 0) { @@ -172,6 +182,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage, } } + #[\Override] public function file_get_contents(string $path): string|false { $handle = $this->fopen($path, 'r'); if (!$handle) { @@ -182,6 +193,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage, return $data; } + #[\Override] public function file_put_contents(string $path, mixed $data): int|float|false { $handle = $this->fopen($path, 'w'); if (!$handle) { @@ -193,6 +205,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage, return $count; } + #[\Override] public function rename(string $source, string $target): bool { $this->remove($target); @@ -200,6 +213,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage, return $this->copy($source, $target) && $this->remove($source); } + #[\Override] public function copy(string $source, string $target): bool { if ($this->is_dir($source)) { $this->remove($target); @@ -230,6 +244,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage, } } + #[\Override] public function getMimeType(string $path): string|false { if ($this->is_dir($path)) { return 'httpd/unix-directory'; @@ -240,6 +255,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage, } } + #[\Override] public function hash(string $type, string $path, bool $raw = false): string|false { $fh = $this->fopen($path, 'rb'); if (!$fh) { @@ -251,6 +267,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage, return hash_final($ctx, $raw); } + #[\Override] public function getLocalFile(string $path): string|false { return $this->getCachedFile($path); } @@ -301,6 +318,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage, * exclusive access to the backend and will not pick up files that have been added in a way that circumvents * Nextcloud filesystem. */ + #[\Override] public function hasUpdated(string $path, int $time): bool { return $this->filemtime($path) > $time; } @@ -312,6 +330,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage, return $this->cacheDependencies; } + #[\Override] public function getCache(string $path = '', ?IStorage $storage = null): ICache { if (!$storage) { $storage = $this; @@ -323,6 +342,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage, return $storage->cache; } + #[\Override] public function getScanner(string $path = '', ?IStorage $storage = null): IScanner { if (!$storage) { $storage = $this; @@ -336,6 +356,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage, return $storage->scanner; } + #[\Override] public function getWatcher(string $path = '', ?IStorage $storage = null): IWatcher { if (!$storage) { $storage = $this; @@ -349,6 +370,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage, return $this->watcher; } + #[\Override] public function getPropagator(?IStorage $storage = null): IPropagator { if (!$storage) { $storage = $this; @@ -364,6 +386,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage, return $storage->propagator; } + #[\Override] public function getUpdater(?IStorage $storage = null): IUpdater { if (!$storage) { $storage = $this; @@ -378,12 +401,14 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage, return $storage->updater; } + #[\Override] public function getStorageCache(?IStorage $storage = null): \OC\Files\Cache\Storage { /** @var Cache $cache */ $cache = $this->getCache(storage: $storage); return $cache->getStorageCache(); } + #[\Override] public function getOwner(string $path): string|false { if ($this->owner === null) { $this->owner = \OC_User::getUser(); @@ -392,6 +417,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage, return $this->owner; } + #[\Override] public function getETag(string $path): string|false { return uniqid(); } @@ -423,6 +449,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage, /** * Test a storage for availability */ + #[\Override] public function test(): bool { try { if ($this->stat('')) { @@ -439,10 +466,12 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage, } } + #[\Override] public function free_space(string $path): int|float|false { return FileInfo::SPACE_UNKNOWN; } + #[\Override] public function isLocal(): bool { // the common implementation returns a temporary file by // default, which is not local @@ -452,6 +481,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage, /** * Check if the storage is an instance of $class or is a wrapper for a storage that is an instance of $class */ + #[\Override] public function instanceOfStorage(string $class): bool { if (ltrim($class, '\\') === 'OC\Files\Storage\Shared') { // FIXME Temporary fix to keep existing checks working @@ -470,6 +500,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage, return false; } + #[\Override] public function verifyPath(string $path, string $fileName): void { $this->getFilenameValidator() ->validateFilename($fileName); @@ -507,6 +538,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage, return $this->mountOptions[$name] ?? $default; } + #[\Override] public function copyFromStorage(IStorage $sourceStorage, string $sourceInternalPath, string $targetInternalPath, bool $preserveMtime = false): bool { if ($sourceStorage === $this) { return $this->copy($sourceInternalPath, $targetInternalPath); @@ -564,6 +596,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage, return $storage === $this; } + #[\Override] public function moveFromStorage(IStorage $sourceStorage, string $sourceInternalPath, string $targetInternalPath): bool { if ( !$sourceStorage->instanceOfStorage(Encryption::class) @@ -607,6 +640,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage, return $result; } + #[\Override] public function getMetaData(string $path): ?array { if (Filesystem::isFileBlacklisted($path)) { throw new ForbiddenException('Invalid path: ' . $path, false); @@ -637,6 +671,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage, return $data; } + #[\Override] public function acquireLock(string $path, int $type, ILockingProvider $provider): void { $logger = $this->getLockLogger(); if ($logger) { @@ -664,6 +699,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage, } } + #[\Override] public function releaseLock(string $path, int $type, ILockingProvider $provider): void { $logger = $this->getLockLogger(); if ($logger) { @@ -691,6 +727,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage, } } + #[\Override] public function changeLock(string $path, int $type, ILockingProvider $provider): void { $logger = $this->getLockLogger(); if ($logger) { @@ -729,22 +766,27 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage, /** * @return array{available: bool, last_checked: int} */ + #[\Override] public function getAvailability(): array { return $this->getStorageCache()->getAvailability(); } + #[\Override] public function setAvailability(bool $isAvailable): void { $this->getStorageCache()->setAvailability($isAvailable); } + #[\Override] public function setOwner(?string $user): void { $this->owner = $user; } + #[\Override] public function needsPartFile(): bool { return true; } + #[\Override] public function writeStream(string $path, $stream, ?int $size = null): int { $target = $this->fopen($path, 'w'); if (!$target) { @@ -762,6 +804,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage, return $count; } + #[\Override] public function getDirectoryContent(string $directory): \Traversable { $dh = $this->opendir($directory); diff --git a/lib/private/Files/Storage/CommonTest.php b/lib/private/Files/Storage/CommonTest.php index b1a939cc00b..bcd73ad7cfc 100644 --- a/lib/private/Files/Storage/CommonTest.php +++ b/lib/private/Files/Storage/CommonTest.php @@ -19,42 +19,55 @@ class CommonTest extends Common { $this->storage = new Local($parameters); } + #[\Override] public function getId(): string { return 'test::' . $this->storage->getId(); } + #[\Override] public function mkdir(string $path): bool { return $this->storage->mkdir($path); } + #[\Override] public function rmdir(string $path): bool { return $this->storage->rmdir($path); } + #[\Override] public function opendir(string $path) { return $this->storage->opendir($path); } + #[\Override] public function stat(string $path): array|false { return $this->storage->stat($path); } + #[\Override] public function filetype(string $path): string|false { return @$this->storage->filetype($path); } + #[\Override] public function isReadable(string $path): bool { return $this->storage->isReadable($path); } + #[\Override] public function isUpdatable(string $path): bool { return $this->storage->isUpdatable($path); } + #[\Override] public function file_exists(string $path): bool { return $this->storage->file_exists($path); } + #[\Override] public function unlink(string $path): bool { return $this->storage->unlink($path); } + #[\Override] public function fopen(string $path, string $mode) { return $this->storage->fopen($path, $mode); } + #[\Override] public function free_space(string $path): int|float|false { return $this->storage->free_space($path); } + #[\Override] public function touch(string $path, ?int $mtime = null): bool { return $this->storage->touch($path, $mtime); } diff --git a/lib/private/Files/Storage/DAV.php b/lib/private/Files/Storage/DAV.php index 8ccfe305136..0c74abdfee1 100644 --- a/lib/private/Files/Storage/DAV.php +++ b/lib/private/Files/Storage/DAV.php @@ -192,6 +192,7 @@ class DAV extends Common { $this->statCache->clear(); } + #[\Override] public function getId(): string { return 'webdav::' . $this->user . '@' . $this->host . '/' . $this->root; } @@ -205,6 +206,7 @@ class DAV extends Common { return $baseUri; } + #[\Override] public function mkdir(string $path): bool { $this->init(); $path = $this->cleanPath($path); @@ -215,6 +217,7 @@ class DAV extends Common { return $result; } + #[\Override] public function rmdir(string $path): bool { $this->init(); $path = $this->cleanPath($path); @@ -226,6 +229,7 @@ class DAV extends Common { return $result; } + #[\Override] public function opendir(string $path) { $this->init(); $path = $this->cleanPath($path); @@ -311,6 +315,7 @@ class DAV extends Common { return $response; } + #[\Override] public function filetype(string $path): string|false { try { $response = $this->propfind($path); @@ -329,6 +334,7 @@ class DAV extends Common { return false; } + #[\Override] public function file_exists(string $path): bool { try { $path = $this->cleanPath($path); @@ -347,6 +353,7 @@ class DAV extends Common { return false; } + #[\Override] public function unlink(string $path): bool { $this->init(); $path = $this->cleanPath($path); @@ -356,6 +363,7 @@ class DAV extends Common { return $result; } + #[\Override] public function fopen(string $path, string $mode) { $this->init(); $path = $this->cleanPath($path); @@ -444,6 +452,7 @@ class DAV extends Common { unlink($tmpFile); } + #[\Override] public function free_space(string $path): int|float|false { $this->init(); $path = $this->cleanPath($path); @@ -462,6 +471,7 @@ class DAV extends Common { } } + #[\Override] public function touch(string $path, ?int $mtime = null): bool { $this->init(); if (is_null($mtime)) { @@ -499,6 +509,7 @@ class DAV extends Common { return true; } + #[\Override] public function file_put_contents(string $path, mixed $data): int|float|false { $path = $this->cleanPath($path); $result = parent::file_put_contents($path, $data); @@ -527,6 +538,7 @@ class DAV extends Common { $this->removeCachedFile($target); } + #[\Override] public function rename(string $source, string $target): bool { $this->init(); $source = $this->cleanPath($source); @@ -558,6 +570,7 @@ class DAV extends Common { return false; } + #[\Override] public function copy(string $source, string $target): bool { $this->init(); $source = $this->cleanPath($source); @@ -586,6 +599,7 @@ class DAV extends Common { return false; } + #[\Override] public function getMetaData(string $path): ?array { if (Filesystem::isFileBlacklisted($path)) { throw new ForbiddenException('Invalid path: ' . $path, false); @@ -648,17 +662,20 @@ class DAV extends Common { ]; } + #[\Override] public function stat(string $path): array|false { $meta = $this->getMetaData($path); return $meta ?: false; } + #[\Override] public function getMimeType(string $path): string|false { $meta = $this->getMetaData($path); return $meta ? $meta['mimetype'] : false; } + #[\Override] public function cleanPath(string $path): string { if ($path === '') { return $path; @@ -710,27 +727,33 @@ class DAV extends Common { return true; } + #[\Override] public function isUpdatable(string $path): bool { return (bool)($this->getPermissions($path) & Constants::PERMISSION_UPDATE); } + #[\Override] public function isCreatable(string $path): bool { return (bool)($this->getPermissions($path) & Constants::PERMISSION_CREATE); } + #[\Override] public function isSharable(string $path): bool { return (bool)($this->getPermissions($path) & Constants::PERMISSION_SHARE); } + #[\Override] public function isDeletable(string $path): bool { return (bool)($this->getPermissions($path) & Constants::PERMISSION_DELETE); } + #[\Override] public function getPermissions(string $path): int { $stat = $this->getMetaData($path); return $stat ? $stat['permissions'] : 0; } + #[\Override] public function getETag(string $path): string|false { $meta = $this->getMetaData($path); return $meta ? $meta['etag'] : false; @@ -754,6 +777,7 @@ class DAV extends Common { return $permissions; } + #[\Override] public function hasUpdated(string $path, int $time): bool { $this->init(); $path = $this->cleanPath($path); @@ -852,6 +876,7 @@ class DAV extends Common { // TODO: only log for now, but in the future need to wrap/rethrow exception } + #[\Override] public function getDirectoryContent(string $directory): \Traversable { $this->init(); $directory = $this->cleanPath($directory); diff --git a/lib/private/Files/Storage/FailedStorage.php b/lib/private/Files/Storage/FailedStorage.php index 1b1123921aa..e85982cb6ec 100644 --- a/lib/private/Files/Storage/FailedStorage.php +++ b/lib/private/Files/Storage/FailedStorage.php @@ -29,166 +29,207 @@ class FailedStorage extends Common { } } + #[\Override] public function getId(): string { // we can't return anything sane here return 'failedstorage'; } + #[\Override] public function mkdir(string $path): never { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } + #[\Override] public function rmdir(string $path): never { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } + #[\Override] public function opendir(string $path): never { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } + #[\Override] public function is_dir(string $path): never { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } + #[\Override] public function is_file(string $path): never { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } + #[\Override] public function stat(string $path): never { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } + #[\Override] public function filetype(string $path): never { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } + #[\Override] public function filesize(string $path): never { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } + #[\Override] public function isCreatable(string $path): never { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } + #[\Override] public function isReadable(string $path): never { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } + #[\Override] public function isUpdatable(string $path): never { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } + #[\Override] public function isDeletable(string $path): never { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } + #[\Override] public function isSharable(string $path): never { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } + #[\Override] public function getPermissions(string $path): never { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } + #[\Override] public function file_exists(string $path): never { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } + #[\Override] public function filemtime(string $path): never { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } + #[\Override] public function file_get_contents(string $path): never { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } + #[\Override] public function file_put_contents(string $path, mixed $data): never { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } + #[\Override] public function unlink(string $path): never { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } + #[\Override] public function rename(string $source, string $target): never { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } + #[\Override] public function copy(string $source, string $target): never { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } + #[\Override] public function fopen(string $path, string $mode): never { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } + #[\Override] public function getMimeType(string $path): never { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } + #[\Override] public function hash(string $type, string $path, bool $raw = false): never { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } + #[\Override] public function free_space(string $path): never { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } + #[\Override] public function touch(string $path, ?int $mtime = null): never { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } + #[\Override] public function getLocalFile(string $path): never { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } + #[\Override] public function hasUpdated(string $path, int $time): never { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } + #[\Override] public function getETag(string $path): never { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } + #[\Override] public function getDirectDownload(string $path): never { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } + #[\Override] public function getDirectDownloadById(string $fileId): never { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } + #[\Override] public function verifyPath(string $path, string $fileName): void { } + #[\Override] public function copyFromStorage(IStorage $sourceStorage, string $sourceInternalPath, string $targetInternalPath, bool $preserveMtime = false): never { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } + #[\Override] public function moveFromStorage(IStorage $sourceStorage, string $sourceInternalPath, string $targetInternalPath): never { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } + #[\Override] public function acquireLock(string $path, int $type, ILockingProvider $provider): never { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } + #[\Override] public function releaseLock(string $path, int $type, ILockingProvider $provider): never { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } + #[\Override] public function changeLock(string $path, int $type, ILockingProvider $provider): never { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } + #[\Override] public function getAvailability(): never { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } + #[\Override] public function setAvailability(bool $isAvailable): never { throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); } + #[\Override] public function getCache(string $path = '', ?IStorage $storage = null): FailedCache { return new FailedCache(); } diff --git a/lib/private/Files/Storage/Home.php b/lib/private/Files/Storage/Home.php index 6627437c0ec..ab3a8c8806a 100644 --- a/lib/private/Files/Storage/Home.php +++ b/lib/private/Files/Storage/Home.php @@ -39,10 +39,12 @@ class Home extends Local implements IHomeStorage { parent::__construct(['datadir' => $datadir]); } + #[\Override] public function getId(): string { return $this->id; } + #[\Override] public function getCache(string $path = '', ?IStorage $storage = null): ICache { if (!$storage) { $storage = $this; @@ -53,6 +55,7 @@ class Home extends Local implements IHomeStorage { return $this->cache; } + #[\Override] public function getPropagator(?IStorage $storage = null): IPropagator { if (!$storage) { $storage = $this; @@ -64,10 +67,12 @@ class Home extends Local implements IHomeStorage { } + #[\Override] public function getUser(): IUser { return $this->user; } + #[\Override] public function getOwner(string $path): string|false { return $this->user->getUID(); } diff --git a/lib/private/Files/Storage/Local.php b/lib/private/Files/Storage/Local.php index e3afc6bd017..e5806f855bc 100644 --- a/lib/private/Files/Storage/Local.php +++ b/lib/private/Files/Storage/Local.php @@ -78,10 +78,12 @@ class Local extends Common { public function __destruct() { } + #[\Override] public function getId(): string { return 'local::' . $this->datadir; } + #[\Override] public function mkdir(string $path): bool { $sourcePath = $this->getSourcePath($path); $oldMask = umask($this->defUMask); @@ -90,6 +92,7 @@ class Local extends Common { return $result; } + #[\Override] public function rmdir(string $path): bool { if (!$this->isDeletable($path)) { return false; @@ -129,10 +132,12 @@ class Local extends Common { } } + #[\Override] public function opendir(string $path) { return opendir($this->getSourcePath($path)); } + #[\Override] public function is_dir(string $path): bool { if ($this->caseInsensitive && !$this->file_exists($path)) { return false; @@ -143,6 +148,7 @@ class Local extends Common { return is_dir($this->getSourcePath($path)); } + #[\Override] public function is_file(string $path): bool { if ($this->caseInsensitive && !$this->file_exists($path)) { return false; @@ -150,6 +156,7 @@ class Local extends Common { return is_file($this->getSourcePath($path)); } + #[\Override] public function stat(string $path): array|false { $fullPath = $this->getSourcePath($path); clearstatcache(true, $fullPath); @@ -168,6 +175,7 @@ class Local extends Common { return $statResult; } + #[\Override] public function getMetaData(string $path): ?array { try { $stat = $this->stat($path); @@ -217,6 +225,7 @@ class Local extends Common { return $data; } + #[\Override] public function filetype(string $path): string|false { $filetype = @filetype($this->getSourcePath($path)); if ($filetype === 'link') { @@ -225,6 +234,7 @@ class Local extends Common { return $filetype; } + #[\Override] public function filesize(string $path): int|float|false { $type = $this->filetype($path); if ($type === false) { @@ -241,14 +251,17 @@ class Local extends Common { return filesize($fullPath); } + #[\Override] public function isReadable(string $path): bool { return is_readable($this->getSourcePath($path)); } + #[\Override] public function isUpdatable(string $path): bool { return is_writable($this->getSourcePath($path)); } + #[\Override] public function file_exists(string $path): bool { if ($this->caseInsensitive) { $fullPath = $this->getSourcePath($path); @@ -263,6 +276,7 @@ class Local extends Common { } } + #[\Override] public function filemtime(string $path): int|false { $fullPath = $this->getSourcePath($path); clearstatcache(true, $fullPath); @@ -276,6 +290,7 @@ class Local extends Common { return filemtime($fullPath); } + #[\Override] public function touch(string $path, ?int $mtime = null): bool { // sets the modification time of the file to the given value. // If mtime is nil the current time is set. @@ -297,10 +312,12 @@ class Local extends Common { return $result; } + #[\Override] public function file_get_contents(string $path): string|false { return file_get_contents($this->getSourcePath($path)); } + #[\Override] public function file_put_contents(string $path, mixed $data): int|float|false { $oldMask = umask($this->defUMask); if ($this->unlinkOnTruncate) { @@ -311,6 +328,7 @@ class Local extends Common { return $result; } + #[\Override] public function unlink(string $path): bool { if ($this->is_dir($path)) { return $this->rmdir($path); @@ -331,6 +349,7 @@ class Local extends Common { } } + #[\Override] public function rename(string $source, string $target): bool { $srcParent = dirname($source); $dstParent = dirname($target); @@ -374,6 +393,7 @@ class Local extends Common { return $this->copy($source, $target) && $this->unlink($source); } + #[\Override] public function copy(string $source, string $target): bool { if ($this->is_dir($source)) { return parent::copy($source, $target); @@ -393,6 +413,7 @@ class Local extends Common { } } + #[\Override] public function fopen(string $path, string $mode) { $sourcePath = $this->getSourcePath($path); if (!file_exists($sourcePath) && $mode === 'r') { @@ -407,10 +428,12 @@ class Local extends Common { return $result; } + #[\Override] public function hash(string $type, string $path, bool $raw = false): string|false { return hash_file($type, $this->getSourcePath($path), $raw); } + #[\Override] public function free_space(string $path): int|float|false { $sourcePath = $this->getSourcePath($path); // using !is_dir because $sourcePath might be a part file or @@ -431,10 +454,12 @@ class Local extends Common { return $this->searchInDir($query); } + #[\Override] public function getLocalFile(string $path): string|false { return $this->getSourcePath($path); } + #[\Override] protected function searchInDir(string $query, string $dir = ''): array { $files = []; $physicalDir = $this->getSourcePath($dir); @@ -454,6 +479,7 @@ class Local extends Common { return $files; } + #[\Override] public function hasUpdated(string $path, int $time): bool { if ($this->file_exists($path)) { return $this->filemtime($path) > $time; @@ -499,10 +525,12 @@ class Local extends Common { throw new ForbiddenException('Following symlinks is not allowed', false); } + #[\Override] public function isLocal(): bool { return true; } + #[\Override] public function getETag(string $path): string|false { return $this->calculateEtag($path, $this->stat($path)); } @@ -546,6 +574,7 @@ class Local extends Common { && !$sourceStorage->instanceOfStorage(Encryption::class); } + #[\Override] public function copyFromStorage(IStorage $sourceStorage, string $sourceInternalPath, string $targetInternalPath, bool $preserveMtime = false): bool { if ($this->canDoCrossStorageMove($sourceStorage)) { // resolve any jailed paths @@ -566,6 +595,7 @@ class Local extends Common { } } + #[\Override] public function moveFromStorage(IStorage $sourceStorage, string $sourceInternalPath, string $targetInternalPath): bool { if ($this->canDoCrossStorageMove($sourceStorage)) { // resolve any jailed paths @@ -586,6 +616,7 @@ class Local extends Common { } } + #[\Override] public function writeStream(string $path, $stream, ?int $size = null): int { /** @var int|false $result We consider here that returned size will never be a float because we write less than 4GB */ $result = $this->file_put_contents($path, $stream); diff --git a/lib/private/Files/Storage/LocalRootStorage.php b/lib/private/Files/Storage/LocalRootStorage.php index d8d0fc2c75c..4086b481051 100644 --- a/lib/private/Files/Storage/LocalRootStorage.php +++ b/lib/private/Files/Storage/LocalRootStorage.php @@ -13,6 +13,7 @@ use OCP\Files\Cache\IScanner; use OCP\Files\Storage\IStorage; class LocalRootStorage extends Local { + #[\Override] public function getScanner(string $path = '', ?IStorage $storage = null): IScanner { if (!$storage) { $storage = $this; diff --git a/lib/private/Files/Storage/Storage.php b/lib/private/Files/Storage/Storage.php index 938d676471b..88383350152 100644 --- a/lib/private/Files/Storage/Storage.php +++ b/lib/private/Files/Storage/Storage.php @@ -23,14 +23,19 @@ use OCP\Files\Storage\IStorage; * All paths passed to the storage are relative to the storage and should NOT have a leading slash. */ interface Storage extends IStorage, ILockingStorage { + #[\Override] public function getCache(string $path = '', ?IStorage $storage = null): ICache; + #[\Override] public function getScanner(string $path = '', ?IStorage $storage = null): IScanner; + #[\Override] public function getWatcher(string $path = '', ?IStorage $storage = null): IWatcher; + #[\Override] public function getPropagator(?IStorage $storage = null): IPropagator; + #[\Override] public function getUpdater(?IStorage $storage = null): IUpdater; public function getStorageCache(): \OC\Files\Cache\Storage; diff --git a/lib/private/Files/Storage/StorageFactory.php b/lib/private/Files/Storage/StorageFactory.php index 24efd3ecc1c..e590c44ed55 100644 --- a/lib/private/Files/Storage/StorageFactory.php +++ b/lib/private/Files/Storage/StorageFactory.php @@ -20,6 +20,7 @@ class StorageFactory implements IStorageFactory { */ private $storageWrappers = []; + #[\Override] public function addStorageWrapper(string $wrapperName, callable $callback, int $priority = 50, array $existingMounts = []): bool { if (isset($this->storageWrappers[$wrapperName])) { return false; @@ -47,6 +48,7 @@ class StorageFactory implements IStorageFactory { /** * Create an instance of a storage and apply the registered storage wrappers */ + #[\Override] public function getInstance(IMountPoint $mountPoint, string $class, array $arguments): IStorage { if (!is_a($class, IConstructableStorage::class, true)) { Server::get(LoggerInterface::class)->warning('Building a storage not implementing IConstructableStorage is deprecated since 31.0.0', ['class' => $class]); diff --git a/lib/private/Files/Storage/Temporary.php b/lib/private/Files/Storage/Temporary.php index ecf8a1315a9..bb46d7100a1 100644 --- a/lib/private/Files/Storage/Temporary.php +++ b/lib/private/Files/Storage/Temporary.php @@ -23,6 +23,7 @@ class Temporary extends Local { Files::rmdirr($this->datadir); } + #[\Override] public function __destruct() { parent::__destruct(); $this->cleanUp(); diff --git a/lib/private/Files/Storage/Wrapper/Availability.php b/lib/private/Files/Storage/Wrapper/Availability.php index 7ae6bbe08be..924567e1afe 100644 --- a/lib/private/Files/Storage/Wrapper/Availability.php +++ b/lib/private/Files/Storage/Wrapper/Availability.php @@ -88,62 +88,77 @@ class Availability extends Wrapper { } } + #[\Override] public function mkdir(string $path): bool { return $this->handleAvailability('mkdir', $path); } + #[\Override] public function rmdir(string $path): bool { return $this->handleAvailability('rmdir', $path); } + #[\Override] public function opendir(string $path) { return $this->handleAvailability('opendir', $path); } + #[\Override] public function is_dir(string $path): bool { return $this->handleAvailability('is_dir', $path); } + #[\Override] public function is_file(string $path): bool { return $this->handleAvailability('is_file', $path); } + #[\Override] public function stat(string $path): array|false { return $this->handleAvailability('stat', $path); } + #[\Override] public function filetype(string $path): string|false { return $this->handleAvailability('filetype', $path); } + #[\Override] public function filesize(string $path): int|float|false { return $this->handleAvailability('filesize', $path); } + #[\Override] public function isCreatable(string $path): bool { return $this->handleAvailability('isCreatable', $path); } + #[\Override] public function isReadable(string $path): bool { return $this->handleAvailability('isReadable', $path); } + #[\Override] public function isUpdatable(string $path): bool { return $this->handleAvailability('isUpdatable', $path); } + #[\Override] public function isDeletable(string $path): bool { return $this->handleAvailability('isDeletable', $path); } + #[\Override] public function isSharable(string $path): bool { return $this->handleAvailability('isSharable', $path); } + #[\Override] public function getPermissions(string $path): int { return $this->handleAvailability('getPermissions', $path); } + #[\Override] public function file_exists(string $path): bool { if ($path === '') { return true; @@ -151,54 +166,67 @@ class Availability extends Wrapper { return $this->handleAvailability('file_exists', $path); } + #[\Override] public function filemtime(string $path): int|false { return $this->handleAvailability('filemtime', $path); } + #[\Override] public function file_get_contents(string $path): string|false { return $this->handleAvailability('file_get_contents', $path); } + #[\Override] public function file_put_contents(string $path, mixed $data): int|float|false { return $this->handleAvailability('file_put_contents', $path, $data); } + #[\Override] public function unlink(string $path): bool { return $this->handleAvailability('unlink', $path); } + #[\Override] public function rename(string $source, string $target): bool { return $this->handleAvailability('rename', $source, $target); } + #[\Override] public function copy(string $source, string $target): bool { return $this->handleAvailability('copy', $source, $target); } + #[\Override] public function fopen(string $path, string $mode) { return $this->handleAvailability('fopen', $path, $mode); } + #[\Override] public function getMimeType(string $path): string|false { return $this->handleAvailability('getMimeType', $path); } + #[\Override] public function hash(string $type, string $path, bool $raw = false): string|false { return $this->handleAvailability('hash', $type, $path, $raw); } + #[\Override] public function free_space(string $path): int|float|false { return $this->handleAvailability('free_space', $path); } + #[\Override] public function touch(string $path, ?int $mtime = null): bool { return $this->handleAvailability('touch', $path, $mtime); } + #[\Override] public function getLocalFile(string $path): string|false { return $this->handleAvailability('getLocalFile', $path); } + #[\Override] public function hasUpdated(string $path, int $time): bool { if (!$this->isAvailable()) { return false; @@ -212,6 +240,7 @@ class Availability extends Wrapper { } } + #[\Override] public function getOwner(string $path): string|false { try { return parent::getOwner($path); @@ -221,26 +250,32 @@ class Availability extends Wrapper { } } + #[\Override] public function getETag(string $path): string|false { return $this->handleAvailability('getETag', $path); } + #[\Override] public function getDirectDownload(string $path): array|false { return $this->handleAvailability('getDirectDownload', $path); } + #[\Override] public function getDirectDownloadById(string $fileId): array|false { return $this->handleAvailability('getDirectDownloadById', $fileId); } + #[\Override] public function copyFromStorage(IStorage $sourceStorage, string $sourceInternalPath, string $targetInternalPath): bool { return $this->handleAvailability('copyFromStorage', $sourceStorage, $sourceInternalPath, $targetInternalPath); } + #[\Override] public function moveFromStorage(IStorage $sourceStorage, string $sourceInternalPath, string $targetInternalPath): bool { return $this->handleAvailability('moveFromStorage', $sourceStorage, $sourceInternalPath, $targetInternalPath); } + #[\Override] public function getMetaData(string $path): ?array { $this->checkAvailability(); try { @@ -275,6 +310,7 @@ class Availability extends Wrapper { + #[\Override] public function getDirectoryContent(string $directory): \Traversable { $this->checkAvailability(); try { diff --git a/lib/private/Files/Storage/Wrapper/DirPermissionsMask.php b/lib/private/Files/Storage/Wrapper/DirPermissionsMask.php index 14b6441f98b..0ad4fc127b8 100644 --- a/lib/private/Files/Storage/Wrapper/DirPermissionsMask.php +++ b/lib/private/Files/Storage/Wrapper/DirPermissionsMask.php @@ -47,6 +47,7 @@ class DirPermissionsMask extends PermissionsMask { return $path === $this->path || substr($path, 0, $this->pathLength + 1) === $this->path . '/'; } + #[\Override] public function isUpdatable($path): bool { if ($this->checkPath($path)) { return parent::isUpdatable($path); @@ -55,6 +56,7 @@ class DirPermissionsMask extends PermissionsMask { return $this->storage->isUpdatable($path); } + #[\Override] public function isCreatable($path): bool { if ($this->checkPath($path)) { return parent::isCreatable($path); @@ -63,6 +65,7 @@ class DirPermissionsMask extends PermissionsMask { return $this->storage->isCreatable($path); } + #[\Override] public function isDeletable($path): bool { if ($this->checkPath($path)) { return parent::isDeletable($path); @@ -71,6 +74,7 @@ class DirPermissionsMask extends PermissionsMask { return $this->storage->isDeletable($path); } + #[\Override] public function isSharable($path): bool { if ($this->checkPath($path)) { return parent::isSharable($path); @@ -79,6 +83,7 @@ class DirPermissionsMask extends PermissionsMask { return $this->storage->isSharable($path); } + #[\Override] public function getPermissions($path): int { if ($this->checkPath($path)) { return parent::getPermissions($path); @@ -87,6 +92,7 @@ class DirPermissionsMask extends PermissionsMask { return $this->storage->getPermissions($path); } + #[\Override] public function rename($source, $target): bool { if (!$this->isUpdatable($source)) { return false; @@ -110,6 +116,7 @@ class DirPermissionsMask extends PermissionsMask { return false; } + #[\Override] public function copy($source, $target): bool { if (!$this->isReadable($source)) { return false; @@ -133,6 +140,7 @@ class DirPermissionsMask extends PermissionsMask { return false; } + #[\Override] public function touch($path, $mtime = null): bool { if ($this->checkPath($path)) { return parent::touch($path); @@ -141,6 +149,7 @@ class DirPermissionsMask extends PermissionsMask { return $this->storage->touch($path); } + #[\Override] public function mkdir($path): bool { // Always allow creating the path of the dir mask. if ($path !== $this->path && $this->checkPath($path)) { @@ -150,6 +159,7 @@ class DirPermissionsMask extends PermissionsMask { return $this->storage->mkdir($path); } + #[\Override] public function rmdir($path): bool { if ($this->checkPath($path)) { return parent::rmdir($path); @@ -158,6 +168,7 @@ class DirPermissionsMask extends PermissionsMask { return $this->storage->rmdir($path); } + #[\Override] public function unlink($path): bool { if ($this->checkPath($path)) { return parent::unlink($path); @@ -166,6 +177,7 @@ class DirPermissionsMask extends PermissionsMask { return $this->storage->unlink($path); } + #[\Override] public function file_put_contents($path, $data): int|float|false { if ($this->checkPath($path)) { return parent::file_put_contents($path, $data); @@ -174,6 +186,7 @@ class DirPermissionsMask extends PermissionsMask { return $this->storage->file_put_contents($path, $data); } + #[\Override] public function fopen($path, $mode) { if ($this->checkPath($path)) { return parent::fopen($path, $mode); @@ -182,6 +195,7 @@ class DirPermissionsMask extends PermissionsMask { return $this->storage->fopen($path, $mode); } + #[\Override] public function getCache($path = '', $storage = null): ICache { if (!$storage) { $storage = $this; diff --git a/lib/private/Files/Storage/Wrapper/Encoding.php b/lib/private/Files/Storage/Wrapper/Encoding.php index 854a28efc2c..e8c01f0a018 100644 --- a/lib/private/Files/Storage/Wrapper/Encoding.php +++ b/lib/private/Files/Storage/Wrapper/Encoding.php @@ -96,6 +96,7 @@ class Encoding extends Wrapper { return null; } + #[\Override] public function mkdir(string $path): bool { // note: no conversion here, method should not be called with non-NFC names! $result = $this->getWrapperStorage()->mkdir($path); @@ -105,6 +106,7 @@ class Encoding extends Wrapper { return $result; } + #[\Override] public function rmdir(string $path): bool { $result = $this->getWrapperStorage()->rmdir($this->findPathToUse($path)); if ($result) { @@ -113,71 +115,88 @@ class Encoding extends Wrapper { return $result; } + #[\Override] public function opendir(string $path) { $handle = $this->getWrapperStorage()->opendir($this->findPathToUse($path)); return EncodingDirectoryWrapper::wrap($handle); } + #[\Override] public function is_dir(string $path): bool { return $this->getWrapperStorage()->is_dir($this->findPathToUse($path)); } + #[\Override] public function is_file(string $path): bool { return $this->getWrapperStorage()->is_file($this->findPathToUse($path)); } + #[\Override] public function stat(string $path): array|false { return $this->getWrapperStorage()->stat($this->findPathToUse($path)); } + #[\Override] public function filetype(string $path): string|false { return $this->getWrapperStorage()->filetype($this->findPathToUse($path)); } + #[\Override] public function filesize(string $path): int|float|false { return $this->getWrapperStorage()->filesize($this->findPathToUse($path)); } + #[\Override] public function isCreatable(string $path): bool { return $this->getWrapperStorage()->isCreatable($this->findPathToUse($path)); } + #[\Override] public function isReadable(string $path): bool { return $this->getWrapperStorage()->isReadable($this->findPathToUse($path)); } + #[\Override] public function isUpdatable(string $path): bool { return $this->getWrapperStorage()->isUpdatable($this->findPathToUse($path)); } + #[\Override] public function isDeletable(string $path): bool { return $this->getWrapperStorage()->isDeletable($this->findPathToUse($path)); } + #[\Override] public function isSharable(string $path): bool { return $this->getWrapperStorage()->isSharable($this->findPathToUse($path)); } + #[\Override] public function getPermissions(string $path): int { return $this->getWrapperStorage()->getPermissions($this->findPathToUse($path)); } + #[\Override] public function file_exists(string $path): bool { return $this->getWrapperStorage()->file_exists($this->findPathToUse($path)); } + #[\Override] public function filemtime(string $path): int|false { return $this->getWrapperStorage()->filemtime($this->findPathToUse($path)); } + #[\Override] public function file_get_contents(string $path): string|false { return $this->getWrapperStorage()->file_get_contents($this->findPathToUse($path)); } + #[\Override] public function file_put_contents(string $path, mixed $data): int|float|false { return $this->getWrapperStorage()->file_put_contents($this->findPathToUse($path), $data); } + #[\Override] public function unlink(string $path): bool { $result = $this->getWrapperStorage()->unlink($this->findPathToUse($path)); if ($result) { @@ -186,15 +205,18 @@ class Encoding extends Wrapper { return $result; } + #[\Override] public function rename(string $source, string $target): bool { // second name always NFC return $this->getWrapperStorage()->rename($this->findPathToUse($source), $this->findPathToUse($target)); } + #[\Override] public function copy(string $source, string $target): bool { return $this->getWrapperStorage()->copy($this->findPathToUse($source), $this->findPathToUse($target)); } + #[\Override] public function fopen(string $path, string $mode) { $result = $this->getWrapperStorage()->fopen($this->findPathToUse($path), $mode); if ($result && $mode !== 'r' && $mode !== 'rb') { @@ -203,30 +225,37 @@ class Encoding extends Wrapper { return $result; } + #[\Override] public function getMimeType(string $path): string|false { return $this->getWrapperStorage()->getMimeType($this->findPathToUse($path)); } + #[\Override] public function hash(string $type, string $path, bool $raw = false): string|false { return $this->getWrapperStorage()->hash($type, $this->findPathToUse($path), $raw); } + #[\Override] public function free_space(string $path): int|float|false { return $this->getWrapperStorage()->free_space($this->findPathToUse($path)); } + #[\Override] public function touch(string $path, ?int $mtime = null): bool { return $this->getWrapperStorage()->touch($this->findPathToUse($path), $mtime); } + #[\Override] public function getLocalFile(string $path): string|false { return $this->getWrapperStorage()->getLocalFile($this->findPathToUse($path)); } + #[\Override] public function hasUpdated(string $path, int $time): bool { return $this->getWrapperStorage()->hasUpdated($this->findPathToUse($path), $time); } + #[\Override] public function getCache(string $path = '', ?IStorage $storage = null): ICache { if (!$storage) { $storage = $this; @@ -234,6 +263,7 @@ class Encoding extends Wrapper { return $this->getWrapperStorage()->getCache($this->findPathToUse($path), $storage); } + #[\Override] public function getScanner(string $path = '', ?IStorage $storage = null): IScanner { if (!$storage) { $storage = $this; @@ -241,10 +271,12 @@ class Encoding extends Wrapper { return $this->getWrapperStorage()->getScanner($this->findPathToUse($path), $storage); } + #[\Override] public function getETag(string $path): string|false { return $this->getWrapperStorage()->getETag($this->findPathToUse($path)); } + #[\Override] public function copyFromStorage(IStorage $sourceStorage, string $sourceInternalPath, string $targetInternalPath): bool { if ($sourceStorage === $this) { return $this->copy($sourceInternalPath, $this->findPathToUse($targetInternalPath)); @@ -257,6 +289,7 @@ class Encoding extends Wrapper { return $result; } + #[\Override] public function moveFromStorage(IStorage $sourceStorage, string $sourceInternalPath, string $targetInternalPath): bool { if ($sourceStorage === $this) { $result = $this->rename($sourceInternalPath, $this->findPathToUse($targetInternalPath)); @@ -275,6 +308,7 @@ class Encoding extends Wrapper { return $result; } + #[\Override] public function getMetaData(string $path): ?array { $entry = $this->getWrapperStorage()->getMetaData($this->findPathToUse($path)); if ($entry !== null) { @@ -283,6 +317,7 @@ class Encoding extends Wrapper { return $entry; } + #[\Override] public function getDirectoryContent(string $directory): \Traversable { $entries = $this->getWrapperStorage()->getDirectoryContent($this->findPathToUse($directory)); foreach ($entries as $entry) { diff --git a/lib/private/Files/Storage/Wrapper/EncodingDirectoryWrapper.php b/lib/private/Files/Storage/Wrapper/EncodingDirectoryWrapper.php index 0a90b49f0f1..3f07d690a50 100644 --- a/lib/private/Files/Storage/Wrapper/EncodingDirectoryWrapper.php +++ b/lib/private/Files/Storage/Wrapper/EncodingDirectoryWrapper.php @@ -13,6 +13,7 @@ use OC\Files\Filesystem; * Normalize file names while reading directory entries */ class EncodingDirectoryWrapper extends DirectoryWrapper { + #[\Override] public function dir_readdir(): string|false { $file = readdir($this->source); if ($file !== false && $file !== '.' && $file !== '..') { diff --git a/lib/private/Files/Storage/Wrapper/Encryption.php b/lib/private/Files/Storage/Wrapper/Encryption.php index 194c57a4191..8edf25e9a51 100644 --- a/lib/private/Files/Storage/Wrapper/Encryption.php +++ b/lib/private/Files/Storage/Wrapper/Encryption.php @@ -61,6 +61,7 @@ class Encryption extends Wrapper { parent::__construct($parameters); } + #[\Override] public function filesize(string $path): int|float|false { $fullPath = $this->getFullPath($path); @@ -128,6 +129,7 @@ class Encryption extends Wrapper { return $data; } + #[\Override] public function getMetaData(string $path): ?array { $data = $this->getWrapperStorage()->getMetaData($path); if (is_null($data)) { @@ -136,6 +138,7 @@ class Encryption extends Wrapper { return $this->modifyMetaData($path, $data); } + #[\Override] public function getDirectoryContent(string $directory): \Traversable { $parent = rtrim($directory, '/'); foreach ($this->getWrapperStorage()->getDirectoryContent($directory) as $data) { @@ -143,6 +146,7 @@ class Encryption extends Wrapper { } } + #[\Override] public function file_get_contents(string $path): string|false { $encryptionModule = $this->getEncryptionModule($path); @@ -158,6 +162,7 @@ class Encryption extends Wrapper { return $this->getWrapperStorage()->file_get_contents($path); } + #[\Override] public function file_put_contents(string $path, mixed $data): int|float|false { // file put content will always be translated to a stream write $handle = $this->fopen($path, 'w'); @@ -170,6 +175,7 @@ class Encryption extends Wrapper { return false; } + #[\Override] public function unlink(string $path): bool { $fullPath = $this->getFullPath($path); if ($this->util->isExcluded($fullPath)) { @@ -184,6 +190,7 @@ class Encryption extends Wrapper { return $this->getWrapperStorage()->unlink($path); } + #[\Override] public function rename(string $source, string $target): bool { $result = $this->getWrapperStorage()->rename($source, $target); @@ -209,6 +216,7 @@ class Encryption extends Wrapper { return $result; } + #[\Override] public function rmdir(string $path): bool { $result = $this->getWrapperStorage()->rmdir($path); $fullPath = $this->getFullPath($path); @@ -222,6 +230,7 @@ class Encryption extends Wrapper { return $result; } + #[\Override] public function isReadable(string $path): bool { $isReadable = true; @@ -239,6 +248,7 @@ class Encryption extends Wrapper { return $this->getWrapperStorage()->isReadable($path) && $isReadable; } + #[\Override] public function copy(string $source, string $target): bool { $sourcePath = $this->getFullPath($source); @@ -252,6 +262,7 @@ class Encryption extends Wrapper { return $this->copyFromStorage($this, $source, $target); } + #[\Override] public function fopen(string $path, string $mode) { // check if the file is stored in the array cache, this means that we // copy a file over to the versions folder, in this case we don't want to @@ -518,6 +529,7 @@ class Encryption extends Wrapper { return $data; } + #[\Override] public function moveFromStorage( Storage\IStorage $sourceStorage, string $sourceInternalPath, @@ -561,6 +573,7 @@ class Encryption extends Wrapper { return $result; } + #[\Override] public function copyFromStorage( Storage\IStorage $sourceStorage, string $sourceInternalPath, @@ -721,6 +734,7 @@ class Encryption extends Wrapper { return $result; } + #[\Override] public function getLocalFile(string $path): string|false { if ($this->encryptionManager->isEnabled()) { $cachedFile = $this->getCachedFile($path); @@ -731,6 +745,7 @@ class Encryption extends Wrapper { return $this->getWrapperStorage()->getLocalFile($path); } + #[\Override] public function isLocal(): bool { if ($this->encryptionManager->isEnabled()) { return false; @@ -738,6 +753,7 @@ class Encryption extends Wrapper { return $this->getWrapperStorage()->isLocal(); } + #[\Override] public function stat(string $path): array|false { $stat = $this->getWrapperStorage()->stat($path); if (!$stat) { @@ -750,6 +766,7 @@ class Encryption extends Wrapper { return $stat; } + #[\Override] public function hash(string $type, string $path, bool $raw = false): string|false { $fh = $this->fopen($path, 'rb'); if ($fh === false) { @@ -912,6 +929,7 @@ class Encryption extends Wrapper { return $encryptionModule->shouldEncrypt($fullPath); } + #[\Override] public function writeStream(string $path, $stream, ?int $size = null): int { // always fall back to fopen $target = $this->fopen($path, 'w'); diff --git a/lib/private/Files/Storage/Wrapper/Jail.php b/lib/private/Files/Storage/Wrapper/Jail.php index 1d5dfc7153a..7d1a5814e93 100644 --- a/lib/private/Files/Storage/Wrapper/Jail.php +++ b/lib/private/Files/Storage/Wrapper/Jail.php @@ -74,152 +74,189 @@ class Jail extends Wrapper { } } + #[\Override] public function getId(): string { return parent::getId(); } + #[\Override] public function mkdir(string $path): bool { return $this->getWrapperStorage()->mkdir($this->getUnjailedPath($path)); } + #[\Override] public function rmdir(string $path): bool { return $this->getWrapperStorage()->rmdir($this->getUnjailedPath($path)); } + #[\Override] public function opendir(string $path) { return $this->getWrapperStorage()->opendir($this->getUnjailedPath($path)); } + #[\Override] public function is_dir(string $path): bool { return $this->getWrapperStorage()->is_dir($this->getUnjailedPath($path)); } + #[\Override] public function is_file(string $path): bool { return $this->getWrapperStorage()->is_file($this->getUnjailedPath($path)); } + #[\Override] public function stat(string $path): array|false { return $this->getWrapperStorage()->stat($this->getUnjailedPath($path)); } + #[\Override] public function filetype(string $path): string|false { return $this->getWrapperStorage()->filetype($this->getUnjailedPath($path)); } + #[\Override] public function filesize(string $path): int|float|false { return $this->getWrapperStorage()->filesize($this->getUnjailedPath($path)); } + #[\Override] public function isCreatable(string $path): bool { return $this->getWrapperStorage()->isCreatable($this->getUnjailedPath($path)); } + #[\Override] public function isReadable(string $path): bool { return $this->getWrapperStorage()->isReadable($this->getUnjailedPath($path)); } + #[\Override] public function isUpdatable(string $path): bool { return $this->getWrapperStorage()->isUpdatable($this->getUnjailedPath($path)); } + #[\Override] public function isDeletable(string $path): bool { return $this->getWrapperStorage()->isDeletable($this->getUnjailedPath($path)); } + #[\Override] public function isSharable(string $path): bool { return $this->getWrapperStorage()->isSharable($this->getUnjailedPath($path)); } + #[\Override] public function getPermissions(string $path): int { return $this->getWrapperStorage()->getPermissions($this->getUnjailedPath($path)); } + #[\Override] public function file_exists(string $path): bool { return $this->getWrapperStorage()->file_exists($this->getUnjailedPath($path)); } + #[\Override] public function filemtime(string $path): int|false { return $this->getWrapperStorage()->filemtime($this->getUnjailedPath($path)); } + #[\Override] public function file_get_contents(string $path): string|false { return $this->getWrapperStorage()->file_get_contents($this->getUnjailedPath($path)); } + #[\Override] public function file_put_contents(string $path, mixed $data): int|float|false { return $this->getWrapperStorage()->file_put_contents($this->getUnjailedPath($path), $data); } + #[\Override] public function unlink(string $path): bool { return $this->getWrapperStorage()->unlink($this->getUnjailedPath($path)); } + #[\Override] public function rename(string $source, string $target): bool { return $this->getWrapperStorage()->rename($this->getUnjailedPath($source), $this->getUnjailedPath($target)); } + #[\Override] public function copy(string $source, string $target): bool { return $this->getWrapperStorage()->copy($this->getUnjailedPath($source), $this->getUnjailedPath($target)); } + #[\Override] public function fopen(string $path, string $mode) { return $this->getWrapperStorage()->fopen($this->getUnjailedPath($path), $mode); } + #[\Override] public function getMimeType(string $path): string|false { return $this->getWrapperStorage()->getMimeType($this->getUnjailedPath($path)); } + #[\Override] public function hash(string $type, string $path, bool $raw = false): string|false { return $this->getWrapperStorage()->hash($type, $this->getUnjailedPath($path), $raw); } + #[\Override] public function free_space(string $path): int|float|false { return $this->getWrapperStorage()->free_space($this->getUnjailedPath($path)); } + #[\Override] public function touch(string $path, ?int $mtime = null): bool { return $this->getWrapperStorage()->touch($this->getUnjailedPath($path), $mtime); } + #[\Override] public function getLocalFile(string $path): string|false { return $this->getWrapperStorage()->getLocalFile($this->getUnjailedPath($path)); } + #[\Override] public function hasUpdated(string $path, int $time): bool { return $this->getWrapperStorage()->hasUpdated($this->getUnjailedPath($path), $time); } + #[\Override] public function getCache(string $path = '', ?IStorage $storage = null): ICache { $sourceCache = $this->getWrapperStorage()->getCache($this->getUnjailedPath($path)); return new CacheJail($sourceCache, $this->rootPath); } + #[\Override] public function getOwner(string $path): string|false { return $this->getWrapperStorage()->getOwner($this->getUnjailedPath($path)); } + #[\Override] public function getWatcher(string $path = '', ?IStorage $storage = null): IWatcher { $sourceWatcher = $this->getWrapperStorage()->getWatcher($this->getUnjailedPath($path), $this->getWrapperStorage()); return new JailWatcher($sourceWatcher, $this->rootPath); } + #[\Override] public function getETag(string $path): string|false { return $this->getWrapperStorage()->getETag($this->getUnjailedPath($path)); } + #[\Override] public function getMetaData(string $path): ?array { return $this->getWrapperStorage()->getMetaData($this->getUnjailedPath($path)); } + #[\Override] public function acquireLock(string $path, int $type, ILockingProvider $provider): void { $this->getWrapperStorage()->acquireLock($this->getUnjailedPath($path), $type, $provider); } + #[\Override] public function releaseLock(string $path, int $type, ILockingProvider $provider): void { $this->getWrapperStorage()->releaseLock($this->getUnjailedPath($path), $type, $provider); } + #[\Override] public function changeLock(string $path, int $type, ILockingProvider $provider): void { $this->getWrapperStorage()->changeLock($this->getUnjailedPath($path), $type, $provider); } @@ -233,6 +270,7 @@ class Jail extends Wrapper { return [$this->getWrapperStorage(), $this->getUnjailedPath($path)]; } + #[\Override] public function copyFromStorage(IStorage $sourceStorage, string $sourceInternalPath, string $targetInternalPath): bool { if ($sourceStorage === $this) { return $this->copy($sourceInternalPath, $targetInternalPath); @@ -240,6 +278,7 @@ class Jail extends Wrapper { return $this->getWrapperStorage()->copyFromStorage($sourceStorage, $sourceInternalPath, $this->getUnjailedPath($targetInternalPath)); } + #[\Override] public function moveFromStorage(IStorage $sourceStorage, string $sourceInternalPath, string $targetInternalPath): bool { if ($sourceStorage === $this) { return $this->rename($sourceInternalPath, $targetInternalPath); @@ -247,6 +286,7 @@ class Jail extends Wrapper { return $this->getWrapperStorage()->moveFromStorage($sourceStorage, $sourceInternalPath, $this->getUnjailedPath($targetInternalPath)); } + #[\Override] public function getPropagator(?IStorage $storage = null): IPropagator { if (isset($this->propagator)) { return $this->propagator; @@ -259,6 +299,7 @@ class Jail extends Wrapper { return $this->propagator; } + #[\Override] public function writeStream(string $path, $stream, ?int $size = null): int { $storage = $this->getWrapperStorage(); if ($storage->instanceOfStorage(IWriteStreamStorage::class)) { @@ -277,6 +318,7 @@ class Jail extends Wrapper { } } + #[\Override] public function getDirectoryContent(string $directory): \Traversable { return $this->getWrapperStorage()->getDirectoryContent($this->getUnjailedPath($directory)); } diff --git a/lib/private/Files/Storage/Wrapper/KnownMtime.php b/lib/private/Files/Storage/Wrapper/KnownMtime.php index 657c6c9250c..da10e940753 100644 --- a/lib/private/Files/Storage/Wrapper/KnownMtime.php +++ b/lib/private/Files/Storage/Wrapper/KnownMtime.php @@ -26,6 +26,7 @@ class KnownMtime extends Wrapper { $this->clock = $parameters['clock']; } + #[\Override] public function file_put_contents(string $path, mixed $data): int|float|false { $result = parent::file_put_contents($path, $data); if ($result) { @@ -35,6 +36,7 @@ class KnownMtime extends Wrapper { return $result; } + #[\Override] public function stat(string $path): array|false { $stat = parent::stat($path); if ($stat) { @@ -43,6 +45,7 @@ class KnownMtime extends Wrapper { return $stat; } + #[\Override] public function getMetaData(string $path): ?array { $stat = parent::getMetaData($path); if ($stat) { @@ -58,11 +61,13 @@ class KnownMtime extends Wrapper { } } + #[\Override] public function filemtime(string $path): int|false { $knownMtime = $this->knowMtimes->get($path) ?? 0; return max(parent::filemtime($path), $knownMtime); } + #[\Override] public function mkdir(string $path): bool { $result = parent::mkdir($path); if ($result) { @@ -71,6 +76,7 @@ class KnownMtime extends Wrapper { return $result; } + #[\Override] public function rmdir(string $path): bool { $result = parent::rmdir($path); if ($result) { @@ -79,6 +85,7 @@ class KnownMtime extends Wrapper { return $result; } + #[\Override] public function unlink(string $path): bool { $result = parent::unlink($path); if ($result) { @@ -87,6 +94,7 @@ class KnownMtime extends Wrapper { return $result; } + #[\Override] public function rename(string $source, string $target): bool { $result = parent::rename($source, $target); if ($result) { @@ -96,6 +104,7 @@ class KnownMtime extends Wrapper { return $result; } + #[\Override] public function copy(string $source, string $target): bool { $result = parent::copy($source, $target); if ($result) { @@ -104,6 +113,7 @@ class KnownMtime extends Wrapper { return $result; } + #[\Override] public function fopen(string $path, string $mode) { $result = parent::fopen($path, $mode); if ($result && $mode === 'w') { @@ -112,6 +122,7 @@ class KnownMtime extends Wrapper { return $result; } + #[\Override] public function touch(string $path, ?int $mtime = null): bool { $result = parent::touch($path, $mtime); if ($result) { @@ -120,6 +131,7 @@ class KnownMtime extends Wrapper { return $result; } + #[\Override] public function copyFromStorage(IStorage $sourceStorage, string $sourceInternalPath, string $targetInternalPath): bool { $result = parent::copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); if ($result) { @@ -128,6 +140,7 @@ class KnownMtime extends Wrapper { return $result; } + #[\Override] public function moveFromStorage(IStorage $sourceStorage, string $sourceInternalPath, string $targetInternalPath): bool { $result = parent::moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); if ($result) { @@ -136,6 +149,7 @@ class KnownMtime extends Wrapper { return $result; } + #[\Override] public function writeStream(string $path, $stream, ?int $size = null): int { $result = parent::writeStream($path, $stream, $size); if ($result) { diff --git a/lib/private/Files/Storage/Wrapper/PermissionsMask.php b/lib/private/Files/Storage/Wrapper/PermissionsMask.php index e67885b4397..15061b7c023 100644 --- a/lib/private/Files/Storage/Wrapper/PermissionsMask.php +++ b/lib/private/Files/Storage/Wrapper/PermissionsMask.php @@ -42,26 +42,32 @@ class PermissionsMask extends Wrapper { return ($this->mask & $permissions) === $permissions; } + #[\Override] public function isUpdatable(string $path): bool { return $this->checkMask(Constants::PERMISSION_UPDATE) && parent::isUpdatable($path); } + #[\Override] public function isCreatable(string $path): bool { return $this->checkMask(Constants::PERMISSION_CREATE) && parent::isCreatable($path); } + #[\Override] public function isDeletable(string $path): bool { return $this->checkMask(Constants::PERMISSION_DELETE) && parent::isDeletable($path); } + #[\Override] public function isSharable(string $path): bool { return $this->checkMask(Constants::PERMISSION_SHARE) && parent::isSharable($path); } + #[\Override] public function getPermissions(string $path): int { return $this->getWrapperStorage()->getPermissions($path) & $this->mask; } + #[\Override] public function rename(string $source, string $target): bool { //This is a rename of the transfer file to the original file if (dirname($source) === dirname($target) && strpos($source, '.ocTransferId') > 0) { @@ -70,32 +76,39 @@ class PermissionsMask extends Wrapper { return $this->checkMask(Constants::PERMISSION_UPDATE) && parent::rename($source, $target); } + #[\Override] public function copy(string $source, string $target): bool { return $this->checkMask(Constants::PERMISSION_CREATE) && parent::copy($source, $target); } + #[\Override] public function touch(string $path, ?int $mtime = null): bool { $permissions = $this->file_exists($path) ? Constants::PERMISSION_UPDATE : Constants::PERMISSION_CREATE; return $this->checkMask($permissions) && parent::touch($path, $mtime); } + #[\Override] public function mkdir(string $path): bool { return $this->checkMask(Constants::PERMISSION_CREATE) && parent::mkdir($path); } + #[\Override] public function rmdir(string $path): bool { return $this->checkMask(Constants::PERMISSION_DELETE) && parent::rmdir($path); } + #[\Override] public function unlink(string $path): bool { return $this->checkMask(Constants::PERMISSION_DELETE) && parent::unlink($path); } + #[\Override] public function file_put_contents(string $path, mixed $data): int|float|false { $permissions = $this->file_exists($path) ? Constants::PERMISSION_UPDATE : Constants::PERMISSION_CREATE; return $this->checkMask($permissions) ? parent::file_put_contents($path, $data) : false; } + #[\Override] public function fopen(string $path, string $mode) { if ($mode === 'r' || $mode === 'rb') { return parent::fopen($path, $mode); @@ -105,6 +118,7 @@ class PermissionsMask extends Wrapper { } } + #[\Override] public function getCache(string $path = '', ?IStorage $storage = null): ICache { if (!$storage) { $storage = $this; @@ -113,6 +127,7 @@ class PermissionsMask extends Wrapper { return new CachePermissionsMask($sourceCache, $this->mask); } + #[\Override] public function getMetaData(string $path): ?array { $data = parent::getMetaData($path); @@ -123,6 +138,7 @@ class PermissionsMask extends Wrapper { return $data; } + #[\Override] public function getScanner(string $path = '', ?IStorage $storage = null): IScanner { if (!$storage) { $storage = $this->getWrapperStorage(); @@ -130,6 +146,7 @@ class PermissionsMask extends Wrapper { return parent::getScanner($path, $storage); } + #[\Override] public function getDirectoryContent(string $directory): \Traversable { foreach ($this->getWrapperStorage()->getDirectoryContent($directory) as $data) { $data['scan_permissions'] ??= $data['permissions']; diff --git a/lib/private/Files/Storage/Wrapper/Quota.php b/lib/private/Files/Storage/Wrapper/Quota.php index ce0de5bb711..e0c3366146e 100644 --- a/lib/private/Files/Storage/Wrapper/Quota.php +++ b/lib/private/Files/Storage/Wrapper/Quota.php @@ -71,6 +71,7 @@ class Quota extends Wrapper { } } + #[\Override] public function free_space(string $path): int|float|false { if (!$this->hasQuota()) { return $this->getWrapperStorage()->free_space($path); @@ -91,6 +92,7 @@ class Quota extends Wrapper { } } + #[\Override] public function file_put_contents(string $path, mixed $data): int|float|false { if (!$this->hasQuota()) { return $this->getWrapperStorage()->file_put_contents($path, $data); @@ -103,6 +105,7 @@ class Quota extends Wrapper { } } + #[\Override] public function copy(string $source, string $target): bool { if (!$this->hasQuota()) { return $this->getWrapperStorage()->copy($source, $target); @@ -115,6 +118,7 @@ class Quota extends Wrapper { } } + #[\Override] public function fopen(string $path, string $mode) { if (!$this->hasQuota()) { return $this->getWrapperStorage()->fopen($path, $mode); @@ -154,6 +158,7 @@ class Quota extends Wrapper { return str_starts_with(ltrim($path, '/'), 'files/'); } + #[\Override] public function copyFromStorage(IStorage $sourceStorage, string $sourceInternalPath, string $targetInternalPath): bool { if (!$this->hasQuota()) { return $this->getWrapperStorage()->copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); @@ -166,6 +171,7 @@ class Quota extends Wrapper { } } + #[\Override] public function moveFromStorage(IStorage $sourceStorage, string $sourceInternalPath, string $targetInternalPath): bool { if (!$this->hasQuota()) { return $this->getWrapperStorage()->moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); @@ -178,6 +184,7 @@ class Quota extends Wrapper { } } + #[\Override] public function mkdir(string $path): bool { if (!$this->hasQuota()) { return $this->getWrapperStorage()->mkdir($path); @@ -190,6 +197,7 @@ class Quota extends Wrapper { return parent::mkdir($path); } + #[\Override] public function touch(string $path, ?int $mtime = null): bool { if (!$this->hasQuota()) { return $this->getWrapperStorage()->touch($path, $mtime); diff --git a/lib/private/Files/Storage/Wrapper/Wrapper.php b/lib/private/Files/Storage/Wrapper/Wrapper.php index d9928626ed1..ff43e75d6ec 100644 --- a/lib/private/Files/Storage/Wrapper/Wrapper.php +++ b/lib/private/Files/Storage/Wrapper/Wrapper.php @@ -55,122 +55,152 @@ class Wrapper implements Storage, ILockingStorage, IWriteStreamStorage { return $this->storage; } + #[\Override] public function getId(): string { return $this->getWrapperStorage()->getId(); } + #[\Override] public function mkdir(string $path): bool { return $this->getWrapperStorage()->mkdir($path); } + #[\Override] public function rmdir(string $path): bool { return $this->getWrapperStorage()->rmdir($path); } + #[\Override] public function opendir(string $path) { return $this->getWrapperStorage()->opendir($path); } + #[\Override] public function is_dir(string $path): bool { return $this->getWrapperStorage()->is_dir($path); } + #[\Override] public function is_file(string $path): bool { return $this->getWrapperStorage()->is_file($path); } + #[\Override] public function stat(string $path): array|false { return $this->getWrapperStorage()->stat($path); } + #[\Override] public function filetype(string $path): string|false { return $this->getWrapperStorage()->filetype($path); } + #[\Override] public function filesize(string $path): int|float|false { return $this->getWrapperStorage()->filesize($path); } + #[\Override] public function isCreatable(string $path): bool { return $this->getWrapperStorage()->isCreatable($path); } + #[\Override] public function isReadable(string $path): bool { return $this->getWrapperStorage()->isReadable($path); } + #[\Override] public function isUpdatable(string $path): bool { return $this->getWrapperStorage()->isUpdatable($path); } + #[\Override] public function isDeletable(string $path): bool { return $this->getWrapperStorage()->isDeletable($path); } + #[\Override] public function isSharable(string $path): bool { return $this->getWrapperStorage()->isSharable($path); } + #[\Override] public function getPermissions(string $path): int { return $this->getWrapperStorage()->getPermissions($path); } + #[\Override] public function file_exists(string $path): bool { return $this->getWrapperStorage()->file_exists($path); } + #[\Override] public function filemtime(string $path): int|false { return $this->getWrapperStorage()->filemtime($path); } + #[\Override] public function file_get_contents(string $path): string|false { return $this->getWrapperStorage()->file_get_contents($path); } + #[\Override] public function file_put_contents(string $path, mixed $data): int|float|false { return $this->getWrapperStorage()->file_put_contents($path, $data); } + #[\Override] public function unlink(string $path): bool { return $this->getWrapperStorage()->unlink($path); } + #[\Override] public function rename(string $source, string $target): bool { return $this->getWrapperStorage()->rename($source, $target); } + #[\Override] public function copy(string $source, string $target): bool { return $this->getWrapperStorage()->copy($source, $target); } + #[\Override] public function fopen(string $path, string $mode) { return $this->getWrapperStorage()->fopen($path, $mode); } + #[\Override] public function getMimeType(string $path): string|false { return $this->getWrapperStorage()->getMimeType($path); } + #[\Override] public function hash(string $type, string $path, bool $raw = false): string|false { return $this->getWrapperStorage()->hash($type, $path, $raw); } + #[\Override] public function free_space(string $path): int|float|false { return $this->getWrapperStorage()->free_space($path); } + #[\Override] public function touch(string $path, ?int $mtime = null): bool { return $this->getWrapperStorage()->touch($path, $mtime); } + #[\Override] public function getLocalFile(string $path): string|false { return $this->getWrapperStorage()->getLocalFile($path); } + #[\Override] public function hasUpdated(string $path, int $time): bool { return $this->getWrapperStorage()->hasUpdated($path, $time); } + #[\Override] public function getCache(string $path = '', ?IStorage $storage = null): ICache { if (!$storage instanceof IStorage) { $storage = $this; @@ -179,6 +209,7 @@ class Wrapper implements Storage, ILockingStorage, IWriteStreamStorage { return $this->getWrapperStorage()->getCache($path, $storage); } + #[\Override] public function getScanner(string $path = '', ?IStorage $storage = null): IScanner { if (!$storage instanceof IStorage) { $storage = $this; @@ -187,10 +218,12 @@ class Wrapper implements Storage, ILockingStorage, IWriteStreamStorage { return $this->getWrapperStorage()->getScanner($path, $storage); } + #[\Override] public function getOwner(string $path): string|false { return $this->getWrapperStorage()->getOwner($path); } + #[\Override] public function getWatcher(string $path = '', ?IStorage $storage = null): IWatcher { if (!$storage instanceof IStorage) { $storage = $this; @@ -199,6 +232,7 @@ class Wrapper implements Storage, ILockingStorage, IWriteStreamStorage { return $this->getWrapperStorage()->getWatcher($path, $storage); } + #[\Override] public function getPropagator(?IStorage $storage = null): IPropagator { if (!$storage instanceof IStorage) { $storage = $this; @@ -207,6 +241,7 @@ class Wrapper implements Storage, ILockingStorage, IWriteStreamStorage { return $this->getWrapperStorage()->getPropagator($storage); } + #[\Override] public function getUpdater(?IStorage $storage = null): IUpdater { if (!$storage instanceof IStorage) { $storage = $this; @@ -215,22 +250,27 @@ class Wrapper implements Storage, ILockingStorage, IWriteStreamStorage { return $this->getWrapperStorage()->getUpdater($storage); } + #[\Override] public function getStorageCache(): \OC\Files\Cache\Storage { return $this->getWrapperStorage()->getStorageCache(); } + #[\Override] public function getETag(string $path): string|false { return $this->getWrapperStorage()->getETag($path); } + #[\Override] public function test(): bool { return $this->getWrapperStorage()->test(); } + #[\Override] public function isLocal(): bool { return $this->getWrapperStorage()->isLocal(); } + #[\Override] public function instanceOfStorage(string $class): bool { return is_a($this, $class) || $this->getWrapperStorage()->instanceOfStorage($class); } @@ -277,18 +317,22 @@ class Wrapper implements Storage, ILockingStorage, IWriteStreamStorage { return $this->getWrapperStorage()->getDirectDownloadById($fileId); } + #[\Override] public function getAvailability(): array { return $this->getWrapperStorage()->getAvailability(); } + #[\Override] public function setAvailability(bool $isAvailable): void { $this->getWrapperStorage()->setAvailability($isAvailable); } + #[\Override] public function verifyPath(string $path, string $fileName): void { $this->getWrapperStorage()->verifyPath($path, $fileName); } + #[\Override] public function copyFromStorage(IStorage $sourceStorage, string $sourceInternalPath, string $targetInternalPath): bool { if ($sourceStorage === $this) { return $this->copy($sourceInternalPath, $targetInternalPath); @@ -297,6 +341,7 @@ class Wrapper implements Storage, ILockingStorage, IWriteStreamStorage { return $this->getWrapperStorage()->copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); } + #[\Override] public function moveFromStorage(IStorage $sourceStorage, string $sourceInternalPath, string $targetInternalPath): bool { if ($sourceStorage === $this) { return $this->rename($sourceInternalPath, $targetInternalPath); @@ -305,10 +350,12 @@ class Wrapper implements Storage, ILockingStorage, IWriteStreamStorage { return $this->getWrapperStorage()->moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); } + #[\Override] public function getMetaData(string $path): ?array { return $this->getWrapperStorage()->getMetaData($path); } + #[\Override] public function acquireLock(string $path, int $type, ILockingProvider $provider): void { $storage = $this->getWrapperStorage(); if ($storage->instanceOfStorage(ILockingStorage::class)) { @@ -316,6 +363,7 @@ class Wrapper implements Storage, ILockingStorage, IWriteStreamStorage { } } + #[\Override] public function releaseLock(string $path, int $type, ILockingProvider $provider): void { $storage = $this->getWrapperStorage(); if ($storage->instanceOfStorage(ILockingStorage::class)) { @@ -323,6 +371,7 @@ class Wrapper implements Storage, ILockingStorage, IWriteStreamStorage { } } + #[\Override] public function changeLock(string $path, int $type, ILockingProvider $provider): void { $storage = $this->getWrapperStorage(); if ($storage->instanceOfStorage(ILockingStorage::class)) { @@ -330,10 +379,12 @@ class Wrapper implements Storage, ILockingStorage, IWriteStreamStorage { } } + #[\Override] public function needsPartFile(): bool { return $this->getWrapperStorage()->needsPartFile(); } + #[\Override] public function writeStream(string $path, $stream, ?int $size = null): int { $storage = $this->getWrapperStorage(); if ($storage->instanceOfStorage(IWriteStreamStorage::class)) { @@ -356,6 +407,7 @@ class Wrapper implements Storage, ILockingStorage, IWriteStreamStorage { return $count; } + #[\Override] public function getDirectoryContent(string $directory): \Traversable { return $this->getWrapperStorage()->getDirectoryContent($directory); } @@ -373,6 +425,7 @@ class Wrapper implements Storage, ILockingStorage, IWriteStreamStorage { return false; } + #[\Override] public function setOwner(?string $user): void { $this->getWrapperStorage()->setOwner($user); } diff --git a/lib/private/Files/Stream/Encryption.php b/lib/private/Files/Stream/Encryption.php index ef147ec421f..1c662aa023c 100644 --- a/lib/private/Files/Stream/Encryption.php +++ b/lib/private/Files/Stream/Encryption.php @@ -142,6 +142,7 @@ class Encryption extends Wrapper { * @return resource * @throws \BadMethodCallException */ + #[\Override] protected static function wrapSource($source, $context = [], $protocol = null, $class = null, $mode = 'r+') { try { if ($protocol === null) { @@ -182,6 +183,7 @@ class Encryption extends Wrapper { * @return array * @throws \BadMethodCallException */ + #[\Override] protected function loadContext($name = null) { $context = parent::loadContext($name); @@ -195,6 +197,7 @@ class Encryption extends Wrapper { return $context; } + #[\Override] public function stream_open($path, $mode, $options, &$opened_path) { $this->loadContext('ocencryption'); @@ -246,10 +249,12 @@ class Encryption extends Wrapper { return true; } + #[\Override] public function stream_eof() { return $this->position >= $this->unencryptedSize; } + #[\Override] public function stream_read($count) { $result = ''; @@ -301,6 +306,7 @@ class Encryption extends Wrapper { return $data; } + #[\Override] public function stream_write($data) { $length = 0; // loop over $data to fit it in 6126 sized unencrypted blocks @@ -351,10 +357,12 @@ class Encryption extends Wrapper { return $length; } + #[\Override] public function stream_tell() { return $this->position; } + #[\Override] public function stream_seek($offset, $whence = SEEK_SET) { $return = false; @@ -390,6 +398,7 @@ class Encryption extends Wrapper { return $return; } + #[\Override] public function stream_close() { $this->flush('end'); $position = (int)floor($this->position / $this->unencryptedBlockSize); @@ -496,6 +505,7 @@ class Encryption extends Wrapper { * @param array $options * @return bool */ + #[\Override] public function dir_opendir($path, $options) { return false; } diff --git a/lib/private/Files/Stream/HashWrapper.php b/lib/private/Files/Stream/HashWrapper.php index 5956ad92549..16206e56c4a 100644 --- a/lib/private/Files/Stream/HashWrapper.php +++ b/lib/private/Files/Stream/HashWrapper.php @@ -34,20 +34,24 @@ class HashWrapper extends Wrapper { return true; } + #[\Override] public function dir_opendir($path, $options) { return $this->open(); } + #[\Override] public function stream_open($path, $mode, $options, &$opened_path) { return $this->open(); } + #[\Override] public function stream_read($count) { $result = parent::stream_read($count); hash_update($this->hash, $result); return $result; } + #[\Override] public function stream_close() { if (is_callable($this->callback)) { // if the stream is closed as a result of the end-of-request GC, the hash context might be cleaned up before this stream diff --git a/lib/private/Files/Stream/Quota.php b/lib/private/Files/Stream/Quota.php index 3c7e09c633b..755d9b428d6 100644 --- a/lib/private/Files/Stream/Quota.php +++ b/lib/private/Files/Stream/Quota.php @@ -35,6 +35,7 @@ class Quota extends Wrapper { return Wrapper::wrapSource($stream, $context, 'quota', self::class); } + #[\Override] public function stream_open($path, $mode, $options, &$opened_path) { $context = $this->loadContext('quota'); $this->source = $context['source']; @@ -43,10 +44,12 @@ class Quota extends Wrapper { return true; } + #[\Override] public function dir_opendir($path, $options) { return false; } + #[\Override] public function stream_seek($offset, $whence = SEEK_SET) { if ($whence === SEEK_END) { // go to the end to find out last position's offset @@ -67,11 +70,13 @@ class Quota extends Wrapper { return fseek($this->source, $offset, $whence) === 0; } + #[\Override] public function stream_read($count) { $this->limit -= $count; return fread($this->source, $count); } + #[\Override] public function stream_write($data) { $size = strlen($data); if ($size > $this->limit) { diff --git a/lib/private/Files/Stream/SeekableHttpStream.php b/lib/private/Files/Stream/SeekableHttpStream.php index 6ce0a880e8d..cefa8ced1db 100644 --- a/lib/private/Files/Stream/SeekableHttpStream.php +++ b/lib/private/Files/Stream/SeekableHttpStream.php @@ -144,6 +144,7 @@ class SeekableHttpStream implements File { return is_resource($this->current); } + #[\Override] public function stream_open($path, $mode, $options, &$opened_path) { $options = stream_context_get_options($this->context)[self::PROTOCOL]; $this->openCallback = $options['callback']; @@ -151,6 +152,7 @@ class SeekableHttpStream implements File { return $this->reconnect(0); } + #[\Override] public function stream_read($count) { if (!$this->getCurrent()) { return false; @@ -160,6 +162,7 @@ class SeekableHttpStream implements File { return $ret; } + #[\Override] public function stream_seek($offset, $whence = SEEK_SET) { switch ($whence) { case SEEK_SET: @@ -195,10 +198,12 @@ class SeekableHttpStream implements File { return true; } + #[\Override] public function stream_tell() { return $this->offset; } + #[\Override] public function stream_stat() { if ($this->getCurrent()) { $stat = fstat($this->getCurrent()); @@ -211,6 +216,7 @@ class SeekableHttpStream implements File { } } + #[\Override] public function stream_eof() { if ($this->getCurrent()) { return feof($this->getCurrent()); @@ -219,6 +225,7 @@ class SeekableHttpStream implements File { } } + #[\Override] public function stream_close() { if ($this->hasOpenStream()) { fclose($this->current); @@ -226,22 +233,27 @@ class SeekableHttpStream implements File { $this->current = null; } + #[\Override] public function stream_write($data) { return false; } + #[\Override] public function stream_set_option($option, $arg1, $arg2) { return false; } + #[\Override] public function stream_truncate($size) { return false; } + #[\Override] public function stream_lock($operation) { return false; } + #[\Override] public function stream_flush() { return; //noop because readonly stream } diff --git a/lib/private/Files/Template/TemplateManager.php b/lib/private/Files/Template/TemplateManager.php index d965a41957a..54c082c006f 100644 --- a/lib/private/Files/Template/TemplateManager.php +++ b/lib/private/Files/Template/TemplateManager.php @@ -295,6 +295,7 @@ class TemplateManager implements ITemplateManager { ]; } + #[\Override] public function hasTemplateDirectory(): bool { try { $this->getTemplateFolder(); diff --git a/lib/private/Files/Type/Detection.php b/lib/private/Files/Type/Detection.php index f056c5bdd58..67a65cdf0e0 100644 --- a/lib/private/Files/Type/Detection.php +++ b/lib/private/Files/Type/Detection.php @@ -121,6 +121,7 @@ class Detection implements IMimeTypeDetector { /** * @return array */ + #[\Override] public function getAllAliases(): array { $this->loadAliases(); return $this->mimeTypeAlias; @@ -149,6 +150,7 @@ class Detection implements IMimeTypeDetector { /** * @return array */ + #[\Override] public function getAllMappings(): array { $this->loadMappings(); return $this->mimeTypes; @@ -168,6 +170,7 @@ class Detection implements IMimeTypeDetector { /** * @return array */ + #[\Override] public function getAllNamings(): array { $this->loadNamings(); return $this->mimeTypesNames; @@ -179,6 +182,7 @@ class Detection implements IMimeTypeDetector { * @param string $path * @return string */ + #[\Override] public function detectPath($path): string { $this->loadMappings(); @@ -211,6 +215,7 @@ class Detection implements IMimeTypeDetector { * @return string * @since 18.0.0 */ + #[\Override] public function detectContent(string $path): string { $this->loadMappings(); @@ -274,6 +279,7 @@ class Detection implements IMimeTypeDetector { * @param string $path * @return string */ + #[\Override] public function detect($path): string { $mimeType = $this->detectPath($path); @@ -290,6 +296,7 @@ class Detection implements IMimeTypeDetector { * @param string $data * @return string */ + #[\Override] public function detectString($data): string { if (class_exists(finfo::class)) { $finfo = new finfo(FILEINFO_MIME_TYPE); @@ -314,6 +321,7 @@ class Detection implements IMimeTypeDetector { * @param string $mimeType * @return string */ + #[\Override] public function getSecureMimeType($mimeType): string { $this->loadMappings(); @@ -325,6 +333,7 @@ class Detection implements IMimeTypeDetector { * @param string $mimeType the MIME type * @return string the url */ + #[\Override] public function mimeTypeIcon($mimeType): string { $this->loadAliases(); diff --git a/lib/private/Files/Type/Loader.php b/lib/private/Files/Type/Loader.php index 5fbe4139759..48a62bc2858 100644 --- a/lib/private/Files/Type/Loader.php +++ b/lib/private/Files/Type/Loader.php @@ -40,6 +40,7 @@ class Loader implements IMimeTypeLoader { /** * Get a mimetype from its ID */ + #[\Override] public function getMimetypeById(int $id): ?string { if (!$this->mimetypes) { $this->loadMimetypes(); @@ -53,6 +54,7 @@ class Loader implements IMimeTypeLoader { /** * Get a mimetype ID, adding the mimetype to the DB if it does not exist */ + #[\Override] public function getId(string $mimetype): int { if (!$this->mimetypeIds) { $this->loadMimetypes(); @@ -66,6 +68,7 @@ class Loader implements IMimeTypeLoader { /** * Test if a mimetype exists in the database */ + #[\Override] public function exists(string $mimetype): bool { if (!$this->mimetypeIds) { $this->loadMimetypes(); @@ -76,6 +79,7 @@ class Loader implements IMimeTypeLoader { /** * Clear all loaded mimetypes, allow for re-loading */ + #[\Override] public function reset(): void { $this->mimetypes = []; $this->mimetypeIds = []; @@ -145,6 +149,7 @@ class Loader implements IMimeTypeLoader { * * @return int number of changed rows */ + #[\Override] public function updateFilecache(string $ext, int $mimeTypeId): int { $folderMimeTypeId = $this->getId('httpd/unix-directory'); $update = $this->dbConnection->getQueryBuilder(); diff --git a/lib/private/FilesMetadata/FilesMetadataManager.php b/lib/private/FilesMetadata/FilesMetadataManager.php index 9282513109b..b6077f1f271 100644 --- a/lib/private/FilesMetadata/FilesMetadataManager.php +++ b/lib/private/FilesMetadata/FilesMetadataManager.php @@ -72,6 +72,7 @@ class FilesMetadataManager implements IFilesMetadataManager { * @see self::PROCESS_LIVE * @since 28.0.0 */ + #[\Override] public function refreshMetadata( Node $node, int $process = self::PROCESS_LIVE, @@ -122,6 +123,7 @@ class FilesMetadataManager implements IFilesMetadataManager { * @throws FilesMetadataNotFoundException if not found * @since 28.0.0 */ + #[\Override] public function getMetadata(int $fileId, bool $generate = false): IFilesMetadata { try { return $this->metadataRequestService->getMetadataFromFileId($fileId); @@ -143,6 +145,7 @@ class FilesMetadataManager implements IFilesMetadataManager { * @psalm-return array * @since 28.0.0 */ + #[\Override] public function getMetadataForFiles(array $fileIds): array { return $this->metadataRequestService->getMetadataFromFileIds($fileIds); } @@ -154,6 +157,7 @@ class FilesMetadataManager implements IFilesMetadataManager { * @throws FilesMetadataException if metadata seems malformed * @since 28.0.0 */ + #[\Override] public function saveMetadata(IFilesMetadata $filesMetadata): void { if ($filesMetadata->getFileId() === 0 || !$filesMetadata->updated()) { return; @@ -200,6 +204,7 @@ class FilesMetadataManager implements IFilesMetadataManager { * @inheritDoc * @since 28.0.0 */ + #[\Override] public function deleteMetadata(int $fileId): void { try { $this->metadataRequestService->dropMetadata($fileId); @@ -214,6 +219,7 @@ class FilesMetadataManager implements IFilesMetadataManager { } } + #[\Override] public function deleteMetadataForFiles(int $storage, array $fileIds): void { try { $this->metadataRequestService->dropMetadataForFiles($storage, $fileIds); @@ -238,6 +244,7 @@ class FilesMetadataManager implements IFilesMetadataManager { * @see IMetadataQuery * @since 28.0.0 */ + #[\Override] public function getMetadataQuery( IQueryBuilder $qb, string $fileTableAlias, @@ -251,6 +258,7 @@ class FilesMetadataManager implements IFilesMetadataManager { * @return IFilesMetadata * @since 28.0.0 */ + #[\Override] public function getKnownMetadata(): IFilesMetadata { if ($this->all !== null) { return $this->all; @@ -286,6 +294,7 @@ class FilesMetadataManager implements IFilesMetadataManager { * @see IMetadataValueWrapper::EDIT_REQ_WRITE_PERMISSION * @see IMetadataValueWrapper::EDIT_REQ_READ_PERMISSION */ + #[\Override] public function initMetadata( string $key, string $type, diff --git a/lib/private/FilesMetadata/Job/UpdateSingleMetadata.php b/lib/private/FilesMetadata/Job/UpdateSingleMetadata.php index 5746493ddef..2a01fd665cd 100644 --- a/lib/private/FilesMetadata/Job/UpdateSingleMetadata.php +++ b/lib/private/FilesMetadata/Job/UpdateSingleMetadata.php @@ -34,6 +34,7 @@ class UpdateSingleMetadata extends QueuedJob { parent::__construct($time); } + #[\Override] protected function run($argument) { [$userId, $fileId] = $argument; diff --git a/lib/private/FilesMetadata/Listener/MetadataDelete.php b/lib/private/FilesMetadata/Listener/MetadataDelete.php index 5a404614df0..018706cdcd0 100644 --- a/lib/private/FilesMetadata/Listener/MetadataDelete.php +++ b/lib/private/FilesMetadata/Listener/MetadataDelete.php @@ -27,6 +27,7 @@ class MetadataDelete implements IEventListener { ) { } + #[\Override] public function handle(Event $event): void { if (!($event instanceof CacheEntriesRemovedEvent)) { return; diff --git a/lib/private/FilesMetadata/Listener/MetadataUpdate.php b/lib/private/FilesMetadata/Listener/MetadataUpdate.php index 4c5c913c740..057021535d7 100644 --- a/lib/private/FilesMetadata/Listener/MetadataUpdate.php +++ b/lib/private/FilesMetadata/Listener/MetadataUpdate.php @@ -33,6 +33,7 @@ class MetadataUpdate implements IEventListener { /** * @param Event $event */ + #[\Override] public function handle(Event $event): void { if (!($event instanceof NodeWrittenEvent)) { return; diff --git a/lib/private/FilesMetadata/MetadataQuery.php b/lib/private/FilesMetadata/MetadataQuery.php index 19495c38e5e..34d06779610 100644 --- a/lib/private/FilesMetadata/MetadataQuery.php +++ b/lib/private/FilesMetadata/MetadataQuery.php @@ -53,6 +53,7 @@ class MetadataQuery implements IMetadataQuery { * @see self::extractMetadata() * @since 28.0.0 */ + #[\Override] public function retrieveMetadata(): void { $this->queryBuilder->selectAlias($this->alias . '.json', 'meta_json'); $this->queryBuilder->selectAlias($this->alias . '.sync_token', 'meta_sync_token'); @@ -70,6 +71,7 @@ class MetadataQuery implements IMetadataQuery { * @see self::retrieveMetadata() * @since 28.0.0 */ + #[\Override] public function extractMetadata(array $row): IFilesMetadata { $fileId = (array_key_exists($this->fileIdField, $row)) ? $row[$this->fileIdField] : 0; $metadata = new FilesMetadata((int)$fileId); @@ -89,6 +91,7 @@ class MetadataQuery implements IMetadataQuery { * @inheritDoc * @since 28.0.0 */ + #[\Override] public function joinIndex(string $metadataKey, bool $enforce = false): string { if (array_key_exists($metadataKey, $this->knownJoinedIndex)) { return $this->knownJoinedIndex[$metadataKey]; @@ -140,6 +143,7 @@ class MetadataQuery implements IMetadataQuery { * @throws FilesMetadataNotFoundException * @since 28.0.0 */ + #[\Override] public function getMetadataKeyField(string $metadataKey): string { return $this->joinedTableAlias($metadataKey) . '.meta_key'; } @@ -154,6 +158,7 @@ class MetadataQuery implements IMetadataQuery { * @throws FilesMetadataTypeException is metadataKey is not set as indexed * @since 28.0.0 */ + #[\Override] public function getMetadataValueField(string $metadataKey): string { if ($this->manager instanceof IFilesMetadataManager) { /** diff --git a/lib/private/FilesMetadata/Model/FilesMetadata.php b/lib/private/FilesMetadata/Model/FilesMetadata.php index b66e1fe3711..85774b82027 100644 --- a/lib/private/FilesMetadata/Model/FilesMetadata.php +++ b/lib/private/FilesMetadata/Model/FilesMetadata.php @@ -39,6 +39,7 @@ class FilesMetadata implements IFilesMetadata { * @return int related file id * @since 28.0.0 */ + #[\Override] public function getFileId(): int { return $this->fileId; } @@ -64,6 +65,7 @@ class FilesMetadata implements IFilesMetadata { * @return int timestamp * @since 28.0.0 */ + #[\Override] public function lastUpdateTimestamp(): int { return $this->lastUpdate; } @@ -73,6 +75,7 @@ class FilesMetadata implements IFilesMetadata { * @return string token * @since 28.0.0 */ + #[\Override] public function getSyncToken(): string { return $this->syncToken; } @@ -82,6 +85,7 @@ class FilesMetadata implements IFilesMetadata { * @return string[] list of keys * @since 28.0.0 */ + #[\Override] public function getKeys(): array { return array_keys($this->metadata); } @@ -93,6 +97,7 @@ class FilesMetadata implements IFilesMetadata { * @return bool TRUE if key exist * @since 28.0.0 */ + #[\Override] public function hasKey(string $needle): bool { return (in_array($needle, $this->getKeys())); } @@ -102,6 +107,7 @@ class FilesMetadata implements IFilesMetadata { * @return string[] list of indexes * @since 28.0.0 */ + #[\Override] public function getIndexes(): array { $indexes = []; foreach ($this->getKeys() as $key) { @@ -120,6 +126,7 @@ class FilesMetadata implements IFilesMetadata { * @return bool TRUE if key exists and is set as indexed * @since 28.0.0 */ + #[\Override] public function isIndex(string $key): bool { return $this->metadata[$key]?->isIndexed() ?? false; } @@ -132,6 +139,7 @@ class FilesMetadata implements IFilesMetadata { * @throws FilesMetadataNotFoundException * @since 28.0.0 */ + #[\Override] public function getEditPermission(string $key): int { if (!array_key_exists($key, $this->metadata)) { throw new FilesMetadataNotFoundException(); @@ -148,6 +156,7 @@ class FilesMetadata implements IFilesMetadata { * @throws FilesMetadataNotFoundException * @since 28.0.0 */ + #[\Override] public function setEditPermission(string $key, int $permission): void { if (!array_key_exists($key, $this->metadata)) { throw new FilesMetadataNotFoundException(); @@ -157,6 +166,7 @@ class FilesMetadata implements IFilesMetadata { } + #[\Override] public function getEtag(string $key): string { if (!array_key_exists($key, $this->metadata)) { return ''; @@ -165,6 +175,7 @@ class FilesMetadata implements IFilesMetadata { return $this->metadata[$key]->getEtag(); } + #[\Override] public function setEtag(string $key, string $etag): void { if (!array_key_exists($key, $this->metadata)) { throw new FilesMetadataNotFoundException(); @@ -182,6 +193,7 @@ class FilesMetadata implements IFilesMetadata { * @throws FilesMetadataTypeException * @since 28.0.0 */ + #[\Override] public function getString(string $key): string { if (!array_key_exists($key, $this->metadata)) { throw new FilesMetadataNotFoundException(); @@ -199,6 +211,7 @@ class FilesMetadata implements IFilesMetadata { * @throws FilesMetadataTypeException * @since 28.0.0 */ + #[\Override] public function getInt(string $key): int { if (!array_key_exists($key, $this->metadata)) { throw new FilesMetadataNotFoundException(); @@ -216,6 +229,7 @@ class FilesMetadata implements IFilesMetadata { * @throws FilesMetadataTypeException * @since 28.0.0 */ + #[\Override] public function getFloat(string $key): float { if (!array_key_exists($key, $this->metadata)) { throw new FilesMetadataNotFoundException(); @@ -233,6 +247,7 @@ class FilesMetadata implements IFilesMetadata { * @throws FilesMetadataTypeException * @since 28.0.0 */ + #[\Override] public function getBool(string $key): bool { if (!array_key_exists($key, $this->metadata)) { throw new FilesMetadataNotFoundException(); @@ -250,6 +265,7 @@ class FilesMetadata implements IFilesMetadata { * @throws FilesMetadataTypeException * @since 28.0.0 */ + #[\Override] public function getArray(string $key): array { if (!array_key_exists($key, $this->metadata)) { throw new FilesMetadataNotFoundException(); @@ -267,6 +283,7 @@ class FilesMetadata implements IFilesMetadata { * @throws FilesMetadataTypeException * @since 28.0.0 */ + #[\Override] public function getStringList(string $key): array { if (!array_key_exists($key, $this->metadata)) { throw new FilesMetadataNotFoundException(); @@ -284,6 +301,7 @@ class FilesMetadata implements IFilesMetadata { * @throws FilesMetadataTypeException * @since 28.0.0 */ + #[\Override] public function getIntList(string $key): array { if (!array_key_exists($key, $this->metadata)) { throw new FilesMetadataNotFoundException(); @@ -307,6 +325,7 @@ class FilesMetadata implements IFilesMetadata { * @see IMetadataValueWrapper::TYPE_INT_LIST * @since 28.0.0 */ + #[\Override] public function getType(string $key): string { if (!array_key_exists($key, $this->metadata)) { throw new FilesMetadataNotFoundException(); @@ -325,6 +344,7 @@ class FilesMetadata implements IFilesMetadata { * @throws FilesMetadataKeyFormatException * @since 28.0.0 */ + #[\Override] public function setString(string $key, string $value, bool $index = false): IFilesMetadata { $this->confirmKeyFormat($key); try { @@ -352,6 +372,7 @@ class FilesMetadata implements IFilesMetadata { * @throws FilesMetadataKeyFormatException * @since 28.0.0 */ + #[\Override] public function setInt(string $key, int $value, bool $index = false): IFilesMetadata { $this->confirmKeyFormat($key); try { @@ -378,6 +399,7 @@ class FilesMetadata implements IFilesMetadata { * @throws FilesMetadataKeyFormatException * @since 28.0.0 */ + #[\Override] public function setFloat(string $key, float $value, bool $index = false): IFilesMetadata { $this->confirmKeyFormat($key); try { @@ -406,6 +428,7 @@ class FilesMetadata implements IFilesMetadata { * @throws FilesMetadataKeyFormatException * @since 28.0.0 */ + #[\Override] public function setBool(string $key, bool $value, bool $index = false): IFilesMetadata { $this->confirmKeyFormat($key); try { @@ -433,6 +456,7 @@ class FilesMetadata implements IFilesMetadata { * @throws FilesMetadataKeyFormatException * @since 28.0.0 */ + #[\Override] public function setArray(string $key, array $value): IFilesMetadata { $this->confirmKeyFormat($key); try { @@ -460,6 +484,7 @@ class FilesMetadata implements IFilesMetadata { * @throws FilesMetadataKeyFormatException * @since 28.0.0 */ + #[\Override] public function setStringList(string $key, array $value, bool $index = false): IFilesMetadata { $this->confirmKeyFormat($key); try { @@ -487,6 +512,7 @@ class FilesMetadata implements IFilesMetadata { * @throws FilesMetadataKeyFormatException * @since 28.0.0 */ + #[\Override] public function setIntList(string $key, array $value, bool $index = false): IFilesMetadata { $this->confirmKeyFormat($key); try { @@ -511,6 +537,7 @@ class FilesMetadata implements IFilesMetadata { * @return self * @since 28.0.0 */ + #[\Override] public function unset(string $key): IFilesMetadata { if (!array_key_exists($key, $this->metadata)) { return $this; @@ -529,6 +556,7 @@ class FilesMetadata implements IFilesMetadata { * @return self * @since 28.0.0 */ + #[\Override] public function removeStartsWith(string $keyPrefix): IFilesMetadata { if ($keyPrefix === '') { return $this; @@ -563,10 +591,12 @@ class FilesMetadata implements IFilesMetadata { * @return bool TRUE if metadata have been modified * @since 28.0.0 */ + #[\Override] public function updated(): bool { return $this->updated; } + #[\Override] public function jsonSerialize(bool $emptyValues = false): array { $data = []; foreach ($this->metadata as $metaKey => $metaValueWrapper) { @@ -579,6 +609,7 @@ class FilesMetadata implements IFilesMetadata { /** * @return array */ + #[\Override] public function asArray(): array { $data = []; foreach ($this->metadata as $metaKey => $metaValueWrapper) { @@ -599,6 +630,7 @@ class FilesMetadata implements IFilesMetadata { * @return IFilesMetadata * @since 28.0.0 */ + #[\Override] public function import(array $data): IFilesMetadata { foreach ($data as $k => $v) { $valueWrapper = new MetadataValueWrapper(); diff --git a/lib/private/FilesMetadata/Model/MetadataValueWrapper.php b/lib/private/FilesMetadata/Model/MetadataValueWrapper.php index 606f3b5acec..b6547c6ba2e 100644 --- a/lib/private/FilesMetadata/Model/MetadataValueWrapper.php +++ b/lib/private/FilesMetadata/Model/MetadataValueWrapper.php @@ -54,6 +54,7 @@ class MetadataValueWrapper implements IMetadataValueWrapper { * @see self::TYPE_STRING * @since 28.0.0 */ + #[\Override] public function getType(): string { return $this->type; } @@ -72,6 +73,7 @@ class MetadataValueWrapper implements IMetadataValueWrapper { * @see self::TYPE_STRING * @since 28.0.0 */ + #[\Override] public function isType(string $type): bool { return (strtolower($type) === strtolower($this->type)); } @@ -91,6 +93,7 @@ class MetadataValueWrapper implements IMetadataValueWrapper { * @see self::TYPE_FLOAT * @since 28.0.0 */ + #[\Override] public function assertType(string $type): self { if (!$this->isType($type)) { throw new FilesMetadataTypeException('type is \'' . $this->getType() . '\', expecting \'' . $type . '\''); @@ -107,6 +110,7 @@ class MetadataValueWrapper implements IMetadataValueWrapper { * @throws FilesMetadataTypeException if wrapper was not set to store a string * @since 28.0.0 */ + #[\Override] public function setValueString(string $value): self { $this->assertType(self::TYPE_STRING); $this->value = $value; @@ -122,6 +126,7 @@ class MetadataValueWrapper implements IMetadataValueWrapper { * @throws FilesMetadataTypeException if wrapper was not set to store an int * @since 28.0.0 */ + #[\Override] public function setValueInt(int $value): self { $this->assertType(self::TYPE_INT); $this->value = $value; @@ -137,6 +142,7 @@ class MetadataValueWrapper implements IMetadataValueWrapper { * @throws FilesMetadataTypeException if wrapper was not set to store a float * @since 28.0.0 */ + #[\Override] public function setValueFloat(float $value): self { $this->assertType(self::TYPE_FLOAT); $this->value = $value; @@ -152,6 +158,7 @@ class MetadataValueWrapper implements IMetadataValueWrapper { * @throws FilesMetadataTypeException if wrapper was not set to store a bool * @since 28.0.0 */ + #[\Override] public function setValueBool(bool $value): self { $this->assertType(self::TYPE_BOOL); $this->value = $value; @@ -168,6 +175,7 @@ class MetadataValueWrapper implements IMetadataValueWrapper { * @throws FilesMetadataTypeException if wrapper was not set to store an array * @since 28.0.0 */ + #[\Override] public function setValueArray(array $value): self { $this->assertType(self::TYPE_ARRAY); $this->value = $value; @@ -183,6 +191,7 @@ class MetadataValueWrapper implements IMetadataValueWrapper { * @throws FilesMetadataTypeException if wrapper was not set to store a string list * @since 28.0.0 */ + #[\Override] public function setValueStringList(array $value): self { $this->assertType(self::TYPE_STRING_LIST); // TODO confirm value is an array or string ? @@ -199,6 +208,7 @@ class MetadataValueWrapper implements IMetadataValueWrapper { * @throws FilesMetadataTypeException if wrapper was not set to store an int list * @since 28.0.0 */ + #[\Override] public function setValueIntList(array $value): self { $this->assertType(self::TYPE_INT_LIST); // TODO confirm value is an array of int ? @@ -215,6 +225,7 @@ class MetadataValueWrapper implements IMetadataValueWrapper { * @throws FilesMetadataNotFoundException if value is not set * @since 28.0.0 */ + #[\Override] public function getValueString(): string { $this->assertType(self::TYPE_STRING); if ($this->value === null) { @@ -231,6 +242,7 @@ class MetadataValueWrapper implements IMetadataValueWrapper { * @throws FilesMetadataNotFoundException if value is not set * @since 28.0.0 */ + #[\Override] public function getValueInt(): int { $this->assertType(self::TYPE_INT); if ($this->value === null) { @@ -247,6 +259,7 @@ class MetadataValueWrapper implements IMetadataValueWrapper { * @throws FilesMetadataNotFoundException if value is not set * @since 28.0.0 */ + #[\Override] public function getValueFloat(): float { $this->assertType(self::TYPE_FLOAT); if ($this->value === null) { @@ -263,6 +276,7 @@ class MetadataValueWrapper implements IMetadataValueWrapper { * @throws FilesMetadataNotFoundException if value is not set * @since 28.0.0 */ + #[\Override] public function getValueBool(): bool { $this->assertType(self::TYPE_BOOL); if ($this->value === null) { @@ -279,6 +293,7 @@ class MetadataValueWrapper implements IMetadataValueWrapper { * @throws FilesMetadataNotFoundException if value is not set * @since 28.0.0 */ + #[\Override] public function getValueArray(): array { $this->assertType(self::TYPE_ARRAY); if ($this->value === null) { @@ -295,6 +310,7 @@ class MetadataValueWrapper implements IMetadataValueWrapper { * @throws FilesMetadataNotFoundException if value is not set * @since 28.0.0 */ + #[\Override] public function getValueStringList(): array { $this->assertType(self::TYPE_STRING_LIST); if ($this->value === null) { @@ -311,6 +327,7 @@ class MetadataValueWrapper implements IMetadataValueWrapper { * @throws FilesMetadataNotFoundException if value is not set * @since 28.0.0 */ + #[\Override] public function getValueIntList(): array { $this->assertType(self::TYPE_INT_LIST); if ($this->value === null) { @@ -326,6 +343,7 @@ class MetadataValueWrapper implements IMetadataValueWrapper { * @throws FilesMetadataNotFoundException if value is not set * @since 28.0.0 */ + #[\Override] public function getValueAny(): mixed { if ($this->value === null) { throw new FilesMetadataNotFoundException('value is not set'); @@ -339,6 +357,7 @@ class MetadataValueWrapper implements IMetadataValueWrapper { * @return string stored etag * @since 29.0.0 */ + #[\Override] public function getEtag(): string { return $this->etag; } @@ -350,6 +369,7 @@ class MetadataValueWrapper implements IMetadataValueWrapper { * @return self * @since 29.0.0 */ + #[\Override] public function setEtag(string $etag): self { $this->etag = $etag; return $this; @@ -362,6 +382,7 @@ class MetadataValueWrapper implements IMetadataValueWrapper { * @return self * @since 28.0.0 */ + #[\Override] public function setIndexed(bool $indexed): self { $this->indexed = $indexed; @@ -373,6 +394,7 @@ class MetadataValueWrapper implements IMetadataValueWrapper { * @return bool TRUE if value is an indexed value * @since 28.0.0 */ + #[\Override] public function isIndexed(): bool { return $this->indexed; } @@ -384,6 +406,7 @@ class MetadataValueWrapper implements IMetadataValueWrapper { * @return self * @since 28.0.0 */ + #[\Override] public function setEditPermission(int $permission): self { $this->editPermission = $permission; @@ -395,6 +418,7 @@ class MetadataValueWrapper implements IMetadataValueWrapper { * @return int edit permission * @since 28.0.0 */ + #[\Override] public function getEditPermission(): int { return $this->editPermission; } @@ -407,6 +431,7 @@ class MetadataValueWrapper implements IMetadataValueWrapper { * @see jsonSerialize * @since 28.0.0 */ + #[\Override] public function import(array $data): self { $this->value = $data['value'] ?? null; $this->type = $data['type'] ?? ''; @@ -416,6 +441,7 @@ class MetadataValueWrapper implements IMetadataValueWrapper { return $this; } + #[\Override] public function jsonSerialize(bool $emptyValues = false): array { return [ 'value' => ($emptyValues) ? null : $this->value, diff --git a/lib/private/FullTextSearch/FullTextSearchManager.php b/lib/private/FullTextSearch/FullTextSearchManager.php index 989da8d6bae..67f9b88b7e8 100644 --- a/lib/private/FullTextSearch/FullTextSearchManager.php +++ b/lib/private/FullTextSearch/FullTextSearchManager.php @@ -31,6 +31,7 @@ class FullTextSearchManager implements IFullTextSearchManager { /** * @since 15.0.0 */ + #[\Override] public function registerProviderService(IProviderService $providerService): void { $this->providerService = $providerService; } @@ -38,6 +39,7 @@ class FullTextSearchManager implements IFullTextSearchManager { /** * @since 15.0.0 */ + #[\Override] public function registerIndexService(IIndexService $indexService): void { $this->indexService = $indexService; } @@ -45,6 +47,7 @@ class FullTextSearchManager implements IFullTextSearchManager { /** * @since 15.0.0 */ + #[\Override] public function registerSearchService(ISearchService $searchService): void { $this->searchService = $searchService; } @@ -52,6 +55,7 @@ class FullTextSearchManager implements IFullTextSearchManager { /** * @since 16.0.0 */ + #[\Override] public function isAvailable(): bool { if ($this->indexService === null || $this->providerService === null @@ -102,6 +106,7 @@ class FullTextSearchManager implements IFullTextSearchManager { /** * @throws FullTextSearchAppNotAvailableException */ + #[\Override] public function addJavascriptAPI(): void { $this->getProviderService()->addJavascriptAPI(); } @@ -110,6 +115,7 @@ class FullTextSearchManager implements IFullTextSearchManager { /** * @throws FullTextSearchAppNotAvailableException */ + #[\Override] public function isProviderIndexed(string $providerId): bool { return $this->getProviderService()->isProviderIndexed($providerId); } @@ -118,6 +124,7 @@ class FullTextSearchManager implements IFullTextSearchManager { /** * @throws FullTextSearchAppNotAvailableException */ + #[\Override] public function getIndex(string $providerId, string $documentId): IIndex { return $this->getIndexService()->getIndex($providerId, $documentId); } @@ -127,6 +134,7 @@ class FullTextSearchManager implements IFullTextSearchManager { * * @throws FullTextSearchAppNotAvailableException */ + #[\Override] public function createIndex( string $providerId, string $documentId, @@ -142,6 +150,7 @@ class FullTextSearchManager implements IFullTextSearchManager { * * @throws FullTextSearchAppNotAvailableException */ + #[\Override] public function updateIndexStatus( string $providerId, string $documentId, @@ -156,6 +165,7 @@ class FullTextSearchManager implements IFullTextSearchManager { * * @throws FullTextSearchAppNotAvailableException */ + #[\Override] public function updateIndexesStatus( string $providerId, array $documentIds, @@ -171,6 +181,7 @@ class FullTextSearchManager implements IFullTextSearchManager { * * @throws FullTextSearchAppNotAvailableException */ + #[\Override] public function updateIndexes(array $indexes): void { $this->getIndexService()->updateIndexes($indexes); } @@ -180,6 +191,7 @@ class FullTextSearchManager implements IFullTextSearchManager { * @return ISearchResult[] * @throws FullTextSearchAppNotAvailableException */ + #[\Override] public function search(array $request, string $userId = ''): array { $searchRequest = $this->getSearchService()->generateSearchRequest($request); diff --git a/lib/private/FullTextSearch/Model/DocumentAccess.php b/lib/private/FullTextSearch/Model/DocumentAccess.php index 9efffeaee88..10adb4bb5a0 100644 --- a/lib/private/FullTextSearch/Model/DocumentAccess.php +++ b/lib/private/FullTextSearch/Model/DocumentAccess.php @@ -61,6 +61,7 @@ final class DocumentAccess implements IDocumentAccess, JsonSerializable { * * @since 16.0.0 */ + #[\Override] public function setOwnerId(string $ownerId): IDocumentAccess { $this->ownerId = $ownerId; @@ -72,6 +73,7 @@ final class DocumentAccess implements IDocumentAccess, JsonSerializable { * * @since 16.0.0 */ + #[\Override] public function getOwnerId(): string { return $this->ownerId; } @@ -82,6 +84,7 @@ final class DocumentAccess implements IDocumentAccess, JsonSerializable { * * @since 16.0.0 */ + #[\Override] public function setViewerId(string $viewerId): IDocumentAccess { $this->viewerId = $viewerId; @@ -93,6 +96,7 @@ final class DocumentAccess implements IDocumentAccess, JsonSerializable { * * @since 16.0.0 */ + #[\Override] public function getViewerId(): string { return $this->viewerId; } @@ -103,6 +107,7 @@ final class DocumentAccess implements IDocumentAccess, JsonSerializable { * * @since 16.0.0 */ + #[\Override] public function setUsers(array $users): IDocumentAccess { $this->users = $users; @@ -114,6 +119,7 @@ final class DocumentAccess implements IDocumentAccess, JsonSerializable { * * @since 16.0.0 */ + #[\Override] public function addUser(string $user): IDocumentAccess { $this->users[] = $user; @@ -126,6 +132,7 @@ final class DocumentAccess implements IDocumentAccess, JsonSerializable { * * @since 16.0.0 */ + #[\Override] public function addUsers($users): IDocumentAccess { $this->users = array_merge($this->users, $users); @@ -137,6 +144,7 @@ final class DocumentAccess implements IDocumentAccess, JsonSerializable { * * @since 16.0.0 */ + #[\Override] public function getUsers(): array { return $this->users; } @@ -147,6 +155,7 @@ final class DocumentAccess implements IDocumentAccess, JsonSerializable { * * @since 16.0.0 */ + #[\Override] public function setGroups(array $groups): IDocumentAccess { $this->groups = $groups; @@ -158,6 +167,7 @@ final class DocumentAccess implements IDocumentAccess, JsonSerializable { * * @since 16.0.0 */ + #[\Override] public function addGroup(string $group): IDocumentAccess { $this->groups[] = $group; @@ -170,6 +180,7 @@ final class DocumentAccess implements IDocumentAccess, JsonSerializable { * * @since 16.0.0 */ + #[\Override] public function addGroups(array $groups): IDocumentAccess { $this->groups = array_merge($this->groups, $groups); @@ -181,6 +192,7 @@ final class DocumentAccess implements IDocumentAccess, JsonSerializable { * * @since 16.0.0 */ + #[\Override] public function getGroups(): array { return $this->groups; } @@ -191,6 +203,7 @@ final class DocumentAccess implements IDocumentAccess, JsonSerializable { * * @since 16.0.0 */ + #[\Override] public function setCircles(array $circles): IDocumentAccess { $this->circles = $circles; @@ -202,6 +215,7 @@ final class DocumentAccess implements IDocumentAccess, JsonSerializable { * * @since 16.0.0 */ + #[\Override] public function addCircle(string $circle): IDocumentAccess { $this->circles[] = $circle; @@ -214,6 +228,7 @@ final class DocumentAccess implements IDocumentAccess, JsonSerializable { * * @since 16.0.0 */ + #[\Override] public function addCircles(array $circles): IDocumentAccess { $this->circles = array_merge($this->circles, $circles); @@ -225,6 +240,7 @@ final class DocumentAccess implements IDocumentAccess, JsonSerializable { * * @since 16.0.0 */ + #[\Override] public function getCircles(): array { return $this->circles; } @@ -235,6 +251,7 @@ final class DocumentAccess implements IDocumentAccess, JsonSerializable { * * @since 16.0.0 */ + #[\Override] public function setLinks(array $links): IDocumentAccess { $this->links = $links; @@ -246,6 +263,7 @@ final class DocumentAccess implements IDocumentAccess, JsonSerializable { * * @since 16.0.0 */ + #[\Override] public function getLinks(): array { return $this->links; } @@ -254,6 +272,7 @@ final class DocumentAccess implements IDocumentAccess, JsonSerializable { /** * @since 16.0.0 */ + #[\Override] public function jsonSerialize(): array { return [ 'ownerId' => $this->getOwnerId(), diff --git a/lib/private/FullTextSearch/Model/IndexDocument.php b/lib/private/FullTextSearch/Model/IndexDocument.php index 2a46c7bee57..ec6f2f0ee1e 100644 --- a/lib/private/FullTextSearch/Model/IndexDocument.php +++ b/lib/private/FullTextSearch/Model/IndexDocument.php @@ -85,6 +85,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function getId(): string { return $this->id; } @@ -95,6 +96,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function getProviderId(): string { return $this->providerId; } @@ -107,6 +109,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function setIndex(IIndex $index): IIndexDocument { $this->index = $index; @@ -119,6 +122,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * @throws FullTextSearchIndexNotAvailableException * @since 15.0.0 */ + #[\Override] final public function getIndex(): IIndex { if ($this->index === null) { throw new FullTextSearchIndexNotAvailableException('No IIndex generated'); @@ -132,6 +136,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 16.0.0 */ + #[\Override] final public function hasIndex(): bool { return $this->index !== null; } @@ -141,6 +146,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function setModifiedTime(int $modifiedTime): IIndexDocument { $this->modifiedTime = $modifiedTime; @@ -152,6 +158,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function getModifiedTime(): int { return $this->modifiedTime; } @@ -161,6 +168,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function isOlderThan(int $time): bool { return ($this->modifiedTime < $time); } @@ -173,6 +181,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function setAccess(IDocumentAccess $access): IIndexDocument { $this->access = $access; @@ -184,6 +193,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function getAccess(): IDocumentAccess { return $this->access; } @@ -194,6 +204,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function addTag(string $tag): IIndexDocument { $this->tags[] = $tag; @@ -205,6 +216,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function setTags(array $tags): IIndexDocument { $this->tags = $tags; @@ -216,6 +228,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function getTags(): array { return $this->tags; } @@ -226,6 +239,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function addMetaTag(string $tag): IIndexDocument { $this->metaTags[] = $tag; @@ -237,6 +251,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function setMetaTags(array $tags): IIndexDocument { $this->metaTags = $tags; @@ -248,6 +263,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function getMetaTags(): array { return $this->metaTags; } @@ -258,6 +274,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function addSubTag(string $sub, string $tag): IIndexDocument { if (!array_key_exists($sub, $this->subTags)) { $this->subTags[$sub] = []; @@ -274,6 +291,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function setSubTags(array $tags): IIndexDocument { $this->subTags = $tags; @@ -287,6 +305,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function getSubTags(bool $formatted = false): array { if ($formatted === false) { return $this->subTags; @@ -310,6 +329,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function setSource(string $source): IIndexDocument { $this->source = $source; @@ -321,6 +341,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function getSource(): string { return $this->source; } @@ -331,6 +352,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function setTitle(string $title): IIndexDocument { $this->title = $title; @@ -342,6 +364,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function getTitle(): string { return $this->title; } @@ -354,6 +377,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function setContent(string $content, int $encoded = 0): IIndexDocument { $this->content = $content; $this->contentEncoded = $encoded; @@ -366,6 +390,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function getContent(): string { return $this->content; } @@ -375,6 +400,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function isContentEncoded(): int { return $this->contentEncoded; } @@ -384,6 +410,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function getContentSize(): int { return strlen($this->getContent()); } @@ -394,6 +421,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function initHash(): IIndexDocument { if ($this->getContent() === '' || is_null($this->getContent())) { return $this; @@ -409,6 +437,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function setHash(string $hash): IIndexDocument { $this->hash = $hash; @@ -420,6 +449,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function getHash(): string { return $this->hash; } @@ -433,6 +463,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function addPart(string $part, string $content): IIndexDocument { $this->parts[$part] = $content; @@ -444,6 +475,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function setParts(array $parts): IIndexDocument { $this->parts = $parts; @@ -455,6 +487,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function getParts(): array { return $this->parts; } @@ -465,6 +498,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function setLink(string $link): IIndexDocument { $this->link = $link; @@ -476,6 +510,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function getLink(): string { return $this->link; } @@ -486,6 +521,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function setMore(array $more): IIndexDocument { $this->more = $more; @@ -497,6 +533,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function getMore(): array { return $this->more; } @@ -508,6 +545,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 16.0.0 */ + #[\Override] final public function addExcerpt(string $source, string $excerpt): IIndexDocument { $this->excerpts[] = [ @@ -524,6 +562,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 16.0.0 */ + #[\Override] final public function setExcerpts(array $excerpts): IIndexDocument { $new = []; foreach ($excerpts as $entry) { @@ -543,6 +582,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function getExcerpts(): array { return $this->excerpts; } @@ -570,6 +610,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function setScore(string $score): IIndexDocument { $this->score = $score; @@ -581,6 +622,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function getScore(): string { return $this->score; } @@ -595,6 +637,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function setInfo(string $info, string $value): IIndexDocument { $this->info[$info] = $value; @@ -606,6 +649,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function getInfo(string $info, string $default = ''): string { if (!key_exists($info, $this->info)) { return $default; @@ -623,6 +667,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function setInfoArray(string $info, array $value): IIndexDocument { $this->info[$info] = $value; @@ -634,6 +679,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function getInfoArray(string $info, array $default = []): array { if (!key_exists($info, $this->info)) { return $default; @@ -651,6 +697,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function setInfoInt(string $info, int $value): IIndexDocument { $this->info[$info] = $value; @@ -662,6 +709,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function getInfoInt(string $info, int $default = 0): int { if (!key_exists($info, $this->info)) { return $default; @@ -679,6 +727,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function setInfoBool(string $info, bool $value): IIndexDocument { $this->info[$info] = $value; @@ -690,6 +739,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function getInfoBool(string $info, bool $default = false): bool { if (!key_exists($info, $this->info)) { return $default; @@ -703,6 +753,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * * @since 15.0.0 */ + #[\Override] final public function getInfoAll(): array { $info = []; foreach ($this->info as $k => $v) { @@ -747,6 +798,7 @@ class IndexDocument implements IIndexDocument, JsonSerializable { /** * @since 15.0.0 */ + #[\Override] public function jsonSerialize(): array { return [ 'id' => $this->getId(), diff --git a/lib/private/FullTextSearch/Model/SearchOption.php b/lib/private/FullTextSearch/Model/SearchOption.php index c7769a62138..5329b78421f 100644 --- a/lib/private/FullTextSearch/Model/SearchOption.php +++ b/lib/private/FullTextSearch/Model/SearchOption.php @@ -93,6 +93,7 @@ final class SearchOption implements ISearchOption, JsonSerializable { * * @since 15.0.0 */ + #[\Override] public function setName(string $name): ISearchOption { $this->name = $name; @@ -104,6 +105,7 @@ final class SearchOption implements ISearchOption, JsonSerializable { * * @since 15.0.0 */ + #[\Override] public function getName(): string { return $this->name; } @@ -114,6 +116,7 @@ final class SearchOption implements ISearchOption, JsonSerializable { * * @since 15.0.0 */ + #[\Override] public function setTitle(string $title): ISearchOption { $this->title = $title; @@ -125,6 +128,7 @@ final class SearchOption implements ISearchOption, JsonSerializable { * * @since 15.0.0 */ + #[\Override] public function getTitle(): string { return $this->title; } @@ -136,6 +140,7 @@ final class SearchOption implements ISearchOption, JsonSerializable { * * @since 15.0.0 */ + #[\Override] public function setType(string $type): ISearchOption { $this->type = $type; @@ -147,6 +152,7 @@ final class SearchOption implements ISearchOption, JsonSerializable { * * @since 15.0.0 */ + #[\Override] public function getType(): string { return $this->type; } @@ -158,6 +164,7 @@ final class SearchOption implements ISearchOption, JsonSerializable { * * @since 15.0.0 */ + #[\Override] public function setSize(string $size): ISearchOption { $this->size = $size; @@ -169,6 +176,7 @@ final class SearchOption implements ISearchOption, JsonSerializable { * * @since 15.0.0 */ + #[\Override] public function getSize(): string { return $this->size; } @@ -179,6 +187,7 @@ final class SearchOption implements ISearchOption, JsonSerializable { * * @since 15.0.0 */ + #[\Override] public function setPlaceholder(string $placeholder): ISearchOption { $this->placeholder = $placeholder; @@ -190,6 +199,7 @@ final class SearchOption implements ISearchOption, JsonSerializable { * * @since 15.0.0 */ + #[\Override] public function getPlaceholder(): string { return $this->placeholder; } @@ -197,6 +207,7 @@ final class SearchOption implements ISearchOption, JsonSerializable { /** * @since 15.0.0 */ + #[\Override] public function jsonSerialize(): array { return [ 'name' => $this->getName(), diff --git a/lib/private/FullTextSearch/Model/SearchRequestSimpleQuery.php b/lib/private/FullTextSearch/Model/SearchRequestSimpleQuery.php index 5b075daf7e6..2ab47c04eb2 100644 --- a/lib/private/FullTextSearch/Model/SearchRequestSimpleQuery.php +++ b/lib/private/FullTextSearch/Model/SearchRequestSimpleQuery.php @@ -38,6 +38,7 @@ final class SearchRequestSimpleQuery implements ISearchRequestSimpleQuery, JsonS * * @since 17.0.0 */ + #[\Override] public function getType(): int { return $this->type; } @@ -48,6 +49,7 @@ final class SearchRequestSimpleQuery implements ISearchRequestSimpleQuery, JsonS * * @since 17.0.0 */ + #[\Override] public function getField(): string { return $this->field; } @@ -57,6 +59,7 @@ final class SearchRequestSimpleQuery implements ISearchRequestSimpleQuery, JsonS * * @since 17.0.0 */ + #[\Override] public function setField(string $field): ISearchRequestSimpleQuery { $this->field = $field; @@ -69,6 +72,7 @@ final class SearchRequestSimpleQuery implements ISearchRequestSimpleQuery, JsonS * * @since 17.0.0 */ + #[\Override] public function getValues(): array { return $this->values; } @@ -79,6 +83,7 @@ final class SearchRequestSimpleQuery implements ISearchRequestSimpleQuery, JsonS * * @since 17.0.0 */ + #[\Override] public function addValue(string $value): ISearchRequestSimpleQuery { $this->values[] = $value; @@ -90,6 +95,7 @@ final class SearchRequestSimpleQuery implements ISearchRequestSimpleQuery, JsonS * * @since 17.0.0 */ + #[\Override] public function addValueInt(int $value): ISearchRequestSimpleQuery { $this->values[] = $value; @@ -101,6 +107,7 @@ final class SearchRequestSimpleQuery implements ISearchRequestSimpleQuery, JsonS * * @since 17.0.0 */ + #[\Override] public function addValueArray(array $value): ISearchRequestSimpleQuery { $this->values[] = $value; @@ -112,6 +119,7 @@ final class SearchRequestSimpleQuery implements ISearchRequestSimpleQuery, JsonS * * @since 17.0.0 */ + #[\Override] public function addValueBool(bool $value): ISearchRequestSimpleQuery { $this->values[] = $value; @@ -122,6 +130,7 @@ final class SearchRequestSimpleQuery implements ISearchRequestSimpleQuery, JsonS /** * @since 17.0.0 */ + #[\Override] public function jsonSerialize(): array { return [ 'type' => $this->getType(), diff --git a/lib/private/FullTextSearch/Model/SearchTemplate.php b/lib/private/FullTextSearch/Model/SearchTemplate.php index 6f9a04a911e..e54c3c88da7 100644 --- a/lib/private/FullTextSearch/Model/SearchTemplate.php +++ b/lib/private/FullTextSearch/Model/SearchTemplate.php @@ -68,6 +68,7 @@ final class SearchTemplate implements ISearchTemplate, JsonSerializable { * * @since 15.0.0 */ + #[\Override] public function setIcon(string $class): ISearchTemplate { $this->icon = $class; @@ -77,6 +78,7 @@ final class SearchTemplate implements ISearchTemplate, JsonSerializable { /** * Get the class of the icon. */ + #[\Override] public function getIcon(): string { return $this->icon; } @@ -87,6 +89,7 @@ final class SearchTemplate implements ISearchTemplate, JsonSerializable { * * @since 15.0.0 */ + #[\Override] public function setCss(string $css): ISearchTemplate { $this->css = $css; @@ -98,6 +101,7 @@ final class SearchTemplate implements ISearchTemplate, JsonSerializable { * * @since 15.0.0 */ + #[\Override] public function getCss(): string { return $this->css; } @@ -111,6 +115,7 @@ final class SearchTemplate implements ISearchTemplate, JsonSerializable { * * @since 15.0.0 */ + #[\Override] public function setTemplate(string $template): ISearchTemplate { $this->template = $template; @@ -122,6 +127,7 @@ final class SearchTemplate implements ISearchTemplate, JsonSerializable { * * @since 15.0.0 */ + #[\Override] public function getTemplate(): string { return $this->template; } @@ -135,6 +141,7 @@ final class SearchTemplate implements ISearchTemplate, JsonSerializable { * * @since 15.0.0 */ + #[\Override] public function addPanelOption(ISearchOption $option): ISearchTemplate { $this->panelOptions[] = $option; @@ -148,6 +155,7 @@ final class SearchTemplate implements ISearchTemplate, JsonSerializable { * * @return SearchOption[] */ + #[\Override] public function getPanelOptions(): array { return $this->panelOptions; } @@ -160,6 +168,7 @@ final class SearchTemplate implements ISearchTemplate, JsonSerializable { * * @since 15.0.0 */ + #[\Override] public function addNavigationOption(ISearchOption $option): ISearchTemplate { $this->navigationOptions[] = $option; @@ -171,6 +180,7 @@ final class SearchTemplate implements ISearchTemplate, JsonSerializable { * * @since 15.0.0 */ + #[\Override] public function getNavigationOptions(): array { return $this->navigationOptions; } @@ -179,6 +189,7 @@ final class SearchTemplate implements ISearchTemplate, JsonSerializable { /** * @since 15.0.0 */ + #[\Override] public function jsonSerialize(): array { return [ 'icon' => $this->getIcon(), diff --git a/lib/private/Group/Backend.php b/lib/private/Group/Backend.php index 011ff986143..b9c295c34ff 100644 --- a/lib/private/Group/Backend.php +++ b/lib/private/Group/Backend.php @@ -54,6 +54,7 @@ abstract class Backend implements GroupInterface { * Returns the supported actions as int to be * compared with \OC\Group\Backend::CREATE_GROUP etc. */ + #[\Override] public function implementsActions($actions) { return (bool)($this->getSupportedActions() & $actions); } @@ -66,6 +67,7 @@ abstract class Backend implements GroupInterface { * * Checks whether the user is member of a group or not. */ + #[\Override] public function inGroup($uid, $gid) { return in_array($gid, $this->getUserGroups($uid)); } @@ -78,6 +80,7 @@ abstract class Backend implements GroupInterface { * This function fetches all groups a user belongs to. It does not check * if the user exists at all. */ + #[\Override] public function getUserGroups($uid) { return []; } @@ -92,6 +95,7 @@ abstract class Backend implements GroupInterface { * Returns a list with all groups */ + #[\Override] public function getGroups($search = '', $limit = -1, $offset = 0) { return []; } @@ -101,6 +105,7 @@ abstract class Backend implements GroupInterface { * @param string $gid * @return bool */ + #[\Override] public function groupExists($gid) { return in_array($gid, $this->getGroups($gid, 1)); } @@ -113,6 +118,7 @@ abstract class Backend implements GroupInterface { * @param int $offset * @return array an array of user ids */ + #[\Override] public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) { return []; } diff --git a/lib/private/Group/Database.php b/lib/private/Group/Database.php index 190eb37348b..fff9cef31f7 100644 --- a/lib/private/Group/Database.php +++ b/lib/private/Group/Database.php @@ -65,6 +65,7 @@ class Database extends ABackend implements } } + #[\Override] public function createGroup(string $name): ?string { $this->fixDI(); @@ -100,6 +101,7 @@ class Database extends ABackend implements * * Deletes a group and removes it from the group_user-table */ + #[\Override] public function deleteGroup(string $gid): bool { $this->fixDI(); @@ -135,6 +137,7 @@ class Database extends ABackend implements * * Checks whether the user is member of a group or not. */ + #[\Override] public function inGroup($uid, $gid) { $this->fixDI(); @@ -160,6 +163,7 @@ class Database extends ABackend implements * * Adds a user to a group. */ + #[\Override] public function addToGroup(string $uid, string $gid): bool { $this->fixDI(); @@ -184,6 +188,7 @@ class Database extends ABackend implements * * removes the user from a group. */ + #[\Override] public function removeFromGroup(string $uid, string $gid): bool { $this->fixDI(); @@ -204,6 +209,7 @@ class Database extends ABackend implements * This function fetches all groups a user belongs to. It does not check * if the user exists at all. */ + #[\Override] public function getUserGroups($uid) { //guests has empty or null $uid if ($uid === null || $uid === '') { @@ -242,6 +248,7 @@ class Database extends ABackend implements * * Returns a list with all groups */ + #[\Override] public function getGroups(string $search = '', int $limit = -1, int $offset = 0) { $this->fixDI(); @@ -285,6 +292,7 @@ class Database extends ABackend implements * @param string $gid * @return bool */ + #[\Override] public function groupExists($gid) { $this->fixDI(); @@ -314,6 +322,7 @@ class Database extends ABackend implements /** * {@inheritdoc} */ + #[\Override] public function groupsExists(array $gids): array { $notFoundGids = []; $existingGroups = []; @@ -356,10 +365,12 @@ class Database extends ABackend implements * @param int $offset * @return array an array of user ids */ + #[\Override] public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0): array { return array_values(array_map(fn ($user) => $user->getUid(), $this->searchInGroup($gid, $search, $limit, $offset))); } + #[\Override] public function searchInGroup(string $gid, string $search = '', int $limit = -1, int $offset = 0): array { $this->fixDI(); @@ -427,6 +438,7 @@ class Database extends ABackend implements * @param string $search * @return int */ + #[\Override] public function countUsersInGroup(string $gid, string $search = ''): int { $this->fixDI(); @@ -461,6 +473,7 @@ class Database extends ABackend implements * * @return int */ + #[\Override] public function countDisabledInGroup(string $gid): int { $this->fixDI(); @@ -486,6 +499,7 @@ class Database extends ABackend implements return $count; } + #[\Override] public function getDisplayName(string $gid): string { if (isset($this->groupCache[$gid])) { $displayName = $this->groupCache[$gid]['displayname']; @@ -509,6 +523,7 @@ class Database extends ABackend implements return (string)$displayName; } + #[\Override] public function getGroupDetails(string $gid): array { $displayName = $this->getDisplayName($gid); if ($displayName !== '') { @@ -521,6 +536,7 @@ class Database extends ABackend implements /** * {@inheritdoc} */ + #[\Override] public function getGroupsDetails(array $gids): array { $notFoundGids = []; $details = []; @@ -557,6 +573,7 @@ class Database extends ABackend implements return $details; } + #[\Override] public function setDisplayName(string $gid, string $displayName): bool { if (!$this->groupExists($gid)) { return false; @@ -583,6 +600,7 @@ class Database extends ABackend implements * @return string the name of the backend to be shown * @since 21.0.0 */ + #[\Override] public function getBackendName(): string { return 'Database'; } diff --git a/lib/private/Group/DisplayNameCache.php b/lib/private/Group/DisplayNameCache.php index 8108b359726..cfd39897015 100644 --- a/lib/private/Group/DisplayNameCache.php +++ b/lib/private/Group/DisplayNameCache.php @@ -61,6 +61,7 @@ class DisplayNameCache implements IEventListener { $this->memCache->clear(); } + #[\Override] public function handle(Event $event): void { if ($event instanceof GroupChangedEvent && $event->getFeature() === 'displayName') { $groupId = $event->getGroup()->getGID(); diff --git a/lib/private/Group/Group.php b/lib/private/Group/Group.php index ffb42458ecc..7b7ca00a88f 100644 --- a/lib/private/Group/Group.php +++ b/lib/private/Group/Group.php @@ -51,10 +51,12 @@ class Group implements IGroup { ) { } + #[\Override] public function getGID(): string { return $this->gid; } + #[\Override] public function getDisplayName(): string { if (is_null($this->displayName)) { foreach ($this->backends as $backend) { @@ -71,6 +73,7 @@ class Group implements IGroup { return $this->displayName; } + #[\Override] public function setDisplayName(string $displayName): bool { $displayName = trim($displayName); if ($displayName !== '') { @@ -93,6 +96,7 @@ class Group implements IGroup { * * @return array */ + #[\Override] public function getUsers(): array { if ($this->usersLoaded) { return $this->users; @@ -120,6 +124,7 @@ class Group implements IGroup { * @param IUser $user * @return bool */ + #[\Override] public function inGroup(IUser $user): bool { if (isset($this->users[$user->getUID()])) { return true; @@ -138,6 +143,7 @@ class Group implements IGroup { * * @param IUser $user */ + #[\Override] public function addUser(IUser $user): void { if ($this->inGroup($user)) { return; @@ -167,6 +173,7 @@ class Group implements IGroup { /** * remove a user from the group */ + #[\Override] public function removeUser(IUser $user): void { $result = false; $this->dispatcher->dispatchTyped(new BeforeUserRemovedEvent($this, $user)); @@ -200,6 +207,7 @@ class Group implements IGroup { * Search for users in the group by userid or display name * @return IUser[] */ + #[\Override] public function searchUsers(string $search, ?int $limit = null, ?int $offset = null): array { $users = []; foreach ($this->backends as $backend) { @@ -227,6 +235,7 @@ class Group implements IGroup { * @param string $search * @return int|bool */ + #[\Override] public function count($search = ''): int|bool { $users = false; foreach ($this->backends as $backend) { @@ -248,6 +257,7 @@ class Group implements IGroup { * * @return int|bool */ + #[\Override] public function countDisabled(): int|bool { $users = false; foreach ($this->backends as $backend) { @@ -272,6 +282,7 @@ class Group implements IGroup { * @return IUser[] * @deprecated 27.0.0 Use searchUsers instead (same implementation) */ + #[\Override] public function searchDisplayName(string $search, ?int $limit = null, ?int $offset = null): array { return $this->searchUsers($search, $limit, $offset); } @@ -281,6 +292,7 @@ class Group implements IGroup { * * @return string[] */ + #[\Override] public function getBackendNames(): array { $backends = []; foreach ($this->backends as $backend) { @@ -299,6 +311,7 @@ class Group implements IGroup { * * @return bool */ + #[\Override] public function delete(): bool { // Prevent users from deleting group admin if ($this->getGID() === 'admin') { @@ -345,6 +358,7 @@ class Group implements IGroup { * @return bool * @since 14.0.0 */ + #[\Override] public function canRemoveUser(): bool { foreach ($this->backends as $backend) { if ($backend->implementsActions(GroupInterface::REMOVE_FROM_GOUP)) { @@ -358,6 +372,7 @@ class Group implements IGroup { * @return bool * @since 14.0.0 */ + #[\Override] public function canAddUser(): bool { foreach ($this->backends as $backend) { if ($backend->implementsActions(GroupInterface::ADD_TO_GROUP)) { @@ -371,6 +386,7 @@ class Group implements IGroup { * @return bool * @since 16.0.0 */ + #[\Override] public function hideFromCollaboration(): bool { return array_reduce($this->backends, function (bool $hide, GroupInterface $backend) { return $hide || ($backend instanceof IHideFromCollaborationBackend && $backend->hideGroup($this->gid)); diff --git a/lib/private/Group/Manager.php b/lib/private/Group/Manager.php index 6b57897ee79..028dffd2273 100644 --- a/lib/private/Group/Manager.php +++ b/lib/private/Group/Manager.php @@ -81,6 +81,7 @@ class Manager extends PublicEmitter implements IGroupManager { * @param string $backendClass Full classname including complete namespace * @return bool */ + #[\Override] public function isBackendUsed($backendClass) { $backendClass = strtolower(ltrim($backendClass, '\\')); @@ -96,11 +97,13 @@ class Manager extends PublicEmitter implements IGroupManager { /** * @param GroupInterface $backend */ + #[\Override] public function addBackend($backend) { $this->backends[] = $backend; $this->clearCaches(); } + #[\Override] public function clearBackends() { $this->backends = []; $this->clearCaches(); @@ -111,6 +114,7 @@ class Manager extends PublicEmitter implements IGroupManager { * * @return GroupInterface[] */ + #[\Override] public function getBackends() { return $this->backends; } @@ -125,6 +129,7 @@ class Manager extends PublicEmitter implements IGroupManager { * @param string $gid * @return IGroup|null */ + #[\Override] public function get($gid) { if (isset($this->cachedGroups[$gid])) { return $this->cachedGroups[$gid]; @@ -222,6 +227,7 @@ class Manager extends PublicEmitter implements IGroupManager { * @param string $gid * @return bool */ + #[\Override] public function groupExists($gid) { return $this->get($gid) instanceof IGroup; } @@ -230,6 +236,7 @@ class Manager extends PublicEmitter implements IGroupManager { * @param string $gid * @return IGroup|null */ + #[\Override] public function createGroup($gid) { if ($gid === '' || $gid === null) { return null; @@ -262,6 +269,7 @@ class Manager extends PublicEmitter implements IGroupManager { } } + #[\Override] public function search(string $search, ?int $limit = null, ?int $offset = 0) { $groups = []; foreach ($this->backends as $backend) { @@ -281,6 +289,7 @@ class Manager extends PublicEmitter implements IGroupManager { * @param IUser|null $user * @return array */ + #[\Override] public function getUserGroups(?IUser $user = null): array { if (!$user instanceof IUser) { return []; @@ -313,6 +322,7 @@ class Manager extends PublicEmitter implements IGroupManager { * @param string $userId * @return bool if admin */ + #[\Override] public function isAdmin($userId) { if (!$this->remoteAddress->allowsAdminActions()) { return false; @@ -326,6 +336,7 @@ class Manager extends PublicEmitter implements IGroupManager { return $this->isInGroup($userId, 'admin'); } + #[\Override] public function isDelegatedAdmin(string $userId): bool { if (!$this->remoteAddress->allowsAdminActions()) { return false; @@ -345,10 +356,12 @@ class Manager extends PublicEmitter implements IGroupManager { * @param string $group * @return bool if in group */ + #[\Override] public function isInGroup($userId, $group) { return in_array($group, $this->getUserIdGroupIds($userId)); } + #[\Override] public function getUserGroupIds(IUser $user): array { return $this->getUserIdGroupIds($user->getUID()); } @@ -375,6 +388,7 @@ class Manager extends PublicEmitter implements IGroupManager { * @param string $groupId * @return ?string */ + #[\Override] public function getDisplayName(string $groupId): ?string { return $this->displayNameCache->getDisplayName($groupId); } @@ -391,6 +405,7 @@ class Manager extends PublicEmitter implements IGroupManager { }, $this->getUserGroups($user)); } + #[\Override] public function displayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) { $group = $this->get($gid); if (is_null($group)) { diff --git a/lib/private/Hooks/PublicEmitter.php b/lib/private/Hooks/PublicEmitter.php index 77cb2bf30dd..e6cb97e93d7 100644 --- a/lib/private/Hooks/PublicEmitter.php +++ b/lib/private/Hooks/PublicEmitter.php @@ -19,6 +19,7 @@ class PublicEmitter extends BasicEmitter { * * @suppress PhanAccessMethodProtected */ + #[\Override] public function emit($scope, $method, array $arguments = []) { parent::emit($scope, $method, $arguments); } diff --git a/lib/private/Http/Client/Client.php b/lib/private/Http/Client/Client.php index f1b81df3964..0a42ace17c0 100644 --- a/lib/private/Http/Client/Client.php +++ b/lib/private/Http/Client/Client.php @@ -208,6 +208,7 @@ class Client implements IClient { * @return IResponse * @throws \Exception If the request could not get completed */ + #[\Override] public function get(string $uri, array $options = []): IResponse { $this->preventLocalAddress($uri, $options); $response = $this->client->request('get', $uri, $this->buildRequestOptions($options)); @@ -239,6 +240,7 @@ class Client implements IClient { * @return IResponse * @throws \Exception If the request could not get completed */ + #[\Override] public function head(string $uri, array $options = []): IResponse { $this->preventLocalAddress($uri, $options); $response = $this->client->request('head', $uri, $this->buildRequestOptions($options)); @@ -274,6 +276,7 @@ class Client implements IClient { * @return IResponse * @throws \Exception If the request could not get completed */ + #[\Override] public function post(string $uri, array $options = []): IResponse { $this->preventLocalAddress($uri, $options); @@ -315,6 +318,7 @@ class Client implements IClient { * @return IResponse * @throws \Exception If the request could not get completed */ + #[\Override] public function put(string $uri, array $options = []): IResponse { $this->preventLocalAddress($uri, $options); $response = $this->client->request('put', $uri, $this->buildRequestOptions($options)); @@ -350,6 +354,7 @@ class Client implements IClient { * @return IResponse * @throws \Exception If the request could not get completed */ + #[\Override] public function patch(string $uri, array $options = []): IResponse { $this->preventLocalAddress($uri, $options); $response = $this->client->request('patch', $uri, $this->buildRequestOptions($options)); @@ -385,6 +390,7 @@ class Client implements IClient { * @return IResponse * @throws \Exception If the request could not get completed */ + #[\Override] public function delete(string $uri, array $options = []): IResponse { $this->preventLocalAddress($uri, $options); $response = $this->client->request('delete', $uri, $this->buildRequestOptions($options)); @@ -420,6 +426,7 @@ class Client implements IClient { * @return IResponse * @throws \Exception If the request could not get completed */ + #[\Override] public function options(string $uri, array $options = []): IResponse { $this->preventLocalAddress($uri, $options); $response = $this->client->request('options', $uri, $this->buildRequestOptions($options)); @@ -434,6 +441,7 @@ class Client implements IClient { * @throws \Throwable When $e did not have a response * @since 29.0.0 */ + #[\Override] public function getResponseFromThrowable(\Throwable $e): IResponse { if (method_exists($e, 'hasResponse') && method_exists($e, 'getResponse') && $e->hasResponse()) { return new Response($e->getResponse()); @@ -472,6 +480,7 @@ class Client implements IClient { * @return IResponse * @throws \Exception If the request could not get completed */ + #[\Override] public function request(string $method, string $uri, array $options = []): IResponse { $this->preventLocalAddress($uri, $options); $response = $this->client->request($method, $uri, $this->buildRequestOptions($options)); @@ -479,6 +488,7 @@ class Client implements IClient { return new Response($response, $isStream); } + #[\Override] public function sendRequest(RequestInterface $request): ResponseInterface { $this->preventLocalAddress((string)$request->getUri(), []); return $this->client->send($request, $this->buildRequestOptions([])); @@ -519,6 +529,7 @@ class Client implements IClient { * 'timeout' => 5, * @return IPromise */ + #[\Override] public function getAsync(string $uri, array $options = []): IPromise { $this->preventLocalAddress($uri, $options); $response = $this->client->requestAsync('get', $uri, $this->buildRequestOptions($options)); @@ -548,6 +559,7 @@ class Client implements IClient { * 'timeout' => 5, * @return IPromise */ + #[\Override] public function headAsync(string $uri, array $options = []): IPromise { $this->preventLocalAddress($uri, $options); $response = $this->client->requestAsync('head', $uri, $this->buildRequestOptions($options)); @@ -582,6 +594,7 @@ class Client implements IClient { * 'timeout' => 5, * @return IPromise */ + #[\Override] public function postAsync(string $uri, array $options = []): IPromise { $this->preventLocalAddress($uri, $options); @@ -621,6 +634,7 @@ class Client implements IClient { * 'timeout' => 5, * @return IPromise */ + #[\Override] public function putAsync(string $uri, array $options = []): IPromise { $this->preventLocalAddress($uri, $options); $response = $this->client->requestAsync('put', $uri, $this->buildRequestOptions($options)); @@ -655,6 +669,7 @@ class Client implements IClient { * 'timeout' => 5, * @return IPromise */ + #[\Override] public function deleteAsync(string $uri, array $options = []): IPromise { $this->preventLocalAddress($uri, $options); $response = $this->client->requestAsync('delete', $uri, $this->buildRequestOptions($options)); @@ -689,6 +704,7 @@ class Client implements IClient { * 'timeout' => 5, * @return IPromise */ + #[\Override] public function optionsAsync(string $uri, array $options = []): IPromise { $this->preventLocalAddress($uri, $options); $response = $this->client->requestAsync('options', $uri, $this->buildRequestOptions($options)); diff --git a/lib/private/Http/Client/ClientService.php b/lib/private/Http/Client/ClientService.php index 1e40ef31bc1..12d633a962b 100644 --- a/lib/private/Http/Client/ClientService.php +++ b/lib/private/Http/Client/ClientService.php @@ -39,6 +39,7 @@ class ClientService implements IClientService { ) { } + #[\Override] public function newClient(): IClient { $handler = new CurlHandler(); $stack = HandlerStack::create($handler); diff --git a/lib/private/Http/Client/GuzzlePromiseAdapter.php b/lib/private/Http/Client/GuzzlePromiseAdapter.php index 7d1e1e19112..796071d1eeb 100644 --- a/lib/private/Http/Client/GuzzlePromiseAdapter.php +++ b/lib/private/Http/Client/GuzzlePromiseAdapter.php @@ -41,6 +41,7 @@ class GuzzlePromiseAdapter implements IPromise { * @return IPromise * @since 28.0.0 */ + #[\Override] public function then( ?callable $onFulfilled = null, ?callable $onRejected = null, @@ -74,6 +75,7 @@ class GuzzlePromiseAdapter implements IPromise { * @return IPromise::STATE_* * @since 28.0.0 */ + #[\Override] public function getState(): string { $state = $this->promise->getState(); if ($state === PromiseInterface::FULFILLED) { @@ -98,6 +100,7 @@ class GuzzlePromiseAdapter implements IPromise { * @link https://github.com/promises-aplus/cancellation-spec/issues/7 * @since 28.0.0 */ + #[\Override] public function cancel(): void { $this->promise->cancel(); } @@ -118,6 +121,7 @@ class GuzzlePromiseAdapter implements IPromise { * promise does not settle after waiting. * @since 28.0.0 */ + #[\Override] public function wait(bool $unwrap = true): mixed { return $this->promise->wait($unwrap); } diff --git a/lib/private/Http/Client/Response.php b/lib/private/Http/Client/Response.php index 460b5251a52..f005347067c 100644 --- a/lib/private/Http/Client/Response.php +++ b/lib/private/Http/Client/Response.php @@ -18,16 +18,19 @@ class Response implements IResponse { ) { } + #[\Override] public function getBody() { return $this->stream ? $this->response->getBody()->detach() :$this->response->getBody()->getContents(); } + #[\Override] public function getStatusCode(): int { return $this->response->getStatusCode(); } + #[\Override] public function getHeader(string $key): string { $headers = $this->response->getHeader($key); @@ -38,6 +41,7 @@ class Response implements IResponse { return $headers[0]; } + #[\Override] public function getHeaders(): array { return $this->response->getHeaders(); } diff --git a/lib/private/Http/WellKnown/RequestManager.php b/lib/private/Http/WellKnown/RequestManager.php index 11d5d388f35..a79974089e7 100644 --- a/lib/private/Http/WellKnown/RequestManager.php +++ b/lib/private/Http/WellKnown/RequestManager.php @@ -37,6 +37,7 @@ class RequestManager { ) { } + #[\Override] public function getHttpRequest(): IRequest { return $this->request; } diff --git a/lib/private/Image.php b/lib/private/Image.php index 7e6a7621dcf..2ab199e69c6 100644 --- a/lib/private/Image.php +++ b/lib/private/Image.php @@ -67,6 +67,7 @@ class Image implements IImage { * @psalm-assert-if-true \GdImage $this->resource * @return bool */ + #[\Override] public function valid(): bool { if (is_object($this->resource) && get_class($this->resource) === \GdImage::class) { return true; @@ -80,6 +81,7 @@ class Image implements IImage { * * @return string */ + #[\Override] public function mimeType(): ?string { return $this->valid() ? $this->mimeType : null; } @@ -89,6 +91,7 @@ class Image implements IImage { * * @return int */ + #[\Override] public function width(): int { if ($this->valid()) { return imagesx($this->resource); @@ -101,6 +104,7 @@ class Image implements IImage { * * @return int */ + #[\Override] public function height(): int { if ($this->valid()) { return imagesy($this->resource); @@ -113,6 +117,7 @@ class Image implements IImage { * * @return int */ + #[\Override] public function widthTopLeft(): int { $o = $this->getOrientation(); $this->logger->debug('Image->widthTopLeft() Orientation: ' . $o, ['app' => 'core']); @@ -137,6 +142,7 @@ class Image implements IImage { * * @return int */ + #[\Override] public function heightTopLeft(): int { $o = $this->getOrientation(); $this->logger->debug('Image->heightTopLeft() Orientation: ' . $o, ['app' => 'core']); @@ -162,6 +168,7 @@ class Image implements IImage { * @param string $mimeType * @return bool */ + #[\Override] public function show(?string $mimeType = null): bool { if ($mimeType === null) { $mimeType = $this->mimeType(); @@ -180,6 +187,7 @@ class Image implements IImage { * @return bool */ + #[\Override] public function save(?string $filePath = null, ?string $mimeType = null): bool { if ($mimeType === null) { $mimeType = $this->mimeType(); @@ -296,6 +304,7 @@ class Image implements IImage { /** * @return false|\GdImage Returns the image resource if any */ + #[\Override] public function resource() { return $this->resource; } @@ -303,6 +312,7 @@ class Image implements IImage { /** * @return string Returns the mimetype of the data. Returns null if the data is not valid. */ + #[\Override] public function dataMimeType(): ?string { if (!$this->valid()) { return null; @@ -322,6 +332,7 @@ class Image implements IImage { /** * @return null|string Returns the raw image data. */ + #[\Override] public function data(): ?string { if (!$this->valid()) { return null; @@ -393,6 +404,7 @@ class Image implements IImage { * * @return int The orientation or -1 if no EXIF data is available. */ + #[\Override] public function getOrientation(): int { if ($this->exif !== null) { return $this->exif['Orientation']; @@ -422,6 +434,7 @@ class Image implements IImage { return (int)$exif['Orientation']; } + #[\Override] public function readExif(string $data): void { if (!is_callable('exif_read_data')) { $this->logger->debug('Image->fixOrientation() Exif module not enabled.', ['app' => 'core']); @@ -445,6 +458,7 @@ class Image implements IImage { * * @return bool */ + #[\Override] public function fixOrientation(): bool { if (!$this->valid()) { $this->logger->debug(__METHOD__ . '(): No image loaded', ['app' => 'core']); @@ -781,6 +795,7 @@ class Image implements IImage { /** * @inheritDoc */ + #[\Override] public function loadFromData(string $str): GdImage|false { if (!$this->checkImageDataSize($str)) { return false; @@ -833,6 +848,7 @@ class Image implements IImage { * @param int $maxSize The maximum size of either the width or height. * @return bool */ + #[\Override] public function resize(int $maxSize): bool { if (!$this->valid()) { $this->logger->debug(__METHOD__ . '(): No image loaded', ['app' => 'core']); @@ -868,6 +884,7 @@ class Image implements IImage { * @param int $height * @return bool */ + #[\Override] public function preciseResize(int $width, int $height): bool { if (!$this->valid()) { $this->logger->debug(__METHOD__ . '(): No image loaded', ['app' => 'core']); @@ -921,6 +938,7 @@ class Image implements IImage { * @param int $size maximum size for the result (optional) * @return bool for success or failure */ + #[\Override] public function centerCrop(int $size = 0): bool { if (!$this->valid()) { $this->logger->debug('Image->centerCrop, No image loaded', ['app' => 'core']); @@ -984,6 +1002,7 @@ class Image implements IImage { * @param int $h Height * @return bool for success or failure */ + #[\Override] public function crop(int $x, int $y, int $w, int $h): bool { if (!$this->valid()) { $this->logger->debug(__METHOD__ . '(): No image loaded', ['app' => 'core']); @@ -1043,6 +1062,7 @@ class Image implements IImage { * @param int $maxHeight * @return bool */ + #[\Override] public function fitIn(int $maxWidth, int $maxHeight): bool { if (!$this->valid()) { $this->logger->debug(__METHOD__ . '(): No image loaded', ['app' => 'core']); @@ -1066,6 +1086,7 @@ class Image implements IImage { * @param int $maxHeight * @return bool */ + #[\Override] public function scaleDownToFit(int $maxWidth, int $maxHeight): bool { if (!$this->valid()) { $this->logger->debug(__METHOD__ . '(): No image loaded', ['app' => 'core']); @@ -1081,6 +1102,7 @@ class Image implements IImage { return false; } + #[\Override] public function copy(): IImage { $image = new self($this->logger, $this->appConfig, $this->config); if (!$this->valid()) { @@ -1106,6 +1128,7 @@ class Image implements IImage { return $image; } + #[\Override] public function cropCopy(int $x, int $y, int $w, int $h): IImage { $image = new self($this->logger, $this->appConfig, $this->config); $image->imageType = $this->imageType; @@ -1115,6 +1138,7 @@ class Image implements IImage { return $image; } + #[\Override] public function preciseResizeCopy(int $width, int $height): IImage { $image = new self($this->logger, $this->appConfig, $this->config); $image->imageType = $this->imageType; @@ -1124,6 +1148,7 @@ class Image implements IImage { return $image; } + #[\Override] public function resizeCopy(int $maxSize): IImage { $image = new self($this->logger, $this->appConfig, $this->config); $image->imageType = $this->imageType; diff --git a/lib/private/InitialStateService.php b/lib/private/InitialStateService.php index 300aa238397..f7798f3cdaa 100644 --- a/lib/private/InitialStateService.php +++ b/lib/private/InitialStateService.php @@ -32,6 +32,7 @@ class InitialStateService implements IInitialStateService { ) { } + #[\Override] public function provideInitialState(string $appName, string $key, $data): void { // Scalars and JsonSerializable are fine if (is_scalar($data) || $data instanceof \JsonSerializable || is_array($data)) { @@ -49,6 +50,7 @@ class InitialStateService implements IInitialStateService { $this->logger->warning('Invalid ' . $key . ' data provided to provideInitialState by ' . $appName); } + #[\Override] public function provideLazyInitialState(string $appName, string $key, Closure $closure): void { if (!isset($this->lazyStates[$appName])) { $this->lazyStates[$appName] = []; diff --git a/lib/private/IntegrityCheck/Iterator/ExcludeFileByNameFilterIterator.php b/lib/private/IntegrityCheck/Iterator/ExcludeFileByNameFilterIterator.php index d28eae2740b..7a63a080529 100644 --- a/lib/private/IntegrityCheck/Iterator/ExcludeFileByNameFilterIterator.php +++ b/lib/private/IntegrityCheck/Iterator/ExcludeFileByNameFilterIterator.php @@ -42,6 +42,7 @@ class ExcludeFileByNameFilterIterator extends \RecursiveFilterIterator { '/^\.webapp-nextcloud-(\d+\.){2}(\d+)(-r\d+)?$/', // Gentoo/Funtoo & derivatives use a tool known as webapp-config to manage wep-apps. ]; + #[\Override] public function accept(): bool { /** @var \SplFileInfo $current */ $current = $this->current(); diff --git a/lib/private/IntegrityCheck/Iterator/ExcludeFoldersByPathFilterIterator.php b/lib/private/IntegrityCheck/Iterator/ExcludeFoldersByPathFilterIterator.php index 1d44ed2ebc0..52ccbec082c 100644 --- a/lib/private/IntegrityCheck/Iterator/ExcludeFoldersByPathFilterIterator.php +++ b/lib/private/IntegrityCheck/Iterator/ExcludeFoldersByPathFilterIterator.php @@ -43,6 +43,7 @@ class ExcludeFoldersByPathFilterIterator extends \RecursiveFilterIterator { $this->excludedFolders = array_merge($excludedFolders, $appFolders); } + #[\Override] public function accept(): bool { return !\in_array( $this->current()->getPathName(), diff --git a/lib/private/L10N/Factory.php b/lib/private/L10N/Factory.php index 4c9b32c97d1..635c5d65589 100644 --- a/lib/private/L10N/Factory.php +++ b/lib/private/L10N/Factory.php @@ -92,6 +92,7 @@ class Factory implements IFactory { * @param string|null $locale * @return IL10N */ + #[\Override] public function get($app, $lang = null, $locale = null) { return new LazyL10N(function () use ($app, $lang, $locale) { $app = $this->appManager->cleanAppId($app); @@ -179,6 +180,7 @@ class Factory implements IFactory { * * @return string language If nothing works it returns 'en' */ + #[\Override] public function findLanguage(?string $appId = null): string { // Step 1: Forced language always has precedence over anything else $forceLang = $this->cleanLanguage($this->request->getParam('forceLanguage')) ?? $this->config->getSystemValue('force_language', false); @@ -236,6 +238,7 @@ class Factory implements IFactory { return 'en'; } + #[\Override] public function findGenericLanguage(?string $appId = null): string { // Step 1: Forced language always has precedence over anything else $forcedLanguage = $this->cleanLanguage($this->request->getParam('forceLanguage')) ?? $this->config->getSystemValue('force_language', false); @@ -259,6 +262,7 @@ class Factory implements IFactory { * @param string $lang * @return null|string */ + #[\Override] public function findLocale($lang = null) { $forceLocale = $this->config->getSystemValue('force_locale', false); if (is_string($forceLocale) && $this->localeExists($forceLocale)) { @@ -302,6 +306,7 @@ class Factory implements IFactory { * @param string $locale * @return null|string */ + #[\Override] public function findLanguageFromLocale(string $app = 'core', ?string $locale = null) { if ($this->languageExists($app, $locale)) { return $locale; @@ -320,6 +325,7 @@ class Factory implements IFactory { * @param string|null $app App id or null for core * @return string[] an array of available languages */ + #[\Override] public function findAvailableLanguages($app = null): array { $key = $app; if ($key === null) { @@ -373,6 +379,7 @@ class Factory implements IFactory { /** * @return array|mixed */ + #[\Override] public function findAvailableLocales() { if (!empty($this->availableLocales)) { return $this->availableLocales; @@ -389,6 +396,7 @@ class Factory implements IFactory { * @param string $lang * @return bool */ + #[\Override] public function languageExists($app, $lang) { if ($lang === 'en') { //english is always available return true; @@ -398,6 +406,7 @@ class Factory implements IFactory { return in_array($lang, $languages); } + #[\Override] public function getLanguageDirection(string $language): string { if (in_array($language, self::RTL_LANGUAGES, true)) { return 'rtl'; @@ -406,6 +415,7 @@ class Factory implements IFactory { return 'ltr'; } + #[\Override] public function getLanguageIterator(?IUser $user = null): ILanguageIterator { $user = $user ?? $this->userSession->getUser(); if ($user === null) { @@ -421,6 +431,7 @@ class Factory implements IFactory { * @return string * @since 20.0.0 */ + #[\Override] public function getUserLanguage(?IUser $user = null): string { $language = $this->config->getSystemValue('force_language', false); if ($language !== false) { @@ -455,6 +466,7 @@ class Factory implements IFactory { * @param string $locale * @return bool */ + #[\Override] public function localeExists($locale) { if ($locale === 'en') { //english is always available return true; @@ -607,6 +619,7 @@ class Factory implements IFactory { /** * @inheritDoc */ + #[\Override] public function getLanguages(): array { $forceLanguage = $this->config->getSystemValue('force_language', false); if ($forceLanguage !== false) { diff --git a/lib/private/L10N/L10N.php b/lib/private/L10N/L10N.php index 9011183926f..07a392d5226 100644 --- a/lib/private/L10N/L10N.php +++ b/lib/private/L10N/L10N.php @@ -41,6 +41,7 @@ class L10N implements IL10N { * * @return string language */ + #[\Override] public function getLanguageCode(): string { return $this->lang; } @@ -50,6 +51,7 @@ class L10N implements IL10N { * * @return string locale */ + #[\Override] public function getLocaleCode(): string { return $this->locale ?? ''; } @@ -63,6 +65,7 @@ class L10N implements IL10N { * Returns the translation. If no translation is found, $text will be * returned. */ + #[\Override] public function t(string $text, $parameters = []): string { if (!\is_array($parameters)) { $parameters = [$parameters]; @@ -86,6 +89,7 @@ class L10N implements IL10N { * provided by the po file. * */ + #[\Override] public function n(string $text_singular, string $text_plural, int $count, array $parameters = []): string { $identifier = "_{$text_singular}_::_{$text_plural}_"; if (isset($this->translations[$identifier])) { @@ -121,6 +125,7 @@ class L10N implements IL10N { * - firstday: Returns the first day of the week (0 sunday - 6 saturday) * - jsdate: Returns the short JS date format */ + #[\Override] public function l(string $type, $data = null, array $options = []) { if ($this->locale === null) { // Use the language of the instance diff --git a/lib/private/L10N/L10NString.php b/lib/private/L10N/L10NString.php index 2bd4f123025..88bdb125b79 100644 --- a/lib/private/L10N/L10NString.php +++ b/lib/private/L10N/L10NString.php @@ -54,6 +54,7 @@ class L10NString implements \JsonSerializable { return vsprintf($text, $this->parameters); } + #[\Override] public function jsonSerialize(): string { return $this->__toString(); } diff --git a/lib/private/L10N/LanguageIterator.php b/lib/private/L10N/LanguageIterator.php index 195de54ae4b..0055180f2a2 100644 --- a/lib/private/L10N/LanguageIterator.php +++ b/lib/private/L10N/LanguageIterator.php @@ -24,6 +24,7 @@ class LanguageIterator implements ILanguageIterator { /** * Rewind the Iterator to the first element */ + #[\Override] public function rewind(): void { $this->i = 0; } @@ -33,6 +34,7 @@ class LanguageIterator implements ILanguageIterator { * * @since 14.0.0 */ + #[\Override] public function current(): string { switch ($this->i) { /** @noinspection PhpMissingBreakStatementInspection */ @@ -91,6 +93,7 @@ class LanguageIterator implements ILanguageIterator { * * @since 14.0.0 */ + #[\Override] public function next(): void { ++$this->i; } @@ -100,6 +103,7 @@ class LanguageIterator implements ILanguageIterator { * * @since 14.0.0 */ + #[\Override] public function key(): int { return $this->i; } @@ -109,6 +113,7 @@ class LanguageIterator implements ILanguageIterator { * * @since 14.0.0 */ + #[\Override] public function valid(): bool { return $this->i <= 6; } diff --git a/lib/private/L10N/LazyL10N.php b/lib/private/L10N/LazyL10N.php index b93e0596b79..bb499045d3e 100644 --- a/lib/private/L10N/LazyL10N.php +++ b/lib/private/L10N/LazyL10N.php @@ -26,22 +26,27 @@ class LazyL10N implements IL10N { return $this->l; } + #[\Override] public function t(string $text, $parameters = []): string { return $this->getL()->t($text, $parameters); } + #[\Override] public function n(string $text_singular, string $text_plural, int $count, array $parameters = []): string { return $this->getL()->n($text_singular, $text_plural, $count, $parameters); } + #[\Override] public function l(string $type, $data, array $options = []) { return $this->getL()->l($type, $data, $options); } + #[\Override] public function getLanguageCode(): string { return $this->getL()->getLanguageCode(); } + #[\Override] public function getLocaleCode(): string { return $this->getL()->getLocaleCode(); } diff --git a/lib/private/LDAP/NullLDAPProviderFactory.php b/lib/private/LDAP/NullLDAPProviderFactory.php index 34556cbc1ad..5960e69a458 100644 --- a/lib/private/LDAP/NullLDAPProviderFactory.php +++ b/lib/private/LDAP/NullLDAPProviderFactory.php @@ -15,10 +15,12 @@ class NullLDAPProviderFactory implements ILDAPProviderFactory { public function __construct(IServerContainer $serverContainer) { } + #[\Override] public function getLDAPProvider(): never { throw new \Exception('No LDAP provider is available'); } + #[\Override] public function isAvailable(): bool { return false; } diff --git a/lib/private/Lock/AbstractLockingProvider.php b/lib/private/Lock/AbstractLockingProvider.php index 4afd5d32c59..c8612ff3ba5 100644 --- a/lib/private/Lock/AbstractLockingProvider.php +++ b/lib/private/Lock/AbstractLockingProvider.php @@ -79,6 +79,7 @@ abstract class AbstractLockingProvider implements ILockingProvider { } /** @inheritDoc */ + #[\Override] public function releaseAll(): void { foreach ($this->acquiredLocks['shared'] as $path => $count) { for ($i = 0; $i < $count; $i++) { diff --git a/lib/private/Lock/DBLockingProvider.php b/lib/private/Lock/DBLockingProvider.php index cb7f5cff350..ec5d84a5384 100644 --- a/lib/private/Lock/DBLockingProvider.php +++ b/lib/private/Lock/DBLockingProvider.php @@ -37,6 +37,7 @@ class DBLockingProvider extends AbstractLockingProvider { } /** @inheritDoc */ + #[\Override] protected function markAcquire(string $path, int $targetType): void { parent::markAcquire($path, $targetType); if ($this->cacheSharedLocks) { @@ -49,6 +50,7 @@ class DBLockingProvider extends AbstractLockingProvider { /** * Change the type of an existing tracked lock */ + #[\Override] protected function markChange(string $path, int $targetType): void { parent::markChange($path, $targetType); if ($this->cacheSharedLocks) { @@ -77,6 +79,7 @@ class DBLockingProvider extends AbstractLockingProvider { } /** @inheritDoc */ + #[\Override] public function isLocked(string $path, int $type): bool { if ($this->hasAcquiredLock($path, $type)) { return true; @@ -102,6 +105,7 @@ class DBLockingProvider extends AbstractLockingProvider { } /** @inheritDoc */ + #[\Override] public function acquireLock(string $path, int $type, ?string $readablePath = null): void { $expire = $this->getExpireTime(); if ($type === self::LOCK_SHARED) { @@ -142,6 +146,7 @@ class DBLockingProvider extends AbstractLockingProvider { } /** @inheritDoc */ + #[\Override] public function releaseLock(string $path, int $type): void { $this->markRelease($path, $type); @@ -164,6 +169,7 @@ class DBLockingProvider extends AbstractLockingProvider { } /** @inheritDoc */ + #[\Override] public function changeLock(string $path, int $targetType): void { $expire = $this->getExpireTime(); if ($targetType === self::LOCK_SHARED) { @@ -212,6 +218,7 @@ class DBLockingProvider extends AbstractLockingProvider { } /** @inheritDoc */ + #[\Override] public function releaseAll(): void { parent::releaseAll(); diff --git a/lib/private/Lock/MemcacheLockingProvider.php b/lib/private/Lock/MemcacheLockingProvider.php index 8cc0c27bbf9..77c61bcfe88 100644 --- a/lib/private/Lock/MemcacheLockingProvider.php +++ b/lib/private/Lock/MemcacheLockingProvider.php @@ -47,6 +47,7 @@ class MemcacheLockingProvider extends AbstractLockingProvider { } } + #[\Override] public function isLocked(string $path, int $type): bool { $lockValue = $this->memcache->get($path); if ($type === self::LOCK_SHARED) { @@ -58,6 +59,7 @@ class MemcacheLockingProvider extends AbstractLockingProvider { } } + #[\Override] public function acquireLock(string $path, int $type, ?string $readablePath = null): void { if ($type === self::LOCK_SHARED) { // save the old TTL to for `restoreTTL` @@ -81,6 +83,7 @@ class MemcacheLockingProvider extends AbstractLockingProvider { $this->markAcquire($path, $type); } + #[\Override] public function releaseLock(string $path, int $type): void { if ($type === self::LOCK_SHARED) { $ownSharedLockCount = $this->getOwnSharedLockCount($path); @@ -114,6 +117,7 @@ class MemcacheLockingProvider extends AbstractLockingProvider { $this->markRelease($path, $type); } + #[\Override] public function changeLock(string $path, int $targetType): void { if ($targetType === self::LOCK_SHARED) { if (!$this->memcache->cas($path, 'exclusive', 1)) { diff --git a/lib/private/Lock/NoopLockingProvider.php b/lib/private/Lock/NoopLockingProvider.php index 42f1f9ae5ec..f5cadbf045f 100644 --- a/lib/private/Lock/NoopLockingProvider.php +++ b/lib/private/Lock/NoopLockingProvider.php @@ -19,6 +19,7 @@ class NoopLockingProvider implements ILockingProvider { /** * {@inheritdoc} */ + #[\Override] public function isLocked(string $path, int $type): bool { return false; } @@ -26,6 +27,7 @@ class NoopLockingProvider implements ILockingProvider { /** * {@inheritdoc} */ + #[\Override] public function acquireLock(string $path, int $type, ?string $readablePath = null): void { // do nothing } @@ -33,6 +35,7 @@ class NoopLockingProvider implements ILockingProvider { /** * {@inheritdoc} */ + #[\Override] public function releaseLock(string $path, int $type): void { // do nothing } @@ -40,6 +43,7 @@ class NoopLockingProvider implements ILockingProvider { /**1 * {@inheritdoc} */ + #[\Override] public function releaseAll(): void { // do nothing } @@ -47,6 +51,7 @@ class NoopLockingProvider implements ILockingProvider { /** * {@inheritdoc} */ + #[\Override] public function changeLock(string $path, int $targetType): void { // do nothing } diff --git a/lib/private/Lockdown/Filesystem/NullCache.php b/lib/private/Lockdown/Filesystem/NullCache.php index b722d719d6a..d5508ae877d 100644 --- a/lib/private/Lockdown/Filesystem/NullCache.php +++ b/lib/private/Lockdown/Filesystem/NullCache.php @@ -20,10 +20,12 @@ use OCP\Files\Search\ISearchOperator; use OCP\Files\Search\ISearchQuery; class NullCache implements ICache { + #[\Override] public function getNumericStorageId(): int { return -1; } + #[\Override] public function get($file): false|ICacheEntry { if ($file !== '') { return false; @@ -44,86 +46,107 @@ class NullCache implements ICache { ]); } + #[\Override] public function getFolderContents(string $folder, ?string $mimeTypeFilter = null): array { return []; } + #[\Override] public function getFolderContentsById(int $fileId, ?string $mimeTypeFilter = null): array { return []; } + #[\Override] public function put($file, array $data): never { throw new ForbiddenException('This request is not allowed to access the filesystem'); } + #[\Override] public function insert($file, array $data): never { throw new ForbiddenException('This request is not allowed to access the filesystem'); } + #[\Override] public function update($id, array $data): never { throw new ForbiddenException('This request is not allowed to access the filesystem'); } + #[\Override] public function getId($file) { return -1; } + #[\Override] public function getParentId($file) { return -1; } + #[\Override] public function inCache($file) { return $file === ''; } + #[\Override] public function remove($file) { throw new ForbiddenException('This request is not allowed to access the filesystem'); } + #[\Override] public function move($source, $target) { throw new ForbiddenException('This request is not allowed to access the filesystem'); } + #[\Override] public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) { throw new ForbiddenException('This request is not allowed to access the filesystem'); } + #[\Override] public function getStatus($file) { return ICache::COMPLETE; } + #[\Override] public function search($pattern) { return []; } + #[\Override] public function searchByMime($mimetype) { return []; } + #[\Override] public function searchQuery(ISearchQuery $query) { return []; } + #[\Override] public function getIncomplete() { return []; } + #[\Override] public function getPathById($id) { return ''; } + #[\Override] public function normalize($path) { return $path; } + #[\Override] public function copyFromCache(ICache $sourceCache, ICacheEntry $sourceEntry, string $targetPath): int { throw new ForbiddenException('This request is not allowed to access the filesystem'); } + #[\Override] public function getQueryFilterForStorage(): ISearchOperator { return new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', -1); } + #[\Override] public function getCacheEntryFromSearchResult(ICacheEntry $rawEntry): ?ICacheEntry { return null; } diff --git a/lib/private/Lockdown/Filesystem/NullStorage.php b/lib/private/Lockdown/Filesystem/NullStorage.php index 727259319ed..5cf32f125d4 100644 --- a/lib/private/Lockdown/Filesystem/NullStorage.php +++ b/lib/private/Lockdown/Filesystem/NullStorage.php @@ -18,154 +18,192 @@ class NullStorage extends Common { parent::__construct($parameters); } + #[\Override] public function getId(): string { return 'null'; } + #[\Override] public function mkdir(string $path): never { throw new ForbiddenException('This request is not allowed to access the filesystem'); } + #[\Override] public function rmdir(string $path): never { throw new ForbiddenException('This request is not allowed to access the filesystem'); } + #[\Override] public function opendir(string $path): IteratorDirectory { return new IteratorDirectory(); } + #[\Override] public function is_dir(string $path): bool { return $path === ''; } + #[\Override] public function is_file(string $path): bool { return false; } + #[\Override] public function stat(string $path): never { throw new ForbiddenException('This request is not allowed to access the filesystem'); } + #[\Override] public function filetype(string $path): string|false { return ($path === '') ? 'dir' : false; } + #[\Override] public function filesize(string $path): never { throw new ForbiddenException('This request is not allowed to access the filesystem'); } + #[\Override] public function isCreatable(string $path): bool { return false; } + #[\Override] public function isReadable(string $path): bool { return $path === ''; } + #[\Override] public function isUpdatable(string $path): bool { return false; } + #[\Override] public function isDeletable(string $path): bool { return false; } + #[\Override] public function isSharable(string $path): bool { return false; } + #[\Override] public function getPermissions(string $path): int { return 0; } + #[\Override] public function file_exists(string $path): bool { return $path === ''; } + #[\Override] public function filemtime(string $path): int|false { return ($path === '') ? time() : false; } + #[\Override] public function file_get_contents(string $path): never { throw new ForbiddenException('This request is not allowed to access the filesystem'); } + #[\Override] public function file_put_contents(string $path, mixed $data): never { throw new ForbiddenException('This request is not allowed to access the filesystem'); } + #[\Override] public function unlink(string $path): never { throw new ForbiddenException('This request is not allowed to access the filesystem'); } + #[\Override] public function rename(string $source, string $target): never { throw new ForbiddenException('This request is not allowed to access the filesystem'); } + #[\Override] public function copy(string $source, string $target): never { throw new ForbiddenException('This request is not allowed to access the filesystem'); } + #[\Override] public function fopen(string $path, string $mode): never { throw new ForbiddenException('This request is not allowed to access the filesystem'); } + #[\Override] public function getMimeType(string $path): never { throw new ForbiddenException('This request is not allowed to access the filesystem'); } + #[\Override] public function hash(string $type, string $path, bool $raw = false): never { throw new ForbiddenException('This request is not allowed to access the filesystem'); } + #[\Override] public function free_space(string $path): int { return FileInfo::SPACE_UNKNOWN; } + #[\Override] public function touch(string $path, ?int $mtime = null): never { throw new ForbiddenException('This request is not allowed to access the filesystem'); } + #[\Override] public function getLocalFile(string $path): string|false { return false; } + #[\Override] public function hasUpdated(string $path, int $time): bool { return false; } + #[\Override] public function getETag(string $path): string { return ''; } + #[\Override] public function isLocal(): bool { return false; } + #[\Override] public function getDirectDownload(string $path): array|false { return false; } + #[\Override] public function getDirectDownloadById(string $fileId): array|false { return false; } + #[\Override] public function copyFromStorage(IStorage $sourceStorage, string $sourceInternalPath, string $targetInternalPath, bool $preserveMtime = false): never { throw new ForbiddenException('This request is not allowed to access the filesystem'); } + #[\Override] public function moveFromStorage(IStorage $sourceStorage, string $sourceInternalPath, string $targetInternalPath): never { throw new ForbiddenException('This request is not allowed to access the filesystem'); } + #[\Override] public function test(): bool { return true; } + #[\Override] public function getOwner(string $path): string|false { return false; } + #[\Override] public function getCache(string $path = '', ?IStorage $storage = null): ICache { return new NullCache(); } diff --git a/lib/private/Lockdown/LockdownManager.php b/lib/private/Lockdown/LockdownManager.php index 4f351812bad..9fa4892b548 100644 --- a/lib/private/Lockdown/LockdownManager.php +++ b/lib/private/Lockdown/LockdownManager.php @@ -29,6 +29,7 @@ class LockdownManager implements ILockdownManager { } + #[\Override] public function enable() { $this->enabled = true; } @@ -52,6 +53,7 @@ class LockdownManager implements ILockdownManager { return $this->scope; } + #[\Override] public function setToken(IToken $token) { $this->scope = $token->getScopeAsArray(); $session = $this->getSession(); @@ -59,6 +61,7 @@ class LockdownManager implements ILockdownManager { $this->enable(); } + #[\Override] public function canAccessFilesystem() { $scope = $this->getScopeAsArray(); return !$scope || $scope[IToken::SCOPE_FILESYSTEM]; diff --git a/lib/private/Log.php b/lib/private/Log.php index 8fb376ebb1b..a7b1a5fba0b 100644 --- a/lib/private/Log.php +++ b/lib/private/Log.php @@ -367,6 +367,7 @@ class Log implements ILogger, IDataLogger { } } + #[\Override] public function logData(string $message, array $data, array $context = []): void { $app = $context['app'] ?? 'no app in context'; $level = $context['level'] ?? ILogger::ERROR; diff --git a/lib/private/Log/Errorlog.php b/lib/private/Log/Errorlog.php index 6188bb70fd5..0a0fa530cb3 100644 --- a/lib/private/Log/Errorlog.php +++ b/lib/private/Log/Errorlog.php @@ -25,6 +25,7 @@ class Errorlog extends LogDetails implements IWriter { * * @param string|array $message */ + #[\Override] public function write(string $app, $message, int $level): void { error_log('[' . $this->tag . '][' . $app . '][' . $level . '] ' . $this->logDetailsAsJSON($app, $message, $level)); } diff --git a/lib/private/Log/File.php b/lib/private/Log/File.php index 580656ee55a..1ad360784d2 100644 --- a/lib/private/Log/File.php +++ b/lib/private/Log/File.php @@ -45,6 +45,7 @@ class File extends LogDetails implements IWriter, IFileBased { * write a message in the log * @param string|array $message */ + #[\Override] public function write(string $app, $message, int $level): void { $entry = $this->logDetailsAsJSON($app, $message, $level); $handle = @fopen($this->logFile, 'a'); @@ -69,6 +70,7 @@ class File extends LogDetails implements IWriter, IFileBased { /** * get entries from the log in reverse chronological order */ + #[\Override] public function getEntries(int $limit = 50, int $offset = 0): array { $minLevel = $this->config->getValue('loglevel', ILogger::WARN); $entries = []; @@ -111,6 +113,7 @@ class File extends LogDetails implements IWriter, IFileBased { return $entries; } + #[\Override] public function getLogFilePath():string { return $this->logFile; } diff --git a/lib/private/Log/LogFactory.php b/lib/private/Log/LogFactory.php index 58c4f433ca6..2c995f46e59 100644 --- a/lib/private/Log/LogFactory.php +++ b/lib/private/Log/LogFactory.php @@ -24,6 +24,7 @@ class LogFactory implements ILogFactory { /** * @throws QueryException */ + #[\Override] public function get(string $type):IWriter { return match (strtolower($type)) { 'errorlog' => new Errorlog($this->systemConfig), @@ -43,6 +44,7 @@ class LogFactory implements ILogFactory { }; } + #[\Override] public function getCustomPsrLogger(string $path, string $type = 'file', string $tag = 'Nextcloud'): LoggerInterface { $log = $this->createNewLogger($type, $tag, $path); return new PsrLoggerAdapter( diff --git a/lib/private/Log/PsrLoggerAdapter.php b/lib/private/Log/PsrLoggerAdapter.php index 888a482b92c..de5b4df5e15 100644 --- a/lib/private/Log/PsrLoggerAdapter.php +++ b/lib/private/Log/PsrLoggerAdapter.php @@ -53,6 +53,7 @@ final class PsrLoggerAdapter implements LoggerInterface, IDataLogger { * * @param mixed[] $context */ + #[\Override] public function emergency(string|Stringable $message, array $context = []): void { $this->log(LogLevel::EMERGENCY, (string)$message, $context); } @@ -65,6 +66,7 @@ final class PsrLoggerAdapter implements LoggerInterface, IDataLogger { * * @param mixed[] $context */ + #[\Override] public function alert(string|Stringable $message, array $context = []): void { $this->log(LogLevel::ALERT, (string)$message, $context); } @@ -76,6 +78,7 @@ final class PsrLoggerAdapter implements LoggerInterface, IDataLogger { * * @param mixed[] $context */ + #[\Override] public function critical(string|Stringable $message, array $context = []): void { $this->log(LogLevel::CRITICAL, (string)$message, $context); } @@ -86,6 +89,7 @@ final class PsrLoggerAdapter implements LoggerInterface, IDataLogger { * * @param mixed[] $context */ + #[\Override] public function error(string|Stringable $message, array $context = []): void { $this->log(LogLevel::ERROR, (string)$message, $context); } @@ -98,6 +102,7 @@ final class PsrLoggerAdapter implements LoggerInterface, IDataLogger { * * @param mixed[] $context */ + #[\Override] public function warning(string|Stringable $message, array $context = []): void { $this->log(LogLevel::WARNING, (string)$message, $context); } @@ -107,6 +112,7 @@ final class PsrLoggerAdapter implements LoggerInterface, IDataLogger { * * @param mixed[] $context */ + #[\Override] public function notice(string|Stringable $message, array $context = []): void { $this->log(LogLevel::NOTICE, (string)$message, $context); } @@ -118,6 +124,7 @@ final class PsrLoggerAdapter implements LoggerInterface, IDataLogger { * * @param mixed[] $context */ + #[\Override] public function info(string|Stringable $message, array $context = []): void { $this->log(LogLevel::INFO, (string)$message, $context); } @@ -127,6 +134,7 @@ final class PsrLoggerAdapter implements LoggerInterface, IDataLogger { * * @param mixed[] $context */ + #[\Override] public function debug(string|Stringable $message, array $context = []): void { $this->log(LogLevel::DEBUG, (string)$message, $context); } @@ -139,6 +147,7 @@ final class PsrLoggerAdapter implements LoggerInterface, IDataLogger { * * @throws InvalidArgumentException */ + #[\Override] public function log($level, $message, array $context = []): void { if (is_string($level)) { $level = self::logLevelToInt($level); @@ -162,6 +171,7 @@ final class PsrLoggerAdapter implements LoggerInterface, IDataLogger { } } + #[\Override] public function logData(string $message, array $data, array $context = []): void { $this->logger->logData($message, $data, $context); } diff --git a/lib/private/Log/Rotate.php b/lib/private/Log/Rotate.php index b433d302ccc..1d2f37b1dba 100644 --- a/lib/private/Log/Rotate.php +++ b/lib/private/Log/Rotate.php @@ -29,6 +29,7 @@ class Rotate extends TimedJob { $this->setInterval(3600); } + #[\Override] public function run($argument): void { $config = Server::get(IConfig::class); $this->filePath = $config->getSystemValueString('logfile', $config->getSystemValueString('datadirectory', \OC::$SERVERROOT . '/data') . '/nextcloud.log'); diff --git a/lib/private/Log/Syslog.php b/lib/private/Log/Syslog.php index 46214599eb8..92305edc17d 100644 --- a/lib/private/Log/Syslog.php +++ b/lib/private/Log/Syslog.php @@ -42,6 +42,7 @@ class Syslog extends LogDetails implements IWriter { * write a message in the log * @param string|array $message */ + #[\Override] public function write(string $app, $message, int $level): void { $syslog_level = $this->levels[$level]; openlog($this->tag, LOG_PID | LOG_CONS, LOG_USER); diff --git a/lib/private/Log/Systemdlog.php b/lib/private/Log/Systemdlog.php index ffea0511732..8e3a68e2ffb 100644 --- a/lib/private/Log/Systemdlog.php +++ b/lib/private/Log/Systemdlog.php @@ -57,6 +57,7 @@ class Systemdlog extends LogDetails implements IWriter { * Write a message to the log. * @param string|array $message */ + #[\Override] public function write(string $app, $message, int $level): void { $journal_level = $this->levels[$level]; sd_journal_send('PRIORITY=' . $journal_level, diff --git a/lib/private/Mail/Attachment.php b/lib/private/Mail/Attachment.php index 2a5246c0019..54b0cc76d9a 100644 --- a/lib/private/Mail/Attachment.php +++ b/lib/private/Mail/Attachment.php @@ -30,6 +30,7 @@ class Attachment implements IAttachment { * @return $this * @since 13.0.0 */ + #[\Override] public function setFilename(string $filename): IAttachment { $this->name = $filename; return $this; @@ -39,6 +40,7 @@ class Attachment implements IAttachment { * @return $this * @since 13.0.0 */ + #[\Override] public function setContentType(string $contentType): IAttachment { $this->contentType = $contentType; return $this; @@ -48,6 +50,7 @@ class Attachment implements IAttachment { * @return $this * @since 13.0.0 */ + #[\Override] public function setBody(string $body): IAttachment { $this->body = $body; return $this; diff --git a/lib/private/Mail/EMailTemplate.php b/lib/private/Mail/EMailTemplate.php index a327109cc12..2e4d905cf44 100644 --- a/lib/private/Mail/EMailTemplate.php +++ b/lib/private/Mail/EMailTemplate.php @@ -333,6 +333,7 @@ EOF; /** * Sets the subject of the email */ + #[\Override] public function setSubject(string $subject): void { $this->subject = $subject; } @@ -340,6 +341,7 @@ EOF; /** * Adds a header to the email */ + #[\Override] public function addHeader(): void { if ($this->headerAdded) { return; @@ -362,6 +364,7 @@ EOF; * @param string|bool $plainTitle Title that is used in the plain text email * if empty the $title is used, if false none will be used */ + #[\Override] public function addHeading(string $title, $plainTitle = ''): void { if ($this->footerAdded) { return; @@ -395,6 +398,7 @@ EOF; * @param string|bool $plainText Text that is used in the plain text email * if empty the $text is used, if false none will be used */ + #[\Override] public function addBodyText(string $text, $plainText = ''): void { if ($this->footerAdded) { return; @@ -426,6 +430,7 @@ EOF; * @param integer $plainIndent plainIndent If > 0, Indent plainText by this amount. * @since 12.0.0 */ + #[\Override] public function addBodyListItem( string $text, string $metaInfo = '', @@ -512,6 +517,7 @@ EOF; * @param string $plainTextLeft Text of left button that is used in the plain text version - if unset the $textLeft is used * @param string $plainTextRight Text of right button that is used in the plain text version - if unset the $textRight is used */ + #[\Override] public function addBodyButtonGroup( string $textLeft, string $urlLeft, @@ -554,6 +560,7 @@ EOF; * * @since 12.0.0 */ + #[\Override] public function addBodyButton(string $text, string $url, $plainText = ''): void { if ($this->footerAdded) { return; @@ -597,6 +604,7 @@ EOF; * * @param string $text If the text is empty the default "Name - Slogan
This is an automatically sent email" will be used */ + #[\Override] public function addFooter(string $text = '', ?string $lang = null): void { if ($text === '') { $l10n = $this->l10nFactory->get('lib', $lang); @@ -623,6 +631,7 @@ EOF; /** * Returns the rendered email subject as string */ + #[\Override] public function renderSubject(): string { return $this->subject; } @@ -630,6 +639,7 @@ EOF; /** * Returns the rendered HTML email as string */ + #[\Override] public function renderHtml(): string { if (!$this->footerAdded) { $this->footerAdded = true; @@ -642,6 +652,7 @@ EOF; /** * Returns the rendered plain text email as string */ + #[\Override] public function renderText(): string { if (!$this->footerAdded) { $this->footerAdded = true; diff --git a/lib/private/Mail/EmailValidator.php b/lib/private/Mail/EmailValidator.php index e819817b7a9..82e951ebc1e 100644 --- a/lib/private/Mail/EmailValidator.php +++ b/lib/private/Mail/EmailValidator.php @@ -21,6 +21,7 @@ class EmailValidator implements IEmailValidator { ) { } + #[\Override] public function isValid(string $email): bool { if ($email === '') { // Shortcut: empty addresses are never valid diff --git a/lib/private/Mail/Mailer.php b/lib/private/Mail/Mailer.php index a7fe5dd7438..99d9cd99f3a 100644 --- a/lib/private/Mail/Mailer.php +++ b/lib/private/Mail/Mailer.php @@ -76,6 +76,7 @@ class Mailer implements IMailer { /** * Creates a new message object that can be passed to send() */ + #[\Override] public function createMessage(): Message { $plainTextOnly = $this->config->getSystemValueBool('mail_send_plaintext_only', false); return new Message(new Email(), $plainTextOnly); @@ -87,6 +88,7 @@ class Mailer implements IMailer { * @param string|null $contentType * @since 13.0.0 */ + #[\Override] public function createAttachment($data = null, $filename = null, $contentType = null): IAttachment { return new Attachment($data, $filename, $contentType); } @@ -95,6 +97,7 @@ class Mailer implements IMailer { * @param string|null $contentType * @since 13.0.0 */ + #[\Override] public function createAttachmentFromPath(string $path, $contentType = null): IAttachment { return new Attachment(null, null, $contentType, $path); } @@ -104,6 +107,7 @@ class Mailer implements IMailer { * * @since 12.0.0 */ + #[\Override] public function createEMailTemplate(string $emailId, array $data = []): IEMailTemplate { $logoDimensions = $this->config->getAppValue('theming', 'logoDimensions', self::DEFAULT_DIMENSIONS); if (str_contains($logoDimensions, 'x')) { @@ -165,6 +169,7 @@ class Mailer implements IMailer { * @param IMessage $message Message to send * @return string[] $failedRecipients */ + #[\Override] public function send(IMessage $message): array { $debugMode = $this->config->getSystemValueBool('mail_smtpdebug', false); @@ -237,6 +242,7 @@ class Mailer implements IMailer { * @return bool True if the mail address is valid, false otherwise * @deprecated 32.0.0 use {@see IEmailValidator::isValid()} instead */ + #[\Override] public function validateMailAddress(string $email): bool { return $this->emailValidator->isValid($email); } diff --git a/lib/private/Mail/Message.php b/lib/private/Mail/Message.php index 097af11e24c..d27f2e5797d 100644 --- a/lib/private/Mail/Message.php +++ b/lib/private/Mail/Message.php @@ -39,6 +39,7 @@ class Message implements IMessage { * @since 13.0.0 * @return $this */ + #[\Override] public function attach(IAttachment $attachment): IMessage { /** @var Attachment $attachment */ $attachment->attach($this->symfonyEmail); @@ -50,6 +51,7 @@ class Message implements IMessage { * {@inheritDoc} * @since 26.0.0 */ + #[\Override] public function attachInline(string $body, string $name, ?string $contentType = null): IMessage { # To be sure this works with iCalendar messages, we encode with 8bit instead of # quoted-printable encoding. We save the current encoder, replace the current @@ -94,6 +96,7 @@ class Message implements IMessage { * @param array $addresses Example: array('sender@domain.org', 'other@domain.org' => 'A name') * @return $this */ + #[\Override] public function setFrom(array $addresses): IMessage { $this->from = $addresses; return $this; @@ -110,6 +113,7 @@ class Message implements IMessage { * Set the Reply-To address of this message * @return $this */ + #[\Override] public function setReplyTo(array $addresses): IMessage { $this->replyTo = $addresses; return $this; @@ -128,6 +132,7 @@ class Message implements IMessage { * @param array $recipients Example: array('recipient@domain.org', 'other@domain.org' => 'A name') * @return $this */ + #[\Override] public function setTo(array $recipients): IMessage { $this->to = $recipients; return $this; @@ -146,6 +151,7 @@ class Message implements IMessage { * @param array $recipients Example: array('recipient@domain.org', 'other@domain.org' => 'A name') * @return $this */ + #[\Override] public function setCc(array $recipients): IMessage { $this->cc = $recipients; return $this; @@ -164,6 +170,7 @@ class Message implements IMessage { * @param array $recipients Example: array('recipient@domain.org', 'other@domain.org' => 'A name') * @return $this */ + #[\Override] public function setBcc(array $recipients): IMessage { $this->bcc = $recipients; return $this; @@ -179,6 +186,7 @@ class Message implements IMessage { /** * @return $this */ + #[\Override] public function setSubject(string $subject): IMessage { $this->symfonyEmail->subject($subject); return $this; @@ -194,6 +202,7 @@ class Message implements IMessage { /** * @return $this */ + #[\Override] public function setPlainBody(string $body): IMessage { $this->symfonyEmail->text($body); return $this; @@ -211,6 +220,7 @@ class Message implements IMessage { /** * @return $this */ + #[\Override] public function setHtmlBody(string $body): IMessage { if (!$this->plainTextOnly) { $this->symfonyEmail->html($body); @@ -275,6 +285,7 @@ class Message implements IMessage { /** * @return $this */ + #[\Override] public function useTemplate(IEMailTemplate $emailTemplate): IMessage { $this->setSubject($emailTemplate->renderSubject()); $this->setPlainBody($emailTemplate->renderText()); @@ -291,6 +302,7 @@ class Message implements IMessage { * @param AutoSubmitted::VALUE_* $value (one of AutoSubmitted::VALUE_NO, AutoSubmitted::VALUE_AUTO_GENERATED, AutoSubmitted::VALUE_AUTO_REPLIED) * @return $this */ + #[\Override] public function setAutoSubmitted(string $value): IMessage { $headers = $this->symfonyEmail->getHeaders(); diff --git a/lib/private/Mail/Provider/Manager.php b/lib/private/Mail/Provider/Manager.php index f162d30b834..99f7b21c621 100644 --- a/lib/private/Mail/Provider/Manager.php +++ b/lib/private/Mail/Provider/Manager.php @@ -34,6 +34,7 @@ class Manager implements IManager { * * @return bool */ + #[\Override] public function has(): bool { // return true if collection has any providers @@ -48,6 +49,7 @@ class Manager implements IManager { * * @return int */ + #[\Override] public function count(): int { // return count of providers in collection @@ -62,6 +64,7 @@ class Manager implements IManager { * * @return array collection of provider id and label ['jmap' => 'JMap Connector'] */ + #[\Override] public function types(): array { // construct types collection @@ -82,6 +85,7 @@ class Manager implements IManager { * * @return array collection of provider id and object ['jmap' => IProviderObject] */ + #[\Override] public function providers(): array { // evaluate if we already have a cached collection of providers and return the collection if we do @@ -125,6 +129,7 @@ class Manager implements IManager { * * @return IProvider|null */ + #[\Override] public function findProviderById(string $providerId): ?IProvider { // evaluate if we already have a cached collection of providers @@ -149,6 +154,7 @@ class Manager implements IManager { * * @return array> collection of provider id, service id and object ['jmap' => ['Service1' => IServiceObject]] */ + #[\Override] public function services(string $userId): array { // initilize collection @@ -178,6 +184,7 @@ class Manager implements IManager { * * @return IService|null returns service object or null if none found */ + #[\Override] public function findServiceById(string $userId, string $serviceId, ?string $providerId = null): ?IService { // evaluate if provider id was specified @@ -222,6 +229,7 @@ class Manager implements IManager { * * @return IService|null returns service object or null if none found */ + #[\Override] public function findServiceByAddress(string $userId, string $address, ?string $providerId = null): ?IService { // evaluate if provider id was specified diff --git a/lib/private/Memcache/APCu.php b/lib/private/Memcache/APCu.php index 324218797e5..f7f4f65fa5e 100644 --- a/lib/private/Memcache/APCu.php +++ b/lib/private/Memcache/APCu.php @@ -18,6 +18,7 @@ class APCu extends Cache implements IMemcache { use CADTrait; + #[\Override] public function get($key) { $result = apcu_fetch($this->getPrefix() . $key, $success); if (!$success) { @@ -26,6 +27,7 @@ class APCu extends Cache implements IMemcache { return $result; } + #[\Override] public function set($key, $value, $ttl = 0) { if ($ttl === 0) { $ttl = self::DEFAULT_TTL; @@ -33,14 +35,17 @@ class APCu extends Cache implements IMemcache { return apcu_store($this->getPrefix() . $key, $value, $ttl); } + #[\Override] public function hasKey($key) { return apcu_exists($this->getPrefix() . $key); } + #[\Override] public function remove($key) { return apcu_delete($this->getPrefix() . $key); } + #[\Override] public function clear($prefix = '') { $ns = $this->getPrefix() . $prefix; $ns = preg_quote($ns, '/'); @@ -60,6 +65,7 @@ class APCu extends Cache implements IMemcache { * @param int $ttl Time To Live in seconds. Defaults to 60*60*24 * @return bool */ + #[\Override] public function add($key, $value, $ttl = 0) { if ($ttl === 0) { $ttl = self::DEFAULT_TTL; @@ -74,6 +80,7 @@ class APCu extends Cache implements IMemcache { * @param int $step * @return int | bool */ + #[\Override] public function inc($key, $step = 1) { $success = null; return apcu_inc($this->getPrefix() . $key, $step, $success, self::DEFAULT_TTL); @@ -86,6 +93,7 @@ class APCu extends Cache implements IMemcache { * @param int $step * @return int | bool */ + #[\Override] public function dec($key, $step = 1) { return apcu_exists($this->getPrefix() . $key) ? apcu_dec($this->getPrefix() . $key, $step) @@ -100,6 +108,7 @@ class APCu extends Cache implements IMemcache { * @param mixed $new * @return bool */ + #[\Override] public function cas($key, $old, $new) { // apc only does cas for ints if (is_int($old) && is_int($new)) { @@ -109,6 +118,7 @@ class APCu extends Cache implements IMemcache { } } + #[\Override] public static function isAvailable(): bool { if (!extension_loaded('apcu')) { return false; diff --git a/lib/private/Memcache/ArrayCache.php b/lib/private/Memcache/ArrayCache.php index 9b3540b771f..b93211d9143 100644 --- a/lib/private/Memcache/ArrayCache.php +++ b/lib/private/Memcache/ArrayCache.php @@ -18,6 +18,7 @@ class ArrayCache extends Cache implements IMemcache { /** * {@inheritDoc} */ + #[\Override] public function get($key) { if ($this->hasKey($key)) { return $this->cachedData[$key]; @@ -28,6 +29,7 @@ class ArrayCache extends Cache implements IMemcache { /** * {@inheritDoc} */ + #[\Override] public function set($key, $value, $ttl = 0) { $this->cachedData[$key] = $value; return true; @@ -36,6 +38,7 @@ class ArrayCache extends Cache implements IMemcache { /** * {@inheritDoc} */ + #[\Override] public function hasKey($key) { return isset($this->cachedData[$key]); } @@ -43,6 +46,7 @@ class ArrayCache extends Cache implements IMemcache { /** * {@inheritDoc} */ + #[\Override] public function remove($key) { unset($this->cachedData[$key]); return true; @@ -51,6 +55,7 @@ class ArrayCache extends Cache implements IMemcache { /** * {@inheritDoc} */ + #[\Override] public function clear($prefix = '') { if ($prefix === '') { $this->cachedData = []; @@ -73,6 +78,7 @@ class ArrayCache extends Cache implements IMemcache { * @param int $ttl Time To Live in seconds. Defaults to 60*60*24 * @return bool */ + #[\Override] public function add($key, $value, $ttl = 0) { // since this cache is not shared race conditions aren't an issue if ($this->hasKey($key)) { @@ -89,6 +95,7 @@ class ArrayCache extends Cache implements IMemcache { * @param int $step * @return int | bool */ + #[\Override] public function inc($key, $step = 1) { $oldValue = $this->get($key); if (is_int($oldValue)) { @@ -107,6 +114,7 @@ class ArrayCache extends Cache implements IMemcache { * @param int $step * @return int | bool */ + #[\Override] public function dec($key, $step = 1) { $oldValue = $this->get($key); if (is_int($oldValue)) { @@ -125,6 +133,7 @@ class ArrayCache extends Cache implements IMemcache { * @param mixed $new * @return bool */ + #[\Override] public function cas($key, $old, $new) { if ($this->get($key) === $old) { return $this->set($key, $new); @@ -136,6 +145,7 @@ class ArrayCache extends Cache implements IMemcache { /** * {@inheritDoc} */ + #[\Override] public static function isAvailable(): bool { return true; } diff --git a/lib/private/Memcache/Cache.php b/lib/private/Memcache/Cache.php index 48013e2fe6b..f1a8b0f811c 100644 --- a/lib/private/Memcache/Cache.php +++ b/lib/private/Memcache/Cache.php @@ -29,6 +29,7 @@ abstract class Cache implements \ArrayAccess, ICache { * @param string $key * @return mixed */ + #[\Override] abstract public function get($key); /** @@ -37,32 +38,38 @@ abstract class Cache implements \ArrayAccess, ICache { * @param int $ttl * @return mixed */ + #[\Override] abstract public function set($key, $value, $ttl = 0); /** * @param string $key * @return mixed */ + #[\Override] abstract public function hasKey($key); /** * @param string $key * @return mixed */ + #[\Override] abstract public function remove($key); /** * @param string $prefix * @return mixed */ + #[\Override] abstract public function clear($prefix = ''); //implement the ArrayAccess interface + #[\Override] public function offsetExists($offset): bool { return $this->hasKey($offset); } + #[\Override] public function offsetSet($offset, $value): void { $this->set($offset, $value); } @@ -70,11 +77,13 @@ abstract class Cache implements \ArrayAccess, ICache { /** * @return mixed */ + #[\Override] #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->get($offset); } + #[\Override] public function offsetUnset($offset): void { $this->remove($offset); } diff --git a/lib/private/Memcache/Factory.php b/lib/private/Memcache/Factory.php index 940813536c5..6cefc3d2dbc 100644 --- a/lib/private/Memcache/Factory.php +++ b/lib/private/Memcache/Factory.php @@ -161,6 +161,7 @@ class Factory implements ICacheFactory { * @param string $prefix * @return IMemcache */ + #[\Override] public function createLocking(string $prefix = ''): IMemcache { $cache = new $this->lockingCacheClass($this->getGlobalPrefix() . '/' . $prefix); if ($this->lockingCacheClass === Redis::class) { @@ -183,6 +184,7 @@ class Factory implements ICacheFactory { * @param string $prefix * @return ICache */ + #[\Override] public function createDistributed(string $prefix = ''): ICache { $cache = new $this->distributedCacheClass($this->getGlobalPrefix() . '/' . $prefix); if ($this->distributedCacheClass === Redis::class) { @@ -205,6 +207,7 @@ class Factory implements ICacheFactory { * @param string $prefix * @return ICache */ + #[\Override] public function createLocal(string $prefix = ''): ICache { $cache = new $this->localCacheClass($this->getGlobalPrefix() . '/' . $prefix); if ($this->localCacheClass === Redis::class) { @@ -226,10 +229,12 @@ class Factory implements ICacheFactory { * * @return bool */ + #[\Override] public function isAvailable(): bool { return $this->distributedCacheClass !== self::NULL_CACHE; } + #[\Override] public function createInMemory(int $capacity = 512): ICache { return new CappedMemoryCache($capacity); } @@ -239,6 +244,7 @@ class Factory implements ICacheFactory { * * @return bool */ + #[\Override] public function isLocalCacheAvailable(): bool { return $this->localCacheClass !== self::NULL_CACHE; } diff --git a/lib/private/Memcache/LoggerWrapperCache.php b/lib/private/Memcache/LoggerWrapperCache.php index a25185eb8c4..512a8ed2293 100644 --- a/lib/private/Memcache/LoggerWrapperCache.php +++ b/lib/private/Memcache/LoggerWrapperCache.php @@ -21,6 +21,7 @@ class LoggerWrapperCache extends Cache implements IMemcacheTTL { parent::__construct($wrappedCache->getPrefix()); } + #[\Override] public function getPrefix(): string { return $this->prefix; } @@ -30,6 +31,7 @@ class LoggerWrapperCache extends Cache implements IMemcacheTTL { } /** @inheritDoc */ + #[\Override] public function get($key) { file_put_contents( $this->logFile, @@ -40,6 +42,7 @@ class LoggerWrapperCache extends Cache implements IMemcacheTTL { } /** @inheritDoc */ + #[\Override] public function set($key, $value, $ttl = 0) { file_put_contents( $this->logFile, @@ -51,6 +54,7 @@ class LoggerWrapperCache extends Cache implements IMemcacheTTL { } /** @inheritDoc */ + #[\Override] public function hasKey($key) { file_put_contents( $this->logFile, @@ -62,6 +66,7 @@ class LoggerWrapperCache extends Cache implements IMemcacheTTL { } /** @inheritDoc */ + #[\Override] public function remove($key) { file_put_contents( $this->logFile, @@ -73,6 +78,7 @@ class LoggerWrapperCache extends Cache implements IMemcacheTTL { } /** @inheritDoc */ + #[\Override] public function clear($prefix = '') { file_put_contents( $this->logFile, @@ -84,6 +90,7 @@ class LoggerWrapperCache extends Cache implements IMemcacheTTL { } /** @inheritDoc */ + #[\Override] public function add($key, $value, $ttl = 0) { file_put_contents( $this->logFile, @@ -95,6 +102,7 @@ class LoggerWrapperCache extends Cache implements IMemcacheTTL { } /** @inheritDoc */ + #[\Override] public function inc($key, $step = 1) { file_put_contents( $this->logFile, @@ -106,6 +114,7 @@ class LoggerWrapperCache extends Cache implements IMemcacheTTL { } /** @inheritDoc */ + #[\Override] public function dec($key, $step = 1) { file_put_contents( $this->logFile, @@ -117,6 +126,7 @@ class LoggerWrapperCache extends Cache implements IMemcacheTTL { } /** @inheritDoc */ + #[\Override] public function cas($key, $old, $new) { file_put_contents( $this->logFile, @@ -128,6 +138,7 @@ class LoggerWrapperCache extends Cache implements IMemcacheTTL { } /** @inheritDoc */ + #[\Override] public function cad($key, $old) { file_put_contents( $this->logFile, @@ -139,6 +150,7 @@ class LoggerWrapperCache extends Cache implements IMemcacheTTL { } /** @inheritDoc */ + #[\Override] public function ncad(string $key, mixed $old): bool { file_put_contents( $this->logFile, @@ -150,18 +162,22 @@ class LoggerWrapperCache extends Cache implements IMemcacheTTL { } /** @inheritDoc */ + #[\Override] public function setTTL(string $key, int $ttl) { $this->wrappedCache->setTTL($key, $ttl); } + #[\Override] public function getTTL(string $key): int|false { return $this->wrappedCache->getTTL($key); } + #[\Override] public function compareSetTTL(string $key, mixed $value, int $ttl): bool { return $this->wrappedCache->compareSetTTL($key, $value, $ttl); } + #[\Override] public static function isAvailable(): bool { return true; } diff --git a/lib/private/Memcache/Memcached.php b/lib/private/Memcache/Memcached.php index 044a0fccd25..d6e0e182aca 100644 --- a/lib/private/Memcache/Memcached.php +++ b/lib/private/Memcache/Memcached.php @@ -83,6 +83,7 @@ class Memcached extends Cache implements IMemcache { return $this->prefix; } + #[\Override] public function get($key) { $result = self::$cache->get($this->getNameSpace() . $key); if ($result === false && self::$cache->getResultCode() === \Memcached::RES_NOTFOUND) { @@ -92,6 +93,7 @@ class Memcached extends Cache implements IMemcache { } } + #[\Override] public function set($key, $value, $ttl = 0) { if ($ttl > 0) { $result = self::$cache->set($this->getNameSpace() . $key, $value, $ttl); @@ -101,16 +103,19 @@ class Memcached extends Cache implements IMemcache { return $result || $this->isSuccess(); } + #[\Override] public function hasKey($key) { self::$cache->get($this->getNameSpace() . $key); return self::$cache->getResultCode() === \Memcached::RES_SUCCESS; } + #[\Override] public function remove($key) { $result = self::$cache->delete($this->getNameSpace() . $key); return $result || $this->isSuccess() || self::$cache->getResultCode() === \Memcached::RES_NOTFOUND; } + #[\Override] public function clear($prefix = '') { // Newer Memcached doesn't like getAllKeys(), flush everything self::$cache->flush(); @@ -125,6 +130,7 @@ class Memcached extends Cache implements IMemcache { * @param int $ttl Time To Live in seconds. Defaults to 60*60*24 * @return bool */ + #[\Override] public function add($key, $value, $ttl = 0) { $result = self::$cache->add($this->getPrefix() . $key, $value, $ttl); return $result || $this->isSuccess(); @@ -137,6 +143,7 @@ class Memcached extends Cache implements IMemcache { * @param int $step * @return int | bool */ + #[\Override] public function inc($key, $step = 1) { $this->add($key, 0); $result = self::$cache->increment($this->getPrefix() . $key, $step); @@ -155,6 +162,7 @@ class Memcached extends Cache implements IMemcache { * @param int $step * @return int | bool */ + #[\Override] public function dec($key, $step = 1) { $result = self::$cache->decrement($this->getPrefix() . $key, $step); @@ -165,6 +173,7 @@ class Memcached extends Cache implements IMemcache { return $result; } + #[\Override] public static function isAvailable(): bool { return extension_loaded('memcached'); } diff --git a/lib/private/Memcache/NullCache.php b/lib/private/Memcache/NullCache.php index 0fc66db82f8..683a71ba2bb 100644 --- a/lib/private/Memcache/NullCache.php +++ b/lib/private/Memcache/NullCache.php @@ -12,51 +12,63 @@ namespace OC\Memcache; use OCP\IMemcache; class NullCache extends Cache implements IMemcache { + #[\Override] public function get($key) { return null; } + #[\Override] public function set($key, $value, $ttl = 0) { return true; } + #[\Override] public function hasKey($key) { return false; } + #[\Override] public function remove($key) { return true; } + #[\Override] public function add($key, $value, $ttl = 0) { return true; } + #[\Override] public function inc($key, $step = 1) { return true; } + #[\Override] public function dec($key, $step = 1) { return true; } + #[\Override] public function cas($key, $old, $new) { return true; } + #[\Override] public function cad($key, $old) { return true; } + #[\Override] public function ncad(string $key, mixed $old): bool { return true; } + #[\Override] public function clear($prefix = '') { return true; } + #[\Override] public static function isAvailable(): bool { return true; } diff --git a/lib/private/Memcache/ProfilerWrapperCache.php b/lib/private/Memcache/ProfilerWrapperCache.php index c9fb77885b4..49c7eac8d87 100644 --- a/lib/private/Memcache/ProfilerWrapperCache.php +++ b/lib/private/Memcache/ProfilerWrapperCache.php @@ -40,6 +40,7 @@ class ProfilerWrapperCache extends AbstractDataCollector implements IMemcacheTTL } /** @inheritDoc */ + #[\Override] public function get($key) { $start = microtime(true); $ret = $this->wrappedCache->get($key); @@ -58,6 +59,7 @@ class ProfilerWrapperCache extends AbstractDataCollector implements IMemcacheTTL } /** @inheritDoc */ + #[\Override] public function set($key, $value, $ttl = 0) { $start = microtime(true); $ret = $this->wrappedCache->set($key, $value, $ttl); @@ -70,6 +72,7 @@ class ProfilerWrapperCache extends AbstractDataCollector implements IMemcacheTTL } /** @inheritDoc */ + #[\Override] public function hasKey($key) { $start = microtime(true); $ret = $this->wrappedCache->hasKey($key); @@ -82,6 +85,7 @@ class ProfilerWrapperCache extends AbstractDataCollector implements IMemcacheTTL } /** @inheritDoc */ + #[\Override] public function remove($key) { $start = microtime(true); $ret = $this->wrappedCache->remove($key); @@ -94,6 +98,7 @@ class ProfilerWrapperCache extends AbstractDataCollector implements IMemcacheTTL } /** @inheritDoc */ + #[\Override] public function clear($prefix = '') { $start = microtime(true); $ret = $this->wrappedCache->clear($prefix); @@ -106,6 +111,7 @@ class ProfilerWrapperCache extends AbstractDataCollector implements IMemcacheTTL } /** @inheritDoc */ + #[\Override] public function add($key, $value, $ttl = 0) { $start = microtime(true); $ret = $this->wrappedCache->add($key, $value, $ttl); @@ -118,6 +124,7 @@ class ProfilerWrapperCache extends AbstractDataCollector implements IMemcacheTTL } /** @inheritDoc */ + #[\Override] public function inc($key, $step = 1) { $start = microtime(true); $ret = $this->wrappedCache->inc($key, $step); @@ -130,6 +137,7 @@ class ProfilerWrapperCache extends AbstractDataCollector implements IMemcacheTTL } /** @inheritDoc */ + #[\Override] public function dec($key, $step = 1) { $start = microtime(true); $ret = $this->wrappedCache->dec($key, $step); @@ -142,6 +150,7 @@ class ProfilerWrapperCache extends AbstractDataCollector implements IMemcacheTTL } /** @inheritDoc */ + #[\Override] public function cas($key, $old, $new) { $start = microtime(true); $ret = $this->wrappedCache->cas($key, $old, $new); @@ -154,6 +163,7 @@ class ProfilerWrapperCache extends AbstractDataCollector implements IMemcacheTTL } /** @inheritDoc */ + #[\Override] public function cad($key, $old) { $start = microtime(true); $ret = $this->wrappedCache->cad($key, $old); @@ -166,6 +176,7 @@ class ProfilerWrapperCache extends AbstractDataCollector implements IMemcacheTTL } /** @inheritDoc */ + #[\Override] public function ncad(string $key, mixed $old): bool { $start = microtime(true); $ret = $this->wrappedCache->ncad($key, $old); @@ -178,22 +189,27 @@ class ProfilerWrapperCache extends AbstractDataCollector implements IMemcacheTTL } /** @inheritDoc */ + #[\Override] public function setTTL(string $key, int $ttl) { $this->wrappedCache->setTTL($key, $ttl); } + #[\Override] public function getTTL(string $key): int|false { return $this->wrappedCache->getTTL($key); } + #[\Override] public function compareSetTTL(string $key, mixed $value, int $ttl): bool { return $this->wrappedCache->compareSetTTL($key, $value, $ttl); } + #[\Override] public function offsetExists($offset): bool { return $this->hasKey($offset); } + #[\Override] public function offsetSet($offset, $value): void { $this->set($offset, $value); } @@ -201,23 +217,28 @@ class ProfilerWrapperCache extends AbstractDataCollector implements IMemcacheTTL /** * @return mixed */ + #[\Override] #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->get($offset); } + #[\Override] public function offsetUnset($offset): void { $this->remove($offset); } + #[\Override] public function collect(Request $request, Response $response, ?\Throwable $exception = null): void { // Nothing to do here $data is already ready } + #[\Override] public function getName(): string { return 'cache/' . $this->type . '/' . $this->prefix; } + #[\Override] public static function isAvailable(): bool { return true; } diff --git a/lib/private/Memcache/Redis.php b/lib/private/Memcache/Redis.php index 1611d428f30..03da8e138e7 100644 --- a/lib/private/Memcache/Redis.php +++ b/lib/private/Memcache/Redis.php @@ -57,6 +57,7 @@ class Redis extends Cache implements IMemcacheTTL { return self::$cache; } + #[\Override] public function get($key) { $result = $this->getCache()->get($this->getPrefix() . $key); if ($result === false) { @@ -66,6 +67,7 @@ class Redis extends Cache implements IMemcacheTTL { return self::decodeValue($result); } + #[\Override] public function set($key, $value, $ttl = 0) { $value = self::encodeValue($value); if ($ttl === 0) { @@ -76,10 +78,12 @@ class Redis extends Cache implements IMemcacheTTL { return $this->getCache()->setex($this->getPrefix() . $key, $ttl, $value); } + #[\Override] public function hasKey($key) { return (bool)$this->getCache()->exists($this->getPrefix() . $key); } + #[\Override] public function remove($key) { if ($this->getCache()->unlink($this->getPrefix() . $key)) { return true; @@ -88,6 +92,7 @@ class Redis extends Cache implements IMemcacheTTL { } } + #[\Override] public function clear($prefix = '') { // TODO: this is slow and would fail with Redis cluster $prefix = $this->getPrefix() . $prefix . '*'; @@ -105,6 +110,7 @@ class Redis extends Cache implements IMemcacheTTL { * @param int $ttl Time To Live in seconds. Defaults to 60*60*24 * @return bool */ + #[\Override] public function add($key, $value, $ttl = 0) { $value = self::encodeValue($value); if ($ttl === 0) { @@ -126,6 +132,7 @@ class Redis extends Cache implements IMemcacheTTL { * @param int $step * @return int | bool */ + #[\Override] public function inc($key, $step = 1) { return $this->getCache()->incrBy($this->getPrefix() . $key, $step); } @@ -137,6 +144,7 @@ class Redis extends Cache implements IMemcacheTTL { * @param int $step * @return int | bool */ + #[\Override] public function dec($key, $step = 1) { $res = $this->evalLua('dec', [$key], [$step]); return ($res === 'NEX') ? false : $res; @@ -150,6 +158,7 @@ class Redis extends Cache implements IMemcacheTTL { * @param mixed $new * @return bool */ + #[\Override] public function cas($key, $old, $new) { $old = self::encodeValue($old); $new = self::encodeValue($new); @@ -164,18 +173,21 @@ class Redis extends Cache implements IMemcacheTTL { * @param mixed $old * @return bool */ + #[\Override] public function cad($key, $old) { $old = self::encodeValue($old); return $this->evalLua('cad', [$key], [$old]) > 0; } + #[\Override] public function ncad(string $key, mixed $old): bool { $old = self::encodeValue($old); return $this->evalLua('ncad', [$key], [$old]) > 0; } + #[\Override] public function setTTL($key, $ttl) { if ($ttl === 0) { // having infinite TTL can lead to leaked keys as the prefix changes with version upgrades @@ -185,17 +197,20 @@ class Redis extends Cache implements IMemcacheTTL { $this->getCache()->expire($this->getPrefix() . $key, $ttl); } + #[\Override] public function getTTL(string $key): int|false { $ttl = $this->getCache()->ttl($this->getPrefix() . $key); return $ttl > 0 ? (int)$ttl : false; } + #[\Override] public function compareSetTTL(string $key, mixed $value, int $ttl): bool { $value = self::encodeValue($value); return $this->evalLua('caSetTtl', [$key], [$value, $ttl]) > 0; } + #[\Override] public static function isAvailable(): bool { return Server::get('RedisFactory')->isAvailable(); } diff --git a/lib/private/Memcache/WithLocalCache.php b/lib/private/Memcache/WithLocalCache.php index 334fa4bc753..339c097f3db 100644 --- a/lib/private/Memcache/WithLocalCache.php +++ b/lib/private/Memcache/WithLocalCache.php @@ -22,6 +22,7 @@ class WithLocalCache implements ICache { $this->cached = new CappedMemoryCache($localCapacity); } + #[\Override] public function get($key) { if (isset($this->cached[$key])) { return $this->cached[$key]; @@ -34,25 +35,30 @@ class WithLocalCache implements ICache { } } + #[\Override] public function set($key, $value, $ttl = 0) { $this->cached[$key] = $value; return $this->inner->set($key, $value, $ttl); } + #[\Override] public function hasKey($key) { return isset($this->cached[$key]) || $this->inner->hasKey($key); } + #[\Override] public function remove($key) { unset($this->cached[$key]); return $this->inner->remove($key); } + #[\Override] public function clear($prefix = '') { $this->cached->clear(); return $this->inner->clear($prefix); } + #[\Override] public static function isAvailable(): bool { return false; } diff --git a/lib/private/Migration/BackgroundRepair.php b/lib/private/Migration/BackgroundRepair.php index d542b82d5e1..ca252962d4e 100644 --- a/lib/private/Migration/BackgroundRepair.php +++ b/lib/private/Migration/BackgroundRepair.php @@ -35,6 +35,7 @@ class BackgroundRepair extends TimedJob { * @param array $argument * @throws \Exception */ + #[\Override] protected function run($argument): void { if (!isset($argument['app']) || !isset($argument['step'])) { // remove the job - we can never execute it diff --git a/lib/private/Migration/ConsoleOutput.php b/lib/private/Migration/ConsoleOutput.php index 31412bf4ff0..a97ffe5cb93 100644 --- a/lib/private/Migration/ConsoleOutput.php +++ b/lib/private/Migration/ConsoleOutput.php @@ -27,6 +27,7 @@ class ConsoleOutput implements IOutput { ) { } + #[\Override] public function debug(string $message): void { $this->output->writeln($message, OutputInterface::VERBOSITY_VERBOSE); } @@ -34,6 +35,7 @@ class ConsoleOutput implements IOutput { /** * @param string $message */ + #[\Override] public function info($message): void { $this->output->writeln("$message"); } @@ -41,6 +43,7 @@ class ConsoleOutput implements IOutput { /** * @param string $message */ + #[\Override] public function warning($message): void { $this->output->writeln("$message"); } @@ -48,6 +51,7 @@ class ConsoleOutput implements IOutput { /** * @param int $max */ + #[\Override] public function startProgress($max = 0): void { if (!is_null($this->progressBar)) { $this->progressBar->finish(); @@ -60,6 +64,7 @@ class ConsoleOutput implements IOutput { * @param int $step * @param string $description */ + #[\Override] public function advance($step = 1, $description = ''): void { if (is_null($this->progressBar)) { $this->progressBar = new ProgressBar($this->output); @@ -71,6 +76,7 @@ class ConsoleOutput implements IOutput { } } + #[\Override] public function finishProgress(): void { if (is_null($this->progressBar)) { return; diff --git a/lib/private/Migration/NullOutput.php b/lib/private/Migration/NullOutput.php index f099d515c77..86b92312534 100644 --- a/lib/private/Migration/NullOutput.php +++ b/lib/private/Migration/NullOutput.php @@ -18,21 +18,27 @@ use OCP\Migration\IOutput; * @package OC\Migration */ class NullOutput implements IOutput { + #[\Override] public function debug(string $message): void { } + #[\Override] public function info($message): void { } + #[\Override] public function warning($message): void { } + #[\Override] public function startProgress($max = 0): void { } + #[\Override] public function advance($step = 1, $description = ''): void { } + #[\Override] public function finishProgress(): void { } } diff --git a/lib/private/Migration/SimpleOutput.php b/lib/private/Migration/SimpleOutput.php index b7a07cc6ff2..48df5e43141 100644 --- a/lib/private/Migration/SimpleOutput.php +++ b/lib/private/Migration/SimpleOutput.php @@ -25,6 +25,7 @@ class SimpleOutput implements IOutput { ) { } + #[\Override] public function debug(string $message): void { $this->logger->debug($message, ['app' => $this->appName]); } @@ -33,6 +34,7 @@ class SimpleOutput implements IOutput { * @param string $message * @since 9.1.0 */ + #[\Override] public function info($message): void { $this->logger->info($message, ['app' => $this->appName]); } @@ -41,6 +43,7 @@ class SimpleOutput implements IOutput { * @param string $message * @since 9.1.0 */ + #[\Override] public function warning($message): void { $this->logger->warning($message, ['app' => $this->appName]); } @@ -49,6 +52,7 @@ class SimpleOutput implements IOutput { * @param int $max * @since 9.1.0 */ + #[\Override] public function startProgress($max = 0): void { } @@ -57,12 +61,14 @@ class SimpleOutput implements IOutput { * @param string $description * @since 9.1.0 */ + #[\Override] public function advance($step = 1, $description = ''): void { } /** * @since 9.1.0 */ + #[\Override] public function finishProgress(): void { } } diff --git a/lib/private/Notification/Action.php b/lib/private/Notification/Action.php index 0ae86760a32..45e99bf6264 100644 --- a/lib/private/Notification/Action.php +++ b/lib/private/Notification/Action.php @@ -21,6 +21,7 @@ class Action implements IAction { /** * {@inheritDoc} */ + #[\Override] public function setLabel(string $label): IAction { if ($label === '' || isset($label[32])) { throw new InvalidValueException('label'); @@ -32,6 +33,7 @@ class Action implements IAction { /** * {@inheritDoc} */ + #[\Override] public function getLabel(): string { return $this->label; } @@ -39,6 +41,7 @@ class Action implements IAction { /** * {@inheritDoc} */ + #[\Override] public function setParsedLabel(string $label): IAction { if ($label === '') { throw new InvalidValueException('parsedLabel'); @@ -50,6 +53,7 @@ class Action implements IAction { /** * {@inheritDoc} */ + #[\Override] public function getParsedLabel(): string { return $this->labelParsed; } @@ -57,6 +61,7 @@ class Action implements IAction { /** * {@inheritDoc} */ + #[\Override] public function setPrimary(bool $primary): IAction { $this->primary = $primary; return $this; @@ -65,6 +70,7 @@ class Action implements IAction { /** * {@inheritDoc} */ + #[\Override] public function isPrimary(): bool { return $this->primary; } @@ -72,6 +78,7 @@ class Action implements IAction { /** * {@inheritDoc} */ + #[\Override] public function setLink(string $link, string $requestType): IAction { if ($link === '' || isset($link[256])) { throw new InvalidValueException('link'); @@ -99,6 +106,7 @@ class Action implements IAction { /** * {@inheritDoc} */ + #[\Override] public function getLink(): string { return $this->link; } @@ -106,6 +114,7 @@ class Action implements IAction { /** * {@inheritDoc} */ + #[\Override] public function getRequestType(): string { return $this->requestType; } @@ -113,6 +122,7 @@ class Action implements IAction { /** * {@inheritDoc} */ + #[\Override] public function isValid(): bool { return $this->label !== '' && $this->link !== ''; } @@ -120,6 +130,7 @@ class Action implements IAction { /** * {@inheritDoc} */ + #[\Override] public function isValidParsed(): bool { return $this->labelParsed !== '' && $this->link !== ''; } diff --git a/lib/private/Notification/Manager.php b/lib/private/Notification/Manager.php index 24b401a0e90..a1c15759d4f 100644 --- a/lib/private/Notification/Manager.php +++ b/lib/private/Notification/Manager.php @@ -77,6 +77,7 @@ class Manager implements IManager { * \InvalidArgumentException is thrown later * @since 17.0.0 */ + #[\Override] public function registerApp(string $appClass): void { // other apps may want to rely on the 'main' notification app so make it deterministic that // the 'main' notification app adds it's notifications first and removes it's notifications last @@ -95,6 +96,7 @@ class Manager implements IManager { * \InvalidArgumentException is thrown later * @since 17.0.0 */ + #[\Override] public function registerNotifierService(string $notifierService): void { $this->notifierClasses[] = $notifierService; } @@ -136,6 +138,7 @@ class Manager implements IManager { /** * @return INotifier[] */ + #[\Override] public function getNotifiers(): array { if (!$this->parsedRegistrationContext) { $notifierServices = $this->coordinator->getRegistrationContext()->getNotifierServices(); @@ -197,6 +200,7 @@ class Manager implements IManager { * @return INotification * @since 8.2.0 */ + #[\Override] public function createNotification(): INotification { return new Notification($this->validator, $this->richTextFormatter); } @@ -205,6 +209,7 @@ class Manager implements IManager { * @return bool * @since 8.2.0 */ + #[\Override] public function hasNotifiers(): bool { return !empty($this->notifiers) || !empty($this->notifierClasses) @@ -215,6 +220,7 @@ class Manager implements IManager { * @param bool $preparingPushNotification * @since 14.0.0 */ + #[\Override] public function setPreparingPushNotification(bool $preparingPushNotification): void { $this->preparingPushNotification = $preparingPushNotification; } @@ -223,6 +229,7 @@ class Manager implements IManager { * @return bool * @since 14.0.0 */ + #[\Override] public function isPreparingPushNotification(): bool { return $this->preparingPushNotification; } @@ -232,6 +239,7 @@ class Manager implements IManager { * @return bool * @since 20.0.0 */ + #[\Override] public function defer(): bool { $alreadyDeferring = $this->deferPushing; $this->deferPushing = true; @@ -250,6 +258,7 @@ class Manager implements IManager { /** * @since 20.0.0 */ + #[\Override] public function flush(): void { $apps = array_reverse($this->getApps()); @@ -270,6 +279,7 @@ class Manager implements IManager { /** * {@inheritDoc} */ + #[\Override] public function isFairUseOfFreePushService(): bool { $pushAllowed = $this->cache->get('push_fair_use'); if ($pushAllowed === null) { @@ -288,6 +298,7 @@ class Manager implements IManager { /** * {@inheritDoc} */ + #[\Override] public function notify(INotification $notification): void { if (!$notification->isValid()) { throw new IncompleteNotificationException('The given notification is invalid'); @@ -312,6 +323,7 @@ class Manager implements IManager { * @return string * @since 17.0.0 */ + #[\Override] public function getID(): string { return 'core'; } @@ -322,6 +334,7 @@ class Manager implements IManager { * @return string * @since 17.0.0 */ + #[\Override] public function getName(): string { return 'core'; } @@ -329,6 +342,7 @@ class Manager implements IManager { /** * {@inheritDoc} */ + #[\Override] public function prepare(INotification $notification, string $languageCode): INotification { $notifiers = $this->getNotifiers(); @@ -360,6 +374,7 @@ class Manager implements IManager { return $notification; } + #[\Override] public function preloadDataForParsing( array $notifications, string $languageCode, @@ -378,6 +393,7 @@ class Manager implements IManager { /** * @param INotification $notification */ + #[\Override] public function markProcessed(INotification $notification): void { $apps = array_reverse($this->getApps()); @@ -390,6 +406,7 @@ class Manager implements IManager { * @param INotification $notification * @return int */ + #[\Override] public function getCount(INotification $notification): int { $apps = array_reverse($this->getApps()); @@ -404,6 +421,7 @@ class Manager implements IManager { /** * {@inheritDoc} */ + #[\Override] public function dismissNotification(INotification $notification): void { $notifiers = $this->getNotifiers(); diff --git a/lib/private/Notification/Notification.php b/lib/private/Notification/Notification.php index 07d7aef363f..b055b0f9c79 100644 --- a/lib/private/Notification/Notification.php +++ b/lib/private/Notification/Notification.php @@ -58,6 +58,7 @@ class Notification implements INotification { /** * {@inheritDoc} */ + #[\Override] public function setApp(string $app): INotification { if ($app === '' || isset($app[32])) { throw new InvalidValueException('app'); @@ -69,6 +70,7 @@ class Notification implements INotification { /** * {@inheritDoc} */ + #[\Override] public function getApp(): string { return $this->app; } @@ -76,6 +78,7 @@ class Notification implements INotification { /** * {@inheritDoc} */ + #[\Override] public function setUser(string $user): INotification { if ($user === '' || isset($user[64])) { throw new InvalidValueException('user'); @@ -87,6 +90,7 @@ class Notification implements INotification { /** * {@inheritDoc} */ + #[\Override] public function getUser(): string { return $this->user; } @@ -94,6 +98,7 @@ class Notification implements INotification { /** * {@inheritDoc} */ + #[\Override] public function setDateTime(\DateTime $dateTime): INotification { if ($dateTime->getTimestamp() === 0) { throw new InvalidValueException('dateTime'); @@ -105,6 +110,7 @@ class Notification implements INotification { /** * {@inheritDoc} */ + #[\Override] public function getDateTime(): \DateTime { return $this->dateTime; } @@ -112,6 +118,7 @@ class Notification implements INotification { /** * {@inheritDoc} */ + #[\Override] public function setObject(string $type, string $id): INotification { if ($type === '' || isset($type[64])) { throw new InvalidValueException('objectType'); @@ -128,6 +135,7 @@ class Notification implements INotification { /** * {@inheritDoc} */ + #[\Override] public function getObjectType(): string { return $this->objectType; } @@ -135,6 +143,7 @@ class Notification implements INotification { /** * {@inheritDoc} */ + #[\Override] public function getObjectId(): string { return $this->objectId; } @@ -142,6 +151,7 @@ class Notification implements INotification { /** * {@inheritDoc} */ + #[\Override] public function setSubject(string $subject, array $parameters = []): INotification { if ($subject === '' || isset($subject[64])) { throw new InvalidValueException('subject'); @@ -156,6 +166,7 @@ class Notification implements INotification { /** * {@inheritDoc} */ + #[\Override] public function getSubject(): string { return $this->subject; } @@ -163,6 +174,7 @@ class Notification implements INotification { /** * {@inheritDoc} */ + #[\Override] public function getSubjectParameters(): array { return $this->subjectParameters; } @@ -170,6 +182,7 @@ class Notification implements INotification { /** * {@inheritDoc} */ + #[\Override] public function setParsedSubject(string $subject): INotification { if ($subject === '') { throw new InvalidValueException('parsedSubject'); @@ -181,6 +194,7 @@ class Notification implements INotification { /** * {@inheritDoc} */ + #[\Override] public function getParsedSubject(): string { return $this->subjectParsed; } @@ -188,6 +202,7 @@ class Notification implements INotification { /** * {@inheritDoc} */ + #[\Override] public function setRichSubject(string $subject, array $parameters = []): INotification { if ($subject === '') { throw new InvalidValueException('richSubject'); @@ -210,6 +225,7 @@ class Notification implements INotification { /** * {@inheritDoc} */ + #[\Override] public function getRichSubject(): string { return $this->subjectRich; } @@ -217,6 +233,7 @@ class Notification implements INotification { /** * {@inheritDoc} */ + #[\Override] public function getRichSubjectParameters(): array { return $this->subjectRichParameters; } @@ -224,6 +241,7 @@ class Notification implements INotification { /** * {@inheritDoc} */ + #[\Override] public function setMessage(string $message, array $parameters = []): INotification { if ($message === '' || isset($message[64])) { throw new InvalidValueException('message'); @@ -238,6 +256,7 @@ class Notification implements INotification { /** * {@inheritDoc} */ + #[\Override] public function getMessage(): string { return $this->message; } @@ -245,6 +264,7 @@ class Notification implements INotification { /** * {@inheritDoc} */ + #[\Override] public function getMessageParameters(): array { return $this->messageParameters; } @@ -252,6 +272,7 @@ class Notification implements INotification { /** * {@inheritDoc} */ + #[\Override] public function setParsedMessage(string $message): INotification { if ($message === '') { throw new InvalidValueException('parsedMessage'); @@ -263,6 +284,7 @@ class Notification implements INotification { /** * {@inheritDoc} */ + #[\Override] public function getParsedMessage(): string { return $this->messageParsed; } @@ -270,6 +292,7 @@ class Notification implements INotification { /** * {@inheritDoc} */ + #[\Override] public function setRichMessage(string $message, array $parameters = []): INotification { if ($message === '') { throw new InvalidValueException('richMessage'); @@ -292,6 +315,7 @@ class Notification implements INotification { /** * {@inheritDoc} */ + #[\Override] public function getRichMessage(): string { return $this->messageRich; } @@ -299,6 +323,7 @@ class Notification implements INotification { /** * {@inheritDoc} */ + #[\Override] public function getRichMessageParameters(): array { return $this->messageRichParameters; } @@ -306,6 +331,7 @@ class Notification implements INotification { /** * {@inheritDoc} */ + #[\Override] public function setLink(string $link): INotification { if ($link === '' || isset($link[4000])) { throw new InvalidValueException('link'); @@ -323,6 +349,7 @@ class Notification implements INotification { /** * {@inheritDoc} */ + #[\Override] public function getLink(): string { return $this->link; } @@ -330,6 +357,7 @@ class Notification implements INotification { /** * {@inheritDoc} */ + #[\Override] public function setIcon(string $icon): INotification { if ($icon === '' || isset($icon[4000])) { throw new InvalidValueException('icon'); @@ -347,6 +375,7 @@ class Notification implements INotification { /** * {@inheritDoc} */ + #[\Override] public function getIcon(): string { return $this->icon; } @@ -354,6 +383,7 @@ class Notification implements INotification { /** * {@inheritDoc} */ + #[\Override] public function setPriorityNotification(bool $priorityNotification): INotification { if ($priorityNotification && !in_array($this->getApp(), self::PRIORITY_NOTIFICATION_APPS, true)) { throw new InvalidValueException('priorityNotification'); @@ -366,6 +396,7 @@ class Notification implements INotification { /** * {@inheritDoc} */ + #[\Override] public function isPriorityNotification(): bool { return $this->priorityNotification; } @@ -373,6 +404,7 @@ class Notification implements INotification { /** * {@inheritDoc} */ + #[\Override] public function createAction(): IAction { return new Action(); } @@ -380,6 +412,7 @@ class Notification implements INotification { /** * {@inheritDoc} */ + #[\Override] public function addAction(IAction $action): INotification { if (!$action->isValid()) { throw new InvalidValueException('action'); @@ -400,6 +433,7 @@ class Notification implements INotification { /** * {@inheritDoc} */ + #[\Override] public function getActions(): array { return $this->actions; } @@ -407,6 +441,7 @@ class Notification implements INotification { /** * {@inheritDoc} */ + #[\Override] public function addParsedAction(IAction $action): INotification { if (!$action->isValidParsed()) { throw new InvalidValueException('action'); @@ -431,6 +466,7 @@ class Notification implements INotification { /** * {@inheritDoc} */ + #[\Override] public function getParsedActions(): array { return $this->actionsParsed; } @@ -438,6 +474,7 @@ class Notification implements INotification { /** * {@inheritDoc} */ + #[\Override] public function isValid(): bool { return $this->isValidCommon() @@ -448,6 +485,7 @@ class Notification implements INotification { /** * {@inheritDoc} */ + #[\Override] public function isValidParsed(): bool { if ($this->getRichSubject() !== '' || !empty($this->getRichSubjectParameters())) { try { diff --git a/lib/private/OCM/Model/OCMProvider.php b/lib/private/OCM/Model/OCMProvider.php index bbbace0d882..20d3fbf8360 100644 --- a/lib/private/OCM/Model/OCMProvider.php +++ b/lib/private/OCM/Model/OCMProvider.php @@ -38,6 +38,7 @@ class OCMProvider implements IOCMProvider { * * @return $this */ + #[\Override] public function setEnabled(bool $enabled): static { $this->enabled = $enabled; @@ -47,6 +48,7 @@ class OCMProvider implements IOCMProvider { /** * @return bool */ + #[\Override] public function isEnabled(): bool { return $this->enabled; } @@ -56,6 +58,7 @@ class OCMProvider implements IOCMProvider { * * @return $this */ + #[\Override] public function setApiVersion(string $apiVersion): static { $this->apiVersion = $apiVersion; @@ -65,6 +68,7 @@ class OCMProvider implements IOCMProvider { /** * @return string */ + #[\Override] public function getApiVersion(): string { return $this->apiVersion; } @@ -75,6 +79,7 @@ class OCMProvider implements IOCMProvider { * @return string * @since 32.0.0 */ + #[\Override] public function getInviteAcceptDialog(): string { return $this->inviteAcceptDialog; } @@ -87,6 +92,7 @@ class OCMProvider implements IOCMProvider { * @return $this * @since 32.0.0 */ + #[\Override] public function setInviteAcceptDialog(string $inviteAcceptDialog): static { $this->inviteAcceptDialog = $inviteAcceptDialog; @@ -98,6 +104,7 @@ class OCMProvider implements IOCMProvider { * * @return $this */ + #[\Override] public function setEndPoint(string $endPoint): static { $this->endPoint = $endPoint; @@ -107,6 +114,7 @@ class OCMProvider implements IOCMProvider { /** * @return string */ + #[\Override] public function getEndPoint(): string { return $this->endPoint; } @@ -114,6 +122,7 @@ class OCMProvider implements IOCMProvider { /** * @return string */ + #[\Override] public function getProvider(): string { return $this->provider; } @@ -123,6 +132,7 @@ class OCMProvider implements IOCMProvider { * * @return $this */ + #[\Override] public function setCapabilities(array $capabilities): static { $this->capabilities = array_unique(array_merge( $this->capabilities, @@ -134,6 +144,7 @@ class OCMProvider implements IOCMProvider { /** * @return array */ + #[\Override] public function getCapabilities(): array { return $this->capabilities; } @@ -142,6 +153,7 @@ class OCMProvider implements IOCMProvider { * @param string $capability * @return bool */ + #[\Override] public function hasCapability(string $capability): bool { return (in_array($this->normalizeCapability($capability), $this->capabilities, true)); } @@ -155,6 +167,7 @@ class OCMProvider implements IOCMProvider { * create a new resource to later add it with {@see IOCMProvider::addResourceType()} * @return IOCMResource */ + #[\Override] public function createNewResourceType(): IOCMResource { return new OCMResource(); } @@ -164,6 +177,7 @@ class OCMProvider implements IOCMProvider { * * @return $this */ + #[\Override] public function addResourceType(IOCMResource $resource): static { $this->resourceTypes[] = $resource; @@ -175,6 +189,7 @@ class OCMProvider implements IOCMProvider { * * @return $this */ + #[\Override] public function setResourceTypes(array $resourceTypes): static { $this->resourceTypes = $resourceTypes; @@ -184,6 +199,7 @@ class OCMProvider implements IOCMProvider { /** * @return IOCMResource[] */ + #[\Override] public function getResourceTypes(): array { return $this->resourceTypes; } @@ -195,6 +211,7 @@ class OCMProvider implements IOCMProvider { * @return string * @throws OCMArgumentException */ + #[\Override] public function extractProtocolEntry(string $resourceName, string $protocol): string { foreach ($this->getResourceTypes() as $resource) { if ($resource->getName() === $resourceName) { @@ -226,6 +243,7 @@ class OCMProvider implements IOCMProvider { * @return OCMProvider&static * @throws OCMProviderException in case a descent provider cannot be generated from data */ + #[\Override] public function import(array $data): static { $this->setEnabled(is_bool($data['enabled'] ?? '') ? $data['enabled'] : false) // Fall back to old apiVersion for Nextcloud 30 compatibility @@ -269,6 +287,7 @@ class OCMProvider implements IOCMProvider { /** * @since 28.0.0 */ + #[\Override] public function jsonSerialize(): array { $resourceTypes = []; foreach ($this->getResourceTypes() as $res) { diff --git a/lib/private/OCM/Model/OCMResource.php b/lib/private/OCM/Model/OCMResource.php index 3d619db1927..58d8afc4c8f 100644 --- a/lib/private/OCM/Model/OCMResource.php +++ b/lib/private/OCM/Model/OCMResource.php @@ -26,6 +26,7 @@ class OCMResource implements IOCMResource { * * @return $this */ + #[\Override] public function setName(string $name): static { $this->name = $name; @@ -35,6 +36,7 @@ class OCMResource implements IOCMResource { /** * @return string */ + #[\Override] public function getName(): string { return $this->name; } @@ -44,6 +46,7 @@ class OCMResource implements IOCMResource { * * @return $this */ + #[\Override] public function setShareTypes(array $shareTypes): static { $this->shareTypes = $shareTypes; @@ -53,6 +56,7 @@ class OCMResource implements IOCMResource { /** * @return list */ + #[\Override] public function getShareTypes(): array { return $this->shareTypes; } @@ -62,6 +66,7 @@ class OCMResource implements IOCMResource { * * @return $this */ + #[\Override] public function setProtocols(array $protocols): static { $this->protocols = $protocols; @@ -71,6 +76,7 @@ class OCMResource implements IOCMResource { /** * @return array */ + #[\Override] public function getProtocols(): array { return $this->protocols; } @@ -83,6 +89,7 @@ class OCMResource implements IOCMResource { * @return $this * @see self::jsonSerialize() */ + #[\Override] public function import(array $data): static { return $this->setName((string)($data['name'] ?? '')) ->setShareTypes($data['shareTypes'] ?? []) @@ -96,6 +103,7 @@ class OCMResource implements IOCMResource { * protocols: array * } */ + #[\Override] public function jsonSerialize(): array { return [ 'name' => $this->getName(), diff --git a/lib/private/OCM/OCMDiscoveryHandler.php b/lib/private/OCM/OCMDiscoveryHandler.php index b70218151c6..8fbcfd217f5 100644 --- a/lib/private/OCM/OCMDiscoveryHandler.php +++ b/lib/private/OCM/OCMDiscoveryHandler.php @@ -21,6 +21,7 @@ class OCMDiscoveryHandler implements IHandler { ) { } + #[\Override] public function handle(string $service, IRequestContext $context, ?IResponse $previousResponse): ?IResponse { if ($service !== 'ocm') { return $previousResponse; diff --git a/lib/private/OCM/OCMDiscoveryService.php b/lib/private/OCM/OCMDiscoveryService.php index 17a84c12d50..9459e9a03f0 100644 --- a/lib/private/OCM/OCMDiscoveryService.php +++ b/lib/private/OCM/OCMDiscoveryService.php @@ -79,6 +79,7 @@ final class OCMDiscoveryService implements IOCMDiscoveryService { * @throws OCMProviderException if no valid discovery data can be returned * @since 28.0.0 */ + #[\Override] public function discover(string $remote, bool $skipCache = false): IOCMProvider { $remote = rtrim($remote, '/'); if (!str_starts_with($remote, 'http://') && !str_starts_with($remote, 'https://')) { @@ -180,6 +181,7 @@ final class OCMDiscoveryService implements IOCMDiscoveryService { * @return IOCMProvider * @since 33.0.0 */ + #[\Override] public function getLocalOCMProvider(bool $fullDetails = true): IOCMProvider { if ($this->localProvider !== null) { return $this->localProvider; @@ -249,6 +251,7 @@ final class OCMDiscoveryService implements IOCMDiscoveryService { * @throws IncomingRequestException * @since 33.0.0 */ + #[\Override] public function getIncomingSignedRequest(): ?IIncomingSignedRequest { try { $signedRequest = $this->signatureManager->getIncomingSignedRequest($this->signatoryManager); @@ -291,6 +294,7 @@ final class OCMDiscoveryService implements IOCMDiscoveryService { * @throws OCMRequestException on internal issue * @since 33.0.0 */ + #[\Override] public function requestRemoteOcmEndpoint( ?string $capability, string $remote, diff --git a/lib/private/OCM/OCMSignatoryManager.php b/lib/private/OCM/OCMSignatoryManager.php index e9926ff6622..b239a4d1bce 100644 --- a/lib/private/OCM/OCMSignatoryManager.php +++ b/lib/private/OCM/OCMSignatoryManager.php @@ -54,6 +54,7 @@ class OCMSignatoryManager implements ISignatoryManager { * @return string * @since 31.0.0 */ + #[\Override] public function getProviderId(): string { return self::PROVIDER_ID; } @@ -64,6 +65,7 @@ class OCMSignatoryManager implements ISignatoryManager { * @return array * @since 31.0.0 */ + #[\Override] public function getOptions(): array { return [ 'algorithm' => SignatureAlgorithm::RSA_SHA512, @@ -83,6 +85,7 @@ class OCMSignatoryManager implements ISignatoryManager { * @throws IdentityNotFoundException * @since 31.0.0 */ + #[\Override] public function getLocalSignatory(): Signatory { /** * TODO: manage multiple identity (external, internal, ...) to allow a limitation @@ -144,6 +147,7 @@ class OCMSignatoryManager implements ISignatoryManager { * @return Signatory|null must be NULL if no signatory is found * @since 31.0.0 */ + #[\Override] public function getRemoteSignatory(string $remote): ?Signatory { try { $ocmProvider = Server::get(OCMDiscoveryService::class)->discover($remote, true); diff --git a/lib/private/OCS/CoreCapabilities.php b/lib/private/OCS/CoreCapabilities.php index 2729cc738f4..4a697e72c2d 100644 --- a/lib/private/OCS/CoreCapabilities.php +++ b/lib/private/OCS/CoreCapabilities.php @@ -40,6 +40,7 @@ class CoreCapabilities implements ICapability { * }, * } */ + #[\Override] public function getCapabilities(): array { return [ 'core' => [ diff --git a/lib/private/OCS/DiscoveryService.php b/lib/private/OCS/DiscoveryService.php index 85686e59b02..26d7abbd0a7 100644 --- a/lib/private/OCS/DiscoveryService.php +++ b/lib/private/OCS/DiscoveryService.php @@ -44,6 +44,7 @@ class DiscoveryService implements IDiscoveryService { * @param bool $skipCache We won't check if the data is in the cache. This is useful if a background job is updating the status * @return array */ + #[\Override] public function discover(string $remote, string $service, bool $skipCache = false): array { // Check the cache first if ($skipCache === false) { diff --git a/lib/private/OpenMetrics/Exporters/ActiveSessions.php b/lib/private/OpenMetrics/Exporters/ActiveSessions.php index b95279fa83e..a4bc39bee08 100644 --- a/lib/private/OpenMetrics/Exporters/ActiveSessions.php +++ b/lib/private/OpenMetrics/Exporters/ActiveSessions.php @@ -21,22 +21,27 @@ class ActiveSessions implements IMetricFamily { ) { } + #[\Override] public function name(): string { return 'active_sessions'; } + #[\Override] public function type(): MetricType { return MetricType::gauge; } + #[\Override] public function unit(): string { return 'sessions'; } + #[\Override] public function help(): string { return 'Number of active sessions'; } + #[\Override] public function metrics(): Generator { $now = time(); $timeFrames = [ diff --git a/lib/private/OpenMetrics/Exporters/ActiveUsers.php b/lib/private/OpenMetrics/Exporters/ActiveUsers.php index 43425fd37e2..68a1eb23f9c 100644 --- a/lib/private/OpenMetrics/Exporters/ActiveUsers.php +++ b/lib/private/OpenMetrics/Exporters/ActiveUsers.php @@ -21,22 +21,27 @@ class ActiveUsers implements IMetricFamily { ) { } + #[\Override] public function name(): string { return 'active_users'; } + #[\Override] public function type(): MetricType { return MetricType::gauge; } + #[\Override] public function unit(): string { return 'users'; } + #[\Override] public function help(): string { return 'Number of active users'; } + #[\Override] public function metrics(): Generator { $now = time(); $timeFrames = [ diff --git a/lib/private/OpenMetrics/Exporters/LogLevel.php b/lib/private/OpenMetrics/Exporters/LogLevel.php index e073b5d7ba2..ac2d62a911f 100644 --- a/lib/private/OpenMetrics/Exporters/LogLevel.php +++ b/lib/private/OpenMetrics/Exporters/LogLevel.php @@ -22,22 +22,27 @@ class LogLevel implements IMetricFamily { ) { } + #[\Override] public function name(): string { return 'log_level'; } + #[\Override] public function type(): MetricType { return MetricType::gauge; } + #[\Override] public function unit(): string { return ''; } + #[\Override] public function help(): string { return 'Current log level (lower level means more logs)'; } + #[\Override] public function metrics(): Generator { yield new Metric((int)$this->config->getSystemValue('loglevel', ILogger::WARN)); } diff --git a/lib/private/OpenMetrics/Exporters/Maintenance.php b/lib/private/OpenMetrics/Exporters/Maintenance.php index 89b53547e33..a0086cd70b5 100644 --- a/lib/private/OpenMetrics/Exporters/Maintenance.php +++ b/lib/private/OpenMetrics/Exporters/Maintenance.php @@ -21,6 +21,7 @@ use Override; * Export maintenance state */ class Maintenance implements IMetricFamily { + #[\Override] public function name(): string { return 'maintenance'; } diff --git a/lib/private/PhoneNumberUtil.php b/lib/private/PhoneNumberUtil.php index e53c7a51a1b..8e4405ff74f 100644 --- a/lib/private/PhoneNumberUtil.php +++ b/lib/private/PhoneNumberUtil.php @@ -19,6 +19,7 @@ class PhoneNumberUtil implements IPhoneNumberUtil { /** * {@inheritDoc} */ + #[\Override] public function getCountryCodeForRegion(string $regionCode): ?int { $phoneUtil = \libphonenumber\PhoneNumberUtil::getInstance(); $countryCode = $phoneUtil->getCountryCodeForRegion($regionCode); @@ -28,6 +29,7 @@ class PhoneNumberUtil implements IPhoneNumberUtil { /** * {@inheritDoc} */ + #[\Override] public function convertToStandardFormat(string $input, ?string $defaultRegion = null): ?string { $phoneUtil = \libphonenumber\PhoneNumberUtil::getInstance(); try { diff --git a/lib/private/Preview/BMP.php b/lib/private/Preview/BMP.php index b4d4d5829cb..624bd051c44 100644 --- a/lib/private/Preview/BMP.php +++ b/lib/private/Preview/BMP.php @@ -13,6 +13,7 @@ class BMP extends Image { /** * {@inheritDoc} */ + #[\Override] public function getMimeType(): string { return '/image\/bmp/'; } diff --git a/lib/private/Preview/BackgroundCleanupJob.php b/lib/private/Preview/BackgroundCleanupJob.php index 70579d3b9d1..b853e98114f 100644 --- a/lib/private/Preview/BackgroundCleanupJob.php +++ b/lib/private/Preview/BackgroundCleanupJob.php @@ -32,6 +32,7 @@ class BackgroundCleanupJob extends TimedJob { $this->setTimeSensitivity(self::TIME_INSENSITIVE); } + #[\Override] public function run($argument): void { foreach ($this->getDeletedFiles() as $fileId) { $previewIds = []; diff --git a/lib/private/Preview/Bitmap.php b/lib/private/Preview/Bitmap.php index 9585b8a1f39..a9f5004201b 100644 --- a/lib/private/Preview/Bitmap.php +++ b/lib/private/Preview/Bitmap.php @@ -35,6 +35,7 @@ abstract class Bitmap extends ProviderV2 { /** * {@inheritDoc} */ + #[\Override] public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage { $tmpPath = $this->getLocalFile($file); if ($tmpPath === false) { diff --git a/lib/private/Preview/Db/PreviewMapper.php b/lib/private/Preview/Db/PreviewMapper.php index 05c1d4695f2..0d9699a5015 100644 --- a/lib/private/Preview/Db/PreviewMapper.php +++ b/lib/private/Preview/Db/PreviewMapper.php @@ -38,6 +38,7 @@ class PreviewMapper extends QBMapper { parent::__construct($db, self::TABLE_NAME, Preview::class); } + #[\Override] protected function mapRowToEntity(array $row): Entity { $row['mimetype'] = $this->mimeTypeLoader->getMimetypeById((int)$row['mimetype_id']); $row['source_mimetype'] = $this->mimeTypeLoader->getMimetypeById((int)$row['source_mimetype_id']); diff --git a/lib/private/Preview/EMF.php b/lib/private/Preview/EMF.php index a3c48e7d8aa..84d8a5cd9b6 100644 --- a/lib/private/Preview/EMF.php +++ b/lib/private/Preview/EMF.php @@ -10,6 +10,7 @@ declare(strict_types=1); namespace OC\Preview; class EMF extends Office { + #[\Override] public function getMimeType(): string { return '/image\/emf/'; } diff --git a/lib/private/Preview/Font.php b/lib/private/Preview/Font.php index 85f5d1f78d1..312d5de2bb8 100644 --- a/lib/private/Preview/Font.php +++ b/lib/private/Preview/Font.php @@ -14,6 +14,7 @@ class Font extends Bitmap { /** * {@inheritDoc} */ + #[\Override] public function getMimeType(): string { return '/application\/(?:font-sfnt|x-font$)/'; } @@ -21,6 +22,7 @@ class Font extends Bitmap { /** * {@inheritDoc} */ + #[\Override] protected function getAllowedMimeTypes(): string { return '/(application|image)\/(?:font-sfnt|x-font|x-otf|x-ttf|x-pfb$)/'; } diff --git a/lib/private/Preview/GIF.php b/lib/private/Preview/GIF.php index be54bf8659c..e1d632fb4ec 100644 --- a/lib/private/Preview/GIF.php +++ b/lib/private/Preview/GIF.php @@ -13,6 +13,7 @@ class GIF extends Image { /** * {@inheritDoc} */ + #[\Override] public function getMimeType(): string { return '/image\/gif/'; } diff --git a/lib/private/Preview/HEIC.php b/lib/private/Preview/HEIC.php index f2b6cc7254e..413a3ef9e1e 100644 --- a/lib/private/Preview/HEIC.php +++ b/lib/private/Preview/HEIC.php @@ -25,6 +25,7 @@ class HEIC extends ProviderV2 { /** * {@inheritDoc} */ + #[\Override] public function getMimeType(): string { return '/image\/(x-)?hei(f|c)/'; } @@ -32,6 +33,7 @@ class HEIC extends ProviderV2 { /** * {@inheritDoc} */ + #[\Override] public function isAvailable(FileInfo $file): bool { return in_array('HEIC', \Imagick::queryFormats('HEI*')); } @@ -39,6 +41,7 @@ class HEIC extends ProviderV2 { /** * {@inheritDoc} */ + #[\Override] public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage { if (!$this->isAvailable($file)) { return null; diff --git a/lib/private/Preview/Illustrator.php b/lib/private/Preview/Illustrator.php index 937da1d9f87..fdbe68542c7 100644 --- a/lib/private/Preview/Illustrator.php +++ b/lib/private/Preview/Illustrator.php @@ -14,6 +14,7 @@ class Illustrator extends Bitmap { /** * {@inheritDoc} */ + #[\Override] public function getMimeType(): string { return '/application\/illustrator/'; } @@ -21,6 +22,7 @@ class Illustrator extends Bitmap { /** * {@inheritDoc} */ + #[\Override] protected function getAllowedMimeTypes(): string { return '/application\/(illustrator|pdf)/'; } diff --git a/lib/private/Preview/Image.php b/lib/private/Preview/Image.php index 25c74b5fdef..8a299bd2848 100644 --- a/lib/private/Preview/Image.php +++ b/lib/private/Preview/Image.php @@ -17,6 +17,7 @@ abstract class Image extends ProviderV2 { /** * {@inheritDoc} */ + #[\Override] public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage { $maxSizeForImages = Server::get(IConfig::class)->getSystemValueInt('preview_max_filesize_image', 50); $size = $file->getSize(); diff --git a/lib/private/Preview/Imaginary.php b/lib/private/Preview/Imaginary.php index bd5645d417e..e029823a9cf 100644 --- a/lib/private/Preview/Imaginary.php +++ b/lib/private/Preview/Imaginary.php @@ -37,6 +37,7 @@ class Imaginary extends ProviderV2 { /** * {@inheritDoc} */ + #[\Override] public function getMimeType(): string { return self::supportedMimeTypes(); } @@ -186,6 +187,7 @@ class Imaginary extends ProviderV2 { /** * {@inheritDoc} */ + #[\Override] public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage { return $this->getCroppedThumbnail($file, $maxX, $maxY, false); } diff --git a/lib/private/Preview/ImaginaryPDF.php b/lib/private/Preview/ImaginaryPDF.php index 2786700f5a7..0eb2cd970f2 100644 --- a/lib/private/Preview/ImaginaryPDF.php +++ b/lib/private/Preview/ImaginaryPDF.php @@ -9,6 +9,7 @@ declare(strict_types=1); namespace OC\Preview; class ImaginaryPDF extends Imaginary { + #[\Override] public static function supportedMimeTypes(): string { return '/application\/pdf/'; } diff --git a/lib/private/Preview/JPEG.php b/lib/private/Preview/JPEG.php index 97a6a0c94c1..4121e664941 100644 --- a/lib/private/Preview/JPEG.php +++ b/lib/private/Preview/JPEG.php @@ -13,6 +13,7 @@ class JPEG extends Image { /** * {@inheritDoc} */ + #[\Override] public function getMimeType(): string { return '/image\/jpeg/'; } diff --git a/lib/private/Preview/Krita.php b/lib/private/Preview/Krita.php index 8654698c125..736f317f6da 100644 --- a/lib/private/Preview/Krita.php +++ b/lib/private/Preview/Krita.php @@ -15,6 +15,7 @@ class Krita extends Bundled { /** * {@inheritDoc} */ + #[\Override] public function getMimeType(): string { return '/application\/x-krita/'; } @@ -23,6 +24,7 @@ class Krita extends Bundled { /** * @inheritDoc */ + #[\Override] public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage { $image = $this->extractThumbnail($file, 'mergedimage.png'); if (($image !== null) && $image->valid()) { diff --git a/lib/private/Preview/MP3.php b/lib/private/Preview/MP3.php index dd3e809a7de..ed2a904194a 100644 --- a/lib/private/Preview/MP3.php +++ b/lib/private/Preview/MP3.php @@ -19,6 +19,7 @@ class MP3 extends ProviderV2 { /** * {@inheritDoc} */ + #[\Override] public function getMimeType(): string { return '/audio\/mpeg/'; } @@ -26,6 +27,7 @@ class MP3 extends ProviderV2 { /** * {@inheritDoc} */ + #[\Override] public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage { $tmpPath = $this->getLocalFile($file); if ($tmpPath === false) { diff --git a/lib/private/Preview/MSOffice2003.php b/lib/private/Preview/MSOffice2003.php index 977ebf467bf..844ee3ead71 100644 --- a/lib/private/Preview/MSOffice2003.php +++ b/lib/private/Preview/MSOffice2003.php @@ -14,6 +14,7 @@ class MSOffice2003 extends Office { /** * {@inheritDoc} */ + #[\Override] public function getMimeType(): string { return '/application\/vnd.ms-.*/'; } diff --git a/lib/private/Preview/MSOffice2007.php b/lib/private/Preview/MSOffice2007.php index 6ccf70be0c2..6b979f16962 100644 --- a/lib/private/Preview/MSOffice2007.php +++ b/lib/private/Preview/MSOffice2007.php @@ -14,6 +14,7 @@ class MSOffice2007 extends Office { /** * {@inheritDoc} */ + #[\Override] public function getMimeType(): string { return '/application\/vnd.openxmlformats-officedocument.*/'; } diff --git a/lib/private/Preview/MSOfficeDoc.php b/lib/private/Preview/MSOfficeDoc.php index 479e9170689..807c07c5fc5 100644 --- a/lib/private/Preview/MSOfficeDoc.php +++ b/lib/private/Preview/MSOfficeDoc.php @@ -14,6 +14,7 @@ class MSOfficeDoc extends Office { /** * {@inheritDoc} */ + #[\Override] public function getMimeType(): string { return '/application\/msword/'; } diff --git a/lib/private/Preview/MarkDown.php b/lib/private/Preview/MarkDown.php index d8ae8c48ea9..7dba88278d9 100644 --- a/lib/private/Preview/MarkDown.php +++ b/lib/private/Preview/MarkDown.php @@ -15,10 +15,12 @@ class MarkDown extends TXT { /** * {@inheritDoc} */ + #[\Override] public function getMimeType(): string { return '/text\/(x-)?markdown/'; } + #[\Override] public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage { $content = $file->fopen('r'); diff --git a/lib/private/Preview/MimeIconProvider.php b/lib/private/Preview/MimeIconProvider.php index d1963fe882b..4c6ed18ab83 100644 --- a/lib/private/Preview/MimeIconProvider.php +++ b/lib/private/Preview/MimeIconProvider.php @@ -23,6 +23,7 @@ class MimeIconProvider implements IMimeIconProvider { ) { } + #[\Override] public function getMimeIconUrl(string $mime): ?string { if (!$mime) { return null; diff --git a/lib/private/Preview/Movie.php b/lib/private/Preview/Movie.php index ea14423505a..f34bf60c147 100644 --- a/lib/private/Preview/Movie.php +++ b/lib/private/Preview/Movie.php @@ -27,6 +27,7 @@ class Movie extends ProviderV2 { $this->config = Server::get(IConfig::class); } + #[\Override] public function getMimeType(): string { return '/video\/.*/'; } @@ -34,6 +35,7 @@ class Movie extends ProviderV2 { /** * {@inheritDoc} */ + #[\Override] public function isAvailable(FileInfo $file): bool { if (is_null($this->binary)) { if (isset($this->options['movieBinary'])) { @@ -63,6 +65,7 @@ class Movie extends ProviderV2 { /** * {@inheritDoc} */ + #[\Override] public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage { // TODO: use proc_open() and stream the source file ? diff --git a/lib/private/Preview/Office.php b/lib/private/Preview/Office.php index c67e4829db8..d1879a96622 100644 --- a/lib/private/Preview/Office.php +++ b/lib/private/Preview/Office.php @@ -19,6 +19,7 @@ abstract class Office extends ProviderV2 { /** * {@inheritDoc} */ + #[\Override] public function isAvailable(FileInfo $file): bool { return is_string($this->options['officeBinary']); } @@ -26,6 +27,7 @@ abstract class Office extends ProviderV2 { /** * {@inheritDoc} */ + #[\Override] public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage { if (!$this->isAvailable($file)) { return null; diff --git a/lib/private/Preview/OpenDocument.php b/lib/private/Preview/OpenDocument.php index 8eea9fecce7..a574bb41311 100644 --- a/lib/private/Preview/OpenDocument.php +++ b/lib/private/Preview/OpenDocument.php @@ -17,6 +17,7 @@ class OpenDocument extends Bundled { /** * {@inheritDoc} */ + #[\Override] public function getMimeType(): string { return '/application\/vnd.oasis.opendocument.*/'; } @@ -25,6 +26,7 @@ class OpenDocument extends Bundled { /** * @inheritDoc */ + #[\Override] public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage { $image = $this->extractThumbnail($file, 'Thumbnails/thumbnail.png'); if (($image !== null) && $image->valid()) { diff --git a/lib/private/Preview/PDF.php b/lib/private/Preview/PDF.php index dc8b37079b3..2aab2385569 100644 --- a/lib/private/Preview/PDF.php +++ b/lib/private/Preview/PDF.php @@ -14,6 +14,7 @@ class PDF extends Bitmap { /** * {@inheritDoc} */ + #[\Override] public function getMimeType(): string { return '/application\/pdf/'; } @@ -21,6 +22,7 @@ class PDF extends Bitmap { /** * {@inheritDoc} */ + #[\Override] protected function getAllowedMimeTypes(): string { return '/application\/pdf/'; } diff --git a/lib/private/Preview/PNG.php b/lib/private/Preview/PNG.php index 5e2750c4f14..1569a4283fa 100644 --- a/lib/private/Preview/PNG.php +++ b/lib/private/Preview/PNG.php @@ -13,6 +13,7 @@ class PNG extends Image { /** * {@inheritDoc} */ + #[\Override] public function getMimeType(): string { return '/image\/png/'; } diff --git a/lib/private/Preview/Photoshop.php b/lib/private/Preview/Photoshop.php index dcb893626c8..fea1bcf9a0d 100644 --- a/lib/private/Preview/Photoshop.php +++ b/lib/private/Preview/Photoshop.php @@ -14,6 +14,7 @@ class Photoshop extends Bitmap { /** * {@inheritDoc} */ + #[\Override] public function getMimeType(): string { return '/application\/x-photoshop/'; } @@ -21,6 +22,7 @@ class Photoshop extends Bitmap { /** * {@inheritDoc} */ + #[\Override] protected function getAllowedMimeTypes(): string { return '/(application|image)\/(x-photoshop|x-psd)/'; } diff --git a/lib/private/Preview/Postscript.php b/lib/private/Preview/Postscript.php index b03db86e5f8..49b3ff5af22 100644 --- a/lib/private/Preview/Postscript.php +++ b/lib/private/Preview/Postscript.php @@ -14,6 +14,7 @@ class Postscript extends Bitmap { /** * {@inheritDoc} */ + #[\Override] public function getMimeType(): string { return '/application\/postscript/'; } @@ -21,6 +22,7 @@ class Postscript extends Bitmap { /** * {@inheritDoc} */ + #[\Override] protected function getAllowedMimeTypes(): string { return '/(application\/postscript|image\/x-eps)/'; } diff --git a/lib/private/Preview/ProviderV2.php b/lib/private/Preview/ProviderV2.php index 9e1a6fcefcd..d0e013a3030 100644 --- a/lib/private/Preview/ProviderV2.php +++ b/lib/private/Preview/ProviderV2.php @@ -28,6 +28,7 @@ abstract class ProviderV2 implements IProviderV2 { /** * @return string Regex with the mimetypes that are supported by this provider */ + #[\Override] abstract public function getMimeType(): string ; /** @@ -36,6 +37,7 @@ abstract class ProviderV2 implements IProviderV2 { * @param FileInfo $file * @return bool */ + #[\Override] public function isAvailable(FileInfo $file): bool { return true; } @@ -49,6 +51,7 @@ abstract class ProviderV2 implements IProviderV2 { * @return null|IImage null if no preview was generated * @since 17.0.0 */ + #[\Override] abstract public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage; protected function useTempFile(File $file): bool { diff --git a/lib/private/Preview/SGI.php b/lib/private/Preview/SGI.php index 64e1ed2863d..b27a270034d 100644 --- a/lib/private/Preview/SGI.php +++ b/lib/private/Preview/SGI.php @@ -13,6 +13,7 @@ class SGI extends Bitmap { /** * {@inheritDoc} */ + #[\Override] public function getMimeType(): string { return '/image\/(x-)?sgi/'; } @@ -20,6 +21,7 @@ class SGI extends Bitmap { /** * {@inheritDoc} */ + #[\Override] protected function getAllowedMimeTypes(): string { return '/image\/(x-)?sgi/'; } diff --git a/lib/private/Preview/SVG.php b/lib/private/Preview/SVG.php index be9b88fcc40..c23553090d5 100644 --- a/lib/private/Preview/SVG.php +++ b/lib/private/Preview/SVG.php @@ -17,6 +17,7 @@ class SVG extends ProviderV2 { /** * {@inheritDoc} */ + #[\Override] public function getMimeType(): string { return '/image\/svg\+xml/'; } @@ -24,6 +25,7 @@ class SVG extends ProviderV2 { /** * {@inheritDoc} */ + #[\Override] public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage { try { $content = stream_get_contents($file->fopen('r')); diff --git a/lib/private/Preview/StarOffice.php b/lib/private/Preview/StarOffice.php index e2d2b10dfce..2306ea2fb57 100644 --- a/lib/private/Preview/StarOffice.php +++ b/lib/private/Preview/StarOffice.php @@ -14,6 +14,7 @@ class StarOffice extends Office { /** * {@inheritDoc} */ + #[\Override] public function getMimeType(): string { return '/application\/vnd.sun.xml.*/'; } diff --git a/lib/private/Preview/TGA.php b/lib/private/Preview/TGA.php index 24e55a09d90..98ae85ad865 100644 --- a/lib/private/Preview/TGA.php +++ b/lib/private/Preview/TGA.php @@ -13,6 +13,7 @@ class TGA extends Bitmap { /** * {@inheritDoc} */ + #[\Override] public function getMimeType(): string { return '/image\/(x-)?t(ar)?ga/'; } @@ -20,6 +21,7 @@ class TGA extends Bitmap { /** * {@inheritDoc} */ + #[\Override] protected function getAllowedMimeTypes(): string { return '/image\/(x-)?t(ar)?ga/'; } diff --git a/lib/private/Preview/TIFF.php b/lib/private/Preview/TIFF.php index 866e26cc3d8..f04f56c3343 100644 --- a/lib/private/Preview/TIFF.php +++ b/lib/private/Preview/TIFF.php @@ -14,6 +14,7 @@ class TIFF extends Bitmap { /** * {@inheritDoc} */ + #[\Override] public function getMimeType(): string { return '/image\/tiff/'; } @@ -21,6 +22,7 @@ class TIFF extends Bitmap { /** * {@inheritDoc} */ + #[\Override] protected function getAllowedMimeTypes(): string { return '/image\/tiff/'; } diff --git a/lib/private/Preview/TXT.php b/lib/private/Preview/TXT.php index 2d407d88b56..95977e3e5d7 100644 --- a/lib/private/Preview/TXT.php +++ b/lib/private/Preview/TXT.php @@ -16,6 +16,7 @@ class TXT extends ProviderV2 { /** * {@inheritDoc} */ + #[\Override] public function getMimeType(): string { return '/text\/plain/'; } @@ -23,6 +24,7 @@ class TXT extends ProviderV2 { /** * {@inheritDoc} */ + #[\Override] public function isAvailable(FileInfo $file): bool { return $file->getSize() > 0; } @@ -30,6 +32,7 @@ class TXT extends ProviderV2 { /** * {@inheritDoc} */ + #[\Override] public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage { if (!$this->isAvailable($file)) { return null; diff --git a/lib/private/Preview/WebP.php b/lib/private/Preview/WebP.php index 25b922e9190..4edc21aa97f 100644 --- a/lib/private/Preview/WebP.php +++ b/lib/private/Preview/WebP.php @@ -14,10 +14,12 @@ class WebP extends Image { /** * {@inheritDoc} */ + #[\Override] public function getMimeType(): string { return '/image\/webp/'; } + #[\Override] public function isAvailable(FileInfo $file): bool { return (bool)(imagetypes() & IMG_WEBP); } diff --git a/lib/private/Preview/XBitmap.php b/lib/private/Preview/XBitmap.php index 95ea589835a..75a22402f6b 100644 --- a/lib/private/Preview/XBitmap.php +++ b/lib/private/Preview/XBitmap.php @@ -13,6 +13,7 @@ class XBitmap extends Image { /** * {@inheritDoc} */ + #[\Override] public function getMimeType(): string { return '/image\/x-xbitmap/'; } diff --git a/lib/private/PreviewManager.php b/lib/private/PreviewManager.php index 268e265c7ab..578c256aac0 100644 --- a/lib/private/PreviewManager.php +++ b/lib/private/PreviewManager.php @@ -107,6 +107,7 @@ class PreviewManager implements IPreview { * @param string $mimeTypeRegex Regex with the mime types that are supported by this provider * @param ProviderClosure $callable */ + #[\Override] public function registerProvider(string $mimeTypeRegex, Closure $callable): void { if (!$this->enablePreviews) { return; @@ -122,6 +123,7 @@ class PreviewManager implements IPreview { /** * Get all providers */ + #[\Override] public function getProviders(): array { if (!$this->enablePreviews) { return []; @@ -141,6 +143,7 @@ class PreviewManager implements IPreview { /** * Does the manager have any providers */ + #[\Override] public function hasProviders(): bool { $this->registerCoreProviders(); return !empty($this->providers); @@ -163,6 +166,7 @@ class PreviewManager implements IPreview { return $this->generator; } + #[\Override] public function getPreview( File $file, int $width = -1, @@ -193,11 +197,13 @@ class PreviewManager implements IPreview { * @throws \InvalidArgumentException if the preview would be invalid (in case the original image is invalid) * @since 19.0.0 */ + #[\Override] public function generatePreviews(File $file, array $specifications, ?string $mimeType = null): ISimpleFile { $this->throwIfPreviewsDisabled($file, $mimeType); return $this->getGenerator()->generatePreviews($file, $specifications, $mimeType); } + #[\Override] public function isMimeSupported(string $mimeType = '*'): bool { if (!$this->enablePreviews) { return false; @@ -220,6 +226,7 @@ class PreviewManager implements IPreview { return false; } + #[\Override] public function isAvailable(FileInfo $file, ?string $mimeType = null): bool { if (!$this->enablePreviews) { return false; diff --git a/lib/private/Profile/Actions/BlueskyAction.php b/lib/private/Profile/Actions/BlueskyAction.php index d05682aac1a..3c22823effc 100644 --- a/lib/private/Profile/Actions/BlueskyAction.php +++ b/lib/private/Profile/Actions/BlueskyAction.php @@ -25,36 +25,44 @@ class BlueskyAction implements ILinkAction { ) { } + #[\Override] public function preload(IUser $targetUser): void { $account = $this->accountManager->getAccount($targetUser); $this->value = $account->getProperty(IAccountManager::PROPERTY_BLUESKY)->getValue(); } + #[\Override] public function getAppId(): string { return 'core'; } + #[\Override] public function getId(): string { return IAccountManager::PROPERTY_BLUESKY; } + #[\Override] public function getDisplayId(): string { return $this->l10nFactory->get('lib')->t('Bluesky'); } + #[\Override] public function getTitle(): string { $displayUsername = $this->value; return $this->l10nFactory->get('lib')->t('View %s on Bluesky', [$displayUsername]); } + #[\Override] public function getPriority(): int { return 60; } + #[\Override] public function getIcon(): string { return $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/bluesky.svg')); } + #[\Override] public function getTarget(): ?string { if (empty($this->value)) { return null; diff --git a/lib/private/Profile/Actions/EmailAction.php b/lib/private/Profile/Actions/EmailAction.php index c01f368b476..779d94d9205 100644 --- a/lib/private/Profile/Actions/EmailAction.php +++ b/lib/private/Profile/Actions/EmailAction.php @@ -25,35 +25,43 @@ class EmailAction implements ILinkAction { ) { } + #[\Override] public function preload(IUser $targetUser): void { $account = $this->accountManager->getAccount($targetUser); $this->value = $account->getProperty(IAccountManager::PROPERTY_EMAIL)->getValue(); } + #[\Override] public function getAppId(): string { return 'core'; } + #[\Override] public function getId(): string { return IAccountManager::PROPERTY_EMAIL; } + #[\Override] public function getDisplayId(): string { return $this->l10nFactory->get('lib')->t('Email'); } + #[\Override] public function getTitle(): string { return $this->l10nFactory->get('lib')->t('Mail %s', [$this->value]); } + #[\Override] public function getPriority(): int { return 20; } + #[\Override] public function getIcon(): string { return $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/mail.svg')); } + #[\Override] public function getTarget(): ?string { if (empty($this->value)) { return null; diff --git a/lib/private/Profile/Actions/FediverseAction.php b/lib/private/Profile/Actions/FediverseAction.php index b48f1db5c50..17c1f5510a2 100644 --- a/lib/private/Profile/Actions/FediverseAction.php +++ b/lib/private/Profile/Actions/FediverseAction.php @@ -27,6 +27,7 @@ class FediverseAction implements ILinkAction { ) { } + #[\Override] public function preload(IUser $targetUser): void { try { $account = $this->accountManager->getAccount($targetUser); @@ -37,31 +38,38 @@ class FediverseAction implements ILinkAction { } } + #[\Override] public function getAppId(): string { return 'core'; } + #[\Override] public function getId(): string { return IAccountManager::PROPERTY_FEDIVERSE; } + #[\Override] public function getDisplayId(): string { return $this->l10nFactory->get('lib')->t('Fediverse'); } + #[\Override] public function getTitle(): string { $displayUsername = $this->value[0] === '@' ? $this->value : '@' . $this->value; return $this->l10nFactory->get('lib')->t('View %s on the fediverse', [$displayUsername]); } + #[\Override] public function getPriority(): int { return 50; } + #[\Override] public function getIcon(): string { return $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/mastodon.svg')); } + #[\Override] public function getTarget(): ?string { if ($this->value === '') { return null; diff --git a/lib/private/Profile/Actions/PhoneAction.php b/lib/private/Profile/Actions/PhoneAction.php index 598cdc49051..64fc889c77e 100644 --- a/lib/private/Profile/Actions/PhoneAction.php +++ b/lib/private/Profile/Actions/PhoneAction.php @@ -25,35 +25,43 @@ class PhoneAction implements ILinkAction { ) { } + #[\Override] public function preload(IUser $targetUser): void { $account = $this->accountManager->getAccount($targetUser); $this->value = $account->getProperty(IAccountManager::PROPERTY_PHONE)->getValue(); } + #[\Override] public function getAppId(): string { return 'core'; } + #[\Override] public function getId(): string { return IAccountManager::PROPERTY_PHONE; } + #[\Override] public function getDisplayId(): string { return $this->l10nFactory->get('lib')->t('Phone'); } + #[\Override] public function getTitle(): string { return $this->l10nFactory->get('lib')->t('Call %s', [$this->value]); } + #[\Override] public function getPriority(): int { return 30; } + #[\Override] public function getIcon(): string { return $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/phone.svg')); } + #[\Override] public function getTarget(): ?string { if (empty($this->value)) { return null; diff --git a/lib/private/Profile/Actions/TwitterAction.php b/lib/private/Profile/Actions/TwitterAction.php index 78e7137f64b..1e2fb38ae80 100644 --- a/lib/private/Profile/Actions/TwitterAction.php +++ b/lib/private/Profile/Actions/TwitterAction.php @@ -26,36 +26,44 @@ class TwitterAction implements ILinkAction { ) { } + #[\Override] public function preload(IUser $targetUser): void { $account = $this->accountManager->getAccount($targetUser); $this->value = $account->getProperty(IAccountManager::PROPERTY_TWITTER)->getValue(); } + #[\Override] public function getAppId(): string { return 'core'; } + #[\Override] public function getId(): string { return IAccountManager::PROPERTY_TWITTER; } + #[\Override] public function getDisplayId(): string { return $this->l10nFactory->get('lib')->t('Twitter'); } + #[\Override] public function getTitle(): string { $displayUsername = $this->value[0] === '@' ? $this->value : '@' . $this->value; return $this->l10nFactory->get('lib')->t('View %s on Twitter', [$displayUsername]); } + #[\Override] public function getPriority(): int { return 50; } + #[\Override] public function getIcon(): string { return $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/twitter.svg')); } + #[\Override] public function getTarget(): ?string { if (empty($this->value)) { return null; diff --git a/lib/private/Profile/Actions/WebsiteAction.php b/lib/private/Profile/Actions/WebsiteAction.php index 4f5dcb568e7..0967af55c2e 100644 --- a/lib/private/Profile/Actions/WebsiteAction.php +++ b/lib/private/Profile/Actions/WebsiteAction.php @@ -25,35 +25,43 @@ class WebsiteAction implements ILinkAction { ) { } + #[\Override] public function preload(IUser $targetUser): void { $account = $this->accountManager->getAccount($targetUser); $this->value = $account->getProperty(IAccountManager::PROPERTY_WEBSITE)->getValue(); } + #[\Override] public function getAppId(): string { return 'core'; } + #[\Override] public function getId(): string { return IAccountManager::PROPERTY_WEBSITE; } + #[\Override] public function getDisplayId(): string { return $this->l10nFactory->get('lib')->t('Website'); } + #[\Override] public function getTitle(): string { return $this->l10nFactory->get('lib')->t('Visit %s', [$this->value]); } + #[\Override] public function getPriority(): int { return 40; } + #[\Override] public function getIcon(): string { return $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/timezone.svg')); } + #[\Override] public function getTarget(): ?string { if (empty($this->value)) { return null; diff --git a/lib/private/Profile/ProfileManager.php b/lib/private/Profile/ProfileManager.php index c38412f6bd0..df046aacc28 100644 --- a/lib/private/Profile/ProfileManager.php +++ b/lib/private/Profile/ProfileManager.php @@ -95,6 +95,7 @@ class ProfileManager implements IProfileManager { /** * If no user is passed as an argument return whether profile is enabled globally in `config.php` */ + #[\Override] public function isProfileEnabled(?IUser $user = null): bool { $profileEnabledGlobally = $this->config->getSystemValueBool('profile.enabled', true); @@ -187,6 +188,7 @@ class ProfileManager implements IProfileManager { * Return whether the profile parameter of the target user * is visible to the visiting user */ + #[\Override] public function isProfileFieldVisible(string $profileField, IUser $targetUser, ?IUser $visitingUser): bool { try { $account = $this->accountManager->getAccount($targetUser); @@ -234,6 +236,7 @@ class ProfileManager implements IProfileManager { * in an associative array * @psalm-return CoreProfileFields */ + #[\Override] public function getProfileFields(IUser $targetUser, ?IUser $visitingUser): array { $account = $this->accountManager->getAccount($targetUser); diff --git a/lib/private/Profiler/Profile.php b/lib/private/Profiler/Profile.php index d823a7c8327..48b1d54ebd4 100644 --- a/lib/private/Profiler/Profile.php +++ b/lib/private/Profiler/Profile.php @@ -33,63 +33,78 @@ class Profile implements \JsonSerializable, IProfile { ) { } + #[\Override] public function getToken(): string { return $this->token; } + #[\Override] public function setToken(string $token): void { $this->token = $token; } + #[\Override] public function getTime(): ?int { return $this->time; } + #[\Override] public function setTime(int $time): void { $this->time = $time; } + #[\Override] public function getUrl(): ?string { return $this->url; } + #[\Override] public function setUrl(string $url): void { $this->url = $url; } + #[\Override] public function getMethod(): ?string { return $this->method; } + #[\Override] public function setMethod(string $method): void { $this->method = $method; } + #[\Override] public function getStatusCode(): ?int { return $this->statusCode; } + #[\Override] public function setStatusCode(int $statusCode): void { $this->statusCode = $statusCode; } + #[\Override] public function addCollector(IDataCollector $collector) { $this->collectors[$collector->getName()] = $collector; } + #[\Override] public function getParent(): ?IProfile { return $this->parent; } + #[\Override] public function setParent(?IProfile $parent): void { $this->parent = $parent; } + #[\Override] public function getParentToken(): ?string { return $this->parent ? $this->parent->getToken() : null; } /** @return IProfile[] */ + #[\Override] public function getChildren(): array { return $this->children; } @@ -97,6 +112,7 @@ class Profile implements \JsonSerializable, IProfile { /** * @param IProfile[] $children */ + #[\Override] public function setChildren(array $children): void { $this->children = []; foreach ($children as $child) { @@ -104,6 +120,7 @@ class Profile implements \JsonSerializable, IProfile { } } + #[\Override] public function addChild(IProfile $profile): void { $this->children[] = $profile; $profile->setParent($this); @@ -112,6 +129,7 @@ class Profile implements \JsonSerializable, IProfile { /** * @return IDataCollector[] */ + #[\Override] public function getCollectors(): array { return $this->collectors; } @@ -119,6 +137,7 @@ class Profile implements \JsonSerializable, IProfile { /** * @param IDataCollector[] $collectors */ + #[\Override] public function setCollectors(array $collectors): void { $this->collectors = $collectors; } @@ -127,6 +146,7 @@ class Profile implements \JsonSerializable, IProfile { return ['token', 'parent', 'children', 'collectors', 'method', 'url', 'time', 'statusCode']; } + #[\Override] #[\ReturnTypeWillChange] public function jsonSerialize() { // Everything but parent @@ -141,6 +161,7 @@ class Profile implements \JsonSerializable, IProfile { ]; } + #[\Override] public function getCollector(string $collectorName): ?IDataCollector { if (!array_key_exists($collectorName, $this->collectors)) { return null; diff --git a/lib/private/Profiler/Profiler.php b/lib/private/Profiler/Profiler.php index 84a4e3eff34..cde8c548bb8 100644 --- a/lib/private/Profiler/Profiler.php +++ b/lib/private/Profiler/Profiler.php @@ -31,10 +31,12 @@ class Profiler implements IProfiler { } } + #[\Override] public function add(IDataCollector $dataCollector): void { $this->dataCollectors[$dataCollector->getName()] = $dataCollector; } + #[\Override] public function loadProfileFromResponse(Response $response): ?IProfile { if (!$token = $response->getHeaders()['X-Debug-Token']) { return null; @@ -43,6 +45,7 @@ class Profiler implements IProfiler { return $this->loadProfile($token); } + #[\Override] public function loadProfile(string $token): ?IProfile { if ($this->storage) { return $this->storage->read($token); @@ -51,6 +54,7 @@ class Profiler implements IProfiler { } } + #[\Override] public function saveProfile(IProfile $profile): bool { if ($this->storage) { return $this->storage->write($profile); @@ -59,6 +63,7 @@ class Profiler implements IProfiler { } } + #[\Override] public function collect(Request $request, Response $response): IProfile { $profile = new Profile($request->getId()); $profile->setTime(time()); @@ -77,6 +82,7 @@ class Profiler implements IProfiler { /** * @return array[] */ + #[\Override] public function find(?string $url, ?int $limit, ?string $method, ?int $start, ?int $end, ?string $statusCode = null): array { if ($this->storage) { @@ -86,18 +92,22 @@ class Profiler implements IProfiler { } } + #[\Override] public function dataProviders(): array { return array_keys($this->dataCollectors); } + #[\Override] public function isEnabled(): bool { return $this->enabled; } + #[\Override] public function setEnabled(bool $enabled): void { $this->enabled = $enabled; } + #[\Override] public function clear(): void { $this->storage->purge(); } diff --git a/lib/private/Profiler/RoutingDataCollector.php b/lib/private/Profiler/RoutingDataCollector.php index 47d4af1149c..fba3e2425e0 100644 --- a/lib/private/Profiler/RoutingDataCollector.php +++ b/lib/private/Profiler/RoutingDataCollector.php @@ -21,6 +21,7 @@ class RoutingDataCollector extends AbstractDataCollector { ) { } + #[\Override] public function collect(Request $request, Response $response, ?\Throwable $exception = null): void { $this->data = [ 'appName' => $this->appName, @@ -29,6 +30,7 @@ class RoutingDataCollector extends AbstractDataCollector { ]; } + #[\Override] public function getName(): string { return 'router'; } diff --git a/lib/private/Remote/Api/ApiCollection.php b/lib/private/Remote/Api/ApiCollection.php index b42c7c484ba..7f89a70ac11 100644 --- a/lib/private/Remote/Api/ApiCollection.php +++ b/lib/private/Remote/Api/ApiCollection.php @@ -21,10 +21,12 @@ class ApiCollection implements IApiCollection { ) { } + #[\Override] public function getCapabilitiesApi() { return new OCS($this->instance, $this->credentials, $this->clientService); } + #[\Override] public function getUserApi() { return new OCS($this->instance, $this->credentials, $this->clientService); } diff --git a/lib/private/Remote/Api/ApiFactory.php b/lib/private/Remote/Api/ApiFactory.php index 8c908a2f91f..2ffa38991b4 100644 --- a/lib/private/Remote/Api/ApiFactory.php +++ b/lib/private/Remote/Api/ApiFactory.php @@ -19,6 +19,7 @@ class ApiFactory implements IApiFactory { ) { } + #[\Override] public function getApiCollection(IInstance $instance, ICredentials $credentials) { return new ApiCollection($instance, $credentials, $this->clientService); } diff --git a/lib/private/Remote/Api/OCS.php b/lib/private/Remote/Api/OCS.php index 36bc22751a5..458ed718060 100644 --- a/lib/private/Remote/Api/OCS.php +++ b/lib/private/Remote/Api/OCS.php @@ -25,6 +25,7 @@ class OCS extends ApiBase implements ICapabilitiesApi, IUserApi { * @throws NotFoundException * @throws \Exception */ + #[\Override] protected function request($method, $url, array $body = [], array $query = [], array $headers = []) { try { $response = json_decode(parent::request($method, 'ocs/v2.php/' . $url, $body, $query, $headers), true); @@ -67,6 +68,7 @@ class OCS extends ApiBase implements ICapabilitiesApi, IUserApi { } } + #[\Override] public function getUser($userId) { $result = $this->request('get', 'cloud/users/' . $userId); $this->checkResponseArray($result, 'user', User::EXPECTED_KEYS); @@ -76,6 +78,7 @@ class OCS extends ApiBase implements ICapabilitiesApi, IUserApi { /** * @return array The capabilities in the form of [$appId => [$capability => $value]] */ + #[\Override] public function getCapabilities() { $result = $this->request('get', 'cloud/capabilities'); return $result['capabilities']; diff --git a/lib/private/Remote/Credentials.php b/lib/private/Remote/Credentials.php index 607c403b4bf..2bb7c86ee4d 100644 --- a/lib/private/Remote/Credentials.php +++ b/lib/private/Remote/Credentials.php @@ -17,10 +17,12 @@ class Credentials implements ICredentials { ) { } + #[\Override] public function getUsername(): string { return $this->user; } + #[\Override] public function getPassword(): string { return $this->password; } diff --git a/lib/private/Remote/InstanceFactory.php b/lib/private/Remote/InstanceFactory.php index 5279d0146cd..13a4e2c1e56 100644 --- a/lib/private/Remote/InstanceFactory.php +++ b/lib/private/Remote/InstanceFactory.php @@ -17,6 +17,7 @@ class InstanceFactory implements IInstanceFactory { ) { } + #[\Override] public function getInstance($url) { return new Instance($url, $this->cache, $this->clientService); } diff --git a/lib/private/Remote/User.php b/lib/private/Remote/User.php index a8f665154ad..a3d0f3815e8 100644 --- a/lib/private/Remote/User.php +++ b/lib/private/Remote/User.php @@ -32,6 +32,7 @@ class User implements IUser { /** * @return string */ + #[\Override] public function getUserId() { return $this->data['id']; } @@ -39,6 +40,7 @@ class User implements IUser { /** * @return string */ + #[\Override] public function getEmail() { return $this->data['email']; } @@ -46,6 +48,7 @@ class User implements IUser { /** * @return string */ + #[\Override] public function getDisplayName() { return $this->data['displayname']; } @@ -53,6 +56,7 @@ class User implements IUser { /** * @return string */ + #[\Override] public function getPhone() { return $this->data['phone']; } @@ -60,6 +64,7 @@ class User implements IUser { /** * @return string */ + #[\Override] public function getAddress() { return $this->data['address']; } @@ -67,6 +72,7 @@ class User implements IUser { /** * @return string */ + #[\Override] public function getWebsite() { return $this->data['website']; } @@ -74,6 +80,7 @@ class User implements IUser { /** * @return string */ + #[\Override] public function getTwitter() { return $this->data['twitter'] ?? ''; } @@ -81,6 +88,7 @@ class User implements IUser { /** * @return string[] */ + #[\Override] public function getGroups() { return $this->data['groups']; } @@ -88,6 +96,7 @@ class User implements IUser { /** * @return string */ + #[\Override] public function getLanguage() { return $this->data['language']; } @@ -95,6 +104,7 @@ class User implements IUser { /** * @return int */ + #[\Override] public function getUsedSpace() { return $this->data['quota']['used']; } @@ -102,6 +112,7 @@ class User implements IUser { /** * @return int */ + #[\Override] public function getFreeSpace() { return $this->data['quota']['free']; } @@ -109,6 +120,7 @@ class User implements IUser { /** * @return int */ + #[\Override] public function getTotalSpace() { return $this->data['quota']['total']; } @@ -116,6 +128,7 @@ class User implements IUser { /** * @return int */ + #[\Override] public function getQuota() { return $this->data['quota']['quota']; } diff --git a/lib/private/Repair.php b/lib/private/Repair.php index be6de73579c..90e209cfe90 100644 --- a/lib/private/Repair.php +++ b/lib/private/Repair.php @@ -222,12 +222,14 @@ class Repair implements IOutput { ]; } + #[\Override] public function debug(string $message): void { } /** * @param string $message */ + #[\Override] public function info($message): void { // for now just emit as we did in the past $this->dispatcher->dispatchTyped(new RepairInfoEvent($message)); @@ -236,6 +238,7 @@ class Repair implements IOutput { /** * @param string $message */ + #[\Override] public function warning($message): void { // for now just emit as we did in the past $this->dispatcher->dispatchTyped(new RepairWarningEvent($message)); @@ -244,6 +247,7 @@ class Repair implements IOutput { /** * @param int $max */ + #[\Override] public function startProgress($max = 0): void { // for now just emit as we did in the past $this->dispatcher->dispatchTyped(new RepairStartEvent($max, $this->currentStep)); @@ -253,11 +257,13 @@ class Repair implements IOutput { * @param int $step number of step to advance * @param string $description */ + #[\Override] public function advance($step = 1, $description = ''): void { // for now just emit as we did in the past $this->dispatcher->dispatchTyped(new RepairAdvanceEvent($step, $description)); } + #[\Override] public function finishProgress(): void { // for now just emit as we did in the past $this->dispatcher->dispatchTyped(new RepairFinishEvent()); diff --git a/lib/private/Repair/AddBruteForceCleanupJob.php b/lib/private/Repair/AddBruteForceCleanupJob.php index 9473d9031a4..20c1191b006 100644 --- a/lib/private/Repair/AddBruteForceCleanupJob.php +++ b/lib/private/Repair/AddBruteForceCleanupJob.php @@ -19,10 +19,12 @@ class AddBruteForceCleanupJob implements IRepairStep { ) { } + #[\Override] public function getName(): string { return 'Add job to cleanup the bruteforce entries'; } + #[\Override] public function run(IOutput $output): void { $this->jobList->add(CleanupJob::class); } diff --git a/lib/private/Repair/AddCleanupDeletedUsersBackgroundJob.php b/lib/private/Repair/AddCleanupDeletedUsersBackgroundJob.php index 6d983b8456c..ac66d4f59d7 100644 --- a/lib/private/Repair/AddCleanupDeletedUsersBackgroundJob.php +++ b/lib/private/Repair/AddCleanupDeletedUsersBackgroundJob.php @@ -19,10 +19,12 @@ class AddCleanupDeletedUsersBackgroundJob implements IRepairStep { ) { } + #[\Override] public function getName(): string { return 'Add cleanup-deleted-users background job'; } + #[\Override] public function run(IOutput $output): void { $this->jobList->add(CleanupDeletedUsers::class); } diff --git a/lib/private/Repair/AddCleanupUpdaterBackupsJob.php b/lib/private/Repair/AddCleanupUpdaterBackupsJob.php index 731bf4537c7..f0138133196 100644 --- a/lib/private/Repair/AddCleanupUpdaterBackupsJob.php +++ b/lib/private/Repair/AddCleanupUpdaterBackupsJob.php @@ -19,10 +19,12 @@ class AddCleanupUpdaterBackupsJob implements IRepairStep { ) { } + #[\Override] public function getName(): string { return 'Queue a one-time job to cleanup old backups of the updater'; } + #[\Override] public function run(IOutput $output): void { $this->jobList->add(BackgroundCleanupUpdaterBackupsJob::class); } diff --git a/lib/private/Repair/AddMetadataGenerationJob.php b/lib/private/Repair/AddMetadataGenerationJob.php index f907144dc7d..3ab619d6246 100644 --- a/lib/private/Repair/AddMetadataGenerationJob.php +++ b/lib/private/Repair/AddMetadataGenerationJob.php @@ -19,10 +19,12 @@ class AddMetadataGenerationJob implements IRepairStep { ) { } + #[\Override] public function getName(): string { return 'Queue a job to generate metadata'; } + #[\Override] public function run(IOutput $output): void { $this->jobList->add(GenerateMetadataJob::class); } diff --git a/lib/private/Repair/AddMovePreviewJob.php b/lib/private/Repair/AddMovePreviewJob.php index 84d32887f28..37f8398e56f 100644 --- a/lib/private/Repair/AddMovePreviewJob.php +++ b/lib/private/Repair/AddMovePreviewJob.php @@ -20,6 +20,7 @@ class AddMovePreviewJob implements IRepairStep { ) { } + #[\Override] public function getName(): string { return 'Queue a job to move the preview'; } diff --git a/lib/private/Repair/AddRemoveOldTasksBackgroundJob.php b/lib/private/Repair/AddRemoveOldTasksBackgroundJob.php index eac9d5c3dc1..292a4e85a7b 100644 --- a/lib/private/Repair/AddRemoveOldTasksBackgroundJob.php +++ b/lib/private/Repair/AddRemoveOldTasksBackgroundJob.php @@ -21,10 +21,12 @@ class AddRemoveOldTasksBackgroundJob implements IRepairStep { ) { } + #[\Override] public function getName(): string { return 'Add AI tasks cleanup jobs'; } + #[\Override] public function run(IOutput $output) { $this->jobList->add(RemoveOldTextProcessingTasksBackgroundJob::class); $this->jobList->add(RemoveOldTextToImageTasksBackgroundJob::class); diff --git a/lib/private/Repair/CleanTags.php b/lib/private/Repair/CleanTags.php index 4397f2cf09e..3ea09e8c97c 100644 --- a/lib/private/Repair/CleanTags.php +++ b/lib/private/Repair/CleanTags.php @@ -28,6 +28,7 @@ class CleanTags implements IRepairStep { ) { } + #[\Override] public function getName(): string { return 'Clean tags and favorites'; } @@ -35,6 +36,7 @@ class CleanTags implements IRepairStep { /** * Updates the configuration after running an update */ + #[\Override] public function run(IOutput $output): void { $this->deleteOrphanTags($output); $this->deleteOrphanFileEntries($output); diff --git a/lib/private/Repair/CleanUpAbandonedApps.php b/lib/private/Repair/CleanUpAbandonedApps.php index ce166ebd2b3..4300bf18d8b 100644 --- a/lib/private/Repair/CleanUpAbandonedApps.php +++ b/lib/private/Repair/CleanUpAbandonedApps.php @@ -19,10 +19,12 @@ class CleanUpAbandonedApps implements IRepairStep { ) { } + #[\Override] public function getName(): string { return 'Clean up abandoned apps'; } + #[\Override] public function run(IOutput $output): void { foreach (self::ABANDONED_APPS as $app) { // only remove global app values diff --git a/lib/private/Repair/ClearFrontendCaches.php b/lib/private/Repair/ClearFrontendCaches.php index b5631b660cb..4211f6c745f 100644 --- a/lib/private/Repair/ClearFrontendCaches.php +++ b/lib/private/Repair/ClearFrontendCaches.php @@ -20,10 +20,12 @@ class ClearFrontendCaches implements IRepairStep { ) { } + #[\Override] public function getName(): string { return 'Clear frontend caches'; } + #[\Override] public function run(IOutput $output): void { try { $c = $this->cacheFactory->createDistributed('imagePath'); diff --git a/lib/private/Repair/ClearGeneratedAvatarCache.php b/lib/private/Repair/ClearGeneratedAvatarCache.php index cc71a5dc6e4..75b5d8fe85e 100644 --- a/lib/private/Repair/ClearGeneratedAvatarCache.php +++ b/lib/private/Repair/ClearGeneratedAvatarCache.php @@ -22,6 +22,7 @@ class ClearGeneratedAvatarCache implements IRepairStep { ) { } + #[\Override] public function getName(): string { return 'Clear every generated avatar'; } @@ -37,6 +38,7 @@ class ClearGeneratedAvatarCache implements IRepairStep { return version_compare($versionFromBeforeUpdate, '27.0.0', '<'); } + #[\Override] public function run(IOutput $output): void { if ($this->shouldRun()) { try { diff --git a/lib/private/Repair/ClearGeneratedAvatarCacheJob.php b/lib/private/Repair/ClearGeneratedAvatarCacheJob.php index 6637becd4a1..2cd0596f274 100644 --- a/lib/private/Repair/ClearGeneratedAvatarCacheJob.php +++ b/lib/private/Repair/ClearGeneratedAvatarCacheJob.php @@ -20,6 +20,7 @@ class ClearGeneratedAvatarCacheJob extends QueuedJob { parent::__construct($timeFactory); } + #[\Override] public function run($argument) { $this->avatarManager->clearCachedAvatars(); } diff --git a/lib/private/Repair/Collation.php b/lib/private/Repair/Collation.php index 450b132ef47..52537886961 100644 --- a/lib/private/Repair/Collation.php +++ b/lib/private/Repair/Collation.php @@ -25,6 +25,7 @@ class Collation implements IRepairStep { ) { } + #[\Override] public function getName(): string { return 'Repair MySQL collation'; } @@ -32,6 +33,7 @@ class Collation implements IRepairStep { /** * Fix mime types */ + #[\Override] public function run(IOutput $output): void { if ($this->connection->getDatabaseProvider() !== IDBConnection::PLATFORM_MYSQL) { $output->info('Not a mysql database -> nothing to do'); diff --git a/lib/private/Repair/ConfigKeyMigration.php b/lib/private/Repair/ConfigKeyMigration.php index acdda68dc0a..8c69fee2e70 100644 --- a/lib/private/Repair/ConfigKeyMigration.php +++ b/lib/private/Repair/ConfigKeyMigration.php @@ -19,10 +19,12 @@ class ConfigKeyMigration implements IRepairStep { ) { } + #[\Override] public function getName(): string { return 'Migrate config keys'; } + #[\Override] public function run(IOutput $output): void { $this->configManager->migrateConfigLexiconKeys(); $this->configManager->updateLexiconEntries('core'); diff --git a/lib/private/Repair/MoveUpdaterStepFile.php b/lib/private/Repair/MoveUpdaterStepFile.php index 28fe0db1314..72ea92be0fb 100644 --- a/lib/private/Repair/MoveUpdaterStepFile.php +++ b/lib/private/Repair/MoveUpdaterStepFile.php @@ -19,10 +19,12 @@ class MoveUpdaterStepFile implements IRepairStep { ) { } + #[\Override] public function getName(): string { return 'Move .step file of updater to backup location'; } + #[\Override] public function run(IOutput $output): void { $updateDir = $this->config->getSystemValue('updatedirectory', null) ?? $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data'); $instanceId = $this->config->getSystemValueString('instanceid'); diff --git a/lib/private/Repair/NC13/AddLogRotateJob.php b/lib/private/Repair/NC13/AddLogRotateJob.php index a44610dd07a..68e3693aac4 100644 --- a/lib/private/Repair/NC13/AddLogRotateJob.php +++ b/lib/private/Repair/NC13/AddLogRotateJob.php @@ -19,10 +19,12 @@ class AddLogRotateJob implements IRepairStep { ) { } + #[\Override] public function getName(): string { return 'Add log rotate job'; } + #[\Override] public function run(IOutput $output): void { $this->jobList->add(Rotate::class); } diff --git a/lib/private/Repair/NC14/AddPreviewBackgroundCleanupJob.php b/lib/private/Repair/NC14/AddPreviewBackgroundCleanupJob.php index c7a95775083..dff83d7a6cb 100644 --- a/lib/private/Repair/NC14/AddPreviewBackgroundCleanupJob.php +++ b/lib/private/Repair/NC14/AddPreviewBackgroundCleanupJob.php @@ -19,10 +19,12 @@ class AddPreviewBackgroundCleanupJob implements IRepairStep { ) { } + #[\Override] public function getName(): string { return 'Add preview background cleanup job'; } + #[\Override] public function run(IOutput $output) { $this->jobList->add(BackgroundCleanupJob::class); } diff --git a/lib/private/Repair/NC16/AddCleanupLoginFlowV2BackgroundJob.php b/lib/private/Repair/NC16/AddCleanupLoginFlowV2BackgroundJob.php index 630b20a4128..028cce593f9 100644 --- a/lib/private/Repair/NC16/AddCleanupLoginFlowV2BackgroundJob.php +++ b/lib/private/Repair/NC16/AddCleanupLoginFlowV2BackgroundJob.php @@ -19,10 +19,12 @@ class AddCleanupLoginFlowV2BackgroundJob implements IRepairStep { ) { } + #[\Override] public function getName(): string { return 'Add background job to cleanup login flow v2 tokens'; } + #[\Override] public function run(IOutput $output) { $this->jobList->add(CleanupLoginFlowV2::class); } diff --git a/lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php b/lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php index 646dd2c5e83..d21c0df6177 100644 --- a/lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php +++ b/lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php @@ -35,6 +35,7 @@ class CleanupCardDAVPhotoCache implements IRepairStep { ) { } + #[\Override] public function getName(): string { return 'Cleanup invalid photocache files for carddav'; } @@ -80,6 +81,7 @@ class CleanupCardDAVPhotoCache implements IRepairStep { ); } + #[\Override] public function run(IOutput $output): void { if ($this->shouldRun()) { $this->repair($output); diff --git a/lib/private/Repair/NC16/ClearCollectionsAccessCache.php b/lib/private/Repair/NC16/ClearCollectionsAccessCache.php index e1eef24eedd..163f5794700 100644 --- a/lib/private/Repair/NC16/ClearCollectionsAccessCache.php +++ b/lib/private/Repair/NC16/ClearCollectionsAccessCache.php @@ -20,6 +20,7 @@ class ClearCollectionsAccessCache implements IRepairStep { ) { } + #[\Override] public function getName(): string { return 'Clear access cache of projects'; } @@ -29,6 +30,7 @@ class ClearCollectionsAccessCache implements IRepairStep { return version_compare($versionFromBeforeUpdate, '17.0.0.3', '<='); } + #[\Override] public function run(IOutput $output): void { if ($this->shouldRun()) { $this->manager->invalidateAccessCacheForAllCollections(); diff --git a/lib/private/Repair/NC18/ResetGeneratedAvatarFlag.php b/lib/private/Repair/NC18/ResetGeneratedAvatarFlag.php index d07bc2d7193..5de39b58a95 100644 --- a/lib/private/Repair/NC18/ResetGeneratedAvatarFlag.php +++ b/lib/private/Repair/NC18/ResetGeneratedAvatarFlag.php @@ -20,6 +20,7 @@ class ResetGeneratedAvatarFlag implements IRepairStep { ) { } + #[\Override] public function getName(): string { return 'Reset generated avatar flag'; } @@ -29,6 +30,7 @@ class ResetGeneratedAvatarFlag implements IRepairStep { return version_compare($versionFromBeforeUpdate, '18.0.0.5', '<='); } + #[\Override] public function run(IOutput $output): void { if ($this->shouldRun()) { $query = $this->connection->getQueryBuilder(); diff --git a/lib/private/Repair/NC20/EncryptionLegacyCipher.php b/lib/private/Repair/NC20/EncryptionLegacyCipher.php index ca8986e78db..32f98a140d7 100644 --- a/lib/private/Repair/NC20/EncryptionLegacyCipher.php +++ b/lib/private/Repair/NC20/EncryptionLegacyCipher.php @@ -20,6 +20,7 @@ class EncryptionLegacyCipher implements IRepairStep { ) { } + #[\Override] public function getName(): string { return 'Keep legacy encryption enabled'; } @@ -29,6 +30,7 @@ class EncryptionLegacyCipher implements IRepairStep { return version_compare($versionFromBeforeUpdate, '20.0.0.0', '<='); } + #[\Override] public function run(IOutput $output): void { if (!$this->shouldRun()) { return; diff --git a/lib/private/Repair/NC20/EncryptionMigration.php b/lib/private/Repair/NC20/EncryptionMigration.php index 91fca99c5d2..d46752dbcfc 100644 --- a/lib/private/Repair/NC20/EncryptionMigration.php +++ b/lib/private/Repair/NC20/EncryptionMigration.php @@ -20,6 +20,7 @@ class EncryptionMigration implements IRepairStep { ) { } + #[\Override] public function getName(): string { return 'Check encryption key format'; } @@ -29,6 +30,7 @@ class EncryptionMigration implements IRepairStep { return version_compare($versionFromBeforeUpdate, '20.0.0.1', '<='); } + #[\Override] public function run(IOutput $output): void { if (!$this->shouldRun()) { return; diff --git a/lib/private/Repair/NC20/ShippedDashboardEnable.php b/lib/private/Repair/NC20/ShippedDashboardEnable.php index 5d505d0c3ef..4ff1bae77e1 100644 --- a/lib/private/Repair/NC20/ShippedDashboardEnable.php +++ b/lib/private/Repair/NC20/ShippedDashboardEnable.php @@ -18,10 +18,12 @@ class ShippedDashboardEnable implements IRepairStep { ) { } + #[\Override] public function getName(): string { return 'Remove old dashboard app config data'; } + #[\Override] public function run(IOutput $output): void { $version = $this->config->getAppValue('dashboard', 'version', '7.0.0'); if (version_compare($version, '7.0.0', '<')) { diff --git a/lib/private/Repair/NC21/AddCheckForUserCertificatesJob.php b/lib/private/Repair/NC21/AddCheckForUserCertificatesJob.php index 1890df81cf1..e16a5862cd5 100644 --- a/lib/private/Repair/NC21/AddCheckForUserCertificatesJob.php +++ b/lib/private/Repair/NC21/AddCheckForUserCertificatesJob.php @@ -21,6 +21,7 @@ class AddCheckForUserCertificatesJob implements IRepairStep { ) { } + #[\Override] public function getName(): string { return 'Queue a one-time job to check for user uploaded certificates'; } @@ -32,6 +33,7 @@ class AddCheckForUserCertificatesJob implements IRepairStep { return version_compare($versionFromBeforeUpdate, '21.0.0.2', '<'); } + #[\Override] public function run(IOutput $output): void { if ($this->shouldRun()) { $this->config->setAppValue('files_external', 'user_certificate_scan', 'not-run-yet'); diff --git a/lib/private/Repair/NC22/LookupServerSendCheck.php b/lib/private/Repair/NC22/LookupServerSendCheck.php index 453e06fd606..47d752cfcb7 100644 --- a/lib/private/Repair/NC22/LookupServerSendCheck.php +++ b/lib/private/Repair/NC22/LookupServerSendCheck.php @@ -19,10 +19,12 @@ class LookupServerSendCheck implements IRepairStep { ) { } + #[\Override] public function getName(): string { return 'Add background job to set the lookup server share state for users'; } + #[\Override] public function run(IOutput $output): void { $this->jobList->add(LookupServerSendCheckBackgroundJob::class); } diff --git a/lib/private/Repair/NC24/AddTokenCleanupJob.php b/lib/private/Repair/NC24/AddTokenCleanupJob.php index be6b24b0c1c..2fa9235c9f9 100644 --- a/lib/private/Repair/NC24/AddTokenCleanupJob.php +++ b/lib/private/Repair/NC24/AddTokenCleanupJob.php @@ -19,10 +19,12 @@ class AddTokenCleanupJob implements IRepairStep { ) { } + #[\Override] public function getName(): string { return 'Add token cleanup job'; } + #[\Override] public function run(IOutput $output) { $this->jobList->add(TokenCleanupJob::class); } diff --git a/lib/private/Repair/NC25/AddMissingSecretJob.php b/lib/private/Repair/NC25/AddMissingSecretJob.php index 2b8f5934ee8..d754862a1ac 100644 --- a/lib/private/Repair/NC25/AddMissingSecretJob.php +++ b/lib/private/Repair/NC25/AddMissingSecretJob.php @@ -21,10 +21,12 @@ class AddMissingSecretJob implements IRepairStep { ) { } + #[\Override] public function getName(): string { return 'Add possibly missing system config'; } + #[\Override] public function run(IOutput $output): void { $passwordSalt = $this->config->getSystemValueString('passwordsalt', ''); if ($passwordSalt === '') { diff --git a/lib/private/Repair/NC29/SanitizeAccountProperties.php b/lib/private/Repair/NC29/SanitizeAccountProperties.php index 412570ba71d..da51c67e268 100644 --- a/lib/private/Repair/NC29/SanitizeAccountProperties.php +++ b/lib/private/Repair/NC29/SanitizeAccountProperties.php @@ -19,10 +19,12 @@ class SanitizeAccountProperties implements IRepairStep { ) { } + #[\Override] public function getName(): string { return 'Validate account properties and store phone numbers in a known format for search'; } + #[\Override] public function run(IOutput $output): void { $this->jobList->add(SanitizeAccountPropertiesJob::class, null); $output->info('Queued background to validate account properties.'); diff --git a/lib/private/Repair/NC29/SanitizeAccountPropertiesJob.php b/lib/private/Repair/NC29/SanitizeAccountPropertiesJob.php index 530805d3637..fbce960d302 100644 --- a/lib/private/Repair/NC29/SanitizeAccountPropertiesJob.php +++ b/lib/private/Repair/NC29/SanitizeAccountPropertiesJob.php @@ -35,6 +35,7 @@ class SanitizeAccountPropertiesJob extends QueuedJob { $this->setAllowParallelRuns(false); } + #[\Override] protected function run(mixed $argument): void { $numRemoved = 0; diff --git a/lib/private/Repair/NC30/RemoveLegacyDatadirFile.php b/lib/private/Repair/NC30/RemoveLegacyDatadirFile.php index 623163927bd..80b7da014f4 100644 --- a/lib/private/Repair/NC30/RemoveLegacyDatadirFile.php +++ b/lib/private/Repair/NC30/RemoveLegacyDatadirFile.php @@ -19,10 +19,12 @@ class RemoveLegacyDatadirFile implements IRepairStep { ) { } + #[\Override] public function getName(): string { return 'Remove legacy ".ocdata" file'; } + #[\Override] public function run(IOutput $output): void { $ocdata = $this->config->getSystemValueString('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata'; if (file_exists($ocdata)) { diff --git a/lib/private/Repair/OldGroupMembershipShares.php b/lib/private/Repair/OldGroupMembershipShares.php index a0ae19957e5..602cbcac478 100644 --- a/lib/private/Repair/OldGroupMembershipShares.php +++ b/lib/private/Repair/OldGroupMembershipShares.php @@ -25,6 +25,7 @@ class OldGroupMembershipShares implements IRepairStep { ) { } + #[\Override] public function getName(): string { return 'Remove shares of old group memberships'; } @@ -35,6 +36,7 @@ class OldGroupMembershipShares implements IRepairStep { * * @throws \Exception in case of failure */ + #[\Override] public function run(IOutput $output): void { $deletedEntries = 0; diff --git a/lib/private/Repair/Owncloud/CleanPreviewsBackgroundJob.php b/lib/private/Repair/Owncloud/CleanPreviewsBackgroundJob.php index be63bda063e..ff83de3b5bb 100644 --- a/lib/private/Repair/Owncloud/CleanPreviewsBackgroundJob.php +++ b/lib/private/Repair/Owncloud/CleanPreviewsBackgroundJob.php @@ -29,6 +29,7 @@ class CleanPreviewsBackgroundJob extends QueuedJob { parent::__construct($timeFactory); } + #[\Override] public function run($argument): void { $uid = $argument['uid']; if (!$this->userManager->userExists($uid)) { diff --git a/lib/private/Repair/Owncloud/DropAccountTermsTable.php b/lib/private/Repair/Owncloud/DropAccountTermsTable.php index f848a99af57..a0b4b19433c 100644 --- a/lib/private/Repair/Owncloud/DropAccountTermsTable.php +++ b/lib/private/Repair/Owncloud/DropAccountTermsTable.php @@ -18,10 +18,12 @@ class DropAccountTermsTable implements IRepairStep { ) { } + #[\Override] public function getName(): string { return 'Drop account terms table when migrating from ownCloud'; } + #[\Override] public function run(IOutput $output): void { if (!$this->db->tableExists('account_terms')) { return; diff --git a/lib/private/Repair/Owncloud/MigrateOauthTables.php b/lib/private/Repair/Owncloud/MigrateOauthTables.php index 1d7b630b4e5..437ef59821b 100644 --- a/lib/private/Repair/Owncloud/MigrateOauthTables.php +++ b/lib/private/Repair/Owncloud/MigrateOauthTables.php @@ -34,10 +34,12 @@ class MigrateOauthTables implements IRepairStep { ) { } + #[\Override] public function getName(): string { return 'Migrate oauth2_clients table to nextcloud schema'; } + #[\Override] public function run(IOutput $output): void { $schema = new SchemaWrapper($this->db); if (!$schema->hasTable('oauth2_clients')) { diff --git a/lib/private/Repair/Owncloud/MigratePropertiesTable.php b/lib/private/Repair/Owncloud/MigratePropertiesTable.php index 60122bbf3d1..09fe5fddb89 100644 --- a/lib/private/Repair/Owncloud/MigratePropertiesTable.php +++ b/lib/private/Repair/Owncloud/MigratePropertiesTable.php @@ -23,10 +23,12 @@ class MigratePropertiesTable implements IRepairStep { ) { } + #[\Override] public function getName(): string { return 'Migrate oc_properties table to nextcloud schema'; } + #[\Override] public function run(IOutput $output): void { $schema = new SchemaWrapper($this->db); if (!$schema->hasTable('oc_properties')) { diff --git a/lib/private/Repair/Owncloud/MoveAvatars.php b/lib/private/Repair/Owncloud/MoveAvatars.php index fd38fc79d64..26c280fb840 100644 --- a/lib/private/Repair/Owncloud/MoveAvatars.php +++ b/lib/private/Repair/Owncloud/MoveAvatars.php @@ -20,10 +20,12 @@ class MoveAvatars implements IRepairStep { ) { } + #[\Override] public function getName(): string { return 'Add move avatar background job'; } + #[\Override] public function run(IOutput $output): void { // only run once if ($this->config->getAppValue('core', 'moveavatarsdone') === 'yes') { diff --git a/lib/private/Repair/Owncloud/MoveAvatarsBackgroundJob.php b/lib/private/Repair/Owncloud/MoveAvatarsBackgroundJob.php index 3b8936894e7..6895cad0e1c 100644 --- a/lib/private/Repair/Owncloud/MoveAvatarsBackgroundJob.php +++ b/lib/private/Repair/Owncloud/MoveAvatarsBackgroundJob.php @@ -36,6 +36,7 @@ class MoveAvatarsBackgroundJob extends QueuedJob { } } + #[\Override] public function run($argument) { $this->logger->info('Started migrating avatars to AppData folder'); $this->moveAvatars(); diff --git a/lib/private/Repair/Owncloud/SaveAccountsTableData.php b/lib/private/Repair/Owncloud/SaveAccountsTableData.php index 61284a09e5d..d37c941b7e8 100644 --- a/lib/private/Repair/Owncloud/SaveAccountsTableData.php +++ b/lib/private/Repair/Owncloud/SaveAccountsTableData.php @@ -28,10 +28,12 @@ class SaveAccountsTableData implements IRepairStep { ) { } + #[\Override] public function getName(): string { return 'Copy data from accounts table when migrating from ownCloud'; } + #[\Override] public function run(IOutput $output): void { if (!$this->shouldRun()) { return; diff --git a/lib/private/Repair/RemoveLinkShares.php b/lib/private/Repair/RemoveLinkShares.php index 5ea1d4b9258..25255f9d3f8 100644 --- a/lib/private/Repair/RemoveLinkShares.php +++ b/lib/private/Repair/RemoveLinkShares.php @@ -31,6 +31,7 @@ class RemoveLinkShares implements IRepairStep { ) { } + #[\Override] public function getName(): string { return 'Remove potentially over exposing share links'; } @@ -184,6 +185,7 @@ class RemoveLinkShares implements IRepairStep { $this->sendNotification(); } + #[\Override] public function run(IOutput $output): void { if ($this->shouldRun() === false || ($total = $this->getTotal()) === 0) { $output->info('No need to remove link shares.'); diff --git a/lib/private/Repair/RepairDavShares.php b/lib/private/Repair/RepairDavShares.php index c21c0274461..1321fd7913c 100644 --- a/lib/private/Repair/RepairDavShares.php +++ b/lib/private/Repair/RepairDavShares.php @@ -33,6 +33,7 @@ class RepairDavShares implements IRepairStep { ) { } + #[\Override] public function getName(): string { return 'Repair DAV shares'; } @@ -88,6 +89,7 @@ class RepairDavShares implements IRepairStep { return true; } + #[\Override] public function run(IOutput $output): void { $versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0'); if (version_compare($versionFromBeforeUpdate, '20.0.8', '<') diff --git a/lib/private/Repair/RepairInvalidShares.php b/lib/private/Repair/RepairInvalidShares.php index 5939d0d6430..1793ef55f30 100644 --- a/lib/private/Repair/RepairInvalidShares.php +++ b/lib/private/Repair/RepairInvalidShares.php @@ -25,6 +25,7 @@ class RepairInvalidShares implements IRepairStep { ) { } + #[\Override] public function getName(): string { return 'Repair invalid shares'; } @@ -85,6 +86,7 @@ class RepairInvalidShares implements IRepairStep { } } + #[\Override] public function run(IOutput $output) { $ocVersionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0'); if (version_compare($ocVersionFromBeforeUpdate, '12.0.0.11', '<')) { diff --git a/lib/private/Repair/RepairLogoDimension.php b/lib/private/Repair/RepairLogoDimension.php index 854aeb3ab07..7d01bbea696 100644 --- a/lib/private/Repair/RepairLogoDimension.php +++ b/lib/private/Repair/RepairLogoDimension.php @@ -22,10 +22,12 @@ class RepairLogoDimension implements IRepairStep { ) { } + #[\Override] public function getName(): string { return 'Cache logo dimension to fix size in emails on Outlook'; } + #[\Override] public function run(IOutput $output): void { $logoDimensions = $this->config->getAppValue('theming', 'logoDimensions'); if (preg_match('/^\d+x\d+$/', $logoDimensions)) { diff --git a/lib/private/Repair/RepairMimeTypes.php b/lib/private/Repair/RepairMimeTypes.php index a9ef95b50c2..0fa3ebc51fe 100644 --- a/lib/private/Repair/RepairMimeTypes.php +++ b/lib/private/Repair/RepairMimeTypes.php @@ -28,6 +28,7 @@ class RepairMimeTypes implements IRepairStep { ) { } + #[\Override] public function getName(): string { return 'Repair mime types'; } @@ -403,6 +404,7 @@ class RepairMimeTypes implements IRepairStep { * * @throws Exception */ + #[\Override] public function run(IOutput $output): void { $serverVersion = $this->config->getSystemValueString('version', '0.0.0'); $mimeTypeVersion = $this->getMimeTypeVersion(); diff --git a/lib/private/RichObjectStrings/RichTextFormatter.php b/lib/private/RichObjectStrings/RichTextFormatter.php index 9c9ddf94fa9..643ca5ba3fe 100644 --- a/lib/private/RichObjectStrings/RichTextFormatter.php +++ b/lib/private/RichObjectStrings/RichTextFormatter.php @@ -15,6 +15,7 @@ class RichTextFormatter implements IRichTextFormatter { /** * @throws \InvalidArgumentException if a parameter has no name or no type */ + #[\Override] public function richToParsed(string $message, array $parameters): string { $placeholders = []; $replacements = []; diff --git a/lib/private/RichObjectStrings/Validator.php b/lib/private/RichObjectStrings/Validator.php index adc4a8710f7..14a034d0980 100644 --- a/lib/private/RichObjectStrings/Validator.php +++ b/lib/private/RichObjectStrings/Validator.php @@ -32,6 +32,7 @@ class Validator implements IValidator { * @throws InvalidObjectExeption * @since 11.0.0 */ + #[\Override] public function validate(string $subject, array $parameters): void { $matches = []; $result = preg_match_all('/\{(' . self::PLACEHOLDER_REGEX . ')\}/', $subject, $matches); diff --git a/lib/private/Route/CachingRouter.php b/lib/private/Route/CachingRouter.php index 8ed90350135..bbc20ac7b77 100644 --- a/lib/private/Route/CachingRouter.php +++ b/lib/private/Route/CachingRouter.php @@ -46,6 +46,7 @@ class CachingRouter extends Router { * @param bool $absolute * @return string */ + #[\Override] public function generate($name, $parameters = [], $absolute = false) { asort($parameters); $key = $this->context->getHost() . '#' . $this->context->getBaseUrl() . $name . sha1(json_encode($parameters)) . (int)$absolute; @@ -73,6 +74,7 @@ class CachingRouter extends Router { * @throws \Exception * @return array */ + #[\Override] public function findMatchingRoute(string $url): array { $this->eventLogger->start('cacheroute:match', 'Match route'); $key = $this->context->getHost() . '#' . $this->context->getBaseUrl() . '#rootCollection'; @@ -117,6 +119,7 @@ class CachingRouter extends Router { /** * @param array{action:mixed, ...} $parameters */ + #[\Override] protected function callLegacyActionRoute(array $parameters): void { /* * Closures cannot be serialized to cache, so for legacy routes calling an action we have to include the routes.php file again @@ -138,6 +141,7 @@ class CachingRouter extends Router { * @param array $defaults An array of default parameter values * @param array $requirements An array of requirements for parameters (regexes) */ + #[\Override] public function create($name, $pattern, array $defaults = [], array $requirements = []): Route { $this->legacyCreatedRoutes[] = $name; return parent::create($name, $pattern, $defaults, $requirements); @@ -146,6 +150,7 @@ class CachingRouter extends Router { /** * Require a routes.php file */ + #[\Override] protected function requireRouteFile(string $file, string $appName): void { $this->legacyCreatedRoutes = []; parent::requireRouteFile($file, $appName); diff --git a/lib/private/Route/Route.php b/lib/private/Route/Route.php index ad967135104..2d9becc86e3 100644 --- a/lib/private/Route/Route.php +++ b/lib/private/Route/Route.php @@ -17,6 +17,7 @@ class Route extends SymfonyRoute implements IRoute { * @param string|array $method HTTP method * @return \OC\Route\Route */ + #[\Override] public function method($method) { $this->setMethods($method); return $this; @@ -26,6 +27,7 @@ class Route extends SymfonyRoute implements IRoute { * Specify POST as the method to use with this route * @return \OC\Route\Route */ + #[\Override] public function post() { $this->method('POST'); return $this; @@ -35,6 +37,7 @@ class Route extends SymfonyRoute implements IRoute { * Specify GET as the method to use with this route * @return \OC\Route\Route */ + #[\Override] public function get() { $this->method('GET'); return $this; @@ -44,6 +47,7 @@ class Route extends SymfonyRoute implements IRoute { * Specify PUT as the method to use with this route * @return \OC\Route\Route */ + #[\Override] public function put() { $this->method('PUT'); return $this; @@ -53,6 +57,7 @@ class Route extends SymfonyRoute implements IRoute { * Specify DELETE as the method to use with this route * @return \OC\Route\Route */ + #[\Override] public function delete() { $this->method('DELETE'); return $this; @@ -62,6 +67,7 @@ class Route extends SymfonyRoute implements IRoute { * Specify PATCH as the method to use with this route * @return \OC\Route\Route */ + #[\Override] public function patch() { $this->method('PATCH'); return $this; @@ -73,6 +79,7 @@ class Route extends SymfonyRoute implements IRoute { * @param array $defaults The defaults * @return \OC\Route\Route */ + #[\Override] public function defaults($defaults) { $action = $this->getDefault('action'); $this->setDefaults($defaults); @@ -89,6 +96,7 @@ class Route extends SymfonyRoute implements IRoute { * @param array $requirements The requirements * @return \OC\Route\Route */ + #[\Override] public function requirements($requirements) { $method = $this->getMethods(); $this->setRequirements($requirements); @@ -111,6 +119,7 @@ class Route extends SymfonyRoute implements IRoute { * This function is called with $class set to a callable or * to the class with $function */ + #[\Override] public function action($class, $function = null) { $action = [$class, $function]; if (is_null($function)) { @@ -125,6 +134,7 @@ class Route extends SymfonyRoute implements IRoute { * it is called directly * @param string $file */ + #[\Override] public function actionInclude($file) { $this->setDefault('file', $file); return $this; diff --git a/lib/private/Route/Router.php b/lib/private/Route/Router.php index c0170b7dd83..e4d1a65da3f 100644 --- a/lib/private/Route/Router.php +++ b/lib/private/Route/Router.php @@ -233,6 +233,7 @@ class Router implements IRouter { * @param array $requirements An array of requirements for parameters (regexes) * @return \OC\Route\Route */ + #[\Override] public function create($name, $pattern, array $defaults = [], diff --git a/lib/private/Search/Filter/BooleanFilter.php b/lib/private/Search/Filter/BooleanFilter.php index 894dc13b657..2be28b672fe 100644 --- a/lib/private/Search/Filter/BooleanFilter.php +++ b/lib/private/Search/Filter/BooleanFilter.php @@ -23,6 +23,7 @@ class BooleanFilter implements IFilter { }; } + #[\Override] public function get(): bool { return $this->value; } diff --git a/lib/private/Search/Filter/DateTimeFilter.php b/lib/private/Search/Filter/DateTimeFilter.php index 48c1725a5e1..b4a70af8fe5 100644 --- a/lib/private/Search/Filter/DateTimeFilter.php +++ b/lib/private/Search/Filter/DateTimeFilter.php @@ -23,6 +23,7 @@ class DateTimeFilter implements IFilter { $this->value = new DateTimeImmutable($value); } + #[\Override] public function get(): DateTimeImmutable { return $this->value; } diff --git a/lib/private/Search/Filter/FloatFilter.php b/lib/private/Search/Filter/FloatFilter.php index f2384552943..db221725427 100644 --- a/lib/private/Search/Filter/FloatFilter.php +++ b/lib/private/Search/Filter/FloatFilter.php @@ -22,6 +22,7 @@ class FloatFilter implements IFilter { } } + #[\Override] public function get(): float { return $this->value; } diff --git a/lib/private/Search/Filter/GroupFilter.php b/lib/private/Search/Filter/GroupFilter.php index fe0b2ce42d8..ee742290898 100644 --- a/lib/private/Search/Filter/GroupFilter.php +++ b/lib/private/Search/Filter/GroupFilter.php @@ -28,6 +28,7 @@ class GroupFilter implements IFilter { $this->group = $group; } + #[\Override] public function get(): IGroup { return $this->group; } diff --git a/lib/private/Search/Filter/IntegerFilter.php b/lib/private/Search/Filter/IntegerFilter.php index 028b7d0678f..24e91c2501b 100644 --- a/lib/private/Search/Filter/IntegerFilter.php +++ b/lib/private/Search/Filter/IntegerFilter.php @@ -22,6 +22,7 @@ class IntegerFilter implements IFilter { } } + #[\Override] public function get(): int { return $this->value; } diff --git a/lib/private/Search/Filter/StringFilter.php b/lib/private/Search/Filter/StringFilter.php index 6944a7803f3..309d4f6c699 100644 --- a/lib/private/Search/Filter/StringFilter.php +++ b/lib/private/Search/Filter/StringFilter.php @@ -21,6 +21,7 @@ class StringFilter implements IFilter { } } + #[\Override] public function get(): string { return $this->value; } diff --git a/lib/private/Search/Filter/StringsFilter.php b/lib/private/Search/Filter/StringsFilter.php index 8b8fabb5347..c393442e1f6 100644 --- a/lib/private/Search/Filter/StringsFilter.php +++ b/lib/private/Search/Filter/StringsFilter.php @@ -28,6 +28,7 @@ class StringsFilter implements IFilter { /** * @return string[] */ + #[\Override] public function get(): array { return $this->values; } diff --git a/lib/private/Search/Filter/UserFilter.php b/lib/private/Search/Filter/UserFilter.php index 4f2061a4ba6..52660e0dda1 100644 --- a/lib/private/Search/Filter/UserFilter.php +++ b/lib/private/Search/Filter/UserFilter.php @@ -28,6 +28,7 @@ class UserFilter implements IFilter { $this->user = $user; } + #[\Override] public function get(): IUser { return $this->user; } diff --git a/lib/private/Search/FilterCollection.php b/lib/private/Search/FilterCollection.php index 030564db7de..dfd02e7ef2e 100644 --- a/lib/private/Search/FilterCollection.php +++ b/lib/private/Search/FilterCollection.php @@ -27,20 +27,24 @@ class FilterCollection implements IFilterCollection { $this->filters = $filters; } + #[\Override] public function has(string $name): bool { return isset($this->filters[$name]); } + #[\Override] public function get(string $name): ?IFilter { return $this->filters[$name] ?? null; } + #[\Override] public function getIterator(): Generator { foreach ($this->filters as $k => $v) { yield $k => $v; } } + #[\Override] public function count(): int { return count($this->filters); } diff --git a/lib/private/Search/SearchQuery.php b/lib/private/Search/SearchQuery.php index 791edb7a0f7..4ed81bdebff 100644 --- a/lib/private/Search/SearchQuery.php +++ b/lib/private/Search/SearchQuery.php @@ -29,36 +29,44 @@ class SearchQuery implements ISearchQuery { ) { } + #[\Override] public function getTerm(): string { return $this->getFilter('term')?->get() ?? ''; } + #[\Override] public function getFilter(string $name): ?IFilter { return $this->filters->has($name) ? $this->filters->get($name) : null; } + #[\Override] public function getFilters(): IFilterCollection { return $this->filters; } + #[\Override] public function getSortOrder(): int { return $this->sortOrder; } + #[\Override] public function getLimit(): int { return $this->limit; } + #[\Override] public function getCursor(): int|string|null { return $this->cursor; } + #[\Override] public function getRoute(): string { return $this->route; } + #[\Override] public function getRouteParameters(): array { return $this->routeParameters; } diff --git a/lib/private/Security/Bruteforce/Backend/DatabaseBackend.php b/lib/private/Security/Bruteforce/Backend/DatabaseBackend.php index ddf31175c5e..49570685851 100644 --- a/lib/private/Security/Bruteforce/Backend/DatabaseBackend.php +++ b/lib/private/Security/Bruteforce/Backend/DatabaseBackend.php @@ -21,6 +21,7 @@ class DatabaseBackend implements IBackend { /** * {@inheritDoc} */ + #[\Override] public function getAttempts( string $ipSubnet, int $maxAgeTimestamp, @@ -52,6 +53,7 @@ class DatabaseBackend implements IBackend { /** * {@inheritDoc} */ + #[\Override] public function resetAttempts( string $ipSubnet, ?string $action = null, @@ -76,6 +78,7 @@ class DatabaseBackend implements IBackend { /** * {@inheritDoc} */ + #[\Override] public function registerAttempt( string $ip, string $ipSubnet, diff --git a/lib/private/Security/Bruteforce/Backend/MemoryCacheBackend.php b/lib/private/Security/Bruteforce/Backend/MemoryCacheBackend.php index 9a0723db47e..633f75d4e9d 100644 --- a/lib/private/Security/Bruteforce/Backend/MemoryCacheBackend.php +++ b/lib/private/Security/Bruteforce/Backend/MemoryCacheBackend.php @@ -51,6 +51,7 @@ class MemoryCacheBackend implements IBackend { /** * {@inheritDoc} */ + #[\Override] public function getAttempts( string $ipSubnet, int $maxAgeTimestamp, @@ -80,6 +81,7 @@ class MemoryCacheBackend implements IBackend { /** * {@inheritDoc} */ + #[\Override] public function resetAttempts( string $ipSubnet, ?string $action = null, @@ -116,6 +118,7 @@ class MemoryCacheBackend implements IBackend { /** * {@inheritDoc} */ + #[\Override] public function registerAttempt( string $ip, string $ipSubnet, diff --git a/lib/private/Security/Bruteforce/Capabilities.php b/lib/private/Security/Bruteforce/Capabilities.php index 581b4480a27..d2ddc0bf05b 100644 --- a/lib/private/Security/Bruteforce/Capabilities.php +++ b/lib/private/Security/Bruteforce/Capabilities.php @@ -23,6 +23,7 @@ class Capabilities implements IPublicCapability, IInitialStateExcludedCapability /** * @return array{bruteforce: array{delay: int, allow-listed: bool}} */ + #[\Override] public function getCapabilities(): array { return [ 'bruteforce' => [ diff --git a/lib/private/Security/Bruteforce/CleanupJob.php b/lib/private/Security/Bruteforce/CleanupJob.php index f07e4dbacbd..9033d4b775e 100644 --- a/lib/private/Security/Bruteforce/CleanupJob.php +++ b/lib/private/Security/Bruteforce/CleanupJob.php @@ -25,6 +25,7 @@ class CleanupJob extends TimedJob { $this->setTimeSensitivity(self::TIME_INSENSITIVE); } + #[\Override] protected function run($argument): void { // Delete all entries more than 48 hours old $time = $this->time->getTime() - (48 * 3600); diff --git a/lib/private/Security/Bruteforce/Throttler.php b/lib/private/Security/Bruteforce/Throttler.php index 574f6c80c3f..6c5ebdce084 100644 --- a/lib/private/Security/Bruteforce/Throttler.php +++ b/lib/private/Security/Bruteforce/Throttler.php @@ -46,6 +46,7 @@ class Throttler implements IThrottler { /** * {@inheritDoc} */ + #[\Override] public function registerAttempt(string $action, string $ip, array $metadata = []): void { @@ -82,6 +83,7 @@ class Throttler implements IThrottler { /** * Check if the IP is whitelisted */ + #[\Override] public function isBypassListed(string $ip): bool { return $this->allowList->isBypassListed($ip); } @@ -89,6 +91,7 @@ class Throttler implements IThrottler { /** * {@inheritDoc} */ + #[\Override] public function showBruteforceWarning(string $ip, string $action = ''): bool { $attempts = $this->getAttempts($ip, $action); // 4 failed attempts is the last delay below 5 seconds @@ -98,6 +101,7 @@ class Throttler implements IThrottler { /** * {@inheritDoc} */ + #[\Override] public function getAttempts(string $ip, string $action = '', float $maxAgeHours = 12): int { if ($maxAgeHours > 48) { $this->logger->error('Bruteforce has to use less than 48 hours'); @@ -125,6 +129,7 @@ class Throttler implements IThrottler { /** * {@inheritDoc} */ + #[\Override] public function getDelay(string $ip, string $action = ''): int { $attempts = $this->getAttempts($ip, $action); return $this->calculateDelay($attempts); @@ -154,6 +159,7 @@ class Throttler implements IThrottler { /** * {@inheritDoc} */ + #[\Override] public function resetDelay(string $ip, string $action, array $metadata): void { // No need to log if the bruteforce protection is disabled if (!$this->config->getSystemValueBool('auth.bruteforce.protection.enabled', true)) { @@ -177,6 +183,7 @@ class Throttler implements IThrottler { /** * {@inheritDoc} */ + #[\Override] public function resetDelayForIP(string $ip): void { // No need to log if the bruteforce protection is disabled if (!$this->config->getSystemValueBool('auth.bruteforce.protection.enabled', true)) { @@ -194,6 +201,7 @@ class Throttler implements IThrottler { /** * {@inheritDoc} */ + #[\Override] public function sleepDelay(string $ip, string $action = ''): int { $delay = $this->getDelay($ip, $action); if (!$this->config->getSystemValueBool('auth.bruteforce.protection.testing')) { @@ -205,6 +213,7 @@ class Throttler implements IThrottler { /** * {@inheritDoc} */ + #[\Override] public function sleepDelayOrThrowOnMax(string $ip, string $action = ''): int { $maxAttempts = $this->config->getSystemValueInt('auth.bruteforce.max-attempts', self::MAX_ATTEMPTS); $attempts = $this->getAttempts($ip, $action); diff --git a/lib/private/Security/CSP/ContentSecurityPolicyManager.php b/lib/private/Security/CSP/ContentSecurityPolicyManager.php index e9d6b2945a8..7804bca7741 100644 --- a/lib/private/Security/CSP/ContentSecurityPolicyManager.php +++ b/lib/private/Security/CSP/ContentSecurityPolicyManager.php @@ -25,6 +25,7 @@ class ContentSecurityPolicyManager implements IContentSecurityPolicyManager { } /** {@inheritdoc} */ + #[\Override] public function addDefaultPolicy(EmptyContentSecurityPolicy $policy): void { $this->policies[] = $policy; } diff --git a/lib/private/Security/Certificate.php b/lib/private/Security/Certificate.php index 81c2b9461a3..31015a1d6bd 100644 --- a/lib/private/Security/Certificate.php +++ b/lib/private/Security/Certificate.php @@ -63,35 +63,43 @@ class Certificate implements ICertificate { $this->issuerOrganization = $info['issuer']['O'] ?? null; } + #[\Override] public function getName(): string { return $this->name; } + #[\Override] public function getCommonName(): ?string { return $this->commonName; } + #[\Override] public function getOrganization(): ?string { return $this->organization; } + #[\Override] public function getIssueDate(): \DateTime { return $this->issueDate; } + #[\Override] public function getExpireDate(): \DateTime { return $this->expireDate; } + #[\Override] public function isExpired(): bool { $now = new \DateTime(); return $this->issueDate > $now || $now > $this->expireDate; } + #[\Override] public function getIssuerName(): ?string { return $this->issuerName; } + #[\Override] public function getIssuerOrganization(): ?string { return $this->issuerOrganization; } diff --git a/lib/private/Security/CertificateManager.php b/lib/private/Security/CertificateManager.php index 5dfeed1c07a..fb0e3d5fffa 100644 --- a/lib/private/Security/CertificateManager.php +++ b/lib/private/Security/CertificateManager.php @@ -34,6 +34,7 @@ class CertificateManager implements ICertificateManager { * * @return ICertificate[] */ + #[\Override] public function listCertificates(): array { if (!$this->config->getSystemValueBool('installed', false)) { return []; @@ -148,6 +149,7 @@ class CertificateManager implements ICertificateManager { * @param string $name the filename for the certificate * @throws \Exception If the certificate could not get added */ + #[\Override] public function addCertificate(string $certificate, string $name): ICertificate { $path = $this->getPathToCertificates() . 'uploads/' . $name; $directory = dirname($path); @@ -172,6 +174,7 @@ class CertificateManager implements ICertificateManager { /** * Remove the certificate and re-generate the certificate bundle */ + #[\Override] public function removeCertificate(string $name): bool { $path = $this->getPathToCertificates() . 'uploads/' . $name; @@ -192,6 +195,7 @@ class CertificateManager implements ICertificateManager { /** * Get the path to the certificate bundle */ + #[\Override] public function getCertificateBundle(): string { return $this->getPathToCertificates() . 'rootcerts.crt'; } @@ -200,6 +204,7 @@ class CertificateManager implements ICertificateManager { * Get the full local path to the certificate bundle * @throws \Exception when getting bundle path fails */ + #[\Override] public function getAbsoluteBundlePath(): string { try { if ($this->bundlePath === null) { @@ -249,6 +254,7 @@ class CertificateManager implements ICertificateManager { return filemtime($this->getDefaultCertificatesBundlePath()); } + #[\Override] public function getDefaultCertificatesBundlePath(): string { return $this->config->getSystemValueString('default_certificates_bundle_path', \OC::$SERVERROOT . '/resources/config/ca-bundle.crt'); } diff --git a/lib/private/Security/CredentialsManager.php b/lib/private/Security/CredentialsManager.php index 254984261d2..202cde52397 100644 --- a/lib/private/Security/CredentialsManager.php +++ b/lib/private/Security/CredentialsManager.php @@ -32,6 +32,7 @@ class CredentialsManager implements ICredentialsManager { * @param string $userId empty string for system-wide credentials * @param mixed $credentials */ + #[\Override] public function store(string $userId, string $identifier, $credentials): void { $value = $this->crypto->encrypt(json_encode($credentials)); @@ -48,6 +49,7 @@ class CredentialsManager implements ICredentialsManager { * * @param string $userId empty string for system-wide credentials */ + #[\Override] public function retrieve(string $userId, string $identifier): mixed { $qb = $this->dbConnection->getQueryBuilder(); $qb->select('credentials') @@ -78,6 +80,7 @@ class CredentialsManager implements ICredentialsManager { * @param string $userId empty string for system-wide credentials * @return int rows removed */ + #[\Override] public function delete(string $userId, string $identifier): int { $qb = $this->dbConnection->getQueryBuilder(); $qb->delete(self::DB_TABLE) @@ -97,6 +100,7 @@ class CredentialsManager implements ICredentialsManager { * * @return int rows removed */ + #[\Override] public function erase(string $userId): int { $qb = $this->dbConnection->getQueryBuilder(); $qb->delete(self::DB_TABLE) diff --git a/lib/private/Security/Crypto.php b/lib/private/Security/Crypto.php index 7bbeec9e291..594b769e8f3 100644 --- a/lib/private/Security/Crypto.php +++ b/lib/private/Security/Crypto.php @@ -39,6 +39,7 @@ class Crypto implements ICrypto { * @param string $password Password to use (defaults to `secret` in config.php) * @return string Calculated HMAC */ + #[\Override] public function calculateHMAC(string $message, string $password = ''): string { if ($password === '') { $password = $this->config->getSystemValueString('secret'); @@ -60,6 +61,7 @@ class Crypto implements ICrypto { * @throws Exception if it was not possible to gather sufficient entropy * @throws Exception if encrypting the data failed */ + #[\Override] public function encrypt(string $plaintext, string $password = ''): string { if ($password === '') { $password = $this->config->getSystemValueString('secret'); @@ -89,6 +91,7 @@ class Crypto implements ICrypto { * @throws Exception If the HMAC does not match * @throws Exception If the decryption failed */ + #[\Override] public function decrypt(string $authenticatedCiphertext, string $password = ''): string { $secret = $this->config->getSystemValue('secret'); try { diff --git a/lib/private/Security/Hasher.php b/lib/private/Security/Hasher.php index 722fdab902f..d962d4bef19 100644 --- a/lib/private/Security/Hasher.php +++ b/lib/private/Security/Hasher.php @@ -62,6 +62,7 @@ class Hasher implements IHasher { * @param string $message Message to generate hash from * @return string Hash of the message with appended version parameter */ + #[\Override] public function hash(string $message): string { $alg = $this->getPrefferedAlgorithm(); @@ -150,6 +151,7 @@ class Hasher implements IHasher { * @param null|string &$newHash Reference will contain the updated hash if necessary. Update the existing hash with this one. * @return bool Whether $hash is a valid hash of $message */ + #[\Override] public function verify(string $message, string $hash, &$newHash = null): bool { $splittedHash = $this->splitHash($hash); @@ -191,6 +193,7 @@ class Hasher implements IHasher { return $default; } + #[\Override] public function validate(string $prefixedHash): bool { $splitHash = $this->splitHash($prefixedHash); if (empty($splitHash)) { diff --git a/lib/private/Security/Ip/Address.php b/lib/private/Security/Ip/Address.php index 0e94ec2d9ea..122d511a4f2 100644 --- a/lib/private/Security/Ip/Address.php +++ b/lib/private/Security/Ip/Address.php @@ -29,10 +29,12 @@ class Address implements IAddress { $this->ip = $ip; } + #[\Override] public static function isValid(string $ip): bool { return Factory::parseAddressString($ip, ParseStringFlag::MAY_INCLUDE_ZONEID) !== null; } + #[\Override] public function matches(IRange ... $ranges): bool { foreach ($ranges as $range) { if ($range->contains($this)) { diff --git a/lib/private/Security/Ip/Factory.php b/lib/private/Security/Ip/Factory.php index 1eedcf27a09..6014ade61db 100644 --- a/lib/private/Security/Ip/Factory.php +++ b/lib/private/Security/Ip/Factory.php @@ -13,10 +13,12 @@ use OCP\Security\Ip\IFactory; use OCP\Security\Ip\IRange; class Factory implements IFactory { + #[\Override] public function rangeFromString(string $range): IRange { return new Range($range); } + #[\Override] public function addressFromString(string $ip): IAddress { return new Address($ip); } diff --git a/lib/private/Security/Ip/Range.php b/lib/private/Security/Ip/Range.php index e32b7a5abc0..a8baffeef1c 100644 --- a/lib/private/Security/Ip/Range.php +++ b/lib/private/Security/Ip/Range.php @@ -26,10 +26,12 @@ class Range implements IRange { $this->range = $range; } + #[\Override] public static function isValid(string $range): bool { return Factory::parseRangeString($range) !== null; } + #[\Override] public function contains(IAddress $address): bool { return $this->range->contains(Factory::parseAddressString((string)$address, ParseStringFlag::MAY_INCLUDE_ZONEID)); } diff --git a/lib/private/Security/Ip/RemoteAddress.php b/lib/private/Security/Ip/RemoteAddress.php index 4eef8813898..62ca08e7860 100644 --- a/lib/private/Security/Ip/RemoteAddress.php +++ b/lib/private/Security/Ip/RemoteAddress.php @@ -30,16 +30,19 @@ class RemoteAddress implements IRemoteAddress, IAddress { : new Address($remoteAddress); } + #[\Override] public static function isValid(string $ip): bool { return Address::isValid($ip); } + #[\Override] public function matches(IRange ... $ranges): bool { return $this->ip === null ? true : $this->ip->matches(... $ranges); } + #[\Override] public function allowsAdminActions(): bool { if ($this->ip === null) { return true; diff --git a/lib/private/Security/RateLimiting/Backend/DatabaseBackend.php b/lib/private/Security/RateLimiting/Backend/DatabaseBackend.php index 9fb237f2f72..16b51ae264a 100644 --- a/lib/private/Security/RateLimiting/Backend/DatabaseBackend.php +++ b/lib/private/Security/RateLimiting/Backend/DatabaseBackend.php @@ -63,6 +63,7 @@ class DatabaseBackend implements IBackend { /** * {@inheritDoc} */ + #[\Override] public function getAttempts( string $methodIdentifier, string $userIdentifier, @@ -74,6 +75,7 @@ class DatabaseBackend implements IBackend { /** * {@inheritDoc} */ + #[\Override] public function registerAttempt( string $methodIdentifier, string $userIdentifier, diff --git a/lib/private/Security/RateLimiting/Backend/MemoryCacheBackend.php b/lib/private/Security/RateLimiting/Backend/MemoryCacheBackend.php index 4c33b49d05e..466c7efde05 100644 --- a/lib/private/Security/RateLimiting/Backend/MemoryCacheBackend.php +++ b/lib/private/Security/RateLimiting/Backend/MemoryCacheBackend.php @@ -54,6 +54,7 @@ class MemoryCacheBackend implements IBackend { /** * {@inheritDoc} */ + #[\Override] public function getAttempts( string $methodIdentifier, string $userIdentifier, @@ -75,6 +76,7 @@ class MemoryCacheBackend implements IBackend { /** * {@inheritDoc} */ + #[\Override] public function registerAttempt( string $methodIdentifier, string $userIdentifier, diff --git a/lib/private/Security/RateLimiting/Limiter.php b/lib/private/Security/RateLimiting/Limiter.php index 316becfa009..e14def14550 100644 --- a/lib/private/Security/RateLimiting/Limiter.php +++ b/lib/private/Security/RateLimiting/Limiter.php @@ -51,6 +51,7 @@ class Limiter implements ILimiter { * @param int $anonPeriod in seconds * @throws RateLimitExceededException */ + #[\Override] public function registerAnonRequest( string $identifier, int $anonLimit, @@ -69,6 +70,7 @@ class Limiter implements ILimiter { * @param int $userPeriod in seconds * @throws RateLimitExceededException */ + #[\Override] public function registerUserRequest( string $identifier, int $userLimit, diff --git a/lib/private/Security/RemoteHostValidator.php b/lib/private/Security/RemoteHostValidator.php index 30bd59db2c1..459bcb8d512 100644 --- a/lib/private/Security/RemoteHostValidator.php +++ b/lib/private/Security/RemoteHostValidator.php @@ -30,6 +30,7 @@ final class RemoteHostValidator implements IRemoteHostValidator { ) { } + #[\Override] public function isValid(string $host): bool { if ($this->config->getSystemValueBool('allow_local_remote_servers', false)) { return true; diff --git a/lib/private/Security/SecureRandom.php b/lib/private/Security/SecureRandom.php index b2a3d19ce74..ddb6b16655d 100644 --- a/lib/private/Security/SecureRandom.php +++ b/lib/private/Security/SecureRandom.php @@ -27,6 +27,7 @@ class SecureRandom implements ISecureRandom { * specified all valid base64 characters are used. * @throws \LengthException if an invalid length is requested */ + #[\Override] public function generate( int $length, string $characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/', diff --git a/lib/private/Security/Signature/Model/IncomingSignedRequest.php b/lib/private/Security/Signature/Model/IncomingSignedRequest.php index ab2c6f708a1..c5b5584475c 100644 --- a/lib/private/Security/Signature/Model/IncomingSignedRequest.php +++ b/lib/private/Security/Signature/Model/IncomingSignedRequest.php @@ -191,6 +191,7 @@ class IncomingSignedRequest extends SignedRequest implements * @return IRequest * @since 31.0.0 */ + #[\Override] public function getRequest(): IRequest { return $this->request; } @@ -213,6 +214,7 @@ class IncomingSignedRequest extends SignedRequest implements * @throws IncomingRequestException * @since 31.0.0 */ + #[\Override] public function getOrigin(): string { if ($this->origin === '') { throw new IncomingRequestException('empty origin'); @@ -228,6 +230,7 @@ class IncomingSignedRequest extends SignedRequest implements * @throws SignatureElementNotFoundException * @since 31.0.0 */ + #[\Override] public function getKeyId(): string { return $this->getSigningElement('keyId'); } @@ -239,6 +242,7 @@ class IncomingSignedRequest extends SignedRequest implements * @throws SignatoryNotFoundException * @since 31.0.0 */ + #[\Override] public function verify(): void { $publicKey = $this->getSignatory()->getPublicKey(); if ($publicKey === '') { @@ -256,6 +260,7 @@ class IncomingSignedRequest extends SignedRequest implements } } + #[\Override] public function jsonSerialize(): array { return array_merge( parent::jsonSerialize(), diff --git a/lib/private/Security/Signature/Model/OutgoingSignedRequest.php b/lib/private/Security/Signature/Model/OutgoingSignedRequest.php index 1cba76e45ce..0a87aa70895 100644 --- a/lib/private/Security/Signature/Model/OutgoingSignedRequest.php +++ b/lib/private/Security/Signature/Model/OutgoingSignedRequest.php @@ -75,6 +75,7 @@ class OutgoingSignedRequest extends SignedRequest implements * @return $this * @since 31.0.0 */ + #[\Override] public function setHost(string $host): self { $this->host = $host; return $this; @@ -86,6 +87,7 @@ class OutgoingSignedRequest extends SignedRequest implements * @return string * @since 31.0.0 */ + #[\Override] public function getHost(): string { return $this->host; } @@ -99,6 +101,7 @@ class OutgoingSignedRequest extends SignedRequest implements * @return self * @since 31.0.0 */ + #[\Override] public function addHeader(string $key, string|int|float $value): self { $this->headers[$key] = $value; return $this; @@ -110,6 +113,7 @@ class OutgoingSignedRequest extends SignedRequest implements * @return array * @since 31.0.0 */ + #[\Override] public function getHeaders(): array { return $this->headers; } @@ -122,6 +126,7 @@ class OutgoingSignedRequest extends SignedRequest implements * @return self * @since 31.0.0 */ + #[\Override] public function setHeaderList(array $list): self { $this->headerList = $list; return $this; @@ -133,6 +138,7 @@ class OutgoingSignedRequest extends SignedRequest implements * @return list * @since 31.0.0 */ + #[\Override] public function getHeaderList(): array { return $this->headerList; } @@ -145,6 +151,7 @@ class OutgoingSignedRequest extends SignedRequest implements * @return self * @since 31.0.0 */ + #[\Override] public function setAlgorithm(SignatureAlgorithm $algorithm): self { $this->algorithm = $algorithm; return $this; @@ -156,6 +163,7 @@ class OutgoingSignedRequest extends SignedRequest implements * @return SignatureAlgorithm * @since 31.0.0 */ + #[\Override] public function getAlgorithm(): SignatureAlgorithm { return $this->algorithm; } @@ -168,6 +176,7 @@ class OutgoingSignedRequest extends SignedRequest implements * @throws SignatoryNotFoundException * @since 31.0.0 */ + #[\Override] public function sign(): self { $privateKey = $this->getSignatory()->getPrivateKey(); if ($privateKey === '') { @@ -213,6 +222,7 @@ class OutgoingSignedRequest extends SignedRequest implements return base64_encode($signed); } + #[\Override] public function jsonSerialize(): array { return array_merge( parent::jsonSerialize(), diff --git a/lib/private/Security/Signature/Model/SignedRequest.php b/lib/private/Security/Signature/Model/SignedRequest.php index 7fe7149da2b..1b60a49cedc 100644 --- a/lib/private/Security/Signature/Model/SignedRequest.php +++ b/lib/private/Security/Signature/Model/SignedRequest.php @@ -39,6 +39,7 @@ class SignedRequest implements ISignedRequest, JsonSerializable { * @return string * @since 31.0.0 */ + #[\Override] public function getBody(): string { return $this->body; } @@ -62,6 +63,7 @@ class SignedRequest implements ISignedRequest, JsonSerializable { * @return DigestAlgorithm * @since 31.0.0 */ + #[\Override] public function getDigestAlgorithm(): DigestAlgorithm { return $this->digestAlgorithm; } @@ -72,6 +74,7 @@ class SignedRequest implements ISignedRequest, JsonSerializable { * @return string * @since 31.0.0 */ + #[\Override] public function getDigest(): string { if ($this->digest === '') { $this->digest = $this->digestAlgorithm->value . '=' @@ -88,6 +91,7 @@ class SignedRequest implements ISignedRequest, JsonSerializable { * @return self * @since 31.0.0 */ + #[\Override] public function setSigningElements(array $elements): self { $this->signingElements = $elements; return $this; @@ -99,6 +103,7 @@ class SignedRequest implements ISignedRequest, JsonSerializable { * @return array * @since 31.0.0 */ + #[\Override] public function getSigningElements(): array { return $this->signingElements; } @@ -111,6 +116,7 @@ class SignedRequest implements ISignedRequest, JsonSerializable { * @since 31.0.0 * */ + #[\Override] public function getSigningElement(string $key): string { // getSignatureDetail / getSignatureEntry() ? if (!array_key_exists($key, $this->signingElements)) { throw new SignatureElementNotFoundException('missing element ' . $key . ' in Signature header'); @@ -138,6 +144,7 @@ class SignedRequest implements ISignedRequest, JsonSerializable { * @return array * @since 31.0.0 */ + #[\Override] public function getSignatureData(): array { return $this->signatureData; } @@ -161,6 +168,7 @@ class SignedRequest implements ISignedRequest, JsonSerializable { * @return string * @since 31.0.0 */ + #[\Override] public function getSignature(): string { return $this->signature; } @@ -172,6 +180,7 @@ class SignedRequest implements ISignedRequest, JsonSerializable { * @return self * @since 31.0.0 */ + #[\Override] public function setSignatory(Signatory $signatory): self { $this->signatory = $signatory; return $this; @@ -184,6 +193,7 @@ class SignedRequest implements ISignedRequest, JsonSerializable { * @throws SignatoryNotFoundException * @since 31.0.0 */ + #[\Override] public function getSignatory(): Signatory { if ($this->signatory === null) { throw new SignatoryNotFoundException(); @@ -198,10 +208,12 @@ class SignedRequest implements ISignedRequest, JsonSerializable { * @return bool * @since 31.0.0 */ + #[\Override] public function hasSignatory(): bool { return ($this->signatory !== null); } + #[\Override] public function jsonSerialize(): array { return [ 'body' => $this->body, diff --git a/lib/private/Security/Signature/SignatureManager.php b/lib/private/Security/Signature/SignatureManager.php index 0c5bfdcc3ae..11aff48438d 100644 --- a/lib/private/Security/Signature/SignatureManager.php +++ b/lib/private/Security/Signature/SignatureManager.php @@ -90,6 +90,7 @@ class SignatureManager implements ISignatureManager { * @throws SignatureException if signature could not be confirmed * @since 31.0.0 */ + #[\Override] public function getIncomingSignedRequest( ISignatoryManager $signatoryManager, ?string $body = null, @@ -191,6 +192,7 @@ class SignatureManager implements ISignatureManager { * @throws SignatoryNotFoundException * @since 31.0.0 */ + #[\Override] public function getOutgoingSignedRequest( ISignatoryManager $signatoryManager, string $content, @@ -222,6 +224,7 @@ class SignatureManager implements ISignatureManager { * @return array new payload to be sent, including original payload and signature elements in headers * @since 31.0.0 */ + #[\Override] public function signOutgoingRequestIClientPayload( ISignatoryManager $signatoryManager, array $payload, @@ -245,6 +248,7 @@ class SignatureManager implements ISignatureManager { * @throws SignatoryNotFoundException if entry does not exist in local database * @since 31.0.0 */ + #[\Override] public function getSignatory(string $host, string $account = ''): Signatory { return $this->mapper->getByHost($host, $account); } @@ -261,6 +265,7 @@ class SignatureManager implements ISignatureManager { * @throws IdentityNotFoundException is identity is not set in app config * @since 31.0.0 */ + #[\Override] public function generateKeyIdFromConfig(string $path): string { if (!$this->appConfig->hasKey('core', self::APPCONFIG_IDENTITY, true)) { throw new IdentityNotFoundException(self::APPCONFIG_IDENTITY . ' not set'); @@ -280,6 +285,7 @@ class SignatureManager implements ISignatureManager { * @throws IdentityNotFoundException if identity cannot be extracted * @since 31.0.0 */ + #[\Override] public function extractIdentityFromUri(string $uri): string { return Signatory::extractIdentityFromUri($uri); } diff --git a/lib/private/Security/TrustedDomainHelper.php b/lib/private/Security/TrustedDomainHelper.php index a65779780e8..526c20be26f 100644 --- a/lib/private/Security/TrustedDomainHelper.php +++ b/lib/private/Security/TrustedDomainHelper.php @@ -36,6 +36,7 @@ class TrustedDomainHelper implements ITrustedDomainHelper { /** * {@inheritDoc} */ + #[\Override] public function isTrustedUrl(string $url): bool { $parsedUrl = parse_url($url); if (empty($parsedUrl['host'])) { @@ -52,6 +53,7 @@ class TrustedDomainHelper implements ITrustedDomainHelper { /** * {@inheritDoc} */ + #[\Override] public function isTrustedDomain(string $domainWithPort): bool { // overwritehost is always trusted if ($this->config->getSystemValue('overwritehost') !== '') { diff --git a/lib/private/Security/VerificationToken/CleanUpJob.php b/lib/private/Security/VerificationToken/CleanUpJob.php index ba8f4352f80..5b951da1398 100644 --- a/lib/private/Security/VerificationToken/CleanUpJob.php +++ b/lib/private/Security/VerificationToken/CleanUpJob.php @@ -30,6 +30,7 @@ class CleanUpJob extends Job { parent::__construct($time); } + #[\Override] public function setArgument($argument): void { parent::setArgument($argument); $args = \json_decode($argument, true); @@ -39,6 +40,7 @@ class CleanUpJob extends Job { $this->runNotBefore = (int)$args['notBefore']; } + #[\Override] protected function run($argument): void { try { $user = $this->userManager->get($this->userId); @@ -54,6 +56,7 @@ class CleanUpJob extends Job { } } + #[\Override] public function start(IJobList $jobList): void { if ($this->time->getTime() >= $this->runNotBefore) { $jobList->remove($this, $this->argument); diff --git a/lib/private/Security/VerificationToken/VerificationToken.php b/lib/private/Security/VerificationToken/VerificationToken.php index 89f45180359..602b06390aa 100644 --- a/lib/private/Security/VerificationToken/VerificationToken.php +++ b/lib/private/Security/VerificationToken/VerificationToken.php @@ -36,6 +36,7 @@ class VerificationToken implements IVerificationToken { throw new InvalidTokenException($code); } + #[\Override] public function check( string $token, ?IUser $user, @@ -78,6 +79,7 @@ class VerificationToken implements IVerificationToken { } } + #[\Override] public function create( IUser $user, string $subject, @@ -103,6 +105,7 @@ class VerificationToken implements IVerificationToken { return $token; } + #[\Override] public function delete(string $token, IUser $user, string $subject): void { $this->config->deleteUserValue($user->getUID(), 'core', $subject); } diff --git a/lib/private/Server.php b/lib/private/Server.php index e24d47f3f06..2a33c18eb05 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -1355,6 +1355,7 @@ class Server extends ServerContainer implements IServerContainer { * @return Folder|null * @deprecated 20.0.0 */ + #[\Override] public function getUserFolder($userId = null): ?Folder { if ($userId === null) { $user = $this->get(IUserSession::class)->getUser(); @@ -1379,6 +1380,7 @@ class Server extends ServerContainer implements IServerContainer { * @return string * @deprecated 20.0.0 */ + #[\Override] public function getWebRoot(): string { return $this->webRoot; } @@ -1391,6 +1393,7 @@ class Server extends ServerContainer implements IServerContainer { * @return IL10N * @deprecated 20.0.0 use DI of {@see IL10N} or {@see IFactory} instead, or {@see \OCP\Util::getL10N()} as a last resort */ + #[\Override] public function getL10N($app, $lang = null) { return $this->get(IFactory::class)->get($app, $lang); } diff --git a/lib/private/ServerContainer.php b/lib/private/ServerContainer.php index c06c2c46acf..d6b5681dd9f 100644 --- a/lib/private/ServerContainer.php +++ b/lib/private/ServerContainer.php @@ -100,6 +100,7 @@ class ServerContainer extends SimpleContainer { throw new QueryException(); } + #[\Override] public function has($id, bool $noRecursion = false): bool { if (!$noRecursion && ($appContainer = $this->getAppContainerForService($id)) !== null) { return $appContainer->has($id); @@ -119,6 +120,7 @@ class ServerContainer extends SimpleContainer { * @throws QueryException * @deprecated 20.0.0 use \Psr\Container\ContainerInterface::get */ + #[\Override] public function query(string $name, bool $autoload = true, array $chain = []): mixed { $name = $this->sanitizeName($name); diff --git a/lib/private/Session/CryptoSessionData.php b/lib/private/Session/CryptoSessionData.php index 67199aa2337..bd9d35c18f7 100644 --- a/lib/private/Session/CryptoSessionData.php +++ b/lib/private/Session/CryptoSessionData.php @@ -83,6 +83,7 @@ class CryptoSessionData implements \ArrayAccess, ISession { * @param string $key * @param mixed $value */ + #[\Override] public function set(string $key, $value) { if ($this->get($key) === $value) { // Do not write the session if the value hasn't changed to avoid reopening @@ -103,6 +104,7 @@ class CryptoSessionData implements \ArrayAccess, ISession { * @param string $key * @return string|null Either the value or null */ + #[\Override] public function get(string $key) { if (isset($this->sessionValues[$key])) { return $this->sessionValues[$key]; @@ -117,6 +119,7 @@ class CryptoSessionData implements \ArrayAccess, ISession { * @param string $key * @return bool */ + #[\Override] public function exists(string $key): bool { return isset($this->sessionValues[$key]); } @@ -126,6 +129,7 @@ class CryptoSessionData implements \ArrayAccess, ISession { * * @param string $key */ + #[\Override] public function remove(string $key) { $reopened = $this->reopen(); $this->isModified = true; @@ -138,6 +142,7 @@ class CryptoSessionData implements \ArrayAccess, ISession { /** * Reset and recreate the session */ + #[\Override] public function clear() { $reopened = $this->reopen(); $requesttoken = $this->get('requesttoken'); @@ -152,6 +157,7 @@ class CryptoSessionData implements \ArrayAccess, ISession { } } + #[\Override] public function reopen(): bool { $reopened = $this->session->reopen(); if ($reopened) { @@ -167,6 +173,7 @@ class CryptoSessionData implements \ArrayAccess, ISession { * @param bool $updateToken Wheater to update the associated auth token * @return void */ + #[\Override] public function regenerateId(bool $deleteOldSession = true, bool $updateToken = false) { $this->session->regenerateId($deleteOldSession, $updateToken); } @@ -178,6 +185,7 @@ class CryptoSessionData implements \ArrayAccess, ISession { * @throws SessionNotAvailableException * @since 9.1.0 */ + #[\Override] public function getId(): string { return $this->session->getId(); } @@ -185,6 +193,7 @@ class CryptoSessionData implements \ArrayAccess, ISession { /** * Close the session and release the lock, also writes all changed data in batch */ + #[\Override] public function close() { if ($this->isModified) { $encryptedValue = $this->crypto->encrypt(json_encode($this->sessionValues), $this->passphrase); @@ -198,6 +207,7 @@ class CryptoSessionData implements \ArrayAccess, ISession { * @param mixed $offset * @return bool */ + #[\Override] public function offsetExists($offset): bool { return $this->exists($offset); } @@ -206,6 +216,7 @@ class CryptoSessionData implements \ArrayAccess, ISession { * @param mixed $offset * @return mixed */ + #[\Override] #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->get($offset); @@ -215,6 +226,7 @@ class CryptoSessionData implements \ArrayAccess, ISession { * @param mixed $offset * @param mixed $value */ + #[\Override] public function offsetSet($offset, $value): void { $this->set($offset, $value); } @@ -222,6 +234,7 @@ class CryptoSessionData implements \ArrayAccess, ISession { /** * @param mixed $offset */ + #[\Override] public function offsetUnset($offset): void { $this->remove($offset); } diff --git a/lib/private/Session/Internal.php b/lib/private/Session/Internal.php index d07174fad14..953544e374c 100644 --- a/lib/private/Session/Internal.php +++ b/lib/private/Session/Internal.php @@ -55,6 +55,7 @@ class Internal extends Session { * @param string $key * @param integer $value */ + #[\Override] public function set(string $key, $value) { $reopened = $this->reopen(); $_SESSION[$key] = $value; @@ -67,6 +68,7 @@ class Internal extends Session { * @param string $key * @return mixed */ + #[\Override] public function get(string $key) { if (!$this->exists($key)) { return null; @@ -78,6 +80,7 @@ class Internal extends Session { * @param string $key * @return bool */ + #[\Override] public function exists(string $key): bool { return isset($_SESSION[$key]); } @@ -85,12 +88,14 @@ class Internal extends Session { /** * @param string $key */ + #[\Override] public function remove(string $key) { if (isset($_SESSION[$key])) { unset($_SESSION[$key]); } } + #[\Override] public function clear() { $this->reopen(); $this->invoke('session_unset'); @@ -100,6 +105,7 @@ class Internal extends Session { $_SESSION = []; } + #[\Override] public function close() { $this->invoke('session_write_close'); parent::close(); @@ -112,6 +118,7 @@ class Internal extends Session { * @param bool $updateToken Whether to update the associated auth token * @return void */ + #[\Override] public function regenerateId(bool $deleteOldSession = true, bool $updateToken = false) { $this->reopen(); $oldId = null; @@ -154,6 +161,7 @@ class Internal extends Session { * @throws SessionNotAvailableException * @since 9.1.0 */ + #[\Override] public function getId(): string { $id = $this->invoke('session_id', [], true); if ($id === '') { @@ -165,6 +173,7 @@ class Internal extends Session { /** * @throws \Exception */ + #[\Override] public function reopen(): bool { if ($this->sessionClosed) { $this->startSession(false, false); diff --git a/lib/private/Session/Memory.php b/lib/private/Session/Memory.php index 395711836f5..e73a8c3fa31 100644 --- a/lib/private/Session/Memory.php +++ b/lib/private/Session/Memory.php @@ -24,6 +24,7 @@ class Memory extends Session { * @param string $key * @param integer $value */ + #[\Override] public function set(string $key, $value) { $this->data[$key] = $value; } @@ -32,6 +33,7 @@ class Memory extends Session { * @param string $key * @return mixed */ + #[\Override] public function get(string $key) { if (!$this->exists($key)) { return null; @@ -43,6 +45,7 @@ class Memory extends Session { * @param string $key * @return bool */ + #[\Override] public function exists(string $key): bool { return isset($this->data[$key]); } @@ -50,10 +53,12 @@ class Memory extends Session { /** * @param string $key */ + #[\Override] public function remove(string $key) { unset($this->data[$key]); } + #[\Override] public function clear() { $this->data = []; } @@ -63,6 +68,7 @@ class Memory extends Session { * * @param bool $deleteOldSession */ + #[\Override] public function regenerateId(bool $deleteOldSession = true, bool $updateToken = false) { } @@ -73,6 +79,7 @@ class Memory extends Session { * @throws SessionNotAvailableException * @since 9.1.0 */ + #[\Override] public function getId(): string { throw new SessionNotAvailableException('Memory session does not have an ID'); } @@ -80,6 +87,7 @@ class Memory extends Session { /** * Helper function for PHPUnit execution - don't use in non-test code */ + #[\Override] public function reopen(): bool { $reopened = $this->sessionClosed; $this->sessionClosed = false; diff --git a/lib/private/Session/Session.php b/lib/private/Session/Session.php index b7510b63683..08465ba3b08 100644 --- a/lib/private/Session/Session.php +++ b/lib/private/Session/Session.php @@ -23,6 +23,7 @@ abstract class Session implements \ArrayAccess, ISession { * @param mixed $offset * @return bool */ + #[\Override] public function offsetExists($offset): bool { return $this->exists($offset); } @@ -31,6 +32,7 @@ abstract class Session implements \ArrayAccess, ISession { * @param mixed $offset * @return mixed */ + #[\Override] #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->get($offset); @@ -40,6 +42,7 @@ abstract class Session implements \ArrayAccess, ISession { * @param mixed $offset * @param mixed $value */ + #[\Override] public function offsetSet($offset, $value): void { $this->set($offset, $value); } @@ -47,6 +50,7 @@ abstract class Session implements \ArrayAccess, ISession { /** * @param mixed $offset */ + #[\Override] public function offsetUnset($offset): void { $this->remove($offset); } @@ -54,6 +58,7 @@ abstract class Session implements \ArrayAccess, ISession { /** * Close the session and release the lock */ + #[\Override] public function close() { $this->sessionClosed = true; } diff --git a/lib/private/Settings/AuthorizedGroup.php b/lib/private/Settings/AuthorizedGroup.php index 4ad9b228b5c..75befbc02cd 100644 --- a/lib/private/Settings/AuthorizedGroup.php +++ b/lib/private/Settings/AuthorizedGroup.php @@ -27,6 +27,7 @@ class AuthorizedGroup extends Entity implements JsonSerializable { /** * @return array */ + #[\Override] public function jsonSerialize(): array { return [ 'id' => $this->getId(), diff --git a/lib/private/Settings/DeclarativeManager.php b/lib/private/Settings/DeclarativeManager.php index 534b4b19984..10419913a16 100644 --- a/lib/private/Settings/DeclarativeManager.php +++ b/lib/private/Settings/DeclarativeManager.php @@ -57,6 +57,7 @@ class DeclarativeManager implements IDeclarativeManager { /** * @inheritdoc */ + #[\Override] public function registerSchema(string $app, array $schema): void { $this->appSchemas[$app] ??= []; @@ -83,6 +84,7 @@ class DeclarativeManager implements IDeclarativeManager { /** * @inheritdoc */ + #[\Override] public function loadSchemas(): void { if (empty($this->declarativeForms)) { $declarativeSettings = $this->coordinator->getRegistrationContext()->getDeclarativeSettings(); @@ -101,6 +103,7 @@ class DeclarativeManager implements IDeclarativeManager { /** * @inheritdoc */ + #[\Override] public function getFormIDs(IUser $user, string $type, string $section): array { $isAdmin = $this->groupManager->isAdmin($user->getUID()); /** @var array> $formIds */ @@ -130,6 +133,7 @@ class DeclarativeManager implements IDeclarativeManager { * @inheritdoc * @throws Exception */ + #[\Override] public function getFormsWithValues(IUser $user, ?string $type, ?string $section): array { $isAdmin = $this->groupManager->isAdmin($user->getUID()); $forms = []; @@ -252,6 +256,7 @@ class DeclarativeManager implements IDeclarativeManager { /** * @inheritdoc */ + #[\Override] public function setValue(IUser $user, string $app, string $formId, string $fieldId, mixed $value): void { $sectionType = $this->getSectionType($app, $fieldId); $this->assertAuthorized($user, $sectionType); diff --git a/lib/private/Settings/Manager.php b/lib/private/Settings/Manager.php index 7b4dd9fcc9b..129be0f66a3 100644 --- a/lib/private/Settings/Manager.php +++ b/lib/private/Settings/Manager.php @@ -52,6 +52,7 @@ class Manager implements IManager { /** * @inheritdoc */ + #[\Override] public function registerSection(string $type, string $section) { if (!isset($this->sectionClasses[$type])) { $this->sectionClasses[$type] = []; @@ -102,6 +103,7 @@ class Manager implements IManager { /** * @inheritdoc */ + #[\Override] public function getSection(string $type, string $sectionId): ?IIconSection { if (isset($this->sections[$type]) && isset($this->sections[$type][$sectionId])) { return $this->sections[$type][$sectionId]; @@ -119,6 +121,7 @@ class Manager implements IManager { /** * @inheritdoc */ + #[\Override] public function registerSetting(string $type, string $setting) { $this->settingClasses[$setting] = $type; } @@ -179,6 +182,7 @@ class Manager implements IManager { /** * @inheritdoc */ + #[\Override] public function getAdminSections(): array { // built-in sections $sections = []; @@ -202,6 +206,7 @@ class Manager implements IManager { /** * @inheritdoc */ + #[\Override] public function getAdminSettings(string $section, bool $subAdminOnly = false): array { if ($subAdminOnly) { $subAdminSettingsFilter = function (ISettings $settings) { @@ -227,6 +232,7 @@ class Manager implements IManager { /** * @inheritdoc */ + #[\Override] public function getPersonalSections(): array { if ($this->l === null) { $this->l = $this->l10nFactory->get('lib'); @@ -257,6 +263,7 @@ class Manager implements IManager { /** * @inheritdoc */ + #[\Override] public function getPersonalSettings(string $section): array { $settings = []; $appSettings = $this->getSettings('personal', $section); @@ -275,6 +282,7 @@ class Manager implements IManager { /** * @inheritdoc */ + #[\Override] public function getAllowedAdminSettings(string $section, IUser $user): array { $isAdmin = $this->groupManager->isAdmin($user->getUID()); if ($isAdmin) { @@ -309,6 +317,7 @@ class Manager implements IManager { /** * @inheritdoc */ + #[\Override] public function getAllAllowedAdminSettings(IUser $user): array { $this->getSettings('admin', ''); // Make sure all the settings are loaded $settings = []; @@ -326,6 +335,7 @@ class Manager implements IManager { /** * @return array}> */ + #[\Override] public function getAdminDelegatedSettings(): array { $sections = $this->getAdminSections(); $settings = []; diff --git a/lib/private/Setup/MySQL.php b/lib/private/Setup/MySQL.php index 9de18d75a51..e2923578d3d 100644 --- a/lib/private/Setup/MySQL.php +++ b/lib/private/Setup/MySQL.php @@ -17,6 +17,7 @@ use OCP\IDBConnection; class MySQL extends AbstractDatabase { public string $dbprettyname = 'MySQL/MariaDB'; + #[\Override] public function setupDatabase(): void { //check if the database user has admin right $connection = $this->connect(['dbname' => null]); diff --git a/lib/private/Setup/OCI.php b/lib/private/Setup/OCI.php index 7bde42c1ace..5e343b754f1 100644 --- a/lib/private/Setup/OCI.php +++ b/lib/private/Setup/OCI.php @@ -14,6 +14,7 @@ class OCI extends AbstractDatabase { protected $dbtablespace; + #[\Override] public function initialize(array $config): void { parent::initialize($config); if (array_key_exists('dbtablespace', $config)) { @@ -30,6 +31,7 @@ class OCI extends AbstractDatabase { ]); } + #[\Override] public function validate(array $config): array { $errors = []; if (empty($config['dbuser']) && empty($config['dbname'])) { @@ -42,6 +44,7 @@ class OCI extends AbstractDatabase { return $errors; } + #[\Override] public function setupDatabase(): void { try { $this->connect(); diff --git a/lib/private/Setup/PostgreSQL.php b/lib/private/Setup/PostgreSQL.php index 189a6a969a4..687d9b2c7d7 100644 --- a/lib/private/Setup/PostgreSQL.php +++ b/lib/private/Setup/PostgreSQL.php @@ -18,6 +18,7 @@ class PostgreSQL extends AbstractDatabase { /** * @throws DatabaseSetupException */ + #[\Override] public function setupDatabase(): void { try { $connection = $this->connect([ diff --git a/lib/private/Setup/Sqlite.php b/lib/private/Setup/Sqlite.php index 325a26ce896..cbbcf18d259 100644 --- a/lib/private/Setup/Sqlite.php +++ b/lib/private/Setup/Sqlite.php @@ -12,10 +12,12 @@ use OC\DB\ConnectionFactory; class Sqlite extends AbstractDatabase { public string $dbprettyname = 'Sqlite'; + #[\Override] public function validate(array $config): array { return []; } + #[\Override] public function initialize(array $config): void { /* * Web: When using web based installer its not possible to set dbname @@ -45,6 +47,7 @@ class Sqlite extends AbstractDatabase { } } + #[\Override] public function setupDatabase(): void { $datadir = $this->config->getValue( 'datadirectory', diff --git a/lib/private/SetupCheck/SetupCheckManager.php b/lib/private/SetupCheck/SetupCheckManager.php index 721885848e2..ee5c2a8c617 100644 --- a/lib/private/SetupCheck/SetupCheckManager.php +++ b/lib/private/SetupCheck/SetupCheckManager.php @@ -23,6 +23,7 @@ class SetupCheckManager implements ISetupCheckManager { ) { } + #[\Override] public function runAll(): array { $results = []; $setupChecks = $this->coordinator->getRegistrationContext()->getSetupChecks(); diff --git a/lib/private/Share20/DefaultShareProvider.php b/lib/private/Share20/DefaultShareProvider.php index 4c824b2aa55..da0e179fe28 100644 --- a/lib/private/Share20/DefaultShareProvider.php +++ b/lib/private/Share20/DefaultShareProvider.php @@ -81,6 +81,7 @@ class DefaultShareProvider implements * * @return string Containing only [a-zA-Z0-9] */ + #[\Override] public function identifier() { return 'ocinternal'; } @@ -93,6 +94,7 @@ class DefaultShareProvider implements * @throws ShareNotFound * @throws \Exception */ + #[\Override] public function create(IShare $share) { $qb = $this->dbConn->getQueryBuilder(); @@ -212,6 +214,7 @@ class DefaultShareProvider implements * @throws InvalidPathException * @throws NotFoundException */ + #[\Override] public function update(IShare $share) { $originalShare = $this->getShareById($share->getId()); @@ -317,6 +320,7 @@ class DefaultShareProvider implements * @return IShare The share object * @since 9.0.0 */ + #[\Override] public function acceptShare(IShare $share, string $recipient): IShare { if ($share->getShareType() === IShare::TYPE_GROUP) { $group = $this->groupManager->get($share->getSharedWith()); @@ -371,6 +375,7 @@ class DefaultShareProvider implements return $share; } + #[\Override] public function getChildren(IShare $parent): array { $children = []; @@ -405,6 +410,7 @@ class DefaultShareProvider implements * * @param IShare $share */ + #[\Override] public function delete(IShare $share) { $qb = $this->dbConn->getQueryBuilder(); $qb->delete('share') @@ -430,6 +436,7 @@ class DefaultShareProvider implements * @throws BackendError * @throws ProviderException */ + #[\Override] public function deleteFromSelf(IShare $share, $recipient) { if ($share->getShareType() === IShare::TYPE_GROUP) { $group = $this->groupManager->get($share->getSharedWith()); @@ -525,6 +532,7 @@ class DefaultShareProvider implements * For now this only works for group shares * If this gets implemented for normal shares we have to extend it */ + #[\Override] public function restore(IShare $share, string $recipient): IShare { $qb = $this->dbConn->getQueryBuilder(); $qb->select('permissions') @@ -557,6 +565,7 @@ class DefaultShareProvider implements /** * @inheritdoc */ + #[\Override] public function move(IShare $share, $recipient) { if ($share->getShareType() === IShare::TYPE_USER) { // Just update the target @@ -615,6 +624,7 @@ class DefaultShareProvider implements return $share; } + #[\Override] public function getSharesInFolder($userId, Folder $node, $reshares, $shallow = true) { if (!$shallow) { throw new \Exception('non-shallow getSharesInFolder is no longer supported'); @@ -623,6 +633,7 @@ class DefaultShareProvider implements return $this->getSharesInFolderInternal($userId, $node, $reshares); } + #[\Override] public function getAllSharesInFolder(Folder $node): array { return $this->getSharesInFolderInternal(null, $node, null); } @@ -699,6 +710,7 @@ class DefaultShareProvider implements /** * @inheritdoc */ + #[\Override] public function getSharesBy($userId, $shareType, $node, $reshares, $limit, $offset) { $qb = $this->dbConn->getQueryBuilder(); $qb->select('*') @@ -747,6 +759,7 @@ class DefaultShareProvider implements /** * @inheritdoc */ + #[\Override] public function getShareById($id, $recipientId = null) { $qb = $this->dbConn->getQueryBuilder(); @@ -793,6 +806,7 @@ class DefaultShareProvider implements * @param Node $path * @return IShare[] */ + #[\Override] public function getSharesByPath(Node $path) { $qb = $this->dbConn->getQueryBuilder(); @@ -838,10 +852,12 @@ class DefaultShareProvider implements return true; } + #[\Override] public function getSharedWith($userId, $shareType, $node, $limit, $offset) { return $this->_getSharedWith($userId, $shareType, $limit, $offset, $node); } + #[\Override] public function getSharedWithByPath( string $userId, int $shareType, @@ -1051,6 +1067,7 @@ class DefaultShareProvider implements * @return IShare * @throws ShareNotFound */ + #[\Override] public function getShareByToken($token) { $qb = $this->dbConn->getQueryBuilder(); @@ -1195,6 +1212,7 @@ class DefaultShareProvider implements * @param string $uid * @param int $shareType */ + #[\Override] public function userDeleted($uid, $shareType) { $qb = $this->dbConn->getQueryBuilder(); @@ -1260,6 +1278,7 @@ class DefaultShareProvider implements * * @param string $gid */ + #[\Override] public function groupDeleted($gid) { /* * First delete all custom group shares for group members @@ -1308,6 +1327,7 @@ class DefaultShareProvider implements * @param string $gid * @return void */ + #[\Override] public function userDeletedFromGroup($uid, $gid) { /* * Get all group shares @@ -1386,6 +1406,7 @@ class DefaultShareProvider implements /** * @inheritdoc */ + #[\Override] public function getAccessList($nodes, $currentAccess) { $ids = []; foreach ($nodes as $node) { @@ -1516,6 +1537,7 @@ class DefaultShareProvider implements } } + #[\Override] public function sendMailNotification(IShare $share): bool { try { // Check user @@ -1718,6 +1740,7 @@ class DefaultShareProvider implements } } + #[\Override] public function getAllShares(): iterable { $qb = $this->dbConn->getQueryBuilder(); @@ -1782,6 +1805,7 @@ class DefaultShareProvider implements return \json_encode($compressedAttributes); } + #[\Override] public function getUsersForShare(IShare $share): iterable { if ($share->getShareType() === IShare::TYPE_USER) { return [new LazyUser($share->getSharedWith(), $this->userManager)]; diff --git a/lib/private/Share20/GroupDeletedListener.php b/lib/private/Share20/GroupDeletedListener.php index 7e1ad71c465..e6370cd958f 100644 --- a/lib/private/Share20/GroupDeletedListener.php +++ b/lib/private/Share20/GroupDeletedListener.php @@ -22,6 +22,7 @@ class GroupDeletedListener implements IEventListener { ) { } + #[\Override] public function handle(Event $event): void { if (!$event instanceof GroupDeletedEvent) { return; diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index 707fbfd5b41..a2d45ee3147 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -1349,6 +1349,7 @@ class Manager implements IManager { /** * @inheritDoc */ + #[\Override] public function getSharedWithByPath(string $userId, int $shareType, string $path, bool $forChildren, int $limit = 50, int $offset = 0): iterable { try { $provider = $this->factory->getProviderForType($shareType); @@ -1842,6 +1843,7 @@ class Manager implements IManager { return $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_full_match_user_id', 'yes') === 'yes'; } + #[\Override] public function matchDisplayName(): bool { return $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_full_match_displayname', 'yes') === 'yes'; } @@ -1924,6 +1926,7 @@ class Manager implements IManager { return true; } + #[\Override] public function registerShareProvider(string $shareProviderClass): void { $this->factory->registerProvider($shareProviderClass); } @@ -1993,6 +1996,7 @@ class Manager implements IManager { } } + #[\Override] public function getUsersForShare(IShare $share): iterable { $provider = $this->factory->getProviderForType($share->getShareType()); if ($provider instanceof IShareProviderGetUsers) { diff --git a/lib/private/Share20/ProviderFactory.php b/lib/private/Share20/ProviderFactory.php index c84dd5f7f45..769dc7426c7 100644 --- a/lib/private/Share20/ProviderFactory.php +++ b/lib/private/Share20/ProviderFactory.php @@ -46,6 +46,7 @@ class ProviderFactory implements IProviderFactory { ) { } + #[\Override] public function registerProvider(string $shareProviderClass): void { $this->registeredShareProviders[] = $shareProviderClass; } @@ -128,6 +129,7 @@ class ProviderFactory implements IProviderFactory { /** * @inheritdoc */ + #[\Override] public function getProvider($id) { $provider = null; if (isset($this->shareProviders[$id])) { @@ -171,6 +173,7 @@ class ProviderFactory implements IProviderFactory { /** * @inheritdoc */ + #[\Override] public function getProviderForType($shareType) { $provider = null; @@ -199,6 +202,7 @@ class ProviderFactory implements IProviderFactory { return $provider; } + #[\Override] public function getAllProviders() { $shares = [$this->defaultShareProvider(), $this->federatedShareProvider()]; $shareByMail = $this->getShareByMailProvider(); diff --git a/lib/private/Share20/PublicShareTemplateFactory.php b/lib/private/Share20/PublicShareTemplateFactory.php index d1079cc9662..164a0b79a64 100644 --- a/lib/private/Share20/PublicShareTemplateFactory.php +++ b/lib/private/Share20/PublicShareTemplateFactory.php @@ -25,6 +25,7 @@ class PublicShareTemplateFactory implements IPublicShareTemplateFactory { ) { } + #[\Override] public function getProvider(IShare $share): IPublicShareTemplateProvider { $context = $this->coordinator->getRegistrationContext(); if ($context === null) { diff --git a/lib/private/Share20/Share.php b/lib/private/Share20/Share.php index 3dd57fb3565..2ededbc7c36 100644 --- a/lib/private/Share20/Share.php +++ b/lib/private/Share20/Share.php @@ -155,6 +155,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function setNodeId($fileId) { $this->node = null; $this->fileId = $fileId; @@ -164,6 +165,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function getNodeId(): int { if ($this->fileId === null) { $this->fileId = $this->getNode()->getId(); @@ -179,6 +181,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function setNodeType($type) { if ($type !== 'file' && $type !== 'folder') { throw new \InvalidArgumentException(); @@ -191,6 +194,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function getNodeType() { if ($this->nodeType === null) { if ($this->getNodeCacheEntry()) { @@ -208,6 +212,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function setShareType($shareType) { $this->shareType = $shareType; return $this; @@ -216,6 +221,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function getShareType() { return $this->shareType; } @@ -223,6 +229,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function setSharedWith($sharedWith) { if (!is_string($sharedWith)) { throw new \InvalidArgumentException(); @@ -234,6 +241,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function getSharedWith() { return $this->sharedWith; } @@ -241,6 +249,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function setSharedWithDisplayName($displayName) { if (!is_string($displayName)) { throw new \InvalidArgumentException(); @@ -252,6 +261,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function getSharedWithDisplayName() { return $this->sharedWithDisplayName; } @@ -259,6 +269,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function setSharedWithAvatar($src) { if (!is_string($src)) { throw new \InvalidArgumentException(); @@ -270,6 +281,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function getSharedWithAvatar() { return $this->sharedWithAvatar; } @@ -277,6 +289,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function setPermissions($permissions) { //TODO checks @@ -287,6 +300,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function getPermissions() { return $this->permissions; } @@ -294,6 +308,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function newAttributes(): IAttributes { return new ShareAttributes(); } @@ -301,6 +316,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function setAttributes(?IAttributes $attributes) { $this->attributes = $attributes; return $this; @@ -309,6 +325,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function getAttributes(): ?IAttributes { return $this->attributes; } @@ -316,6 +333,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function setStatus(int $status): IShare { $this->status = $status; return $this; @@ -324,6 +342,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function getStatus(): int { return $this->status; } @@ -331,6 +350,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function setNote($note) { $this->note = $note; return $this; @@ -339,6 +359,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function getNote() { if (is_string($this->note)) { return $this->note; @@ -349,6 +370,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function setLabel($label) { $this->label = $label; return $this; @@ -357,6 +379,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function getLabel() { return $this->label; } @@ -364,6 +387,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function setExpirationDate($expireDate) { //TODO checks @@ -374,6 +398,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function getExpirationDate() { return $this->expireDate; } @@ -381,6 +406,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function setNoExpirationDate(bool $noExpirationDate) { $this->noExpirationDate = $noExpirationDate; return $this; @@ -389,6 +415,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function getNoExpirationDate(): bool { return $this->noExpirationDate; } @@ -396,6 +423,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function isExpired() { return $this->getExpirationDate() !== null && $this->getExpirationDate() <= new \DateTime(); @@ -404,6 +432,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function setSharedBy($sharedBy) { if (!is_string($sharedBy)) { throw new \InvalidArgumentException(); @@ -417,6 +446,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function getSharedBy() { //TODO check if set return $this->sharedBy; @@ -425,6 +455,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function setShareOwner($shareOwner) { if (!is_string($shareOwner)) { throw new \InvalidArgumentException(); @@ -438,6 +469,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function getShareOwner() { //TODO check if set return $this->shareOwner; @@ -446,6 +478,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function setPassword($password) { $this->password = $password; return $this; @@ -454,6 +487,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function getPassword() { return $this->password; } @@ -461,6 +495,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function setPasswordExpirationTime(?\DateTimeInterface $passwordExpirationTime = null): IShare { $this->passwordExpirationTime = $passwordExpirationTime; return $this; @@ -469,6 +504,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function getPasswordExpirationTime(): ?\DateTimeInterface { return $this->passwordExpirationTime; } @@ -476,6 +512,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function setSendPasswordByTalk(bool $sendPasswordByTalk) { $this->sendPasswordByTalk = $sendPasswordByTalk; return $this; @@ -484,6 +521,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function getSendPasswordByTalk(): bool { return $this->sendPasswordByTalk; } @@ -491,6 +529,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function setToken($token) { $this->token = $token; return $this; @@ -499,15 +538,18 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function getToken() { return $this->token; } + #[\Override] public function setParent(int $parent): self { $this->parent = $parent; return $this; } + #[\Override] public function getParent(): ?int { return $this->parent; } @@ -515,6 +557,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function setTarget($target) { // if the target is changed, save the original target if ($this->target && !$this->originalTarget) { @@ -527,6 +570,7 @@ class Share implements IShare { /** * Return the original target, if this share was moved */ + #[\Override] public function getOriginalTarget(): ?string { return $this->originalTarget; } @@ -534,6 +578,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function getTarget() { return $this->target; } @@ -541,6 +586,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function setShareTime(\DateTime $shareTime) { $this->shareTime = $shareTime; return $this; @@ -549,6 +595,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function getShareTime() { return $this->shareTime; } @@ -556,6 +603,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function setMailSend($mailSend) { $this->mailSend = $mailSend; return $this; @@ -564,6 +612,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function getMailSend() { return $this->mailSend; } @@ -571,6 +620,7 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function setNodeCacheEntry(ICacheEntry $entry) { $this->nodeCacheEntry = $entry; } @@ -578,28 +628,34 @@ class Share implements IShare { /** * @inheritdoc */ + #[\Override] public function getNodeCacheEntry() { return $this->nodeCacheEntry; } + #[\Override] public function setHideDownload(bool $hide): IShare { $this->hideDownload = $hide; return $this; } + #[\Override] public function getHideDownload(): bool { return $this->hideDownload; } + #[\Override] public function setReminderSent(bool $reminderSent): IShare { $this->reminderSent = $reminderSent; return $this; } + #[\Override] public function getReminderSent(): bool { return $this->reminderSent; } + #[\Override] public function canDownload(): bool { if (($this->getPermissions() & Constants::PERMISSION_READ) === 0) { return false; @@ -613,6 +669,7 @@ class Share implements IShare { return true; } + #[\Override] public function canSeeContent(): bool { $shareManager = Server::get(IManager::class); diff --git a/lib/private/Share20/ShareAttributes.php b/lib/private/Share20/ShareAttributes.php index f90fbd9c6cd..617322d5499 100644 --- a/lib/private/Share20/ShareAttributes.php +++ b/lib/private/Share20/ShareAttributes.php @@ -20,6 +20,7 @@ class ShareAttributes implements IAttributes { /** * @inheritdoc */ + #[\Override] public function setAttribute(string $scope, string $key, mixed $value): IAttributes { if (!\array_key_exists($scope, $this->attributes)) { $this->attributes[$scope] = []; @@ -31,6 +32,7 @@ class ShareAttributes implements IAttributes { /** * @inheritdoc */ + #[\Override] public function getAttribute(string $scope, string $key): mixed { if (\array_key_exists($scope, $this->attributes) && \array_key_exists($key, $this->attributes[$scope])) { @@ -42,6 +44,7 @@ class ShareAttributes implements IAttributes { /** * @inheritdoc */ + #[\Override] public function toArray(): array { $result = []; foreach ($this->attributes as $scope => $keys) { diff --git a/lib/private/Share20/UserDeletedListener.php b/lib/private/Share20/UserDeletedListener.php index e0e091454b0..426b3857c91 100644 --- a/lib/private/Share20/UserDeletedListener.php +++ b/lib/private/Share20/UserDeletedListener.php @@ -22,6 +22,7 @@ class UserDeletedListener implements IEventListener { ) { } + #[\Override] public function handle(Event $event): void { if (!$event instanceof UserDeletedEvent) { return; diff --git a/lib/private/Share20/UserRemovedListener.php b/lib/private/Share20/UserRemovedListener.php index 10cb68f9b9e..e0da6e050f0 100644 --- a/lib/private/Share20/UserRemovedListener.php +++ b/lib/private/Share20/UserRemovedListener.php @@ -22,6 +22,7 @@ class UserRemovedListener implements IEventListener { ) { } + #[\Override] public function handle(Event $event): void { if (!$event instanceof UserRemovedEvent) { return; diff --git a/lib/private/SpeechToText/SpeechToTextManager.php b/lib/private/SpeechToText/SpeechToTextManager.php index d69add2d80b..bf9da3709c6 100644 --- a/lib/private/SpeechToText/SpeechToTextManager.php +++ b/lib/private/SpeechToText/SpeechToTextManager.php @@ -48,6 +48,7 @@ class SpeechToTextManager implements ISpeechToTextManager { ) { } + #[\Override] public function getProviders(): array { $context = $this->coordinator->getRegistrationContext(); if ($context === null) { @@ -74,6 +75,7 @@ class SpeechToTextManager implements ISpeechToTextManager { return $this->providers; } + #[\Override] public function hasProviders(): bool { $context = $this->coordinator->getRegistrationContext(); if ($context === null) { @@ -82,6 +84,7 @@ class SpeechToTextManager implements ISpeechToTextManager { return !empty($context->getSpeechToTextProviders()); } + #[\Override] public function scheduleFileTranscription(File $file, ?string $userId, string $appId): void { if (!$this->hasProviders()) { throw new PreConditionNotMetException('No SpeechToText providers have been registered'); @@ -98,6 +101,7 @@ class SpeechToTextManager implements ISpeechToTextManager { } } + #[\Override] public function cancelScheduledFileTranscription(File $file, ?string $userId, string $appId): void { try { $jobArguments = [ @@ -116,6 +120,7 @@ class SpeechToTextManager implements ISpeechToTextManager { } } + #[\Override] public function transcribeFile(File $file, ?string $userId = null, string $appId = 'core'): string { // try to run a TaskProcessing core:audio2text task // this covers scheduling as well because OC\SpeechToText\TranscriptionJob calls this method diff --git a/lib/private/SpeechToText/TranscriptionJob.php b/lib/private/SpeechToText/TranscriptionJob.php index 6e899ef6e96..11ef970ab0b 100644 --- a/lib/private/SpeechToText/TranscriptionJob.php +++ b/lib/private/SpeechToText/TranscriptionJob.php @@ -40,6 +40,7 @@ class TranscriptionJob extends QueuedJob { /** * @inheritDoc */ + #[\Override] protected function run($argument) { $fileId = $argument['fileId']; $owner = $argument['owner']; diff --git a/lib/private/SubAdmin.php b/lib/private/SubAdmin.php index 5d97623726b..18c5d81d2f7 100644 --- a/lib/private/SubAdmin.php +++ b/lib/private/SubAdmin.php @@ -38,6 +38,7 @@ class SubAdmin extends PublicEmitter implements ISubAdmin { * @param IUser $user user to be SubAdmin * @param IGroup $group group $user becomes subadmin of */ + #[\Override] public function createSubAdmin(IUser $user, IGroup $group): void { $qb = $this->dbConn->getQueryBuilder(); @@ -59,6 +60,7 @@ class SubAdmin extends PublicEmitter implements ISubAdmin { * @param IUser $user the user that is the SubAdmin * @param IGroup $group the group */ + #[\Override] public function deleteSubAdmin(IUser $user, IGroup $group): void { $qb = $this->dbConn->getQueryBuilder(); @@ -78,6 +80,7 @@ class SubAdmin extends PublicEmitter implements ISubAdmin { * @param IUser $user the SubAdmin * @return IGroup[] */ + #[\Override] public function getSubAdminsGroups(IUser $user): array { $groupIds = $this->getSubAdminsGroupIds($user); @@ -130,6 +133,7 @@ class SubAdmin extends PublicEmitter implements ISubAdmin { * @param IGroup $group the group * @return IUser[] */ + #[\Override] public function getGroupsSubAdmins(IGroup $group): array { $qb = $this->dbConn->getQueryBuilder(); @@ -183,6 +187,7 @@ class SubAdmin extends PublicEmitter implements ISubAdmin { * @param IGroup $group * @return bool */ + #[\Override] public function isSubAdminOfGroup(IUser $user, IGroup $group): bool { $qb = $this->dbConn->getQueryBuilder(); @@ -207,6 +212,7 @@ class SubAdmin extends PublicEmitter implements ISubAdmin { * @param IUser $user * @return bool */ + #[\Override] public function isSubAdmin(IUser $user): bool { // Check if the user is already an admin if ($this->groupManager->isAdmin($user->getUID())) { @@ -238,6 +244,7 @@ class SubAdmin extends PublicEmitter implements ISubAdmin { * @param IUser $user * @return bool */ + #[\Override] public function isUserAccessible(IUser $subadmin, IUser $user): bool { if ($subadmin->getUID() === $user->getUID()) { return true; diff --git a/lib/private/Support/CrashReport/Registry.php b/lib/private/Support/CrashReport/Registry.php index 4fbbb8448ca..21acbcc810b 100644 --- a/lib/private/Support/CrashReport/Registry.php +++ b/lib/private/Support/CrashReport/Registry.php @@ -30,6 +30,7 @@ class Registry implements IRegistry { /** * Register a reporter instance */ + #[\Override] public function register(IReporter $reporter): void { $this->reporters[] = $reporter; } @@ -43,6 +44,7 @@ class Registry implements IRegistry { * * @since 15.0.0 */ + #[\Override] public function delegateBreadcrumb(string $message, string $category, array $context = []): void { $this->loadLazyProviders(); @@ -58,6 +60,7 @@ class Registry implements IRegistry { * * @param Exception|Throwable $exception */ + #[\Override] public function delegateReport($exception, array $context = []): void { $this->loadLazyProviders(); @@ -71,6 +74,7 @@ class Registry implements IRegistry { * * @return void */ + #[\Override] public function delegateMessage(string $message, array $context = []): void { $this->loadLazyProviders(); @@ -114,6 +118,7 @@ class Registry implements IRegistry { } } + #[\Override] public function hasReporters(): bool { return !empty($this->lazyReporters) || !empty($this->reporters); } diff --git a/lib/private/Support/Subscription/Assertion.php b/lib/private/Support/Subscription/Assertion.php index 7e90b0f2bbc..a05df9d7594 100644 --- a/lib/private/Support/Subscription/Assertion.php +++ b/lib/private/Support/Subscription/Assertion.php @@ -24,6 +24,7 @@ class Assertion implements IAssertion { /** * @inheritDoc */ + #[\Override] public function createUserIsLegit(): void { if ($this->registry->delegateIsHardUserLimitReached($this->notificationManager)) { $l = $this->l10nFactory->get('lib'); diff --git a/lib/private/Support/Subscription/Registry.php b/lib/private/Support/Subscription/Registry.php index 862f5647cf1..7cf5b4b9583 100644 --- a/lib/private/Support/Subscription/Registry.php +++ b/lib/private/Support/Subscription/Registry.php @@ -53,6 +53,7 @@ class Registry implements IRegistry { * * @since 17.0.0 */ + #[\Override] public function register(ISubscription $subscription): void { if ($this->subscription !== null || $this->subscriptionService !== null) { throw new AlreadyRegisteredException(); @@ -60,6 +61,7 @@ class Registry implements IRegistry { $this->subscription = $subscription; } + #[\Override] public function registerService(string $subscriptionService): void { if ($this->subscription !== null || $this->subscriptionService !== null) { throw new AlreadyRegisteredException(); @@ -74,6 +76,7 @@ class Registry implements IRegistry { * * @since 17.0.0 */ + #[\Override] public function delegateGetSupportedApps(): array { if ($this->getSubscription() instanceof ISupportedApps) { return $this->getSubscription()->getSupportedApps(); @@ -86,6 +89,7 @@ class Registry implements IRegistry { * * @since 17.0.0 */ + #[\Override] public function delegateHasValidSubscription(): bool { // Allow overwriting this manually for environments where the subscription information cannot be fetched if ($this->config->getSystemValueBool('has_valid_subscription')) { @@ -103,6 +107,7 @@ class Registry implements IRegistry { * * @since 17.0.0 */ + #[\Override] public function delegateHasExtendedSupport(): bool { if ($this->getSubscription() instanceof ISubscription) { return $this->getSubscription()->hasExtendedSupport(); @@ -117,6 +122,7 @@ class Registry implements IRegistry { * @param IManager|null $notificationManager * @since 21.0.0 */ + #[\Override] public function delegateIsHardUserLimitReached(?IManager $notificationManager = null): bool { $subscription = $this->getSubscription(); if ($subscription instanceof ISubscription diff --git a/lib/private/SystemTag/ManagerFactory.php b/lib/private/SystemTag/ManagerFactory.php index 4d3a1396529..7f3e732ddf0 100644 --- a/lib/private/SystemTag/ManagerFactory.php +++ b/lib/private/SystemTag/ManagerFactory.php @@ -38,6 +38,7 @@ class ManagerFactory implements ISystemTagManagerFactory { * * @since 9.0.0 */ + #[\Override] public function getManager(): ISystemTagManager { return new SystemTagManager( $this->serverContainer->get(IDBConnection::class), @@ -54,6 +55,7 @@ class ManagerFactory implements ISystemTagManagerFactory { * * @since 9.0.0 */ + #[\Override] public function getObjectMapper(): ISystemTagObjectMapper { return new SystemTagObjectMapper( $this->serverContainer->get(IDBConnection::class), diff --git a/lib/private/SystemTag/SystemTag.php b/lib/private/SystemTag/SystemTag.php index 1a573dabeaa..52f303896b8 100644 --- a/lib/private/SystemTag/SystemTag.php +++ b/lib/private/SystemTag/SystemTag.php @@ -21,22 +21,27 @@ class SystemTag implements ISystemTag { ) { } + #[\Override] public function getId(): string { return $this->id; } + #[\Override] public function getName(): string { return $this->name; } + #[\Override] public function isUserVisible(): bool { return $this->userVisible; } + #[\Override] public function isUserAssignable(): bool { return $this->userAssignable; } + #[\Override] public function getAccessLevel(): int { if (!$this->userVisible) { return self::ACCESS_LEVEL_INVISIBLE; @@ -49,10 +54,12 @@ class SystemTag implements ISystemTag { return self::ACCESS_LEVEL_PUBLIC; } + #[\Override] public function getETag(): ?string { return $this->etag; } + #[\Override] public function getColor(): ?string { return $this->color; } diff --git a/lib/private/SystemTag/SystemTagManager.php b/lib/private/SystemTag/SystemTagManager.php index f83c8176f1a..97d3708be8e 100644 --- a/lib/private/SystemTag/SystemTagManager.php +++ b/lib/private/SystemTag/SystemTagManager.php @@ -51,6 +51,7 @@ class SystemTagManager implements ISystemTagManager { ->andWhere($query->expr()->eq('editable', $query->createParameter('editable'))); } + #[\Override] public function getTagsByIds($tagIds, ?IUser $user = null): array { if (!\is_array($tagIds)) { $tagIds = [$tagIds]; @@ -95,6 +96,7 @@ class SystemTagManager implements ISystemTagManager { return $tags; } + #[\Override] public function getAllTags($visibilityFilter = null, $nameSearchPattern = null): array { $tags = []; @@ -130,6 +132,7 @@ class SystemTagManager implements ISystemTagManager { return $tags; } + #[\Override] public function getTag(string $tagName, bool $userVisible, bool $userAssignable): ISystemTag { // Length of name column is 64 $truncatedTagName = substr($tagName, 0, 64); @@ -159,6 +162,7 @@ class SystemTagManager implements ISystemTagManager { } } + #[\Override] public function createTag(string $tagName, bool $userVisible, bool $userAssignable, ?IUser $user = null): ISystemTag { $user ??= $this->userSession->getUser(); if (!$this->canUserCreateTag($user)) { @@ -213,6 +217,7 @@ class SystemTagManager implements ISystemTagManager { return $tag; } + #[\Override] public function updateTag( string $tagId, string $newName, @@ -291,6 +296,7 @@ class SystemTagManager implements ISystemTagManager { )); } + #[\Override] public function deleteTags($tagIds): void { if (!\is_array($tagIds)) { $tagIds = [$tagIds]; @@ -340,6 +346,7 @@ class SystemTagManager implements ISystemTagManager { } } + #[\Override] public function canUserAssignTag(ISystemTag $tag, ?IUser $user): bool { if ($user === null) { return false; @@ -369,6 +376,7 @@ class SystemTagManager implements ISystemTagManager { return false; } + #[\Override] public function canUserCreateTag(?IUser $user): bool { if ($user === null) { // If no user given, allows only calls from CLI @@ -382,11 +390,13 @@ class SystemTagManager implements ISystemTagManager { return $this->groupManager->isAdmin($user->getUID()); } + #[\Override] public function canUserUpdateTag(?IUser $user): bool { // We currently have no different permissions for updating tags than for creating them return $this->canUserCreateTag($user); } + #[\Override] public function canUserSeeTag(ISystemTag $tag, ?IUser $user): bool { // If no user, then we only show public tags if (!$user && $tag->getAccessLevel() === ISystemTag::ACCESS_LEVEL_PUBLIC) { @@ -413,6 +423,7 @@ class SystemTagManager implements ISystemTagManager { return new SystemTag((string)$row['id'], $row['name'], (bool)$row['visibility'], (bool)$row['editable'], $row['etag'], $row['color']); } + #[\Override] public function setTagGroups(ISystemTag $tag, array $groupIds): void { // delete relationships first $this->connection->beginTransaction(); @@ -444,6 +455,7 @@ class SystemTagManager implements ISystemTagManager { } } + #[\Override] public function getTagGroups(ISystemTag $tag): array { $groupIds = []; $query = $this->connection->getQueryBuilder(); diff --git a/lib/private/SystemTag/SystemTagObjectMapper.php b/lib/private/SystemTag/SystemTagObjectMapper.php index 43dddde0b23..59fafe3200b 100644 --- a/lib/private/SystemTag/SystemTagObjectMapper.php +++ b/lib/private/SystemTag/SystemTagObjectMapper.php @@ -70,6 +70,7 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper { /** * {@inheritdoc} */ + #[\Override] public function getObjectIdsForTags($tagIds, string $objectType, int $limit = 0, string $offset = ''): array { if (!\is_array($tagIds)) { $tagIds = [$tagIds]; @@ -232,6 +233,7 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper { /** * {@inheritdoc} */ + #[\Override] public function haveTag($objIds, string $objectType, string $tagId, bool $all = true): bool { $this->assertTagsExist([$tagId]); @@ -296,6 +298,7 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper { /** * {@inheritdoc} */ + #[\Override] public function setObjectIdsForTag(string $tagId, string $objectType, array $objectIds): void { $currentObjectIds = $this->getObjectIdsForTags($tagId, $objectType); $removedObjectIds = array_diff($currentObjectIds, $objectIds); @@ -369,6 +372,7 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper { /** * {@inheritdoc} */ + #[\Override] public function getAvailableObjectTypes(): array { $query = $this->connection->getQueryBuilder(); $query->selectDistinct('objecttype') diff --git a/lib/private/TagManager.php b/lib/private/TagManager.php index d93647c4e4f..90b8d558d88 100644 --- a/lib/private/TagManager.php +++ b/lib/private/TagManager.php @@ -51,6 +51,7 @@ class TagManager implements ITagManager, IEventListener { * * since 20.0.0 $includeShared isn't used anymore */ + #[\Override] public function load($type, $defaultTags = [], $includeShared = false, $userId = null) { if (is_null($userId)) { $user = $this->userSession->getUser(); @@ -87,6 +88,7 @@ class TagManager implements ITagManager, IEventListener { return $users; } + #[\Override] public function handle(Event $event): void { if (!($event instanceof UserDeletedEvent)) { return; diff --git a/lib/private/Tagging/Tag.php b/lib/private/Tagging/Tag.php index 55a3a410281..7ddcd97e6ac 100644 --- a/lib/private/Tagging/Tag.php +++ b/lib/private/Tagging/Tag.php @@ -45,6 +45,7 @@ class Tag extends Entity { * @todo migrate existing database columns to the correct names * to be able to drop this direct mapping */ + #[\Override] public function columnToProperty(string $columnName): string { if ($columnName === 'category') { return 'name'; @@ -63,6 +64,7 @@ class Tag extends Entity { * @param string $property the name of the property * @return string the column name */ + #[\Override] public function propertyToColumn(string $property): string { if ($property === 'name') { return 'category'; diff --git a/lib/private/Tags.php b/lib/private/Tags.php index d4f4b93e470..ec06259db70 100644 --- a/lib/private/Tags.php +++ b/lib/private/Tags.php @@ -72,6 +72,7 @@ class Tags implements ITags { * * @return boolean */ + #[\Override] public function isEmpty(): bool { return count($this->tags) === 0; } @@ -83,6 +84,7 @@ class Tags implements ITags { * @param string $id The ID of the tag that is going to be mapped * @return array|false */ + #[\Override] public function getTag(string $id) { $key = $this->getTagById($id); if ($key !== false) { @@ -102,6 +104,7 @@ class Tags implements ITags { * * @return array */ + #[\Override] public function getTags(): array { if (!count($this->tags)) { return []; @@ -142,6 +145,7 @@ class Tags implements ITags { * @return array>|false of tags id as key to array of tag names * or false if an error occurred */ + #[\Override] public function getTagsForObjects(array $objIds) { $entries = []; @@ -188,6 +192,7 @@ class Tags implements ITags { * @return int[]|false An array of object ids or false on error. * @throws \Exception */ + #[\Override] public function getIdsForTag($tag) { $tagId = false; if (is_numeric($tag)) { @@ -238,6 +243,7 @@ class Tags implements ITags { * @param string $name The tag name to check for. * @param string $user The user whose tags are to be checked. */ + #[\Override] public function userHasTag(string $name, string $user): bool { return $this->array_searchi($name, $this->getTagsForUser($user)) !== false; } @@ -247,6 +253,7 @@ class Tags implements ITags { * * @param string $name The tag name to check for. */ + #[\Override] public function hasTag(string $name): bool { return $this->getTagId($name) !== false; } @@ -257,6 +264,7 @@ class Tags implements ITags { * @param string $name A string with a name of the tag * @return false|int the id of the added tag or false on error. */ + #[\Override] public function add(string $name) { $name = trim($name); @@ -290,6 +298,7 @@ class Tags implements ITags { * @param string $to The new name of the tag. * @return bool */ + #[\Override] public function rename($from, string $to): bool { $from = trim($from); $to = trim($to); @@ -337,6 +346,7 @@ class Tags implements ITags { * @param int|null $id int Optional object id to add to this|these tag(s) * @return bool Returns false on error. */ + #[\Override] public function addMultiple($names, bool $sync = false, ?int $id = null): bool { if (!is_array($names)) { $names = [$names]; @@ -417,6 +427,7 @@ class Tags implements ITags { * @param array $ids The ids of the objects * @return boolean Returns false on error. */ + #[\Override] public function purgeObjects(array $ids): bool { if (count($ids) === 0) { // job done ;) @@ -443,6 +454,7 @@ class Tags implements ITags { * * @return array|false An array of object ids. */ + #[\Override] public function getFavorites() { if (!$this->userHasTag(ITags::TAG_FAVORITE, $this->user)) { return []; @@ -468,6 +480,7 @@ class Tags implements ITags { * @param int $objid The id of the object * @return boolean */ + #[\Override] public function addToFavorites($objid) { if (!$this->userHasTag(ITags::TAG_FAVORITE, $this->user)) { $this->add(ITags::TAG_FAVORITE); @@ -481,6 +494,7 @@ class Tags implements ITags { * @param int $objid The id of the object * @return boolean */ + #[\Override] public function removeFromFavorites($objid) { return $this->unTag($objid, ITags::TAG_FAVORITE); } @@ -488,6 +502,7 @@ class Tags implements ITags { /** * Creates a tag/object relation. */ + #[\Override] public function tagAs($objid, $tag, ?string $path = null) { if (is_string($tag) && !is_numeric($tag)) { $tag = trim($tag); @@ -536,6 +551,7 @@ class Tags implements ITags { /** * Delete single tag/object relation from the db */ + #[\Override] public function unTag($objid, $tag, ?string $path = null) { if (is_string($tag) && !is_numeric($tag)) { $tag = trim($tag); @@ -584,6 +600,7 @@ class Tags implements ITags { * @param string[]|integer[] $names An array of tags (names or IDs) to delete * @return bool Returns false on error */ + #[\Override] public function delete($names) { if (!is_array($names)) { $names = [$names]; diff --git a/lib/private/Talk/Broker.php b/lib/private/Talk/Broker.php index eaf5fad96c6..6feca955023 100644 --- a/lib/private/Talk/Broker.php +++ b/lib/private/Talk/Broker.php @@ -32,6 +32,7 @@ class Broker implements IBroker { ) { } + #[\Override] public function hasBackend(): bool { if ($this->hasBackend !== null) { return $this->hasBackend; @@ -66,10 +67,12 @@ class Broker implements IBroker { } } + #[\Override] public function newConversationOptions(): IConversationOptions { return ConversationOptions::default(); } + #[\Override] public function createConversation(string $name, array $moderators, ?IConversationOptions $options = null): IConversation { @@ -84,6 +87,7 @@ class Broker implements IBroker { ); } + #[\Override] public function deleteConversation(string $id): void { if (!$this->hasBackend()) { throw new NoBackendException('The Talk broker has no registered backend'); diff --git a/lib/private/Talk/ConversationOptions.php b/lib/private/Talk/ConversationOptions.php index f237491f355..eff5a44a4ab 100644 --- a/lib/private/Talk/ConversationOptions.php +++ b/lib/private/Talk/ConversationOptions.php @@ -23,25 +23,30 @@ class ConversationOptions implements IConversationOptions { return new self(false); } + #[\Override] public function setPublic(bool $isPublic = true): IConversationOptions { $this->isPublic = $isPublic; return $this; } + #[\Override] public function isPublic(): bool { return $this->isPublic; } + #[\Override] public function setMeetingDate(\DateTimeInterface $meetingStartDate, \DateTimeInterface $meetingEndDate): IConversationOptions { $this->meetingStartDate = $meetingStartDate; $this->meetingEndDate = $meetingEndDate; return $this; } + #[\Override] public function getMeetingStartDate(): ?\DateTimeInterface { return $this->meetingStartDate; } + #[\Override] public function getMeetingEndDate(): ?\DateTimeInterface { return $this->meetingEndDate; } diff --git a/lib/private/TaskProcessing/Db/TaskMapper.php b/lib/private/TaskProcessing/Db/TaskMapper.php index fd3b81c0dfb..544fefa40d2 100644 --- a/lib/private/TaskProcessing/Db/TaskMapper.php +++ b/lib/private/TaskProcessing/Db/TaskMapper.php @@ -216,6 +216,7 @@ class TaskMapper extends QBMapper { }; } + #[\Override] public function update(Entity $entity): Entity { $entity->setLastUpdated($this->timeFactory->now()->getTimestamp()); return parent::update($entity); diff --git a/lib/private/TaskProcessing/Manager.php b/lib/private/TaskProcessing/Manager.php index ef8ece9c823..4dd4fc36a24 100644 --- a/lib/private/TaskProcessing/Manager.php +++ b/lib/private/TaskProcessing/Manager.php @@ -197,6 +197,7 @@ class Manager implements IManager { ) { } + #[\Override] public function getId(): string { if ($this->provider instanceof IProviderWithId) { return $this->provider->getId(); @@ -204,10 +205,12 @@ class Manager implements IManager { return Manager::LEGACY_PREFIX_TEXTPROCESSING . $this->provider::class; } + #[\Override] public function getName(): string { return $this->provider->getName(); } + #[\Override] public function getTaskTypeId(): string { return match ($this->provider->getTaskType()) { FreePromptTaskType::class => TextToText::ID, @@ -218,6 +221,7 @@ class Manager implements IManager { }; } + #[\Override] public function getExpectedRuntime(): int { if ($this->provider instanceof IProviderWithExpectedRuntime) { return $this->provider->getExpectedRuntime(); @@ -225,14 +229,17 @@ class Manager implements IManager { return 60; } + #[\Override] public function getOptionalInputShape(): array { return []; } + #[\Override] public function getOptionalOutputShape(): array { return []; } + #[\Override] public function process(?string $userId, array $input, callable $reportProgress): array { if ($this->provider instanceof IProviderWithUserId) { $this->provider->setUserId($userId); @@ -244,26 +251,32 @@ class Manager implements IManager { } } + #[\Override] public function getInputShapeEnumValues(): array { return []; } + #[\Override] public function getInputShapeDefaults(): array { return []; } + #[\Override] public function getOptionalInputShapeEnumValues(): array { return []; } + #[\Override] public function getOptionalInputShapeDefaults(): array { return []; } + #[\Override] public function getOutputShapeEnumValues(): array { return []; } + #[\Override] public function getOptionalOutputShapeEnumValues(): array { return []; } @@ -301,22 +314,27 @@ class Manager implements IManager { $this->l = Server::get(IFactory::class)->get('core'); } + #[\Override] public function getId(): string { return Manager::LEGACY_PREFIX_TEXTPROCESSING . $this->oldTaskTypeClass; } + #[\Override] public function getName(): string { return $this->oldTaskType->getName(); } + #[\Override] public function getDescription(): string { return $this->oldTaskType->getDescription(); } + #[\Override] public function getInputShape(): array { return ['input' => new ShapeDescriptor($this->l->t('Input text'), $this->l->t('The input text'), EShapeType::Text)]; } + #[\Override] public function getOutputShape(): array { return ['output' => new ShapeDescriptor($this->l->t('Input text'), $this->l->t('The input text'), EShapeType::Text)]; } @@ -343,30 +361,37 @@ class Manager implements IManager { ) { } + #[\Override] public function getId(): string { return Manager::LEGACY_PREFIX_TEXTTOIMAGE . $this->provider->getId(); } + #[\Override] public function getName(): string { return $this->provider->getName(); } + #[\Override] public function getTaskTypeId(): string { return TextToImage::ID; } + #[\Override] public function getExpectedRuntime(): int { return $this->provider->getExpectedRuntime(); } + #[\Override] public function getOptionalInputShape(): array { return []; } + #[\Override] public function getOptionalOutputShape(): array { return []; } + #[\Override] public function process(?string $userId, array $input, callable $reportProgress): array { try { $folder = $this->appData->getFolder('text2image'); @@ -417,26 +442,32 @@ class Manager implements IManager { return ['images' => array_map(fn (ISimpleFile $file) => $file->getContent(), $files)]; } + #[\Override] public function getInputShapeEnumValues(): array { return []; } + #[\Override] public function getInputShapeDefaults(): array { return []; } + #[\Override] public function getOptionalInputShapeEnumValues(): array { return []; } + #[\Override] public function getOptionalInputShapeDefaults(): array { return []; } + #[\Override] public function getOutputShapeEnumValues(): array { return []; } + #[\Override] public function getOptionalOutputShapeEnumValues(): array { return []; } @@ -486,6 +517,7 @@ class Manager implements IManager { ) { } + #[\Override] public function getId(): string { if ($this->provider instanceof ISpeechToTextProviderWithId) { return Manager::LEGACY_PREFIX_SPEECHTOTEXT . $this->provider->getId(); @@ -493,26 +525,32 @@ class Manager implements IManager { return Manager::LEGACY_PREFIX_SPEECHTOTEXT . $this->provider::class; } + #[\Override] public function getName(): string { return $this->provider->getName(); } + #[\Override] public function getTaskTypeId(): string { return AudioToText::ID; } + #[\Override] public function getExpectedRuntime(): int { return 60; } + #[\Override] public function getOptionalInputShape(): array { return []; } + #[\Override] public function getOptionalOutputShape(): array { return []; } + #[\Override] public function process(?string $userId, array $input, callable $reportProgress): array { if ($this->provider instanceof ISpeechToTextProviderWithUserId) { $this->provider->setUserId($userId); @@ -525,26 +563,32 @@ class Manager implements IManager { return ['output' => $result]; } + #[\Override] public function getInputShapeEnumValues(): array { return []; } + #[\Override] public function getInputShapeDefaults(): array { return []; } + #[\Override] public function getOptionalInputShapeEnumValues(): array { return []; } + #[\Override] public function getOptionalInputShapeDefaults(): array { return []; } + #[\Override] public function getOutputShapeEnumValues(): array { return []; } + #[\Override] public function getOptionalOutputShapeEnumValues(): array { return []; } @@ -829,10 +873,12 @@ class Manager implements IManager { return array_combine($keys, $values); } + #[\Override] public function hasProviders(): bool { return count($this->getProviders()) !== 0; } + #[\Override] public function getProviders(): array { if ($this->providers === null) { $this->providers = $this->_getProviders(); @@ -841,6 +887,7 @@ class Manager implements IManager { return $this->providers; } + #[\Override] public function getPreferredProvider(string $taskTypeId) { try { if ($this->preferences === null) { @@ -878,6 +925,7 @@ class Manager implements IManager { throw new \OCP\TaskProcessing\Exception\Exception('No matching provider found'); } + #[\Override] public function getAvailableTaskTypes(bool $showDisabled = false, ?string $userId = null): array { // We cache by language, because some task type fields are translated $cacheKey = self::TASK_TYPES_CACHE_KEY . ':' . $this->l10nFactory->findLanguage(); @@ -940,6 +988,7 @@ class Manager implements IManager { return $this->availableTaskTypes; } + #[\Override] public function getAvailableTaskTypeIds(bool $showDisabled = false, ?string $userId = null): array { // userId will be obtained from the session if left to null if (!$this->checkGuestAccess($userId)) { @@ -1003,6 +1052,7 @@ class Manager implements IManager { return false; } + #[\Override] public function scheduleTask(Task $task): void { if (!$this->checkGuestAccess($task->getUserId())) { throw new PreConditionNotMetException('Access to this resource is forbidden for guests.'); @@ -1042,6 +1092,7 @@ class Manager implements IManager { } } + #[\Override] public function runTask(Task $task): Task { if (!$this->checkGuestAccess($task->getUserId())) { throw new PreConditionNotMetException('Access to this resource is forbidden for guests.'); @@ -1068,6 +1119,7 @@ class Manager implements IManager { return $task; } + #[\Override] public function processTask(Task $task, ISynchronousProvider $provider): bool { try { try { @@ -1103,11 +1155,13 @@ class Manager implements IManager { return true; } + #[\Override] public function deleteTask(Task $task): void { $taskEntity = \OC\TaskProcessing\Db\Task::fromPublicTask($task); $this->taskMapper->delete($taskEntity); } + #[\Override] public function getTask(int $id): Task { try { $taskEntity = $this->taskMapper->find($id); @@ -1121,6 +1175,7 @@ class Manager implements IManager { } } + #[\Override] public function cancelTask(int $id): void { $task = $this->getTask($id); if ($task->getStatus() !== Task::STATUS_SCHEDULED && $task->getStatus() !== Task::STATUS_RUNNING) { @@ -1137,6 +1192,7 @@ class Manager implements IManager { } } + #[\Override] public function setTaskProgress(int $id, float $progress): bool { // TODO: Not sure if we should rather catch the exceptions of getTask here and fail silently $task = $this->getTask($id); @@ -1158,6 +1214,7 @@ class Manager implements IManager { return true; } + #[\Override] public function setTaskResult(int $id, ?string $error, ?array $result, bool $isUsingFileIds = false, ?string $userFacingError = null): void { // TODO: Not sure if we should rather catch the exceptions of getTask here and fail silently $task = $this->getTask($id); @@ -1252,6 +1309,7 @@ class Manager implements IManager { $this->dispatcher->dispatchTyped($event); } + #[\Override] public function getNextScheduledTask(array $taskTypeIds = [], array $taskIdsToIgnore = []): Task { try { $taskEntity = $this->taskMapper->findOldestScheduledByType($taskTypeIds, $taskIdsToIgnore); @@ -1265,6 +1323,7 @@ class Manager implements IManager { } } + #[\Override] public function getNextScheduledTasks(array $taskTypeIds = [], array $taskIdsToIgnore = [], int $numberOfTasks = 1): array { try { return array_map(fn ($taskEntity) => $taskEntity->toPublicTask(), $this->taskMapper->findNOldestScheduledByType($taskTypeIds, $taskIdsToIgnore, $numberOfTasks)); @@ -1319,6 +1378,7 @@ class Manager implements IManager { return $newInputOutput; } + #[\Override] public function getUserTask(int $id, ?string $userId): Task { try { $taskEntity = $this->taskMapper->findByIdAndUser($id, $userId); @@ -1332,6 +1392,7 @@ class Manager implements IManager { } } + #[\Override] public function getUserTasks(?string $userId, ?string $taskTypeId = null, ?string $customId = null): array { try { $taskEntities = $this->taskMapper->findByUserAndTaskType($userId, $taskTypeId, $customId); @@ -1343,6 +1404,7 @@ class Manager implements IManager { } } + #[\Override] public function getTasks( ?string $userId, ?string $taskTypeId = null, ?string $appId = null, ?string $customId = null, ?int $status = null, ?int $scheduleAfter = null, ?int $endedBefore = null, @@ -1357,6 +1419,7 @@ class Manager implements IManager { } } + #[\Override] public function countTasks(int $status, array $taskTypeIds = []): int { try { return $this->taskMapper->countByStatus($taskTypeIds, $status); @@ -1365,6 +1428,7 @@ class Manager implements IManager { } } + #[\Override] public function getUserTasksByApp(?string $userId, string $appId, ?string $customId = null): array { try { $taskEntities = $this->taskMapper->findUserTasksByApp($userId, $appId, $customId); @@ -1425,6 +1489,7 @@ class Manager implements IManager { * @throws NotPermittedException * @throws ValidationException|UnauthorizedException */ + #[\Override] public function prepareInputData(Task $task): array { $taskTypes = $this->getAvailableTaskTypes(); $inputShape = $taskTypes[$task->getTaskTypeId()]['inputShape']; @@ -1435,6 +1500,7 @@ class Manager implements IManager { return $input; } + #[\Override] public function lockTask(Task $task): bool { $taskEntity = \OC\TaskProcessing\Db\Task::fromPublicTask($task); if ($this->taskMapper->lockTask($taskEntity) === 0) { @@ -1448,6 +1514,7 @@ class Manager implements IManager { * @throws \JsonException * @throws Exception */ + #[\Override] public function setTaskStatus(Task $task, int $status): void { $currentTaskStatus = $task->getStatus(); if ($currentTaskStatus === Task::STATUS_SCHEDULED && $status === Task::STATUS_RUNNING) { @@ -1602,6 +1669,7 @@ class Manager implements IManager { * @return list * @throws NotFoundException */ + #[\Override] public function extractFileIdsFromTask(Task $task): array { $ids = []; $taskTypes = $this->getAvailableTaskTypes(); diff --git a/lib/private/TaskProcessing/SynchronousBackgroundJob.php b/lib/private/TaskProcessing/SynchronousBackgroundJob.php index 19c53d59932..ec221635992 100644 --- a/lib/private/TaskProcessing/SynchronousBackgroundJob.php +++ b/lib/private/TaskProcessing/SynchronousBackgroundJob.php @@ -30,6 +30,7 @@ class SynchronousBackgroundJob extends QueuedJob { /** * @inheritDoc */ + #[\Override] protected function run($argument) { $providers = $this->taskProcessingManager->getProviders(); diff --git a/lib/private/Teams/TeamManager.php b/lib/private/Teams/TeamManager.php index fea2ccc9587..8e838365ed8 100644 --- a/lib/private/Teams/TeamManager.php +++ b/lib/private/Teams/TeamManager.php @@ -32,10 +32,12 @@ class TeamManager implements ITeamManager { ) { } + #[\Override] public function hasTeamSupport(): bool { return $this->circlesManager !== null; } + #[\Override] public function getProviders(): array { if (!$this->hasTeamSupport()) { return []; @@ -57,6 +59,7 @@ class TeamManager implements ITeamManager { return $this->providers; } + #[\Override] public function getProvider(string $providerId): ITeamResourceProvider { $providers = $this->getProviders(); if (isset($providers[$providerId])) { @@ -66,6 +69,7 @@ class TeamManager implements ITeamManager { throw new \RuntimeException('No provider found for id ' . $providerId); } + #[\Override] public function getSharedWith(string $teamId, string $userId): array { if (!$this->hasTeamSupport()) { return []; @@ -84,6 +88,7 @@ class TeamManager implements ITeamManager { return array_values($resources); } + #[\Override] public function getSharedWithList(array $teams, string $userId, string $resourceId): array { if (!$this->hasTeamSupport()) { return []; @@ -103,6 +108,7 @@ class TeamManager implements ITeamManager { return array_merge_recursive(...$resources); } + #[\Override] public function getTeamsForResource(string $providerId, string $resourceId, string $userId): array { if (!$this->hasTeamSupport()) { return []; @@ -137,6 +143,7 @@ class TeamManager implements ITeamManager { * * @return array userId => displayName */ + #[\Override] public function getMembersOfTeam(string $teamId, string $userId): array { $team = $this->getTeam($teamId, $userId); if ($team === null) { @@ -163,6 +170,7 @@ class TeamManager implements ITeamManager { return $this->circlesManager->getCirclesByIds($teams); } + #[\Override] public function getTeamsForUser(string $userId): array { if (!$this->hasTeamSupport()) { return []; diff --git a/lib/private/TempManager.php b/lib/private/TempManager.php index 052b1845add..c45912f03bb 100644 --- a/lib/private/TempManager.php +++ b/lib/private/TempManager.php @@ -44,6 +44,7 @@ class TempManager implements ITempManager { return $absolutePath . $postFix; } + #[\Override] public function getTemporaryFile($postFix = ''): string|false { $path = $this->generateTemporaryPath($postFix); @@ -65,6 +66,7 @@ class TempManager implements ITempManager { return $path; } + #[\Override] public function getTemporaryFolder($postFix = ''): string|false { $path = $this->generateTemporaryPath($postFix) . '/'; @@ -85,6 +87,7 @@ class TempManager implements ITempManager { /** * Remove the temporary files and folders generated during this request */ + #[\Override] public function clean() { $this->cleanFiles($this->current); } @@ -113,6 +116,7 @@ class TempManager implements ITempManager { /** * Remove old temporary files and folders that were failed to be cleaned */ + #[\Override] public function cleanOld() { $this->cleanFiles($this->getOldFiles()); } @@ -146,6 +150,7 @@ class TempManager implements ITempManager { * @return string Path to the temporary directory or null * @throws \UnexpectedValueException */ + #[\Override] public function getTempBaseDir(): string { if ($this->tmpBaseDir) { return $this->tmpBaseDir; diff --git a/lib/private/Template/CSSResourceLocator.php b/lib/private/Template/CSSResourceLocator.php index f77bfca0562..9de9b4c608a 100644 --- a/lib/private/Template/CSSResourceLocator.php +++ b/lib/private/Template/CSSResourceLocator.php @@ -24,6 +24,7 @@ class CSSResourceLocator extends ResourceLocator { parent::__construct($logger, $config); } + #[\Override] public function doFind(string $resource): void { $parts = explode('/', $resource); if (count($parts) < 2) { @@ -57,6 +58,7 @@ class CSSResourceLocator extends ResourceLocator { $this->append($app_path, join('/', array_slice($parts, 1)) . '.css', $app_url); } + #[\Override] public function doFindTheme(string $resource): void { $theme_dir = 'themes/' . $this->theme . '/'; $this->appendIfExist($this->serverroot, $theme_dir . 'apps/' . $resource . '.css') @@ -64,6 +66,7 @@ class CSSResourceLocator extends ResourceLocator { || $this->appendIfExist($this->serverroot, $theme_dir . 'core/' . $resource . '.css'); } + #[\Override] public function append(string $root, string $file, ?string $webRoot = null, bool $throw = true, bool $scss = false): void { if (!$scss) { parent::append($root, $file, $webRoot, $throw); diff --git a/lib/private/Template/JSResourceLocator.php b/lib/private/Template/JSResourceLocator.php index fc35b6c3128..7353b3c77fd 100644 --- a/lib/private/Template/JSResourceLocator.php +++ b/lib/private/Template/JSResourceLocator.php @@ -25,6 +25,7 @@ class JSResourceLocator extends ResourceLocator { parent::__construct($logger, $config); } + #[\Override] public function doFind(string $resource): void { $theme_dir = 'themes/' . $this->theme . '/'; @@ -89,6 +90,7 @@ class JSResourceLocator extends ResourceLocator { ]); } + #[\Override] public function doFindTheme(string $resource): void { } diff --git a/lib/private/Template/Template.php b/lib/private/Template/Template.php index 040c1daf19e..f7d14f9cbb5 100644 --- a/lib/private/Template/Template.php +++ b/lib/private/Template/Template.php @@ -108,6 +108,7 @@ class Template extends Base implements ITemplate { * This function process the template. If $this->renderAs is set, it * will produce a full page. */ + #[\Override] public function fetchPage(?array $additionalParams = null): string { $data = parent::fetchPage($additionalParams); diff --git a/lib/private/Template/TemplateManager.php b/lib/private/Template/TemplateManager.php index 0f0af51798a..810400e5ac4 100644 --- a/lib/private/Template/TemplateManager.php +++ b/lib/private/Template/TemplateManager.php @@ -32,6 +32,7 @@ class TemplateManager implements ITemplateManager { * @param TemplateResponse::RENDER_AS_* $renderAs * @throws TemplateNotFoundException if the template cannot be found */ + #[\Override] public function getTemplate(string $app, string $name, string $renderAs = TemplateResponse::RENDER_AS_BLANK, bool $registerCall = true): ITemplate { return new Template($app, $name, $renderAs, $registerCall); } @@ -42,6 +43,7 @@ class TemplateManager implements ITemplateManager { * @param string $name Name of the template * @param array $parameters Parameters for the template */ + #[\Override] public function printGuestPage(string $application, string $name, array $parameters = []): void { $content = $this->getTemplate($application, $name, $name === 'error' ? $name : 'guest'); foreach ($parameters as $key => $value) { @@ -55,6 +57,7 @@ class TemplateManager implements ITemplateManager { * @param string $error_msg The error message to show * @param string $hint An optional hint message - needs to be properly escape */ + #[\Override] public function printErrorPage(string $error_msg, string $hint = '', int $statusCode = 500): never { if ($this->appManager->isEnabledForUser('theming') && !$this->appManager->isAppLoaded('theming')) { $this->appManager->loadApp('theming'); @@ -109,6 +112,7 @@ class TemplateManager implements ITemplateManager { /** * print error page using Exception details */ + #[\Override] public function printExceptionErrorPage(\Throwable $exception, int $statusCode = 503): never { $debug = false; http_response_code($statusCode); diff --git a/lib/private/TextProcessing/Db/TaskMapper.php b/lib/private/TextProcessing/Db/TaskMapper.php index b03e5833958..cafcae24362 100644 --- a/lib/private/TextProcessing/Db/TaskMapper.php +++ b/lib/private/TextProcessing/Db/TaskMapper.php @@ -95,6 +95,7 @@ class TaskMapper extends QBMapper { return $qb->executeStatement(); } + #[\Override] public function update(Entity $entity): Entity { $entity->setLastUpdated($this->timeFactory->now()->getTimestamp()); return parent::update($entity); diff --git a/lib/private/TextProcessing/Manager.php b/lib/private/TextProcessing/Manager.php index 3fe45ce55ec..ea2f1d2a5d2 100644 --- a/lib/private/TextProcessing/Manager.php +++ b/lib/private/TextProcessing/Manager.php @@ -62,6 +62,7 @@ class Manager implements IManager { ) { } + #[\Override] public function getProviders(): array { $context = $this->coordinator->getRegistrationContext(); if ($context === null) { @@ -88,6 +89,7 @@ class Manager implements IManager { return $this->providers; } + #[\Override] public function hasProviders(): bool { // check if task processing equivalent types are available $taskTaskTypes = $this->taskProcessingManager->getAvailableTaskTypes(); @@ -107,6 +109,7 @@ class Manager implements IManager { /** * @inheritDoc */ + #[\Override] public function getAvailableTaskTypes(): array { $tasks = []; foreach ($this->getProviders() as $provider) { @@ -131,6 +134,7 @@ class Manager implements IManager { /** * @inheritDoc */ + #[\Override] public function runTask(OCPTask $task): string { // try to run a task processing task if possible $taskTypeClass = $task->getType(); @@ -215,6 +219,7 @@ class Manager implements IManager { /** * @inheritDoc */ + #[\Override] public function scheduleTask(OCPTask $task): void { if (!$this->canHandleTask($task)) { throw new PreConditionNotMetException('No LanguageModel provider is installed that can handle this task'); @@ -245,6 +250,7 @@ class Manager implements IManager { /** * @inheritDoc */ + #[\Override] public function runOrScheduleTask(OCPTask $task): bool { if (!$this->canHandleTask($task)) { throw new PreConditionNotMetException('No LanguageModel provider is installed that can handle this task'); @@ -264,6 +270,7 @@ class Manager implements IManager { /** * @inheritDoc */ + #[\Override] public function deleteTask(Task $task): void { $taskEntity = DbTask::fromPublicTask($task); $this->taskMapper->delete($taskEntity); @@ -280,6 +287,7 @@ class Manager implements IManager { * @throws RuntimeException If the query failed * @throws NotFoundException If the task could not be found */ + #[\Override] public function getTask(int $id): OCPTask { try { $taskEntity = $this->taskMapper->find($id); @@ -303,6 +311,7 @@ class Manager implements IManager { * @throws RuntimeException If the query failed * @throws NotFoundException If the task could not be found */ + #[\Override] public function getUserTask(int $id, ?string $userId): OCPTask { try { $taskEntity = $this->taskMapper->findByIdAndUser($id, $userId); @@ -326,6 +335,7 @@ class Manager implements IManager { * @param string|null $identifier * @return array */ + #[\Override] public function getUserTasksByApp(string $userId, string $appId, ?string $identifier = null): array { try { $taskEntities = $this->taskMapper->findUserTasksByApp($userId, $appId, $identifier); diff --git a/lib/private/TextProcessing/RemoveOldTasksBackgroundJob.php b/lib/private/TextProcessing/RemoveOldTasksBackgroundJob.php index be5e4127d08..2c120d8aac5 100644 --- a/lib/private/TextProcessing/RemoveOldTasksBackgroundJob.php +++ b/lib/private/TextProcessing/RemoveOldTasksBackgroundJob.php @@ -33,6 +33,7 @@ class RemoveOldTasksBackgroundJob extends TimedJob { * @param mixed $argument * @inheritDoc */ + #[\Override] protected function run($argument) { try { $this->taskMapper->deleteOlderThan(self::MAX_TASK_AGE_SECONDS); diff --git a/lib/private/TextProcessing/TaskBackgroundJob.php b/lib/private/TextProcessing/TaskBackgroundJob.php index 2942fd7d0aa..e44adf8b179 100644 --- a/lib/private/TextProcessing/TaskBackgroundJob.php +++ b/lib/private/TextProcessing/TaskBackgroundJob.php @@ -33,6 +33,7 @@ class TaskBackgroundJob extends QueuedJob { * @param array{taskId: int} $argument * @inheritDoc */ + #[\Override] protected function run($argument) { $taskId = $argument['taskId']; $task = $this->textProcessingManager->getTask($taskId); diff --git a/lib/private/TextToImage/Db/TaskMapper.php b/lib/private/TextToImage/Db/TaskMapper.php index 37f492e14cf..f500443f70b 100644 --- a/lib/private/TextToImage/Db/TaskMapper.php +++ b/lib/private/TextToImage/Db/TaskMapper.php @@ -104,6 +104,7 @@ class TaskMapper extends QBMapper { return $deletedTasks; } + #[\Override] public function update(Entity $entity): Entity { $entity->setLastUpdated($this->timeFactory->getDateTime()); return parent::update($entity); diff --git a/lib/private/TextToImage/Manager.php b/lib/private/TextToImage/Manager.php index eec6cc3d241..330b130f075 100644 --- a/lib/private/TextToImage/Manager.php +++ b/lib/private/TextToImage/Manager.php @@ -53,6 +53,7 @@ class Manager implements IManager { /** * @inheritDoc */ + #[\Override] public function getProviders(): array { $context = $this->coordinator->getRegistrationContext(); if ($context === null) { @@ -84,6 +85,7 @@ class Manager implements IManager { /** * @inheritDoc */ + #[\Override] public function hasProviders(): bool { $context = $this->coordinator->getRegistrationContext(); if ($context === null) { @@ -95,6 +97,7 @@ class Manager implements IManager { /** * @inheritDoc */ + #[\Override] public function runTask(Task $task): void { $this->logger->debug('Running TextToImage Task'); if (!$this->hasProviders()) { @@ -191,6 +194,7 @@ class Manager implements IManager { /** * @inheritDoc */ + #[\Override] public function scheduleTask(Task $task): void { if (!$this->hasProviders()) { throw new PreConditionNotMetException('No text to image provider is installed that can handle this task'); @@ -211,6 +215,7 @@ class Manager implements IManager { /** * @inheritDoc */ + #[\Override] public function runOrScheduleTask(Task $task) : void { if (!$this->hasProviders()) { throw new PreConditionNotMetException('No text to image provider is installed that can handle this task'); @@ -228,6 +233,7 @@ class Manager implements IManager { /** * @inheritDoc */ + #[\Override] public function deleteTask(Task $task): void { $taskEntity = DbTask::fromPublicTask($task); $this->taskMapper->delete($taskEntity); @@ -244,6 +250,7 @@ class Manager implements IManager { * @throws RuntimeException If the query failed * @throws TaskNotFoundException If the task could not be found */ + #[\Override] public function getTask(int $id): Task { try { $taskEntity = $this->taskMapper->find($id); @@ -267,6 +274,7 @@ class Manager implements IManager { * @throws RuntimeException If the query failed * @throws TaskNotFoundException If the task could not be found */ + #[\Override] public function getUserTask(int $id, ?string $userId): Task { try { $taskEntity = $this->taskMapper->findByIdAndUser($id, $userId); @@ -291,6 +299,7 @@ class Manager implements IManager { * @return Task[] * @throws RuntimeException */ + #[\Override] public function getUserTasksByApp(?string $userId, string $appId, ?string $identifier = null): array { try { $taskEntities = $this->taskMapper->findUserTasksByApp($userId, $appId, $identifier); diff --git a/lib/private/TextToImage/RemoveOldTasksBackgroundJob.php b/lib/private/TextToImage/RemoveOldTasksBackgroundJob.php index 225984a7956..7a38b847948 100644 --- a/lib/private/TextToImage/RemoveOldTasksBackgroundJob.php +++ b/lib/private/TextToImage/RemoveOldTasksBackgroundJob.php @@ -41,6 +41,7 @@ class RemoveOldTasksBackgroundJob extends TimedJob { * @param mixed $argument * @inheritDoc */ + #[\Override] protected function run($argument) { try { $deletedTasks = $this->taskMapper->deleteOlderThan(self::MAX_TASK_AGE_SECONDS); diff --git a/lib/private/TextToImage/TaskBackgroundJob.php b/lib/private/TextToImage/TaskBackgroundJob.php index 16990005530..8127addca50 100644 --- a/lib/private/TextToImage/TaskBackgroundJob.php +++ b/lib/private/TextToImage/TaskBackgroundJob.php @@ -33,6 +33,7 @@ class TaskBackgroundJob extends QueuedJob { * @param array{taskId: int} $argument * @inheritDoc */ + #[\Override] protected function run($argument) { $taskId = $argument['taskId']; $task = $this->text2imageManager->getTask($taskId); diff --git a/lib/private/Translation/TranslationManager.php b/lib/private/Translation/TranslationManager.php index 08f9f36678a..a4d7138531a 100644 --- a/lib/private/Translation/TranslationManager.php +++ b/lib/private/Translation/TranslationManager.php @@ -41,6 +41,7 @@ class TranslationManager implements ITranslationManager { ) { } + #[\Override] public function getLanguages(): array { $languages = []; foreach ($this->getProviders() as $provider) { @@ -49,6 +50,7 @@ class TranslationManager implements ITranslationManager { return $languages; } + #[\Override] public function translate(string $text, ?string &$fromLanguage, string $toLanguage): string { if (!$this->hasProviders()) { throw new PreConditionNotMetException('No translation providers available'); @@ -112,6 +114,7 @@ class TranslationManager implements ITranslationManager { throw new CouldNotTranslateException($fromLanguage); } + #[\Override] public function getProviders(): array { $context = $this->coordinator->getRegistrationContext(); @@ -134,11 +137,13 @@ class TranslationManager implements ITranslationManager { return $this->providers; } + #[\Override] public function hasProviders(): bool { $context = $this->coordinator->getRegistrationContext(); return !empty($context->getTranslationProviders()); } + #[\Override] public function canDetectLanguage(): bool { foreach ($this->getProviders() as $provider) { if ($provider instanceof IDetectLanguageProvider) { diff --git a/lib/private/URLGenerator.php b/lib/private/URLGenerator.php index 0debd9ba99a..2c7070f1c2d 100644 --- a/lib/private/URLGenerator.php +++ b/lib/private/URLGenerator.php @@ -60,6 +60,7 @@ class URLGenerator implements IURLGenerator { * * Returns a url to the given route. */ + #[\Override] public function linkToRoute(string $routeName, array $arguments = []): string { return $this->router->generate($routeName, $arguments); } @@ -72,10 +73,12 @@ class URLGenerator implements IURLGenerator { * * Returns an absolute url to the given route. */ + #[\Override] public function linkToRouteAbsolute(string $routeName, array $arguments = []): string { return $this->getAbsoluteURL($this->linkToRoute($routeName, $arguments)); } + #[\Override] public function linkToOCSRouteAbsolute(string $routeName, array $arguments = []): string { // Returns `/subfolder/index.php/ocsapp/…` with `'htaccess.IgnoreFrontController' => false` in config.php // And `/subfolder/ocsapp/…` with `'htaccess.IgnoreFrontController' => true` in config.php @@ -110,6 +113,7 @@ class URLGenerator implements IURLGenerator { * * Returns a url to the given app and file. */ + #[\Override] public function linkTo(string $appName, string $file, array $args = []): string { $frontControllerActive = ($this->config->getSystemValueBool('htaccess.IgnoreFrontController', false) || getenv('front_controller_active') === 'true'); @@ -158,6 +162,7 @@ class URLGenerator implements IURLGenerator { * * Returns the path to the image. */ + #[\Override] public function imagePath(string $appName, string $file): string { $cache = $this->cacheFactory->createDistributed('imagePath-' . md5($this->getBaseUrl()) . '-'); $cacheKey = $appName . '-' . $file; @@ -241,6 +246,7 @@ class URLGenerator implements IURLGenerator { * @param string $url the url in the Nextcloud host * @return string the absolute version of the url */ + #[\Override] public function getAbsoluteURL(string $url): string { $separator = str_starts_with($url, '/') ? '' : '/'; @@ -259,6 +265,7 @@ class URLGenerator implements IURLGenerator { * @param string $key * @return string url to the online documentation */ + #[\Override] public function linkToDocs(string $key): string { $theme = Server::get('ThemingDefaults'); return $theme->buildDocLinkToKey($key); @@ -269,6 +276,7 @@ class URLGenerator implements IURLGenerator { * and the apps visible for the current user * @return string */ + #[\Override] public function linkToDefaultPageUrl(): string { // Deny the redirect if the URL contains a @ // This prevents unvalidated redirects like ?redirect_url=:user@domain.com @@ -302,6 +310,7 @@ class URLGenerator implements IURLGenerator { /** * @return string base url of the current request */ + #[\Override] public function getBaseUrl(): string { // BaseUrl can be equal to 'http(s)://' during the first steps of the initial setup. if ($this->baseUrl === null || $this->baseUrl === 'http://' || $this->baseUrl === 'https://') { @@ -313,6 +322,7 @@ class URLGenerator implements IURLGenerator { /** * @return string webroot part of the base url */ + #[\Override] public function getWebroot(): string { return \OC::$WEBROOT; } diff --git a/lib/private/User/AvailabilityCoordinator.php b/lib/private/User/AvailabilityCoordinator.php index 988f2e55260..32535711817 100644 --- a/lib/private/User/AvailabilityCoordinator.php +++ b/lib/private/User/AvailabilityCoordinator.php @@ -34,6 +34,7 @@ class AvailabilityCoordinator implements IAvailabilityCoordinator { $this->cache = $cacheFactory->createLocal('OutOfOfficeData'); } + #[\Override] public function isEnabled(): bool { return $this->config->getAppValue(Application::APP_ID, 'hide_absence_settings', 'no') === 'no'; } @@ -87,6 +88,7 @@ class AvailabilityCoordinator implements IAvailabilityCoordinator { $this->cache->set($data->getUser()->getUID(), $cachedString, 300); } + #[\Override] public function getCurrentOutOfOfficeData(IUser $user): ?IOutOfOfficeData { $timezone = $this->getCachedTimezone($user->getUID()); if ($timezone === null) { @@ -115,11 +117,13 @@ class AvailabilityCoordinator implements IAvailabilityCoordinator { $this->cache->set($userId . '_timezone', $timezone, 3600); } + #[\Override] public function clearCache(string $userId): void { $this->cache->set($userId, null, 300); $this->cache->set($userId . '_timezone', null, 3600); } + #[\Override] public function isInEffect(IOutOfOfficeData $data): bool { return $this->absenceService->isInEffect($data); } diff --git a/lib/private/User/Backend.php b/lib/private/User/Backend.php index 9b6a9a890ef..878a7ae8c7e 100644 --- a/lib/private/User/Backend.php +++ b/lib/private/User/Backend.php @@ -68,6 +68,7 @@ abstract class Backend implements UserInterface { * Returns the supported actions as int to be * compared with self::CREATE_USER etc. */ + #[\Override] public function implementsActions($actions) { return (bool)($this->getSupportedActions() & $actions); } @@ -79,6 +80,7 @@ abstract class Backend implements UserInterface { * * Deletes a user */ + #[\Override] public function deleteUser($uid) { return false; } @@ -91,6 +93,7 @@ abstract class Backend implements UserInterface { * @param null|int $offset * @return string[] an array of all uids */ + #[\Override] public function getUsers($search = '', $limit = null, $offset = null) { return []; } @@ -100,6 +103,7 @@ abstract class Backend implements UserInterface { * @param string $uid the username * @return boolean */ + #[\Override] public function userExists($uid) { return false; } @@ -118,6 +122,7 @@ abstract class Backend implements UserInterface { * @param string $uid user ID of the user * @return string display name */ + #[\Override] public function getDisplayName($uid) { return $uid; } @@ -130,6 +135,7 @@ abstract class Backend implements UserInterface { * @param int|null $offset * @return array an array of all displayNames (value) and the corresponding uids (key) */ + #[\Override] public function getDisplayNames($search = '', $limit = null, $offset = null) { $displayNames = []; $users = $this->getUsers($search, $limit, $offset); @@ -143,6 +149,7 @@ abstract class Backend implements UserInterface { * Check if a user list is available or not * @return boolean if users can be listed or not */ + #[\Override] public function hasUserListings() { return false; } diff --git a/lib/private/User/BackgroundJobs/CleanupDeletedUsers.php b/lib/private/User/BackgroundJobs/CleanupDeletedUsers.php index 0adb7861670..983ff73be65 100644 --- a/lib/private/User/BackgroundJobs/CleanupDeletedUsers.php +++ b/lib/private/User/BackgroundJobs/CleanupDeletedUsers.php @@ -30,6 +30,7 @@ class CleanupDeletedUsers extends TimedJob { $this->setInterval(24 * 60 * 60); } + #[\Override] protected function run($argument): void { $backend = new PartiallyDeletedUsersBackend($this->config); $users = $backend->getUsers(); diff --git a/lib/private/User/Database.php b/lib/private/User/Database.php index 7877deff62f..d65ef769c52 100644 --- a/lib/private/User/Database.php +++ b/lib/private/User/Database.php @@ -82,6 +82,7 @@ class Database extends ABackend implements * Creates a new user. Basic checking of username is done in OC_User * itself, not in its subclasses. */ + #[\Override] public function createUser(string $uid, string $password): bool { if ($this->userExists($uid)) { return false; @@ -116,6 +117,7 @@ class Database extends ABackend implements * @param string $uid The username of the user to delete * @return bool */ + #[\Override] public function deleteUser($uid) { // Delete user-group-relation $dbConn = $this->getDbConnection(); @@ -157,6 +159,7 @@ class Database extends ABackend implements * * Change the password of a user */ + #[\Override] public function setPassword(string $uid, string $password): bool { if (!$this->userExists($uid)) { return false; @@ -176,6 +179,7 @@ class Database extends ABackend implements return $return; } + #[\Override] public function getPasswordHash(string $userId): ?string { if (!$this->userExists($userId)) { return null; @@ -199,6 +203,7 @@ class Database extends ABackend implements return $hash; } + #[\Override] public function setPasswordHash(string $userId, string $passwordHash): bool { if (!Server::get(IHasher::class)->validate($passwordHash)) { throw new InvalidArgumentException(); @@ -224,6 +229,7 @@ class Database extends ABackend implements * * Change the display name of a user */ + #[\Override] public function setDisplayName(string $uid, string $displayName): bool { if (mb_strlen($displayName) > 64) { throw new \InvalidArgumentException('Invalid displayname'); @@ -251,6 +257,7 @@ class Database extends ABackend implements * @param string $uid user ID of the user * @return string display name */ + #[\Override] public function getDisplayName($uid): string { $uid = (string)$uid; $this->loadUser($uid); @@ -265,6 +272,7 @@ class Database extends ABackend implements * @param int|null $offset * @return array an array of all displayNames (value) and the corresponding uids (key) */ + #[\Override] public function getDisplayNames($search = '', $limit = null, $offset = null) { $limit = $this->fixLimit($limit); @@ -304,6 +312,7 @@ class Database extends ABackend implements * @return array * @since 21.0.1 */ + #[\Override] public function searchKnownUsersByDisplayName(string $searcher, string $pattern, ?int $limit = null, ?int $offset = null): array { $limit = $this->fixLimit($limit); @@ -345,6 +354,7 @@ class Database extends ABackend implements * Check if the password is correct without logging in the user * returns the user id or false */ + #[\Override] public function checkPassword(string $loginName, string $password) { $found = $this->loadUser($loginName); @@ -433,6 +443,7 @@ class Database extends ABackend implements * @param null|int $offset * @return string[] an array of all uids */ + #[\Override] public function getUsers($search = '', $limit = null, $offset = null) { $limit = $this->fixLimit($limit); @@ -450,6 +461,7 @@ class Database extends ABackend implements * @param string $uid the username * @return boolean */ + #[\Override] public function userExists($uid) { return $this->loadUser($uid); } @@ -460,6 +472,7 @@ class Database extends ABackend implements * @param string $uid the username * @return string|false */ + #[\Override] public function getHome(string $uid) { if ($this->userExists($uid)) { return $this->config->getSystemValueString('datadirectory', \OC::$SERVERROOT . '/data') . '/' . $uid; @@ -471,6 +484,7 @@ class Database extends ABackend implements /** * @return bool */ + #[\Override] public function hasUserListings() { return true; } @@ -478,6 +492,7 @@ class Database extends ABackend implements /** * counts the users in the database */ + #[\Override] public function countUsers(int $limit = 0): int|false { $dbConn = $this->getDbConnection(); $query = $dbConn->getQueryBuilder(); @@ -510,6 +525,7 @@ class Database extends ABackend implements * * @return string the name of the backend to be shown */ + #[\Override] public function getBackendName() { return 'Database'; } @@ -532,6 +548,7 @@ class Database extends ABackend implements } } + #[\Override] public function getRealUID(string $uid): string { if (!$this->userExists($uid)) { throw new \RuntimeException($uid . ' does not exist'); diff --git a/lib/private/User/DisplayNameCache.php b/lib/private/User/DisplayNameCache.php index 96386ca35f2..186fef23602 100644 --- a/lib/private/User/DisplayNameCache.php +++ b/lib/private/User/DisplayNameCache.php @@ -69,6 +69,7 @@ class DisplayNameCache implements IEventListener { $this->memCache->clear(); } + #[\Override] public function handle(Event $event): void { if ($event instanceof UserChangedEvent && $event->getFeature() === 'displayName') { $userId = $event->getUser()->getUID(); diff --git a/lib/private/User/LazyUser.php b/lib/private/User/LazyUser.php index f7b0dd23c6c..3ae6a557a2d 100644 --- a/lib/private/User/LazyUser.php +++ b/lib/private/User/LazyUser.php @@ -41,10 +41,12 @@ class LazyUser implements IUser { return $this->user; } + #[\Override] public function getUID(): string { return $this->uid; } + #[\Override] public function getDisplayName() { if ($this->displayName) { return $this->displayName; @@ -53,126 +55,157 @@ class LazyUser implements IUser { return $this->userManager->getDisplayName($this->uid) ?? $this->uid; } + #[\Override] public function setDisplayName($displayName) { return $this->getUser()->setDisplayName($displayName); } + #[\Override] public function getLastLogin(): int { return $this->getUser()->getLastLogin(); } + #[\Override] public function getFirstLogin(): int { return $this->getUser()->getFirstLogin(); } + #[\Override] public function updateLastLoginTimestamp(): bool { return $this->getUser()->updateLastLoginTimestamp(); } + #[\Override] public function delete() { return $this->getUser()->delete(); } + #[\Override] public function setPassword($password, $recoveryPassword = null) { return $this->getUser()->setPassword($password, $recoveryPassword); } + #[\Override] public function getPasswordHash(): ?string { return $this->getUser()->getPasswordHash(); } + #[\Override] public function setPasswordHash(string $passwordHash): bool { return $this->getUser()->setPasswordHash($passwordHash); } + #[\Override] public function getHome() { return $this->getUser()->getHome(); } + #[\Override] public function getBackendClassName() { return $this->getUser()->getBackendClassName(); } + #[\Override] public function getBackend(): ?UserInterface { return $this->getUser()->getBackend(); } + #[\Override] public function canChangeAvatar(): bool { return $this->getUser()->canChangeAvatar(); } + #[\Override] public function canChangePassword(): bool { return $this->getUser()->canChangePassword(); } + #[\Override] public function canChangeDisplayName(): bool { return $this->getUser()->canChangeDisplayName(); } + #[\Override] public function canChangeEmail(): bool { return $this->getUser()->canChangeEmail(); } + #[\Override] public function canEditProperty(string $property): bool { return $this->getUser()->canEditProperty($property); } + #[\Override] public function isEnabled() { return $this->getUser()->isEnabled(); } + #[\Override] public function setEnabled(bool $enabled = true) { return $this->getUser()->setEnabled($enabled); } + #[\Override] public function getEMailAddress() { return $this->getUser()->getEMailAddress(); } + #[\Override] public function getSystemEMailAddress(): ?string { return $this->getUser()->getSystemEMailAddress(); } + #[\Override] public function getPrimaryEMailAddress(): ?string { return $this->getUser()->getPrimaryEMailAddress(); } + #[\Override] public function getAvatarImage($size) { return $this->getUser()->getAvatarImage($size); } + #[\Override] public function getCloudId() { return $this->getUser()->getCloudId(); } + #[\Override] public function setEMailAddress($mailAddress) { $this->getUser()->setEMailAddress($mailAddress); } + #[\Override] public function setSystemEMailAddress(string $mailAddress): void { $this->getUser()->setSystemEMailAddress($mailAddress); } + #[\Override] public function setPrimaryEMailAddress(string $mailAddress): void { $this->getUser()->setPrimaryEMailAddress($mailAddress); } + #[\Override] public function getQuota() { return $this->getUser()->getQuota(); } + #[\Override] public function getQuotaBytes(): int|float { return $this->getUser()->getQuotaBytes(); } + #[\Override] public function setQuota($quota) { $this->getUser()->setQuota($quota); } + #[\Override] public function getManagerUids(): array { return $this->getUser()->getManagerUids(); } + #[\Override] public function setManagerUids(array $uids): void { $this->getUser()->setManagerUids($uids); } diff --git a/lib/private/User/Listeners/BeforeUserDeletedListener.php b/lib/private/User/Listeners/BeforeUserDeletedListener.php index c5d7efa767a..322b4e9f94a 100644 --- a/lib/private/User/Listeners/BeforeUserDeletedListener.php +++ b/lib/private/User/Listeners/BeforeUserDeletedListener.php @@ -27,6 +27,7 @@ class BeforeUserDeletedListener implements IEventListener { ) { } + #[\Override] public function handle(Event $event): void { if (!($event instanceof BeforeUserDeletedEvent)) { return; diff --git a/lib/private/User/Listeners/UserChangedListener.php b/lib/private/User/Listeners/UserChangedListener.php index 4dd4439574d..7ce6f8126f1 100644 --- a/lib/private/User/Listeners/UserChangedListener.php +++ b/lib/private/User/Listeners/UserChangedListener.php @@ -23,6 +23,7 @@ class UserChangedListener implements IEventListener { ) { } + #[\Override] public function handle(Event $event): void { if (!($event instanceof UserChangedEvent)) { return; diff --git a/lib/private/User/Manager.php b/lib/private/User/Manager.php index 5c899b7892f..6aa9784e2bd 100644 --- a/lib/private/User/Manager.php +++ b/lib/private/User/Manager.php @@ -88,14 +88,17 @@ class Manager extends PublicEmitter implements IUserManager { * Get the active backends * @return UserInterface[] */ + #[\Override] public function getBackends(): array { return $this->backends; } + #[\Override] public function registerBackend(UserInterface $backend): void { $this->backends[] = $backend; } + #[\Override] public function removeBackend(UserInterface $backend): void { $this->cachedUsers = []; if (($i = array_search($backend, $this->backends)) !== false) { @@ -103,6 +106,7 @@ class Manager extends PublicEmitter implements IUserManager { } } + #[\Override] public function clearBackends(): void { $this->cachedUsers = []; $this->backends = []; @@ -114,6 +118,7 @@ class Manager extends PublicEmitter implements IUserManager { * @param string $uid * @return User|null Either the user or null if the specified user does not exist */ + #[\Override] public function get($uid) { if (is_null($uid) || $uid === '' || $uid === false) { return null; @@ -150,6 +155,7 @@ class Manager extends PublicEmitter implements IUserManager { return null; } + #[\Override] public function getDisplayName(string $uid): ?string { return $this->displayNameCache->getDisplayName($uid); } @@ -184,6 +190,7 @@ class Manager extends PublicEmitter implements IUserManager { * @param string $uid * @return bool */ + #[\Override] public function userExists($uid) { if (strlen($uid) > IUser::MAX_USERID_LENGTH) { return false; @@ -200,6 +207,7 @@ class Manager extends PublicEmitter implements IUserManager { * @param string $password * @return IUser|false the User object on success, false otherwise */ + #[\Override] public function checkPassword($loginName, $password) { $result = $this->checkPasswordNoLogging($loginName, $password); @@ -256,6 +264,7 @@ class Manager extends PublicEmitter implements IUserManager { return false; } + #[\Override] public function search($pattern, $limit = null, $offset = null) { $users = []; foreach ($this->backends as $backend) { @@ -273,6 +282,7 @@ class Manager extends PublicEmitter implements IUserManager { return $users; } + #[\Override] public function searchDisplayName($pattern, $limit = null, $offset = null) { $users = []; foreach ($this->backends as $backend) { @@ -293,6 +303,7 @@ class Manager extends PublicEmitter implements IUserManager { /** * @return IUser[] */ + #[\Override] public function getDisabledUsers(?int $limit = null, int $offset = 0, string $search = ''): array { $users = $this->config->getUsersForUserValue('core', 'enabled', 'false'); $users = array_combine( @@ -342,6 +353,7 @@ class Manager extends PublicEmitter implements IUserManager { * @param int|null $offset * @return IUser[] */ + #[\Override] public function searchKnownUsersByDisplayName(string $searcher, string $pattern, ?int $limit = null, ?int $offset = null): array { $users = []; foreach ($this->backends as $backend) { @@ -375,6 +387,7 @@ class Manager extends PublicEmitter implements IUserManager { * @throws \InvalidArgumentException * @throws HintException */ + #[\Override] public function createUser($uid, $password): IUser|false { // DI injection is not used here as IRegistry needs the user manager itself for user count and thus it would create a cyclic dependency /** @var IAssertion $assertion */ @@ -408,6 +421,7 @@ class Manager extends PublicEmitter implements IUserManager { * @param string $password * @throws \InvalidArgumentException */ + #[\Override] public function createUserFromBackend($uid, $password, UserInterface $backend): IUser|false { $l = Util::getL10N('lib'); @@ -445,6 +459,7 @@ class Manager extends PublicEmitter implements IUserManager { * * @return array an array of backend class as key and count number as value */ + #[\Override] public function countUsers(bool $onlyMappedUsers = false) { $userCountStatistics = []; foreach ($this->backends as $backend) { @@ -472,6 +487,7 @@ class Manager extends PublicEmitter implements IUserManager { return $userCountStatistics; } + #[\Override] public function countUsersTotal(int $limit = 0, bool $onlyMappedUsers = false): int|false { $userCount = false; @@ -536,6 +552,7 @@ class Manager extends PublicEmitter implements IUserManager { * in the preferences table will be affected * @since 9.0.0 */ + #[\Override] public function callForAllUsers(\Closure $callback, $search = '', $onlySeen = false) { if ($onlySeen) { $this->callForSeenUsers($callback); @@ -567,6 +584,7 @@ class Manager extends PublicEmitter implements IUserManager { * @return int * @since 12.0.0 */ + #[\Override] public function countDisabledUsers(): int { $queryBuilder = Server::get(IDBConnection::class)->getQueryBuilder(); $queryBuilder->select($queryBuilder->func()->count('*')) @@ -595,6 +613,7 @@ class Manager extends PublicEmitter implements IUserManager { * @return int * @since 11.0.0 */ + #[\Override] public function countSeenUsers() { $queryBuilder = Server::get(IDBConnection::class)->getQueryBuilder(); $queryBuilder->select($queryBuilder->func()->count('*')) @@ -610,6 +629,7 @@ class Manager extends PublicEmitter implements IUserManager { return $result; } + #[\Override] public function callForSeenUsers(\Closure $callback) { $users = $this->getSeenUsers(); foreach ($users as $user) { @@ -672,6 +692,7 @@ class Manager extends PublicEmitter implements IUserManager { * @return IUser[] * @since 9.1.0 */ + #[\Override] public function getByEmail($email): array { $users = []; $userConfig = $this->getUserConfig(); @@ -692,6 +713,7 @@ class Manager extends PublicEmitter implements IUserManager { * @throws \InvalidArgumentException Message is an already translated string with a reason why the id is not valid * @since 26.0.0 */ + #[\Override] public function validateUserId(string $uid, bool $checkDataDirectory = false): void { $l = Server::get(IFactory::class)->get('lib'); @@ -736,6 +758,7 @@ class Manager extends PublicEmitter implements IUserManager { * @param string $search search users based on search params * @return list list of user IDs */ + #[\Override] public function getLastLoggedInUsers(?int $limit = null, int $offset = 0, string $search = ''): array { // We can't load all users who already logged in $limit = min(100, $limit ?: 25); @@ -808,6 +831,7 @@ class Manager extends PublicEmitter implements IUserManager { return $this->displayNameCache; } + #[\Override] public function getSeenUsers(int $offset = 0, ?int $limit = null): \Iterator { $maxBatchSize = 1000; @@ -834,6 +858,7 @@ class Manager extends PublicEmitter implements IUserManager { } while (count($userIds) === $batchSize && $limit !== 0); } + #[\Override] public function getExistingUser(string $userId, ?string $displayName = null): IUser { return new LazyUser($userId, $this, $displayName); } diff --git a/lib/private/User/OutOfOfficeData.php b/lib/private/User/OutOfOfficeData.php index 0d4e142567e..0a778ea89c3 100644 --- a/lib/private/User/OutOfOfficeData.php +++ b/lib/private/User/OutOfOfficeData.php @@ -25,38 +25,47 @@ class OutOfOfficeData implements IOutOfOfficeData { ) { } + #[\Override] public function getId(): string { return $this->id; } + #[\Override] public function getUser(): IUser { return $this->user; } + #[\Override] public function getStartDate(): int { return $this->startDate; } + #[\Override] public function getEndDate(): int { return $this->endDate; } + #[\Override] public function getShortMessage(): string { return $this->shortMessage; } + #[\Override] public function getMessage(): string { return $this->message; } + #[\Override] public function getReplacementUserId(): ?string { return $this->replacementUserId; } + #[\Override] public function getReplacementUserDisplayName(): ?string { return $this->replacementUserDisplayName; } + #[\Override] public function jsonSerialize(): array { return [ 'id' => $this->getId(), diff --git a/lib/private/User/PartiallyDeletedUsersBackend.php b/lib/private/User/PartiallyDeletedUsersBackend.php index 298ddaff6c6..4a49261768f 100644 --- a/lib/private/User/PartiallyDeletedUsersBackend.php +++ b/lib/private/User/PartiallyDeletedUsersBackend.php @@ -22,23 +22,28 @@ class PartiallyDeletedUsersBackend extends Backend implements IGetHomeBackend, I ) { } + #[\Override] public function deleteUser($uid): bool { // fake true, deleting failed users is automatically handled by User::delete() return true; } + #[\Override] public function getBackendName(): string { return 'deleted users'; } + #[\Override] public function userExists($uid) { return $this->config->getUserValue($uid, 'core', 'deleted') === 'true'; } + #[\Override] public function getHome(string $uid): string|false { return $this->config->getUserValue($uid, 'core', 'deleted.home-path') ?: false; } + #[\Override] public function getUsers($search = '', $limit = null, $offset = null) { return $this->config->getUsersForUserValue('core', 'deleted', 'true'); } diff --git a/lib/private/User/Session.php b/lib/private/User/Session.php index 651d5e8f9c4..beba7778e50 100644 --- a/lib/private/User/Session.php +++ b/lib/private/User/Session.php @@ -98,6 +98,7 @@ class Session implements IUserSession, Emitter { * @param string $method * @param callable $callback */ + #[\Override] public function listen($scope, $method, callable $callback) { $this->manager->listen($scope, $method, $callback); } @@ -107,6 +108,7 @@ class Session implements IUserSession, Emitter { * @param string $method optional * @param callable $callback optional */ + #[\Override] public function removeListener($scope = null, $method = null, ?callable $callback = null) { $this->manager->removeListener($scope, $method, $callback); } @@ -147,6 +149,7 @@ class Session implements IUserSession, Emitter { * * @param IUser|null $user */ + #[\Override] public function setUser($user) { if (is_null($user)) { $this->session->remove('user_id'); @@ -161,6 +164,7 @@ class Session implements IUserSession, Emitter { * * @param IUser|null $user */ + #[\Override] public function setVolatileActiveUser(?IUser $user): void { $this->activeUser = $user; } @@ -170,6 +174,7 @@ class Session implements IUserSession, Emitter { * * @return IUser|null Current user, otherwise null */ + #[\Override] public function getUser() { // FIXME: This is a quick'n dirty work-around for the incognito mode as // described at https://github.com/owncloud/core/pull/12912#issuecomment-67391155 @@ -221,6 +226,7 @@ class Session implements IUserSession, Emitter { * * @return bool if logged in */ + #[\Override] public function isLoggedIn() { $user = $this->getUser(); if (is_null($user)) { @@ -265,10 +271,12 @@ class Session implements IUserSession, Emitter { /** * @return null|string */ + #[\Override] public function getImpersonatingUserID(): ?string { return $this->session->get('oldUserId'); } + #[\Override] public function setImpersonatingUserID(bool $useCurrentUser = true): void { if ($useCurrentUser === false) { $this->session->remove('oldUserId'); @@ -303,6 +311,7 @@ class Session implements IUserSession, Emitter { * @return boolean|null * @throws LoginException */ + #[\Override] public function login($uid, $password) { $this->session->regenerateId(); if ($this->validateToken($password, $uid)) { @@ -962,6 +971,7 @@ class Session implements IUserSession, Emitter { /** * logout the user from the session */ + #[\Override] public function logout() { $user = $this->getUser(); $this->manager->emit('\OC\User', 'logout', [$user]); diff --git a/lib/private/User/User.php b/lib/private/User/User.php index 8de3486a9b9..6b83d1a7fc7 100644 --- a/lib/private/User/User.php +++ b/lib/private/User/User.php @@ -74,6 +74,7 @@ class User implements IUser { $this->urlGenerator = $urlGenerator ?? Server::get(IURLGenerator::class); } + #[\Override] public function getUID(): string { return $this->uid; } @@ -81,6 +82,7 @@ class User implements IUser { /** * Get the display name for the user, if no specific display name is set it will fallback to the user id */ + #[\Override] public function getDisplayName(): string { if ($this->displayName === null) { $displayName = ''; @@ -109,6 +111,7 @@ class User implements IUser { * @since 25.0.0 Throw InvalidArgumentException * @throws \InvalidArgumentException */ + #[\Override] public function setDisplayName($displayName): bool { $displayName = trim($displayName); $oldDisplayName = $this->getDisplayName(); @@ -128,6 +131,7 @@ class User implements IUser { /** * @inheritDoc */ + #[\Override] public function setEMailAddress($mailAddress): void { $this->setSystemEMailAddress($mailAddress); } @@ -135,6 +139,7 @@ class User implements IUser { /** * @inheritDoc */ + #[\Override] public function setSystemEMailAddress(string $mailAddress): void { $oldMailAddress = $this->getSystemEMailAddress(); $mailAddress = mb_strtolower(trim($mailAddress)); @@ -159,6 +164,7 @@ class User implements IUser { /** * @inheritDoc */ + #[\Override] public function setPrimaryEMailAddress(string $mailAddress): void { $mailAddress = mb_strtolower(trim($mailAddress)); if ($mailAddress === '') { @@ -187,6 +193,7 @@ class User implements IUser { * returns the timestamp of the user's last login or 0 if the user did never * login */ + #[\Override] public function getLastLogin(): int { if ($this->lastLogin === null) { $this->lastLogin = (int)$this->config->getUserValue($this->uid, 'login', 'lastLogin', 0); @@ -198,6 +205,7 @@ class User implements IUser { * returns the timestamp of the user's last login or 0 if the user did never * login */ + #[\Override] public function getFirstLogin(): int { if ($this->firstLogin === null) { $this->firstLogin = (int)$this->config->getUserValue($this->uid, 'login', 'firstLogin', 0); @@ -208,6 +216,7 @@ class User implements IUser { /** * updates the timestamp of the most recent login of this user */ + #[\Override] public function updateLastLoginTimestamp(): bool { $previousLogin = $this->getLastLogin(); $firstLogin = $this->getFirstLogin(); @@ -235,6 +244,7 @@ class User implements IUser { /** * Delete the user */ + #[\Override] public function delete(): bool { if ($this->backend === null) { Server::get(LoggerInterface::class)->error('Cannot delete user: No backend set'); @@ -323,6 +333,7 @@ class User implements IUser { * @param string $password * @param string $recoveryPassword for the encryption app to reset encryption keys */ + #[\Override] public function setPassword($password, $recoveryPassword = null): bool { $this->dispatcher->dispatchTyped(new BeforePasswordUpdatedEvent($this, $password, $recoveryPassword)); if ($this->emitter) { @@ -346,6 +357,7 @@ class User implements IUser { } } + #[\Override] public function getPasswordHash(): ?string { if (!($this->backend instanceof IPasswordHashBackend)) { return null; @@ -353,6 +365,7 @@ class User implements IUser { return $this->backend->getPasswordHash($this->uid); } + #[\Override] public function setPasswordHash(string $passwordHash): bool { if (!($this->backend instanceof IPasswordHashBackend)) { return false; @@ -363,6 +376,7 @@ class User implements IUser { /** * Get the users home folder to mount */ + #[\Override] public function getHome(): string { if (!$this->home) { /** @psalm-suppress UndefinedInterfaceMethod Once we get rid of the legacy implementsActions, psalm won't complain anymore */ @@ -378,6 +392,7 @@ class User implements IUser { /** * Get the name of the backend class the user is connected with */ + #[\Override] public function getBackendClassName(): string { if ($this->backend instanceof IUserBackend) { return $this->backend->getBackendName(); @@ -385,22 +400,27 @@ class User implements IUser { return get_class($this->backend); } + #[\Override] public function getBackend(): ?UserInterface { return $this->backend; } + #[\Override] public function canChangeAvatar(): bool { return $this->canEditProperty(IAccountManager::PROPERTY_AVATAR); } + #[\Override] public function canChangePassword(): bool { return $this->backend->implementsActions(Backend::SET_PASSWORD); } + #[\Override] public function canChangeDisplayName(): bool { return $this->canEditProperty(IAccountManager::PROPERTY_DISPLAYNAME); } + #[\Override] public function canChangeEmail(): bool { return $this->canEditProperty(IAccountManager::PROPERTY_EMAIL); } @@ -408,6 +428,7 @@ class User implements IUser { /** * @param IAccountManager::PROPERTY_*|IAccountManager::COLLECTION_* $property */ + #[\Override] public function canEditProperty(string $property): bool { if ($this->backend instanceof IPropertyPermissionBackend) { $permission = $this->backend->canEditProperty($this->uid, $property); @@ -438,6 +459,7 @@ class User implements IUser { /** * Check if the user is enabled */ + #[\Override] public function isEnabled(): bool { $queryDatabaseValue = function (): bool { if ($this->enabled === null) { @@ -458,6 +480,7 @@ class User implements IUser { * * @return void */ + #[\Override] public function setEnabled(bool $enabled = true) { $oldStatus = $this->isEnabled(); $setDatabaseValue = function (bool $enabled): void { @@ -487,6 +510,7 @@ class User implements IUser { * * @since 9.0.0 */ + #[\Override] public function getEMailAddress(): ?string { return $this->getPrimaryEMailAddress() ?? $this->getSystemEMailAddress(); } @@ -494,6 +518,7 @@ class User implements IUser { /** * @inheritDoc */ + #[\Override] public function getSystemEMailAddress(): ?string { $email = $this->config->getUserValue($this->uid, 'settings', 'email', null); return $email ? mb_strtolower(trim($email)) : null; @@ -502,6 +527,7 @@ class User implements IUser { /** * @inheritDoc */ + #[\Override] public function getPrimaryEMailAddress(): ?string { $email = $this->config->getUserValue($this->uid, 'settings', 'primary_email', null); return $email ? mb_strtolower(trim($email)) : null; @@ -512,6 +538,7 @@ class User implements IUser { * * @since 9.0.0 */ + #[\Override] public function getQuota(): string { // allow apps to modify the user quota by hooking into the event $event = new GetQuotaEvent($this); @@ -540,6 +567,7 @@ class User implements IUser { return $quota; } + #[\Override] public function getQuotaBytes(): int|float { $quota = $this->getQuota(); if ($quota === 'none') { @@ -560,6 +588,7 @@ class User implements IUser { * @throws InvalidArgumentException * @since 9.0.0 */ + #[\Override] public function setQuota($quota): void { $oldQuota = $this->config->getUserValue($this->uid, 'files', 'quota', ''); if ($quota !== 'none' && $quota !== 'default') { @@ -576,6 +605,7 @@ class User implements IUser { \OC_Helper::clearStorageInfo('/' . $this->uid . '/files'); } + #[\Override] public function getManagerUids(): array { $encodedUids = $this->config->getUserValue( $this->uid, @@ -586,6 +616,7 @@ class User implements IUser { return json_decode($encodedUids, false, 512, JSON_THROW_ON_ERROR); } + #[\Override] public function setManagerUids(array $uids): void { $oldUids = $this->getManagerUids(); $this->config->setUserValue( @@ -603,6 +634,7 @@ class User implements IUser { * @param int $size * @since 9.0.0 */ + #[\Override] public function getAvatarImage($size): ?IImage { // delay the initialization if (is_null($this->avatarManager)) { @@ -623,6 +655,7 @@ class User implements IUser { * * @since 9.0.0 */ + #[\Override] public function getCloudId(): string { $uid = $this->getUID(); $server = rtrim($this->urlGenerator->getAbsoluteURL('/'), '/'); diff --git a/lib/private/UserStatus/Manager.php b/lib/private/UserStatus/Manager.php index 4cfd1c18e79..abd5440e738 100644 --- a/lib/private/UserStatus/Manager.php +++ b/lib/private/UserStatus/Manager.php @@ -28,6 +28,7 @@ class Manager implements IManager { /** * @inheritDoc */ + #[\Override] public function getUserStatuses(array $userIds): array { $this->setupProvider(); if (!$this->provider) { @@ -73,6 +74,7 @@ class Manager implements IManager { $this->provider = $provider; } + #[\Override] public function setUserStatus(string $userId, string $messageId, string $status, bool $createBackup = false, ?string $customMessage = null): void { $this->setupProvider(); if (!$this->provider instanceof ISettableProvider) { @@ -82,6 +84,7 @@ class Manager implements IManager { $this->provider->setUserStatus($userId, $messageId, $status, $createBackup, $customMessage); } + #[\Override] public function revertUserStatus(string $userId, string $messageId, string $status): void { $this->setupProvider(); if (!$this->provider instanceof ISettableProvider) { @@ -90,6 +93,7 @@ class Manager implements IManager { $this->provider->revertUserStatus($userId, $messageId, $status); } + #[\Override] public function revertMultipleUserStatus(array $userIds, string $messageId, string $status): void { $this->setupProvider(); if (!$this->provider instanceof ISettableProvider) {