diff options
Diffstat (limited to 'lib/public')
-rw-r--r-- | lib/public/Accounts/IAccountManager.php | 2 | ||||
-rw-r--r-- | lib/public/Activity/IEvent.php | 12 | ||||
-rw-r--r-- | lib/public/Authentication/Events/AnyLoginFailedEvent.php | 62 | ||||
-rw-r--r-- | lib/public/BeforeSabrePubliclyLoadedEvent.php | 31 | ||||
-rw-r--r-- | lib/public/Group/Events/GroupChangedEvent.php | 94 | ||||
-rw-r--r-- | lib/public/IGroupManager.php | 10 | ||||
-rw-r--r-- | lib/public/IImage.php | 67 | ||||
-rw-r--r-- | lib/public/IRequest.php | 5 | ||||
-rw-r--r-- | lib/public/IUserManager.php | 8 | ||||
-rw-r--r-- | lib/public/Log/IWriter.php | 4 | ||||
-rw-r--r-- | lib/public/Log/functions.php | 1 | ||||
-rw-r--r-- | lib/public/Migration/IMigrationStep.php | 17 | ||||
-rw-r--r-- | lib/public/Migration/SimpleMigrationStep.php | 26 | ||||
-rw-r--r-- | lib/public/Notification/INotification.php | 12 | ||||
-rw-r--r-- | lib/public/Util.php | 6 |
15 files changed, 281 insertions, 76 deletions
diff --git a/lib/public/Accounts/IAccountManager.php b/lib/public/Accounts/IAccountManager.php index e41327171b4..77c32d6ff4e 100644 --- a/lib/public/Accounts/IAccountManager.php +++ b/lib/public/Accounts/IAccountManager.php @@ -112,6 +112,7 @@ interface IAccountManager { public const PROPERTY_WEBSITE = 'website'; public const PROPERTY_ADDRESS = 'address'; public const PROPERTY_TWITTER = 'twitter'; + public const PROPERTY_FEDIVERSE = 'fediverse'; /** * @since 23.0.0 @@ -151,6 +152,7 @@ interface IAccountManager { self::PROPERTY_WEBSITE, self::PROPERTY_ADDRESS, self::PROPERTY_TWITTER, + self::PROPERTY_FEDIVERSE, self::PROPERTY_ORGANISATION, self::PROPERTY_ROLE, self::PROPERTY_HEADLINE, diff --git a/lib/public/Activity/IEvent.php b/lib/public/Activity/IEvent.php index 1e3c1deef26..4c47cc47a3f 100644 --- a/lib/public/Activity/IEvent.php +++ b/lib/public/Activity/IEvent.php @@ -103,9 +103,7 @@ interface IEvent { * HTML is not allowed in the parsed subject and will be escaped * automatically by the clients. You can use the RichObjectString system * provided by the Nextcloud server to highlight important parameters via - * the setRichSubject method, but make sure, that a plain text message is - * always set via setParsedSubject, to support clients which can not handle - * rich strings. + * the setRichSubject method. * * See https://github.com/nextcloud/server/issues/1706 for more information. * @@ -128,8 +126,6 @@ interface IEvent { * HTML is not allowed in the rich subject and will be escaped automatically * by the clients, but you can use the RichObjectString system provided by * the Nextcloud server to highlight important parameters. - * Also make sure, that a plain text subject is always set via - * setParsedSubject, to support clients which can not handle rich strings. * * See https://github.com/nextcloud/server/issues/1706 for more information. * @@ -170,9 +166,7 @@ interface IEvent { * HTML is not allowed in the parsed message and will be escaped * automatically by the clients. You can use the RichObjectString system * provided by the Nextcloud server to highlight important parameters via - * the setRichMessage method, but make sure, that a plain text message is - * always set via setParsedMessage, to support clients which can not handle - * rich strings. + * the setRichMessage method. * * See https://github.com/nextcloud/server/issues/1706 for more information. * @@ -195,8 +189,6 @@ interface IEvent { * HTML is not allowed in the rich message and will be escaped automatically * by the clients, but you can use the RichObjectString system provided by * the Nextcloud server to highlight important parameters. - * Also make sure, that a plain text message is always set via - * setParsedMessage, to support clients which can not handle rich strings. * * See https://github.com/nextcloud/server/issues/1706 for more information. * diff --git a/lib/public/Authentication/Events/AnyLoginFailedEvent.php b/lib/public/Authentication/Events/AnyLoginFailedEvent.php new file mode 100644 index 00000000000..ddfec6d9da8 --- /dev/null +++ b/lib/public/Authentication/Events/AnyLoginFailedEvent.php @@ -0,0 +1,62 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright Copyright (c) 2022, Roeland Jago Douma <roeland@famdouma.nl> + * + * @author Roeland Jago Douma <roeland@famdouma.nl> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +namespace OCP\Authentication\Events; + +use OCP\EventDispatcher\Event; + +/** + * Emitted when the authentication fails + * + * @since 26.0.0 + */ +class AnyLoginFailedEvent extends Event { + private string $loginName; + private ?string $password; + + /** + * @since 26.0.0 + */ + public function __construct(string $loginName, ?string $password) { + parent::__construct(); + + $this->loginName = $loginName; + $this->password = $password; + } + + /** + * @since 26.0.0 + */ + public function geLoginName(): string { + return $this->loginName; + } + + /** + * @since 26.0.0 + */ + public function getPassword(): ?string { + return $this->password; + } +} diff --git a/lib/public/BeforeSabrePubliclyLoadedEvent.php b/lib/public/BeforeSabrePubliclyLoadedEvent.php new file mode 100644 index 00000000000..afb68a8a952 --- /dev/null +++ b/lib/public/BeforeSabrePubliclyLoadedEvent.php @@ -0,0 +1,31 @@ +<?php +/** + * @copyright Julien Veyssier <eneiluj@posteo.net> 2022 + * + * @author Julien Veyssier <eneiluj@posteo.net> + * + * @license AGPL-3.0-or-later + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see <http://www.gnu.org/licenses/> + * + */ +namespace OCP; + +/** + * Dispatched before Sabre is loaded when accessing public webdav endpoints + * This can be used to inject a Sabre plugin for example + * + * @since 26.0.0 + */ +class BeforeSabrePubliclyLoadedEvent extends SabrePluginEvent { +} diff --git a/lib/public/Group/Events/GroupChangedEvent.php b/lib/public/Group/Events/GroupChangedEvent.php new file mode 100644 index 00000000000..9cb5007a916 --- /dev/null +++ b/lib/public/Group/Events/GroupChangedEvent.php @@ -0,0 +1,94 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright 2022 Anna Larch <anna.larch@gmx.net> + * + * @author Anna Larch <anna.larch@gmx.net> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +namespace OCP\Group\Events; + +use OCP\EventDispatcher\Event; +use OCP\IGroup; + +/** + * @since 26.0.0 + */ +class GroupChangedEvent extends Event { + private IGroup $group; + private string $feature; + /** @var mixed */ + private $value; + /** @var mixed */ + private $oldValue; + + /** + * @since 26.0.0 + */ + public function __construct(IGroup $group, + string $feature, + $value, + $oldValue = null) { + parent::__construct(); + $this->group = $group; + $this->feature = $feature; + $this->value = $value; + $this->oldValue = $oldValue; + } + + /** + * + * @since 26.0.0 + * + * @return IGroup + */ + public function getGroup(): IGroup { + return $this->group; + } + + /** + * + * @since 26.0.0 + * + * @return string + */ + public function getFeature(): string { + return $this->feature; + } + + /** + * @since 26.0.0 + * + * @return mixed + */ + public function getValue() { + return $this->value; + } + + /** + * + * @since 26.0.0 + * + * @return mixed + */ + public function getOldValue() { + return $this->oldValue; + } +} diff --git a/lib/public/IGroupManager.php b/lib/public/IGroupManager.php index d942caac9b4..2e2685eeeb4 100644 --- a/lib/public/IGroupManager.php +++ b/lib/public/IGroupManager.php @@ -145,4 +145,14 @@ interface IGroupManager { * @since 8.0.0 */ public function isInGroup($userId, $group); + + /** + * Get the display name of a Nextcloud group + * + * @param string $groupId + * @return ?string display name, if any + * + * @since 26.0.0 + */ + public function getDisplayName(string $groupId): ?string; } diff --git a/lib/public/IImage.php b/lib/public/IImage.php index 659cd24720d..f1ac3bf1a50 100644 --- a/lib/public/IImage.php +++ b/lib/public/IImage.php @@ -1,4 +1,7 @@ <?php + +declare(strict_types=1); + /** * @copyright Copyright (c) 2016, ownCloud, Inc. * @@ -33,69 +36,60 @@ interface IImage { /** * Determine whether the object contains an image resource. * - * @return bool * @since 8.1.0 */ - public function valid(); + public function valid(): bool; /** - * Returns the MIME type of the image or an empty string if no image is loaded. + * Returns the MIME type of the image or null if no image is loaded. * - * @return string * @since 8.1.0 */ - public function mimeType(); + public function mimeType(): ?string; /** * Returns the width of the image or -1 if no image is loaded. * - * @return int * @since 8.1.0 */ - public function width(); + public function width(): int; /** * Returns the height of the image or -1 if no image is loaded. * - * @return int * @since 8.1.0 */ - public function height(); + public function height(): int; /** * Returns the width when the image orientation is top-left. * - * @return int * @since 8.1.0 */ - public function widthTopLeft(); + public function widthTopLeft(): int; /** * Returns the height when the image orientation is top-left. * - * @return int * @since 8.1.0 */ - public function heightTopLeft(); + public function heightTopLeft(): int; /** * Outputs the image. * - * @param string $mimeType - * @return bool * @since 8.1.0 */ - public function show($mimeType = null); + public function show(?string $mimeType = null): bool; /** * Saves the image. * * @param string $filePath * @param string $mimeType - * @return bool * @since 8.1.0 */ - public function save($filePath = null, $mimeType = null); + public function save(?string $filePath = null, ?string $mimeType = null): bool; /** * @return false|resource|\GdImage Returns the image resource if any @@ -104,16 +98,17 @@ interface IImage { public function resource(); /** - * @return string Returns the raw data mimetype + * @return string Returns the mimetype of the data. Returns null + * if the data is not valid. * @since 13.0.0 */ - public function dataMimeType(); + public function dataMimeType(): ?string; /** * @return string Returns the raw image data. * @since 8.1.0 */ - public function data(); + public function data(): ?string; /** * (I'm open for suggestions on better method name ;) @@ -122,25 +117,23 @@ interface IImage { * @return int The orientation or -1 if no EXIF data is available. * @since 8.1.0 */ - public function getOrientation(); + public function getOrientation(): int; /** * (I'm open for suggestions on better method name ;) * Fixes orientation based on EXIF data. * - * @return bool * @since 8.1.0 */ - public function fixOrientation(); + public function fixOrientation(): bool; /** * Resizes the image preserving ratio. * * @param integer $maxSize The maximum size of either the width or height. - * @return bool * @since 8.1.0 */ - public function resize($maxSize); + public function resize(int $maxSize): bool; /** * @param int $width @@ -157,7 +150,7 @@ interface IImage { * @return bool for success or failure * @since 8.1.0 */ - public function centerCrop($size = 0); + public function centerCrop(int $size = 0): bool; /** * Crops the image from point $x$y with dimension $wx$h. @@ -174,22 +167,22 @@ interface IImage { /** * Resizes the image to fit within a boundary while preserving ratio. * - * @param integer $maxWidth - * @param integer $maxHeight - * @return bool + * Warning: Images smaller than $maxWidth x $maxHeight will end up being scaled up + * + * @param int $maxWidth + * @param int $maxHeight * @since 8.1.0 */ - public function fitIn($maxWidth, $maxHeight); + public function fitIn(int $maxWidth, int $maxHeight): bool; /** * Shrinks the image to fit within a boundary while preserving ratio. * - * @param integer $maxWidth - * @param integer $maxHeight - * @return bool + * @param int $maxWidth + * @param int $maxHeight * @since 8.1.0 */ - public function scaleDownToFit($maxWidth, $maxHeight); + public function scaleDownToFit(int $maxWidth, int $maxHeight): bool; /** * create a copy of this image @@ -222,9 +215,9 @@ interface IImage { public function preciseResizeCopy(int $width, int $height): IImage; /** - * create a new resized copy of this image + * Resizes the image preserving ratio, returning a new copy * - * @param integer $maxSize The maximum size of either the width or height. + * @param int $maxSize The maximum size of either the width or height. * @return IImage * @since 19.0.0 */ diff --git a/lib/public/IRequest.php b/lib/public/IRequest.php index 7696c3fa8c3..bb290233306 100644 --- a/lib/public/IRequest.php +++ b/lib/public/IRequest.php @@ -98,6 +98,11 @@ interface IRequest { public const USER_AGENT_THUNDERBIRD_ADDON = '/^Mozilla\/5\.0 \([A-Za-z ]+\) Nextcloud\-Thunderbird v.*$/'; /** + * @since 26.0.0 + */ + public const JSON_CONTENT_TYPE_REGEX = '/^application\/(?:[a-z0-9.-]+\+)?json\b/'; + + /** * @param string $name * * @psalm-taint-source input diff --git a/lib/public/IUserManager.php b/lib/public/IUserManager.php index af0d5f08809..8caa027468b 100644 --- a/lib/public/IUserManager.php +++ b/lib/public/IUserManager.php @@ -212,4 +212,12 @@ interface IUserManager { * @since 9.1.0 */ public function getByEmail($email); + + /** + * @param string $uid The user ID to validate + * @param bool $checkDataDirectory Whether it should be checked if files for the ID exist inside the data directory + * @throws \InvalidArgumentException Message is an already translated string with a reason why the ID is not valid + * @since 26.0.0 + */ + public function validateUserId(string $uid, bool $checkDataDirectory = false): void; } diff --git a/lib/public/Log/IWriter.php b/lib/public/Log/IWriter.php index acc39533bfd..3c7ec84e8c0 100644 --- a/lib/public/Log/IWriter.php +++ b/lib/public/Log/IWriter.php @@ -30,6 +30,10 @@ namespace OCP\Log; interface IWriter { /** * @since 14.0.0 + * + * @param string $app + * @param string|array $message + * @param int $level */ public function write(string $app, $message, int $level); } diff --git a/lib/public/Log/functions.php b/lib/public/Log/functions.php index cc6961d8fba..ac043b4d958 100644 --- a/lib/public/Log/functions.php +++ b/lib/public/Log/functions.php @@ -49,6 +49,7 @@ use function class_exists; * @since 24.0.0 */ function logger(string $appId = null): LoggerInterface { + /** @psalm-suppress TypeDoesNotContainNull false-positive, it may contain null if we are logging from initialization */ if (!class_exists(OC::class) || OC::$server === null) { // If someone calls this log before Nextcloud is initialized, there is // no logging available. In that case we return a noop implementation diff --git a/lib/public/Migration/IMigrationStep.php b/lib/public/Migration/IMigrationStep.php index 1b5aa828994..da9f62e861e 100644 --- a/lib/public/Migration/IMigrationStep.php +++ b/lib/public/Migration/IMigrationStep.php @@ -27,6 +27,7 @@ declare(strict_types=1); */ namespace OCP\Migration; +use Closure; use OCP\DB\ISchemaWrapper; /** @@ -34,7 +35,7 @@ use OCP\DB\ISchemaWrapper; */ interface IMigrationStep { /** - * Human readable name of the migration step + * Human-readable name of the migration step * * @return string * @since 14.0.0 @@ -42,7 +43,7 @@ interface IMigrationStep { public function name(): string; /** - * Human readable description of the migration steps + * Human-readable description of the migration step * * @return string * @since 14.0.0 @@ -51,29 +52,29 @@ interface IMigrationStep { /** * @param IOutput $output - * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` * @psalm-param Closure():ISchemaWrapper $schemaClosure * @param array $options * @since 13.0.0 */ - public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options); + public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options); /** * @param IOutput $output - * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` * @psalm-param Closure():ISchemaWrapper $schemaClosure * @param array $options * @return null|ISchemaWrapper * @since 13.0.0 */ - public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options); + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options); /** * @param IOutput $output - * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` * @psalm-param Closure():ISchemaWrapper $schemaClosure * @param array $options * @since 13.0.0 */ - public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options); + public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options); } diff --git a/lib/public/Migration/SimpleMigrationStep.php b/lib/public/Migration/SimpleMigrationStep.php index e8d19f533ac..ee657cda470 100644 --- a/lib/public/Migration/SimpleMigrationStep.php +++ b/lib/public/Migration/SimpleMigrationStep.php @@ -28,12 +28,15 @@ declare(strict_types=1); */ namespace OCP\Migration; +use Closure; +use OCP\DB\ISchemaWrapper; + /** * @since 13.0.0 */ abstract class SimpleMigrationStep implements IMigrationStep { /** - * Human readable name of the migration step + * Human-readable name of the migration step * * @return string * @since 14.0.0 @@ -43,7 +46,7 @@ abstract class SimpleMigrationStep implements IMigrationStep { } /** - * Human readable description of the migration step + * Human-readable description of the migration step * * @return string * @since 14.0.0 @@ -53,16 +56,21 @@ abstract class SimpleMigrationStep implements IMigrationStep { } /** - * {@inheritDoc} - * + * @param IOutput $output + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` + * @psalm-param Closure():ISchemaWrapper $schemaClosure + * @param array $options * @since 13.0.0 */ public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) { } /** - * {@inheritDoc} - * + * @param IOutput $output + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` + * @psalm-param Closure():ISchemaWrapper $schemaClosure + * @param array $options + * @return null|ISchemaWrapper * @since 13.0.0 */ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { @@ -70,8 +78,10 @@ abstract class SimpleMigrationStep implements IMigrationStep { } /** - * {@inheritDoc} - * + * @param IOutput $output + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` + * @psalm-param Closure():ISchemaWrapper $schemaClosure + * @param array $options * @since 13.0.0 */ public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) { diff --git a/lib/public/Notification/INotification.php b/lib/public/Notification/INotification.php index 511f65955f5..0c6625e346d 100644 --- a/lib/public/Notification/INotification.php +++ b/lib/public/Notification/INotification.php @@ -121,9 +121,7 @@ interface INotification { * HTML is not allowed in the parsed subject and will be escaped * automatically by the clients. You can use the RichObjectString system * provided by the Nextcloud server to highlight important parameters via - * the setRichSubject method, but make sure, that a plain text message is - * always set via setParsedSubject, to support clients which can not handle - * rich strings. + * the setRichSubject method. * * See https://github.com/nextcloud/server/issues/1706 for more information. * @@ -146,8 +144,6 @@ interface INotification { * HTML is not allowed in the rich subject and will be escaped automatically * by the clients, but you can use the RichObjectString system provided by * the Nextcloud server to highlight important parameters. - * Also make sure, that a plain text subject is always set via - * setParsedSubject, to support clients which can not handle rich strings. * * See https://github.com/nextcloud/server/issues/1706 for more information. * @@ -198,9 +194,7 @@ interface INotification { * HTML is not allowed in the parsed message and will be escaped * automatically by the clients. You can use the RichObjectString system * provided by the Nextcloud server to highlight important parameters via - * the setRichMessage method, but make sure, that a plain text message is - * always set via setParsedMessage, to support clients which can not handle - * rich strings. + * the setRichMessage method. * * See https://github.com/nextcloud/server/issues/1706 for more information. * @@ -223,8 +217,6 @@ interface INotification { * HTML is not allowed in the rich message and will be escaped automatically * by the clients, but you can use the RichObjectString system provided by * the Nextcloud server to highlight important parameters. - * Also make sure, that a plain text message is always set via - * setParsedMessage, to support clients which can not handle rich strings. * * See https://github.com/nextcloud/server/issues/1706 for more information. * diff --git a/lib/public/Util.php b/lib/public/Util.php index 1289f8ccff4..b2b3322fe86 100644 --- a/lib/public/Util.php +++ b/lib/public/Util.php @@ -323,11 +323,11 @@ class Util { * is passed to this function * @since 5.0.0 */ - public static function getDefaultEmailAddress($user_part) { + public static function getDefaultEmailAddress(string $user_part): string { $config = \OC::$server->getConfig(); - $user_part = $config->getSystemValue('mail_from_address', $user_part); + $user_part = $config->getSystemValueString('mail_from_address', $user_part); $host_name = self::getServerHostName(); - $host_name = $config->getSystemValue('mail_domain', $host_name); + $host_name = $config->getSystemValueString('mail_domain', $host_name); $defaultEmailAddress = $user_part.'@'.$host_name; $mailer = \OC::$server->getMailer(); |