diff --git a/apps/dav/lib/Connector/Sabre/AnonymousOptionsPlugin.php b/apps/dav/lib/Connector/Sabre/AnonymousOptionsPlugin.php index a71725af121f0..6c3600fa5eb52 100644 --- a/apps/dav/lib/Connector/Sabre/AnonymousOptionsPlugin.php +++ b/apps/dav/lib/Connector/Sabre/AnonymousOptionsPlugin.php @@ -62,7 +62,7 @@ public function isRequestInRoot($path) { * @return bool */ public function handleAnonymousOptions(RequestInterface $request, ResponseInterface $response) { - $isOffice = preg_match('/Microsoft Office/i', $request->getHeader('User-Agent')); + $isOffice = preg_match('/Microsoft Office/i', $request->getHeader('User-Agent') ?? ''); $emptyAuth = $request->getHeader('Authorization') === null || $request->getHeader('Authorization') === '' || trim($request->getHeader('Authorization')) === 'Bearer'; diff --git a/apps/dav/lib/Connector/Sabre/Auth.php b/apps/dav/lib/Connector/Sabre/Auth.php index 30a27f672dd7c..71e833809ac2d 100644 --- a/apps/dav/lib/Connector/Sabre/Auth.php +++ b/apps/dav/lib/Connector/Sabre/Auth.php @@ -242,7 +242,7 @@ private function auth(RequestInterface $request, ResponseInterface $response) { } } - if (!$this->userSession->isLoggedIn() && in_array('XMLHttpRequest', explode(',', $request->getHeader('X-Requested-With')))) { + if (!$this->userSession->isLoggedIn() && in_array('XMLHttpRequest', explode(',', $request->getHeader('X-Requested-With') ?? ''))) { // do not re-authenticate over ajax, use dummy auth name to prevent browser popup $response->addHeader('WWW-Authenticate','DummyBasic realm="' . $this->realm . '"'); $response->setStatus(401); diff --git a/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php b/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php index 9524fe59746b3..4876e9ad8f3d7 100644 --- a/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php +++ b/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php @@ -241,7 +241,7 @@ public function onReport($reportName, $report, $uri) { * * @return string files base uri */ - private function getFilesBaseUri($uri, $subPath) { + private function getFilesBaseUri(string $uri, string $subPath): string { $uri = trim($uri, '/'); $subPath = trim($subPath, '/'); if (empty($subPath)) { diff --git a/apps/dav/lib/Upload/AssemblyStream.php b/apps/dav/lib/Upload/AssemblyStream.php index 4d8f98a433227..ef6d39974c0ad 100644 --- a/apps/dav/lib/Upload/AssemblyStream.php +++ b/apps/dav/lib/Upload/AssemblyStream.php @@ -277,7 +277,7 @@ public static function wrap(array $nodes) { ]); stream_wrapper_register('assembly', self::class); try { - $wrapped = fopen('assembly://', 'r', null, $context); + $wrapped = fopen('assembly://', 'r', false, $context); } catch (\BadMethodCallException $e) { stream_wrapper_unregister('assembly'); throw $e; diff --git a/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php index 1d1329bbb3c8f..f73434b33b6b1 100644 --- a/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php @@ -229,6 +229,9 @@ public function testOnReport() { $reportTargetNode = $this->getMockBuilder(Directory::class) ->disableOriginalConstructor() ->getMock(); + $reportTargetNode->expects($this->any()) + ->method('getPath') + ->willReturn(''); $response = $this->getMockBuilder(ResponseInterface::class) ->disableOriginalConstructor() diff --git a/apps/files/tests/Controller/ApiControllerTest.php b/apps/files/tests/Controller/ApiControllerTest.php index af2d16699c1a7..73728bd6a4aaf 100644 --- a/apps/files/tests/Controller/ApiControllerTest.php +++ b/apps/files/tests/Controller/ApiControllerTest.php @@ -165,7 +165,7 @@ public function testGetThumbnailInvalidSize() { $this->assertEquals($expected, $this->apiController->getThumbnail(0, 0, '')); } - public function testGetThumbnailInvaidImage() { + public function testGetThumbnailInvalidImage() { $file = $this->createMock(File::class); $this->userFolder->method('get') ->with($this->equalTo('unknown.jpg')) @@ -184,6 +184,8 @@ public function testGetThumbnail() { ->with($this->equalTo('known.jpg')) ->willReturn($file); $preview = $this->createMock(ISimpleFile::class); + $preview->method('getName')->willReturn('my name'); + $preview->method('getMTime')->willReturn(42); $this->preview->expects($this->once()) ->method('getPreview') ->with($this->equalTo($file), 10, 10, true) diff --git a/apps/files_external/lib/Lib/Auth/AuthMechanism.php b/apps/files_external/lib/Lib/Auth/AuthMechanism.php index f676957794d81..210dd705723ef 100644 --- a/apps/files_external/lib/Lib/Auth/AuthMechanism.php +++ b/apps/files_external/lib/Lib/Auth/AuthMechanism.php @@ -90,10 +90,8 @@ public function setScheme($scheme) { /** * Serialize into JSON for client-side JS - * - * @return array */ - public function jsonSerialize() { + public function jsonSerialize(): array { $data = $this->jsonSerializeDefinition(); $data += $this->jsonSerializeIdentifier(); diff --git a/apps/files_external/lib/Lib/Backend/Backend.php b/apps/files_external/lib/Lib/Backend/Backend.php index a6e63eb30d190..021d208aed337 100644 --- a/apps/files_external/lib/Lib/Backend/Backend.php +++ b/apps/files_external/lib/Lib/Backend/Backend.php @@ -137,10 +137,8 @@ public function setLegacyAuthMechanismCallback(callable $callback) { /** * Serialize into JSON for client-side JS - * - * @return array */ - public function jsonSerialize() { + public function jsonSerialize(): array { $data = $this->jsonSerializeDefinition(); $data += $this->jsonSerializeIdentifier(); diff --git a/apps/files_external/lib/Lib/DefinitionParameter.php b/apps/files_external/lib/Lib/DefinitionParameter.php index fbfbbfd4686a6..6b081d5a089f1 100644 --- a/apps/files_external/lib/Lib/DefinitionParameter.php +++ b/apps/files_external/lib/Lib/DefinitionParameter.php @@ -167,10 +167,8 @@ public function setTooltip(string $tooltip) { /** * Serialize into JSON for client-side JS - * - * @return string */ - public function jsonSerialize() { + public function jsonSerialize(): array { return [ 'value' => $this->getText(), 'flags' => $this->getFlags(), diff --git a/apps/files_external/lib/Lib/StorageConfig.php b/apps/files_external/lib/Lib/StorageConfig.php index 97b72005018d0..26ba483b00efa 100644 --- a/apps/files_external/lib/Lib/StorageConfig.php +++ b/apps/files_external/lib/Lib/StorageConfig.php @@ -396,10 +396,8 @@ public function setType($type) { /** * Serialize config to JSON - * - * @return array */ - public function jsonSerialize() { + public function jsonSerialize(): array { $result = []; if (!is_null($this->id)) { $result['id'] = $this->id; diff --git a/apps/theming/lib/Service/JSDataService.php b/apps/theming/lib/Service/JSDataService.php index a6e5d6f8e3656..1c4d138a76468 100644 --- a/apps/theming/lib/Service/JSDataService.php +++ b/apps/theming/lib/Service/JSDataService.php @@ -50,7 +50,7 @@ public function __construct( $this->appConfig = $appConfig; } - public function jsonSerialize() { + public function jsonSerialize(): array { return [ 'name' => $this->themingDefaults->getName(), 'url' => $this->themingDefaults->getBaseUrl(), diff --git a/apps/user_status/lib/Service/JSDataService.php b/apps/user_status/lib/Service/JSDataService.php index 6d83591ab2f47..c08643ec64fbb 100644 --- a/apps/user_status/lib/Service/JSDataService.php +++ b/apps/user_status/lib/Service/JSDataService.php @@ -49,7 +49,7 @@ public function __construct(IUserSession $userSession, $this->statusService = $statusService; } - public function jsonSerialize() { + public function jsonSerialize(): array { $user = $this->userSession->getUser(); if ($user === null) { diff --git a/core/Command/Broadcast/Test.php b/core/Command/Broadcast/Test.php index 91050725e176c..86cd30e4b4c68 100644 --- a/core/Command/Broadcast/Test.php +++ b/core/Command/Broadcast/Test.php @@ -87,7 +87,7 @@ public function getUids(): array { ]; } - public function jsonSerialize() { + public function jsonSerialize(): array { return [ 'description' => 'this is a test event', ]; diff --git a/core/Controller/AvatarController.php b/core/Controller/AvatarController.php index 3b87bf15b2ffa..5acfe9cd404ae 100644 --- a/core/Controller/AvatarController.php +++ b/core/Controller/AvatarController.php @@ -283,11 +283,12 @@ public function getTmpAvatar() { $image = new \OC_Image(); $image->loadFromData($tmpAvatar); - $resp = new DataDisplayResponse($image->data(), + $resp = new DataDisplayResponse( + $image->data() ?? '', Http::STATUS_OK, ['Content-Type' => $image->mimeType()]); - $resp->setETag((string)crc32($image->data())); + $resp->setETag((string)crc32($image->data() ?? '')); $resp->cacheFor(0); $resp->setLastModified(new \DateTime('now', new \DateTimeZone('GMT'))); return $resp; diff --git a/lib/private/Accounts/Account.php b/lib/private/Accounts/Account.php index 1e4189f2b35c7..540d15cd4b9e9 100644 --- a/lib/private/Accounts/Account.php +++ b/lib/private/Accounts/Account.php @@ -104,7 +104,8 @@ public function getFilteredProperties(string $scope = null, string $verified = n return $result; } - public function jsonSerialize() { + /** @return IAccountPropertyCollection[]|IAccountProperty[] */ + public function jsonSerialize(): array { return $this->properties; } diff --git a/lib/private/Accounts/AccountProperty.php b/lib/private/Accounts/AccountProperty.php index 0e6356e9e92e6..4b7f2b0c04c2f 100644 --- a/lib/private/Accounts/AccountProperty.php +++ b/lib/private/Accounts/AccountProperty.php @@ -54,7 +54,7 @@ public function __construct(string $name, string $value, string $scope, string $ $this->verificationData = $verificationData; } - public function jsonSerialize() { + public function jsonSerialize(): array { return [ 'name' => $this->getName(), 'value' => $this->getValue(), diff --git a/lib/private/Accounts/AccountPropertyCollection.php b/lib/private/Accounts/AccountPropertyCollection.php index 3aed76d8746a9..091c5734218b4 100644 --- a/lib/private/Accounts/AccountPropertyCollection.php +++ b/lib/private/Accounts/AccountPropertyCollection.php @@ -102,7 +102,7 @@ public function removePropertyByValue(string $value): IAccountPropertyCollection return $this; } - public function jsonSerialize() { + public function jsonSerialize(): array { return [$this->collectionName => $this->properties]; } diff --git a/lib/private/AppFramework/Http/Request.php b/lib/private/AppFramework/Http/Request.php index a95fd208155cb..c67500bcaa4ed 100644 --- a/lib/private/AppFramework/Http/Request.php +++ b/lib/private/AppFramework/Http/Request.php @@ -199,6 +199,7 @@ public function offsetExists($offset): bool { * @param string $offset * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return isset($this->items['parameters'][$offset]) ? $this->items['parameters'][$offset] @@ -210,7 +211,7 @@ public function offsetGet($offset) { * @param string $offset * @param mixed $value */ - public function offsetSet($offset, $value) { + public function offsetSet($offset, $value): void { throw new \RuntimeException('You cannot change the contents of the request object'); } @@ -218,7 +219,7 @@ public function offsetSet($offset, $value) { * @see offsetExists * @param string $offset */ - public function offsetUnset($offset) { + public function offsetUnset($offset): void { throw new \RuntimeException('You cannot change the contents of the request object'); } diff --git a/lib/private/AppFramework/Utility/SimpleContainer.php b/lib/private/AppFramework/Utility/SimpleContainer.php index c38dbadf0a97d..598c66b6aba74 100644 --- a/lib/private/AppFramework/Utility/SimpleContainer.php +++ b/lib/private/AppFramework/Utility/SimpleContainer.php @@ -197,13 +197,15 @@ protected function sanitizeName($name) { /** * @deprecated 20.0.0 use \Psr\Container\ContainerInterface::has */ - public function offsetExists($id) { + public function offsetExists($id): bool { return $this->container->offsetExists($id); } /** * @deprecated 20.0.0 use \Psr\Container\ContainerInterface::get + * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($id) { return $this->container->offsetGet($id); } @@ -211,14 +213,14 @@ public function offsetGet($id) { /** * @deprecated 20.0.0 use \OCP\IContainer::registerService */ - public function offsetSet($id, $service) { + public function offsetSet($id, $service): void { $this->container->offsetSet($id, $service); } /** * @deprecated 20.0.0 */ - public function offsetUnset($offset) { + public function offsetUnset($offset): void { $this->container->offsetUnset($offset); } } diff --git a/lib/private/Authentication/Token/DefaultToken.php b/lib/private/Authentication/Token/DefaultToken.php index 5a008586a9018..b649fdbb6aff4 100644 --- a/lib/private/Authentication/Token/DefaultToken.php +++ b/lib/private/Authentication/Token/DefaultToken.php @@ -121,7 +121,7 @@ public function getPassword() { return parent::getPassword(); } - public function jsonSerialize() { + public function jsonSerialize(): array { return [ 'id' => $this->id, 'name' => $this->name, diff --git a/lib/private/Authentication/Token/PublicKeyToken.php b/lib/private/Authentication/Token/PublicKeyToken.php index 3351c767ce3bc..d060fe141032b 100644 --- a/lib/private/Authentication/Token/PublicKeyToken.php +++ b/lib/private/Authentication/Token/PublicKeyToken.php @@ -138,7 +138,7 @@ public function getPassword() { return parent::getPassword(); } - public function jsonSerialize() { + public function jsonSerialize(): array { return [ 'id' => $this->id, 'name' => $this->name, diff --git a/lib/private/Cache/CappedMemoryCache.php b/lib/private/Cache/CappedMemoryCache.php index 408c3935ffb99..584a53f0ff288 100644 --- a/lib/private/Cache/CappedMemoryCache.php +++ b/lib/private/Cache/CappedMemoryCache.php @@ -63,19 +63,23 @@ public function clear($prefix = '') { return true; } - public function offsetExists($offset) { + public function offsetExists($offset): bool { return $this->hasKey($offset); } + /** + * @return mixed + */ + #[\ReturnTypeWillChange] public function &offsetGet($offset) { return $this->cache[$offset]; } - public function offsetSet($offset, $value) { + public function offsetSet($offset, $value): void { $this->set($offset, $value); } - public function offsetUnset($offset) { + public function offsetUnset($offset): void { $this->remove($offset); } diff --git a/lib/private/Collaboration/Collaborators/UserPlugin.php b/lib/private/Collaboration/Collaborators/UserPlugin.php index 9ed94082f0d0e..1c00bb26c948e 100644 --- a/lib/private/Collaboration/Collaborators/UserPlugin.php +++ b/lib/private/Collaboration/Collaborators/UserPlugin.php @@ -178,7 +178,7 @@ public function search($search, $limit, $offset, ISearchResult $searchResult) { $this->shareeEnumerationFullMatch && $lowerSearch !== '' && (strtolower($uid) === $lowerSearch || strtolower($userDisplayName) === $lowerSearch || - strtolower($userEmail) === $lowerSearch) + strtolower($userEmail ?? '') === $lowerSearch) ) { if (strtolower($uid) === $lowerSearch) { $foundUserById = true; diff --git a/lib/private/Contacts/ContactsMenu/Actions/LinkAction.php b/lib/private/Contacts/ContactsMenu/Actions/LinkAction.php index 5acafed2fdaf5..3f917854aac8b 100644 --- a/lib/private/Contacts/ContactsMenu/Actions/LinkAction.php +++ b/lib/private/Contacts/ContactsMenu/Actions/LinkAction.php @@ -106,10 +106,7 @@ public function getAppId(): string { return $this->appId; } - /** - * @return array - */ - public function jsonSerialize() { + public function jsonSerialize(): array { return [ 'title' => $this->name, 'icon' => $this->icon, diff --git a/lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php b/lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php index c35afd0870b09..77a4a02128a65 100644 --- a/lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php +++ b/lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php @@ -414,11 +414,11 @@ public function bitwiseOr($x, int $y): IQueryFunction { * Quotes a given input parameter. * * @param mixed $input The parameter to be quoted. - * @param mixed|null $type One of the IQueryBuilder::PARAM_* constants + * @param int $type One of the IQueryBuilder::PARAM_* constants * * @return ILiteral */ - public function literal($input, $type = null): ILiteral { + public function literal($input, $type = IQueryBuilder::PARAM_STR): ILiteral { return new Literal($this->expressionBuilder->literal($input, $type)); } diff --git a/lib/private/EventDispatcher/GenericEventWrapper.php b/lib/private/EventDispatcher/GenericEventWrapper.php index 55e23d2ff7fa7..3574bc8bb8353 100644 --- a/lib/private/EventDispatcher/GenericEventWrapper.php +++ b/lib/private/EventDispatcher/GenericEventWrapper.php @@ -100,19 +100,23 @@ public function hasArgument($key) { return $this->event->hasArgument($key); } + /** + * @return mixed + */ + #[\ReturnTypeWillChange] public function offsetGet($key) { return $this->event->offsetGet($key); } - public function offsetSet($key, $value) { - return $this->event->offsetSet($key, $value); + public function offsetSet($key, $value): void { + $this->event->offsetSet($key, $value); } - public function offsetUnset($key) { - return $this->event->offsetUnset($key); + public function offsetUnset($key): void { + $this->event->offsetUnset($key); } - public function offsetExists($key) { + public function offsetExists($key): bool { return $this->event->offsetExists($key); } diff --git a/lib/private/Files/Cache/CacheEntry.php b/lib/private/Files/Cache/CacheEntry.php index 156f075c2d063..12f0273fb6e7e 100644 --- a/lib/private/Files/Cache/CacheEntry.php +++ b/lib/private/Files/Cache/CacheEntry.php @@ -37,18 +37,22 @@ public function __construct(array $data) { $this->data = $data; } - public function offsetSet($offset, $value) { + public function offsetSet($offset, $value): void { $this->data[$offset] = $value; } - public function offsetExists($offset) { + public function offsetExists($offset): bool { return isset($this->data[$offset]); } - public function offsetUnset($offset) { + public function offsetUnset($offset): void { unset($this->data[$offset]); } + /** + * @return mixed + */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { if (isset($this->data[$offset])) { return $this->data[$offset]; diff --git a/lib/private/Files/FileInfo.php b/lib/private/Files/FileInfo.php index 8a8de6e4c19bc..2f361fc051dba 100644 --- a/lib/private/Files/FileInfo.php +++ b/lib/private/Files/FileInfo.php @@ -104,18 +104,22 @@ public function __construct($path, $storage, $internalPath, $data, $mount, $owne $this->rawSize = $this->data['size'] ?? 0; } - public function offsetSet($offset, $value) { + public function offsetSet($offset, $value): void { $this->data[$offset] = $value; } - public function offsetExists($offset) { + public function offsetExists($offset): bool { return isset($this->data[$offset]); } - public function offsetUnset($offset) { + public function offsetUnset($offset): void { unset($this->data[$offset]); } + /** + * @return mixed + */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { if ($offset === 'type') { return $this->getType(); diff --git a/lib/private/Files/ObjectStore/S3Signature.php b/lib/private/Files/ObjectStore/S3Signature.php index 1e5ef6978351d..64b994bac22a5 100644 --- a/lib/private/Files/ObjectStore/S3Signature.php +++ b/lib/private/Files/ObjectStore/S3Signature.php @@ -137,7 +137,7 @@ private function prepareRequest( $modify['set_headers']['X-Amz-Security-Token'] = $token; } - return Psr7\modify_request($request, $modify); + return Psr7\Utils::modifyRequest($request, $modify); } private function signString($string, CredentialsInterface $credentials) { @@ -201,7 +201,7 @@ private function createCanonicalizedResource(RequestInterface $request) { $query = $request->getUri()->getQuery(); if ($query) { - $params = Psr7\parse_query($query); + $params = Psr7\Query::parse($query); $first = true; foreach ($this->signableQueryString as $key) { if (array_key_exists($key, $params)) { diff --git a/lib/private/Files/ObjectStore/Swift.php b/lib/private/Files/ObjectStore/Swift.php index 3607eff5b2974..a3c8d92f3d274 100644 --- a/lib/private/Files/ObjectStore/Swift.php +++ b/lib/private/Files/ObjectStore/Swift.php @@ -27,7 +27,7 @@ use GuzzleHttp\Client; use GuzzleHttp\Exception\BadResponseException; -use function GuzzleHttp\Psr7\stream_for; +use GuzzleHttp\Psr7\Utils; use Icewind\Streams\RetryWrapper; use OCP\Files\NotFoundException; use OCP\Files\ObjectStore\IObjectStore; @@ -81,13 +81,13 @@ public function writeObject($urn, $stream, string $mimetype = null) { if (filesize($tmpFile) < SWIFT_SEGMENT_SIZE) { $this->getContainer()->createObject([ 'name' => $urn, - 'stream' => stream_for($handle), + 'stream' => Utils::streamFor($handle), 'contentType' => $mimetype, ]); } else { $this->getContainer()->createLargeObject([ 'name' => $urn, - 'stream' => stream_for($handle), + 'stream' => Utils::streamFor($handle), 'segmentSize' => SWIFT_SEGMENT_SIZE, 'contentType' => $mimetype, ]); diff --git a/lib/private/FullTextSearch/Model/IndexDocument.php b/lib/private/FullTextSearch/Model/IndexDocument.php index a1648ab6e2ab1..3078f12c4653f 100644 --- a/lib/private/FullTextSearch/Model/IndexDocument.php +++ b/lib/private/FullTextSearch/Model/IndexDocument.php @@ -963,10 +963,8 @@ public function __destruct() { /** * @since 15.0.0 - * - * @return array */ - public function jsonSerialize() { + public function jsonSerialize(): array { return [ 'id' => $this->getId(), 'providerId' => $this->getProviderId(), diff --git a/lib/private/FullTextSearch/Model/SearchRequestSimpleQuery.php b/lib/private/FullTextSearch/Model/SearchRequestSimpleQuery.php index 9c9ac71efa95c..d6bfe6d91023a 100644 --- a/lib/private/FullTextSearch/Model/SearchRequestSimpleQuery.php +++ b/lib/private/FullTextSearch/Model/SearchRequestSimpleQuery.php @@ -168,10 +168,9 @@ public function addValueBool(bool $value): ISearchRequestSimpleQuery { /** - * @return array|mixed * @since 17.0.0 */ - public function jsonSerialize() { + public function jsonSerialize(): array { return [ 'type' => $this->getType(), 'field' => $this->getField(), diff --git a/lib/private/IntegrityCheck/Iterator/ExcludeFileByNameFilterIterator.php b/lib/private/IntegrityCheck/Iterator/ExcludeFileByNameFilterIterator.php index aea1ad6c3e9de..6d26a40aef435 100644 --- a/lib/private/IntegrityCheck/Iterator/ExcludeFileByNameFilterIterator.php +++ b/lib/private/IntegrityCheck/Iterator/ExcludeFileByNameFilterIterator.php @@ -59,10 +59,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. ]; - /** - * @return bool - */ - public function accept() { + 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 fcdd3e3067ce7..120791f5b035c 100644 --- a/lib/private/IntegrityCheck/Iterator/ExcludeFoldersByPathFilterIterator.php +++ b/lib/private/IntegrityCheck/Iterator/ExcludeFoldersByPathFilterIterator.php @@ -59,10 +59,7 @@ public function __construct(\RecursiveIterator $iterator, $root = '') { $this->excludedFolders = array_merge($excludedFolders, $appFolders); } - /** - * @return bool - */ - public function accept() { + public function accept(): bool { return !\in_array( $this->current()->getPathName(), $this->excludedFolders, diff --git a/lib/private/L10N/L10NString.php b/lib/private/L10N/L10NString.php index 33ccc4b140964..de4bc38d7442a 100644 --- a/lib/private/L10N/L10NString.php +++ b/lib/private/L10N/L10NString.php @@ -82,11 +82,7 @@ public function __toString(): string { return vsprintf($text, $this->parameters); } - - /** - * @return string - */ - public function jsonSerialize() { + public function jsonSerialize(): string { return $this->__toString(); } } diff --git a/lib/private/L10N/LanguageIterator.php b/lib/private/L10N/LanguageIterator.php index c48a27fb6ce09..4a76667caf24b 100644 --- a/lib/private/L10N/LanguageIterator.php +++ b/lib/private/L10N/LanguageIterator.php @@ -45,7 +45,7 @@ public function __construct(IUser $user, IConfig $config) { /** * Rewind the Iterator to the first element */ - public function rewind() { + public function rewind(): void { $this->i = 0; } @@ -112,7 +112,7 @@ public function current(): string { * * @since 14.0.0 */ - public function next() { + public function next(): void { ++$this->i; } diff --git a/lib/private/Log/LogDetails.php b/lib/private/Log/LogDetails.php index 87ce0396594f9..3353ea3f4cc3d 100644 --- a/lib/private/Log/LogDetails.php +++ b/lib/private/Log/LogDetails.php @@ -46,7 +46,7 @@ public function logDetails(string $app, $message, int $level): array { } $time = \DateTime::createFromFormat("U.u", number_format(microtime(true), 4, ".", "")); if ($time === false) { - $time = new \DateTime(null, $timezone); + $time = new \DateTime('now', $timezone); } else { // apply timezone if $time is created from UNIX timestamp $time->setTimezone($timezone); diff --git a/lib/private/Memcache/Cache.php b/lib/private/Memcache/Cache.php index 95213c1684972..1d54a705098e8 100644 --- a/lib/private/Memcache/Cache.php +++ b/lib/private/Memcache/Cache.php @@ -78,19 +78,23 @@ abstract public function clear($prefix = ''); //implement the ArrayAccess interface - public function offsetExists($offset) { + public function offsetExists($offset): bool { return $this->hasKey($offset); } - public function offsetSet($offset, $value) { + public function offsetSet($offset, $value): void { $this->set($offset, $value); } + /** + * @return mixed + */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->get($offset); } - public function offsetUnset($offset) { + public function offsetUnset($offset): void { $this->remove($offset); } } diff --git a/lib/private/Session/CryptoSessionData.php b/lib/private/Session/CryptoSessionData.php index 94ad8f90dcfda..2e3bd46da5b4b 100644 --- a/lib/private/Session/CryptoSessionData.php +++ b/lib/private/Session/CryptoSessionData.php @@ -195,6 +195,7 @@ public function offsetExists($offset): bool { * @param mixed $offset * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->get($offset); } @@ -203,14 +204,14 @@ public function offsetGet($offset) { * @param mixed $offset * @param mixed $value */ - public function offsetSet($offset, $value) { + public function offsetSet($offset, $value): void { $this->set($offset, $value); } /** * @param mixed $offset */ - public function offsetUnset($offset) { + public function offsetUnset($offset): void { $this->remove($offset); } } diff --git a/lib/private/Session/Session.php b/lib/private/Session/Session.php index b9497983fbb07..affba322bec70 100644 --- a/lib/private/Session/Session.php +++ b/lib/private/Session/Session.php @@ -55,6 +55,7 @@ public function offsetExists($offset): bool { * @param mixed $offset * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->get($offset); } @@ -63,14 +64,14 @@ public function offsetGet($offset) { * @param mixed $offset * @param mixed $value */ - public function offsetSet($offset, $value) { + public function offsetSet($offset, $value): void { $this->set($offset, $value); } /** * @param mixed $offset */ - public function offsetUnset($offset) { + public function offsetUnset($offset): void { $this->remove($offset); } diff --git a/lib/private/Setup.php b/lib/private/Setup.php index f1ad04671f98f..589bbb273c06d 100644 --- a/lib/private/Setup.php +++ b/lib/private/Setup.php @@ -480,7 +480,7 @@ private static function findWebRoot(SystemConfig $config): string { if (!filter_var($webRoot, FILTER_VALIDATE_URL)) { throw new InvalidArgumentException('invalid value for overwrite.cli.url'); } - $webRoot = rtrim(parse_url($webRoot, PHP_URL_PATH), '/'); + $webRoot = rtrim((parse_url($webRoot, PHP_URL_PATH) ?? ''), '/'); } else { $webRoot = !empty(\OC::$WEBROOT) ? \OC::$WEBROOT : '/'; } diff --git a/lib/private/Share20/DefaultShareProvider.php b/lib/private/Share20/DefaultShareProvider.php index 85655c4e3795c..a6a8bdb9698f8 100644 --- a/lib/private/Share20/DefaultShareProvider.php +++ b/lib/private/Share20/DefaultShareProvider.php @@ -1363,7 +1363,7 @@ protected function filterSharesOfUser(array $shares) { $best = []; $bestDepth = 0; foreach ($shares as $id => $share) { - $depth = substr_count($share['file_target'], '/'); + $depth = substr_count(($share['file_target'] ?? ''), '/'); if (empty($best) || $depth < $bestDepth) { $bestDepth = $depth; $best = [ diff --git a/lib/private/User/Database.php b/lib/private/User/Database.php index 5dfc74163a795..81094d4d8af72 100644 --- a/lib/private/User/Database.php +++ b/lib/private/User/Database.php @@ -386,13 +386,14 @@ private function loadUser($uid) { $row = $result->fetch(); $result->closeCursor(); - $this->cache[$uid] = false; - // "uid" is primary key, so there can only be a single result if ($row !== false) { - $this->cache[$uid]['uid'] = (string)$row['uid']; - $this->cache[$uid]['displayname'] = (string)$row['displayname']; + $this->cache[$uid] = [ + 'uid' => (string)$row['uid'], + 'displayname' => (string)$row['displayname'], + ]; } else { + $this->cache[$uid] = false; return false; } } diff --git a/lib/public/AppFramework/Services/InitialStateProvider.php b/lib/public/AppFramework/Services/InitialStateProvider.php index c317fad3f5de3..dbc4865379242 100644 --- a/lib/public/AppFramework/Services/InitialStateProvider.php +++ b/lib/public/AppFramework/Services/InitialStateProvider.php @@ -42,7 +42,9 @@ abstract public function getData(); /** * @since 21.0.0 + * @return mixed */ + #[\ReturnTypeWillChange] final public function jsonSerialize() { return $this->getData(); } diff --git a/lib/public/DB/QueryBuilder/IExpressionBuilder.php b/lib/public/DB/QueryBuilder/IExpressionBuilder.php index 77701240d5174..4758fd0620854 100644 --- a/lib/public/DB/QueryBuilder/IExpressionBuilder.php +++ b/lib/public/DB/QueryBuilder/IExpressionBuilder.php @@ -418,7 +418,7 @@ public function bitwiseOr($x, int $y): IQueryFunction; * Quotes a given input parameter. * * @param mixed $input The parameter to be quoted. - * @param mixed|null $type One of the IQueryBuilder::PARAM_* constants + * @param int $type One of the IQueryBuilder::PARAM_* constants * * @return ILiteral * @since 8.2.0 @@ -426,7 +426,7 @@ public function bitwiseOr($x, int $y): IQueryFunction; * @psalm-taint-sink sql $input * @psalm-taint-sink sql $type */ - public function literal($input, $type = null): ILiteral; + public function literal($input, $type = IQueryBuilder::PARAM_STR): ILiteral; /** * Returns a IQueryFunction that casts the column to the given type diff --git a/lib/public/Dashboard/Model/WidgetSetting.php b/lib/public/Dashboard/Model/WidgetSetting.php index c456c63f4f583..fce59a4350b64 100644 --- a/lib/public/Dashboard/Model/WidgetSetting.php +++ b/lib/public/Dashboard/Model/WidgetSetting.php @@ -230,10 +230,8 @@ public function getDefault(): string { /** * @since 15.0.0 * @deprecated 20.0.0 - * - * @return array */ - public function jsonSerialize() { + public function jsonSerialize(): array { return [ 'name' => $this->getName(), 'title' => $this->getTitle(), diff --git a/lib/public/Dashboard/Model/WidgetSetup.php b/lib/public/Dashboard/Model/WidgetSetup.php index 1cc8d9ff561bb..f3e09dcc71b1b 100644 --- a/lib/public/Dashboard/Model/WidgetSetup.php +++ b/lib/public/Dashboard/Model/WidgetSetup.php @@ -261,10 +261,8 @@ public function setDefaultSettings(array $settings): WidgetSetup { /** * @since 15.0.0 * @deprecated 20.0.0 - * - * @return array */ - public function jsonSerialize() { + public function jsonSerialize(): array { return [ 'size' => $this->getSizes(), 'menu' => $this->getMenuEntries(), diff --git a/lib/public/Dashboard/Model/WidgetTemplate.php b/lib/public/Dashboard/Model/WidgetTemplate.php index e6f9742fed7a1..3521960c303c0 100644 --- a/lib/public/Dashboard/Model/WidgetTemplate.php +++ b/lib/public/Dashboard/Model/WidgetTemplate.php @@ -312,10 +312,8 @@ public function getSetting(string $key): WidgetSetting { /** * @since 15.0.0 * @deprecated 20.0.0 - * - * @return array */ - public function jsonSerialize() { + public function jsonSerialize(): array { return [ 'icon' => $this->getIcon(), 'css' => $this->getCss(), diff --git a/lib/public/DirectEditing/ATemplate.php b/lib/public/DirectEditing/ATemplate.php index c38fc898dab43..53aff0d40ffea 100644 --- a/lib/public/DirectEditing/ATemplate.php +++ b/lib/public/DirectEditing/ATemplate.php @@ -57,9 +57,8 @@ abstract public function getPreview(): string; /** * @since 18.0.0 - * @return array|mixed */ - public function jsonSerialize() { + public function jsonSerialize(): array { return [ 'id' => $this->getId(), 'title' => $this->getTitle(), diff --git a/lib/public/EventDispatcher/GenericEvent.php b/lib/public/EventDispatcher/GenericEvent.php index e78ae1827a16c..1ba1cc6da14f7 100644 --- a/lib/public/EventDispatcher/GenericEvent.php +++ b/lib/public/EventDispatcher/GenericEvent.php @@ -156,7 +156,9 @@ public function offsetExists($offset): bool { * @link https://php.net/manual/en/arrayaccess.offsetget.php * @since 18.0.0 * @deprecated 22.0.0 + * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->arguments[$offset]; } diff --git a/lib/public/Files/Template/Template.php b/lib/public/Files/Template/Template.php index 50d8b406be9c2..d71ef3b3655d2 100644 --- a/lib/public/Files/Template/Template.php +++ b/lib/public/Files/Template/Template.php @@ -69,7 +69,7 @@ public function setHasPreview(bool $hasPreview): void { /** * @since 21.0.0 */ - public function jsonSerialize() { + public function jsonSerialize(): array { return [ 'templateType' => $this->templateType, 'templateId' => $this->templateId, diff --git a/lib/public/Files/Template/TemplateFileCreator.php b/lib/public/Files/Template/TemplateFileCreator.php index 7be45e68ef9f0..26edf585869da 100644 --- a/lib/public/Files/Template/TemplateFileCreator.php +++ b/lib/public/Files/Template/TemplateFileCreator.php @@ -106,7 +106,7 @@ public function getOrder(): int { /** * @since 21.0.0 */ - public function jsonSerialize() { + public function jsonSerialize(): array { return [ 'app' => $this->appId, 'label' => $this->actionName, diff --git a/lib/public/L10N/ILanguageIterator.php b/lib/public/L10N/ILanguageIterator.php index 882c8bc6f9e6b..534d4229b1c75 100644 --- a/lib/public/L10N/ILanguageIterator.php +++ b/lib/public/L10N/ILanguageIterator.php @@ -53,7 +53,9 @@ public function current(): string; * Move forward to next element * * @since 14.0.0 + * @return void */ + #[\ReturnTypeWillChange] public function next(); /** diff --git a/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php b/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php index 02cc824ee0c88..fc916ad40995c 100644 --- a/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php +++ b/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php @@ -74,9 +74,12 @@ protected function setUp(): void { $this->outputInterface = $this->getMockBuilder(OutputInterface::class)->getMock(); $this->userInterface = $this->getMockBuilder(UserInterface::class)->getMock(); - $outputFormatterInterface = $this->getMockBuilder(OutputFormatterInterface::class)->getMock(); + /* We need format method to return a string */ + $outputFormatter = $this->createMock(OutputFormatterInterface::class); + $outputFormatter->method('format')->willReturnArgument(0); + $this->outputInterface->expects($this->any())->method('getFormatter') - ->willReturn($outputFormatterInterface); + ->willReturn($outputFormatter); $this->changeKeyStorageRoot = new ChangeKeyStorageRoot( $this->view, diff --git a/tests/Core/Command/Log/FileTest.php b/tests/Core/Command/Log/FileTest.php index 1a8a86759f53e..103888de287a7 100644 --- a/tests/Core/Command/Log/FileTest.php +++ b/tests/Core/Command/Log/FileTest.php @@ -51,6 +51,7 @@ protected function setUp(): void { } public function testEnable() { + $this->config->method('getSystemValue')->willReturnArgument(1); $this->consoleInput->method('getOption') ->willReturnMap([ ['enable', 'true'] @@ -63,6 +64,7 @@ public function testEnable() { } public function testChangeFile() { + $this->config->method('getSystemValue')->willReturnArgument(1); $this->consoleInput->method('getOption') ->willReturnMap([ ['file', '/foo/bar/file.log'] @@ -87,6 +89,7 @@ public function changeRotateSizeProvider() { * @dataProvider changeRotateSizeProvider */ public function testChangeRotateSize($optionValue, $configValue) { + $this->config->method('getSystemValue')->willReturnArgument(1); $this->consoleInput->method('getOption') ->willReturnMap([ ['rotate-size', $optionValue] diff --git a/tests/Core/Command/Preview/RepairTest.php b/tests/Core/Command/Preview/RepairTest.php index c37e57f848c66..a6591745817e6 100644 --- a/tests/Core/Command/Preview/RepairTest.php +++ b/tests/Core/Command/Preview/RepairTest.php @@ -68,9 +68,14 @@ protected function setUp(): void { $this->output->expects($this->any()) ->method('section') ->willReturn($this->output); + + /* We need format method to return a string */ + $outputFormatter = $this->createMock(OutputFormatterInterface::class); + $outputFormatter->method('format')->willReturnArgument(0); + $this->output->expects($this->any()) ->method('getFormatter') - ->willReturn($this->getMockBuilder(OutputFormatterInterface::class)->getMock()); + ->willReturn($outputFormatter); $this->output->expects($this->any()) ->method('writeln') ->willReturnCallback(function ($line) use ($self) { diff --git a/tests/Core/Controller/AvatarControllerTest.php b/tests/Core/Controller/AvatarControllerTest.php index d6c4ea6217cdf..35d89c24a450a 100644 --- a/tests/Core/Controller/AvatarControllerTest.php +++ b/tests/Core/Controller/AvatarControllerTest.php @@ -119,6 +119,8 @@ protected function setUp(): void { $this->avatarFile->method('getContent')->willReturn('image data'); $this->avatarFile->method('getMimeType')->willReturn('image type'); $this->avatarFile->method('getEtag')->willReturn('my etag'); + $this->avatarFile->method('getName')->willReturn('my name'); + $this->avatarFile->method('getMTime')->willReturn(42); } protected function tearDown(): void { @@ -290,7 +292,7 @@ public function testPostAvatarNoPathOrImage() { */ public function testPostAvatarFile() { //Create temp file - $fileName = tempnam(null, "avatarTest"); + $fileName = tempnam('', "avatarTest"); $copyRes = copy(\OC::$SERVERROOT.'/tests/data/testimage.jpg', $fileName); $this->assertTrue($copyRes); @@ -328,7 +330,7 @@ public function testPostAvatarInvalidFile() { */ public function testPostAvatarFileGif() { //Create temp file - $fileName = tempnam(null, "avatarTest"); + $fileName = tempnam('', "avatarTest"); $copyRes = copy(\OC::$SERVERROOT.'/tests/data/testimage.gif', $fileName); $this->assertTrue($copyRes); diff --git a/tests/Core/Controller/CssControllerTest.php b/tests/Core/Controller/CssControllerTest.php index 1179bc0c07074..d2a791ec1b0e7 100644 --- a/tests/Core/Controller/CssControllerTest.php +++ b/tests/Core/Controller/CssControllerTest.php @@ -102,6 +102,8 @@ public function testNoCssFile() { public function testGetFile() { $folder = $this->createMock(ISimpleFolder::class); $file = $this->createMock(ISimpleFile::class); + $file->method('getName')->willReturn('my name'); + $file->method('getMTime')->willReturn(42); $this->appData->method('getFolder') ->with('myapp') ->willReturn($folder); @@ -125,6 +127,8 @@ public function testGetFile() { public function testGetGzipFile() { $folder = $this->createMock(ISimpleFolder::class); $gzipFile = $this->createMock(ISimpleFile::class); + $gzipFile->method('getName')->willReturn('my name'); + $gzipFile->method('getMTime')->willReturn(42); $this->appData->method('getFolder') ->with('myapp') ->willReturn($folder); @@ -153,6 +157,8 @@ public function testGetGzipFile() { public function testGetGzipFileNotFound() { $folder = $this->createMock(ISimpleFolder::class); $file = $this->createMock(ISimpleFile::class); + $file->method('getName')->willReturn('my name'); + $file->method('getMTime')->willReturn(42); $this->appData->method('getFolder') ->with('myapp') ->willReturn($folder); diff --git a/tests/Core/Controller/GuestAvatarControllerTest.php b/tests/Core/Controller/GuestAvatarControllerTest.php index 8870faac4c7a1..e14a5416c4995 100644 --- a/tests/Core/Controller/GuestAvatarControllerTest.php +++ b/tests/Core/Controller/GuestAvatarControllerTest.php @@ -56,6 +56,8 @@ protected function setUp(): void { $this->avatar = $this->getMockBuilder(IAvatar::class)->getMock(); $this->avatarManager = $this->getMockBuilder(IAvatarManager::class)->getMock(); $this->file = $this->getMockBuilder(ISimpleFile::class)->getMock(); + $this->file->method('getName')->willReturn('my name'); + $this->file->method('getMTime')->willReturn(42); $this->guestAvatarController = new GuestAvatarController( 'core', $this->request, diff --git a/tests/Core/Controller/JsControllerTest.php b/tests/Core/Controller/JsControllerTest.php index 01228a6a93e7e..3f76e19efc922 100644 --- a/tests/Core/Controller/JsControllerTest.php +++ b/tests/Core/Controller/JsControllerTest.php @@ -102,6 +102,8 @@ public function testNoCssFile() { public function testGetFile() { $folder = $this->createMock(ISimpleFolder::class); $file = $this->createMock(ISimpleFile::class); + $file->method('getName')->willReturn('my name'); + $file->method('getMTime')->willReturn(42); $this->appData->method('getFolder') ->with('myapp') ->willReturn($folder); @@ -125,6 +127,8 @@ public function testGetFile() { public function testGetGzipFile() { $folder = $this->createMock(ISimpleFolder::class); $gzipFile = $this->createMock(ISimpleFile::class); + $gzipFile->method('getName')->willReturn('my name'); + $gzipFile->method('getMTime')->willReturn(42); $this->appData->method('getFolder') ->with('myapp') ->willReturn($folder); @@ -153,6 +157,8 @@ public function testGetGzipFile() { public function testGetGzipFileNotFound() { $folder = $this->createMock(ISimpleFolder::class); $file = $this->createMock(ISimpleFile::class); + $file->method('getName')->willReturn('my name'); + $file->method('getMTime')->willReturn(42); $this->appData->method('getFolder') ->with('myapp') ->willReturn($folder); diff --git a/tests/Core/Controller/PreviewControllerTest.php b/tests/Core/Controller/PreviewControllerTest.php index e1d1529c655f5..704ddade7a420 100644 --- a/tests/Core/Controller/PreviewControllerTest.php +++ b/tests/Core/Controller/PreviewControllerTest.php @@ -212,6 +212,8 @@ public function testValidPreview() { ->willReturn(true); $preview = $this->createMock(ISimpleFile::class); + $preview->method('getName')->willReturn('my name'); + $preview->method('getMTime')->willReturn(42); $this->previewManager->method('getPreview') ->with($this->equalTo($file), 10, 10, false, $this->equalTo('myMode')) ->willReturn($preview); diff --git a/tests/lib/AppFramework/Http/DispatcherTest.php b/tests/lib/AppFramework/Http/DispatcherTest.php index 966e49effcb87..92b772dbe3136 100644 --- a/tests/lib/AppFramework/Http/DispatcherTest.php +++ b/tests/lib/AppFramework/Http/DispatcherTest.php @@ -148,7 +148,7 @@ protected function setUp(): void { $this->response = $this->createMock(Response::class); - $this->lastModified = new \DateTime(null, new \DateTimeZone('GMT')); + $this->lastModified = new \DateTime('now', new \DateTimeZone('GMT')); $this->etag = 'hi'; } diff --git a/tests/lib/AppFramework/Http/ResponseTest.php b/tests/lib/AppFramework/Http/ResponseTest.php index 0ef128433cd6f..97a1ee25588db 100644 --- a/tests/lib/AppFramework/Http/ResponseTest.php +++ b/tests/lib/AppFramework/Http/ResponseTest.php @@ -216,7 +216,7 @@ public function testGetEtag() { public function testGetLastModified() { - $lastModified = new \DateTime(null, new \DateTimeZone('GMT')); + $lastModified = new \DateTime('now', new \DateTimeZone('GMT')); $lastModified->setTimestamp(1); $this->childResponse->setLastModified($lastModified); $this->assertEquals($lastModified, $this->childResponse->getLastModified()); @@ -252,7 +252,7 @@ public function testCacheSeconds() { public function testEtagLastModifiedHeaders() { - $lastModified = new \DateTime(null, new \DateTimeZone('GMT')); + $lastModified = new \DateTime('now', new \DateTimeZone('GMT')); $lastModified->setTimestamp(1); $this->childResponse->setLastModified($lastModified); $headers = $this->childResponse->getHeaders(); @@ -260,7 +260,7 @@ public function testEtagLastModifiedHeaders() { } public function testChainability() { - $lastModified = new \DateTime(null, new \DateTimeZone('GMT')); + $lastModified = new \DateTime('now', new \DateTimeZone('GMT')); $lastModified->setTimestamp(1); $this->childResponse->setEtag('hi') diff --git a/tests/lib/Authentication/Listeners/RemoteWipeActivityListenerTest.php b/tests/lib/Authentication/Listeners/RemoteWipeActivityListenerTest.php index 6409ff2dc3543..a5038dd23b23c 100644 --- a/tests/lib/Authentication/Listeners/RemoteWipeActivityListenerTest.php +++ b/tests/lib/Authentication/Listeners/RemoteWipeActivityListenerTest.php @@ -37,7 +37,7 @@ use Psr\Log\LoggerInterface; use Test\TestCase; -class RemoteWipeActivityListenerTests extends TestCase { +class RemoteWipeActivityListenerTest extends TestCase { /** @var IActivityManager|MockObject */ private $activityManager; diff --git a/tests/lib/Authentication/Listeners/RemoteWipeNotificationsListenerTest.php b/tests/lib/Authentication/Listeners/RemoteWipeNotificationsListenerTest.php index 1e03a3444041c..ef5545438c2d0 100644 --- a/tests/lib/Authentication/Listeners/RemoteWipeNotificationsListenerTest.php +++ b/tests/lib/Authentication/Listeners/RemoteWipeNotificationsListenerTest.php @@ -38,7 +38,7 @@ use PHPUnit\Framework\MockObject\MockObject; use Test\TestCase; -class RemoteWipeNotificationListenerTests extends TestCase { +class RemoteWipeNotificationsListenerTest extends TestCase { /** @var INotificationManager|MockObject */ private $notificationManager; diff --git a/tests/lib/Encryption/DecryptAllTest.php b/tests/lib/Encryption/DecryptAllTest.php index dc7c40f0fe2b7..90ff045a9b9a0 100644 --- a/tests/lib/Encryption/DecryptAllTest.php +++ b/tests/lib/Encryption/DecryptAllTest.php @@ -81,8 +81,12 @@ protected function setUp(): void { $this->userInterface = $this->getMockBuilder(UserInterface::class) ->disableOriginalConstructor()->getMock(); + /* We need format method to return a string */ + $outputFormatter = $this->createMock(OutputFormatterInterface::class); + $outputFormatter->method('format')->willReturn('foo'); + $this->outputInterface->expects($this->any())->method('getFormatter') - ->willReturn($this->createMock(OutputFormatterInterface::class)); + ->willReturn($outputFormatter); $this->instance = new DecryptAll($this->encryptionManager, $this->userManager, $this->view); @@ -298,10 +302,15 @@ function ($path) { ->method('decryptFile') ->with('/user1/files/foo/subfile'); + + /* We need format method to return a string */ + $outputFormatter = $this->createMock(OutputFormatterInterface::class); + $outputFormatter->method('format')->willReturn('foo'); + $output = $this->createMock(OutputInterface::class); $output->expects($this->any()) ->method('getFormatter') - ->willReturn($this->createMock(OutputFormatterInterface::class)); + ->willReturn($outputFormatter); $progressBar = new ProgressBar($output); $this->invokePrivate($instance, 'decryptUsersFiles', ['user1', $progressBar, '']); diff --git a/tests/lib/Files/Config/UserMountCacheTest.php b/tests/lib/Files/Config/UserMountCacheTest.php index 4ee0f7304401e..321ed2196fde5 100644 --- a/tests/lib/Files/Config/UserMountCacheTest.php +++ b/tests/lib/Files/Config/UserMountCacheTest.php @@ -47,7 +47,18 @@ class UserMountCacheTest extends TestCase { protected function setUp(): void { $this->fileIds = []; $this->connection = \OC::$server->getDatabaseConnection(); - $this->userManager = new Manager($this->createMock(IConfig::class), $this->createMock(EventDispatcherInterface::class), $this->createMock(ICacheFactory::class), $this->createMock(IEventDispatcher::class)); + $config = $this->getMockBuilder(IConfig::class) + ->disableOriginalConstructor() + ->getMock(); + $config + ->expects($this->any()) + ->method('getUserValue') + ->willReturnArgument(3); + $config + ->expects($this->any()) + ->method('getAppValue') + ->willReturnArgument(2); + $this->userManager = new Manager($config, $this->createMock(EventDispatcherInterface::class), $this->createMock(ICacheFactory::class), $this->createMock(IEventDispatcher::class)); $userBackend = new Dummy(); $userBackend->createUser('u1', ''); $userBackend->createUser('u2', ''); diff --git a/tests/lib/Files/Node/FolderTest.php b/tests/lib/Files/Node/FolderTest.php index 94bcac4aa0092..067f728854454 100644 --- a/tests/lib/Files/Node/FolderTest.php +++ b/tests/lib/Files/Node/FolderTest.php @@ -418,7 +418,7 @@ public function testSearchSubStorages() { $subStorage = $this->createMock(Storage::class); $subStorage->method('getId')->willReturn('test::2'); $subCache = new Cache($subStorage); - $subMount = $this->getMockBuilder(MountPoint::class)->setConstructorArgs([null, ''])->getMock(); + $subMount = $this->getMockBuilder(MountPoint::class)->setConstructorArgs([Temporary::class, ''])->getMock(); $mount = $this->createMock(IMountPoint::class); $mount->method('getStorage') @@ -954,11 +954,11 @@ public function testSearchSubStoragesLimitOffset(int $offset, int $limit, array $subStorage1 = $this->createMock(Storage::class); $subStorage1->method('getId')->willReturn('test::2'); $subCache1 = new Cache($subStorage1); - $subMount1 = $this->getMockBuilder(MountPoint::class)->setConstructorArgs([null, ''])->getMock(); + $subMount1 = $this->getMockBuilder(MountPoint::class)->setConstructorArgs([Temporary::class, ''])->getMock(); $subStorage2 = $this->createMock(Storage::class); $subStorage2->method('getId')->willReturn('test::3'); $subCache2 = new Cache($subStorage2); - $subMount2 = $this->getMockBuilder(MountPoint::class)->setConstructorArgs([null, ''])->getMock(); + $subMount2 = $this->getMockBuilder(MountPoint::class)->setConstructorArgs([Temporary::class, ''])->getMock(); $mount = $this->createMock(IMountPoint::class); $mount->method('getStorage') diff --git a/tests/lib/Http/Client/ResponseTest.php b/tests/lib/Http/Client/ResponseTest.php index f8f520d6a7389..1384e4e732c05 100644 --- a/tests/lib/Http/Client/ResponseTest.php +++ b/tests/lib/Http/Client/ResponseTest.php @@ -9,7 +9,7 @@ namespace Test\Http\Client; use GuzzleHttp\Psr7\Response as GuzzleResponse; -use function GuzzleHttp\Psr7\stream_for; +use GuzzleHttp\Psr7\Utils; use OC\Http\Client\Response; /** @@ -25,7 +25,7 @@ protected function setUp(): void { } public function testGetBody() { - $response = new Response($this->guzzleResponse->withBody(stream_for('MyResponse'))); + $response = new Response($this->guzzleResponse->withBody(Utils::streamFor('MyResponse'))); $this->assertSame('MyResponse', $response->getBody()); } diff --git a/tests/lib/InitialStateServiceTest.php b/tests/lib/InitialStateServiceTest.php index 2a23774baf158..db4c98b20cf3d 100644 --- a/tests/lib/InitialStateServiceTest.php +++ b/tests/lib/InitialStateServiceTest.php @@ -54,7 +54,7 @@ public function staticData() { [23], [2.3], [new class implements JsonSerializable { - public function jsonSerialize() { + public function jsonSerialize(): int { return 3; } }], diff --git a/tests/lib/TempManagerTest.php b/tests/lib/TempManagerTest.php index 5df0e68d4fabe..fd4ef8e232465 100644 --- a/tests/lib/TempManagerTest.php +++ b/tests/lib/TempManagerTest.php @@ -26,7 +26,9 @@ protected function setUp(): void { } protected function tearDown(): void { - \OC_Helper::rmdirr($this->baseDir); + if ($this->baseDir !== null) { + \OC_Helper::rmdirr($this->baseDir); + } $this->baseDir = null; parent::tearDown(); } diff --git a/tests/lib/User/ManagerTest.php b/tests/lib/User/ManagerTest.php index cfdecba9803f3..51a739994a66d 100644 --- a/tests/lib/User/ManagerTest.php +++ b/tests/lib/User/ManagerTest.php @@ -667,7 +667,19 @@ public function testCallForSeenUsers() { } public function testDeleteUser() { - $manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->cacheFactory, $this->eventDispatcher); + $config = $this->getMockBuilder(AllConfig::class) + ->disableOriginalConstructor() + ->getMock(); + $config + ->expects($this->any()) + ->method('getUserValue') + ->willReturnArgument(3); + $config + ->expects($this->any()) + ->method('getAppValue') + ->willReturnArgument(2); + + $manager = new \OC\User\Manager($config, $this->oldDispatcher, $this->cacheFactory, $this->eventDispatcher); $backend = new \Test\Util\User\Dummy(); $manager->registerBackend($backend);