From 54992b7c2bbb32f3ee88ddac2ba110f18994335e Mon Sep 17 00:00:00 2001 From: Sami Mazouz Date: Thu, 7 Nov 2024 18:26:35 +0100 Subject: [PATCH] chore: fix tests --- framework/core/src/Frontend/Assets.php | 2 +- .../core/src/Frontend/Compiler/Source/SourceCollector.php | 2 +- framework/core/src/Http/AccessToken.php | 2 +- framework/core/src/Http/RouteHandlerFactory.php | 2 +- framework/core/src/Locale/LocaleManager.php | 2 +- framework/core/src/Mail/FlarumLogTransport.php | 2 +- framework/core/src/Post/PostRepository.php | 4 ++-- framework/core/src/User/AvatarValidator.php | 2 +- framework/core/src/User/UserRepository.php | 8 ++++---- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/framework/core/src/Frontend/Assets.php b/framework/core/src/Frontend/Assets.php index 6de2d5fdf3..b479096dd5 100644 --- a/framework/core/src/Frontend/Assets.php +++ b/framework/core/src/Frontend/Assets.php @@ -86,7 +86,7 @@ private function addSources(string $type, callable $callback): void $this->sources[$type][] = $callback; } - private function populate(CompilerInterface $compiler, string $type, string $locale = null): void + private function populate(CompilerInterface $compiler, string $type, ?string $locale = null): void { $compiler->addSources(function (SourceCollector $sources) use ($type, $locale) { foreach ($this->sources[$type] as $callback) { diff --git a/framework/core/src/Frontend/Compiler/Source/SourceCollector.php b/framework/core/src/Frontend/Compiler/Source/SourceCollector.php index 04ac3bd3f4..66cb52be4a 100644 --- a/framework/core/src/Frontend/Compiler/Source/SourceCollector.php +++ b/framework/core/src/Frontend/Compiler/Source/SourceCollector.php @@ -44,7 +44,7 @@ public function addString(Closure $callback): static return $this; } - public function addDirectory(string $directory, string $extensionId = null): static + public function addDirectory(string $directory, ?string $extensionId = null): static { $this->sources[] = $this->validateSourceType( new DirectorySource($directory, $extensionId) diff --git a/framework/core/src/Http/AccessToken.php b/framework/core/src/Http/AccessToken.php index 15f7a8c566..d54e7b6f4d 100644 --- a/framework/core/src/Http/AccessToken.php +++ b/framework/core/src/Http/AccessToken.php @@ -107,7 +107,7 @@ public static function make(int $userId): static * Update the time of last usage of a token. * If a request object is provided, the IP address and User Agent will also be logged. */ - public function touch($attribute = null, ServerRequestInterface $request = null): bool + public function touch($attribute = null, ?ServerRequestInterface $request = null): bool { $now = Carbon::now(); diff --git a/framework/core/src/Http/RouteHandlerFactory.php b/framework/core/src/Http/RouteHandlerFactory.php index 79d431e74e..64e1946fa5 100644 --- a/framework/core/src/Http/RouteHandlerFactory.php +++ b/framework/core/src/Http/RouteHandlerFactory.php @@ -71,7 +71,7 @@ public function toForum(string $content = null): Closure return $this->toFrontend('forum', $content); } - public function toAdmin(string $content = null): Closure + public function toAdmin(?string $content = null): Closure { return $this->toFrontend('admin', $content); } diff --git a/framework/core/src/Locale/LocaleManager.php b/framework/core/src/Locale/LocaleManager.php index 2bae99c86d..100943a14b 100644 --- a/framework/core/src/Locale/LocaleManager.php +++ b/framework/core/src/Locale/LocaleManager.php @@ -49,7 +49,7 @@ public function hasLocale(string $locale): bool return isset($this->locales[$locale]); } - public function addTranslations(string $locale, string $file, string $module = null): void + public function addTranslations(string $locale, string $file, ?string $module = null): void { $prefix = $module ? $module.'::' : ''; diff --git a/framework/core/src/Mail/FlarumLogTransport.php b/framework/core/src/Mail/FlarumLogTransport.php index 80f3b3c97e..8f548a87d0 100644 --- a/framework/core/src/Mail/FlarumLogTransport.php +++ b/framework/core/src/Mail/FlarumLogTransport.php @@ -19,7 +19,7 @@ class FlarumLogTransport extends LogTransport /** * {@inheritdoc} */ - public function send(RawMessage $message, Envelope $envelope = null): ?SentMessage + public function send(RawMessage $message, ?Envelope $envelope = null): ?SentMessage { $string = $message->toString(); diff --git a/framework/core/src/Post/PostRepository.php b/framework/core/src/Post/PostRepository.php index 056a056f07..6ac36c71d0 100644 --- a/framework/core/src/Post/PostRepository.php +++ b/framework/core/src/Post/PostRepository.php @@ -53,7 +53,7 @@ public function findOrFail(int $id, ?User $actor = null): Post * Find posts that match certain conditions, optionally making sure they * are visible to a certain user, and/or using other criteria. */ - public function findWhere(array $where = [], User $actor = null, array $sort = [], int $count = null, int $start = 0): Collection + public function findWhere(array $where = [], ?User $actor = null, array $sort = [], ?int $count = null, int $start = 0): Collection { $query = $this->queryVisibleTo($actor) ->where($where) @@ -110,7 +110,7 @@ public function getIndexForNumber(int $discussionId, int $number, ?User $actor = * @param int[] $ids * @return Builder */ - protected function queryIds(array $ids, User $actor = null): Builder + protected function queryIds(array $ids, ?User $actor = null): Builder { return $this->queryVisibleTo($actor)->whereIn('posts.id', $ids); } diff --git a/framework/core/src/User/AvatarValidator.php b/framework/core/src/User/AvatarValidator.php index 7865c86018..ade155ba20 100644 --- a/framework/core/src/User/AvatarValidator.php +++ b/framework/core/src/User/AvatarValidator.php @@ -90,7 +90,7 @@ protected function assertFileSize(UploadedFileInterface $file): void } } - protected function raise(string $error, array $parameters = [], string $rule = null): void + protected function raise(string $error, array $parameters = [], ?string $rule = null): void { // When we switched to intl ICU message format, the translation parameters // have become required to be in the format `{param}`. diff --git a/framework/core/src/User/UserRepository.php b/framework/core/src/User/UserRepository.php index c5a43032ad..5ae27a25d8 100644 --- a/framework/core/src/User/UserRepository.php +++ b/framework/core/src/User/UserRepository.php @@ -48,7 +48,7 @@ public function findOrFail(int|string $id, User $actor = null): Model * * @throws \Illuminate\Database\Eloquent\ModelNotFoundException */ - public function findOrFailByUsername(string $username, User $actor = null): Model + public function findOrFailByUsername(string $username, ?User $actor = null): Model { $query = $this->query()->where('username', $username); @@ -75,7 +75,7 @@ public function findByEmail(string $email): ?Model return $this->query()->where('email', $email)->first(); } - public function getIdForUsername(string $username, User $actor = null): ?int + public function getIdForUsername(string $username, ?User $actor = null): ?int { $query = $this->query()->where('username', $username); @@ -93,7 +93,7 @@ public function getIdsForUsernames(array $usernames, User $actor = null): array * Find users by matching a string of words against their username, * optionally making sure they are visible to a certain user. */ - public function getIdsForUsername(string $string, User $actor = null): array + public function getIdsForUsername(string $string, ?User $actor = null): array { $string = $this->escapeLikeString($string); @@ -107,7 +107,7 @@ public function getIdsForUsername(string $string, User $actor = null): array /** * @return Builder */ - protected function scopeVisibleTo(Builder $query, User $actor = null): Builder + protected function scopeVisibleTo(Builder $query, ?User $actor = null): Builder { if ($actor !== null) { $query->whereVisibleTo($actor);