From 5978571ef8a2d26d4d11b5a5a2f20f9be9fa6527 Mon Sep 17 00:00:00 2001 From: Sami Mazouz Date: Thu, 7 Nov 2024 17:39:30 +0100 Subject: [PATCH] chore: fix tests --- extensions/akismet/tests/phpunit.integration.xml | 2 +- extensions/akismet/tests/phpunit.unit.xml | 2 +- extensions/approval/tests/phpunit.integration.xml | 2 +- extensions/approval/tests/phpunit.unit.xml | 2 +- extensions/flags/tests/phpunit.integration.xml | 2 +- extensions/flags/tests/phpunit.unit.xml | 2 +- .../likes/tests/integration/api/LikePostTest.php | 6 +++--- extensions/likes/tests/phpunit.integration.xml | 2 +- extensions/likes/tests/phpunit.unit.xml | 2 +- extensions/lock/src/Post/DiscussionLockedPost.php | 2 +- .../mentions/src/Formatter/FormatTagMentions.php | 2 +- extensions/mentions/tests/phpunit.integration.xml | 2 +- extensions/mentions/tests/phpunit.unit.xml | 2 +- extensions/messages/tests/phpunit.integration.xml | 2 +- extensions/messages/tests/phpunit.unit.xml | 2 +- extensions/nicknames/tests/phpunit.integration.xml | 2 +- extensions/nicknames/tests/phpunit.unit.xml | 2 +- .../tests/integration/SetupComposer.php | 2 +- .../package-manager/tests/phpunit.integration.xml | 2 +- extensions/package-manager/tests/phpunit.unit.xml | 2 +- extensions/statistics/tests/phpunit.integration.xml | 2 +- extensions/statistics/tests/phpunit.unit.xml | 2 +- extensions/sticky/src/Post/DiscussionStickiedPost.php | 2 +- extensions/sticky/tests/phpunit.integration.xml | 2 +- extensions/sticky/tests/phpunit.unit.xml | 2 +- .../subscriptions/tests/phpunit.integration.xml | 2 +- extensions/subscriptions/tests/phpunit.unit.xml | 2 +- extensions/suspend/tests/phpunit.integration.xml | 2 +- extensions/suspend/tests/phpunit.unit.xml | 2 +- extensions/tags/src/Post/DiscussionTaggedPost.php | 2 +- extensions/tags/src/Tag.php | 2 +- extensions/tags/src/TagRepository.php | 6 +++--- extensions/tags/tests/phpunit.integration.xml | 2 +- extensions/tags/tests/phpunit.unit.xml | 2 +- .../src/Database/Exception/MigrationKeyMissing.php | 2 +- framework/core/src/Discussion/Discussion.php | 2 +- framework/core/src/Extend/ApiResource.php | 2 +- framework/core/src/Extend/Auth.php | 2 +- framework/core/src/Extend/Conditional.php | 2 +- framework/core/src/Extend/Console.php | 2 +- framework/core/src/Extend/Csrf.php | 2 +- framework/core/src/Extend/ErrorHandling.php | 2 +- framework/core/src/Extend/Event.php | 2 +- framework/core/src/Extend/ExtenderInterface.php | 2 +- framework/core/src/Extend/Filesystem.php | 2 +- framework/core/src/Extend/Formatter.php | 2 +- framework/core/src/Extend/Frontend.php | 2 +- framework/core/src/Extend/LanguagePack.php | 2 +- framework/core/src/Extend/Link.php | 2 +- framework/core/src/Extend/Locales.php | 2 +- framework/core/src/Extend/Mail.php | 2 +- framework/core/src/Extend/Middleware.php | 2 +- framework/core/src/Extend/Model.php | 2 +- framework/core/src/Extend/ModelPrivate.php | 2 +- framework/core/src/Extend/ModelUrl.php | 2 +- framework/core/src/Extend/ModelVisibility.php | 2 +- framework/core/src/Extend/Notification.php | 2 +- framework/core/src/Extend/Policy.php | 2 +- framework/core/src/Extend/Post.php | 2 +- framework/core/src/Extend/Routes.php | 2 +- framework/core/src/Extend/SearchDriver.php | 2 +- framework/core/src/Extend/SearchIndex.php | 2 +- framework/core/src/Extend/ServiceProvider.php | 2 +- framework/core/src/Extend/Session.php | 2 +- framework/core/src/Extend/Settings.php | 2 +- framework/core/src/Extend/Theme.php | 2 +- framework/core/src/Extend/ThrottleApi.php | 2 +- framework/core/src/Extend/User.php | 2 +- framework/core/src/Extend/Validator.php | 2 +- framework/core/src/Extend/View.php | 2 +- framework/core/src/Foundation/Application.php | 2 +- framework/core/src/Foundation/Console/InfoCommand.php | 2 +- framework/core/src/Foundation/DispatchEventsTrait.php | 2 +- .../src/Frontend/Compiler/Source/SourceCollector.php | 2 +- .../core/src/Install/Console/UserDataProvider.php | 2 +- framework/core/src/Mail/MutateEmail.php | 4 ++-- framework/core/src/Post/MergeableInterface.php | 2 +- .../tests/integration/api/users/GroupSearchTest.php | 2 +- .../core/tests/integration/extenders/PostTest.php | 2 +- framework/core/tests/phpunit.integration.xml | 4 +++- framework/core/tests/phpunit.unit.xml | 4 +++- framework/core/tests/unit/Http/CookieFactoryTest.php | 2 +- framework/core/tests/unit/Locale/TranslatorTest.php | 11 ++++++----- .../Extend/BeginTransactionAndSetDatabase.php | 2 +- .../Extend/OverrideExtensionManagerForTests.php | 2 +- .../src/integration/Extend/SetSettingsBeforeBoot.php | 2 +- .../testing/tests/tests/phpunit.integration.xml | 2 +- php-packages/testing/tests/tests/phpunit.unit.xml | 2 +- 88 files changed, 102 insertions(+), 97 deletions(-) diff --git a/extensions/akismet/tests/phpunit.integration.xml b/extensions/akismet/tests/phpunit.integration.xml index e3e14eab99..849ceb516e 100644 --- a/extensions/akismet/tests/phpunit.integration.xml +++ b/extensions/akismet/tests/phpunit.integration.xml @@ -1,7 +1,7 @@ setting('flarum-likes.like_own_post', $canLikeOwnPost); @@ -82,7 +82,7 @@ public function can_like_a_post_if_allowed(int $postId, ?int $authenticatedAs, s #[Test] #[DataProvider('unallowedUsersToLike')] - public function cannot_like_a_post_if_not_allowed(int $postId, ?int $authenticatedAs, string $message, bool $canLikeOwnPost = null) + public function cannot_like_a_post_if_not_allowed(int $postId, ?int $authenticatedAs, string $message, ?bool $canLikeOwnPost = null) { if (! is_null($canLikeOwnPost)) { $this->setting('flarum-likes.like_own_post', $canLikeOwnPost); @@ -100,7 +100,7 @@ public function cannot_like_a_post_if_not_allowed(int $postId, ?int $authenticat #[Test] #[DataProvider('allowedUsersToLike')] - public function can_dislike_a_post_if_liked_and_allowed(int $postId, ?int $authenticatedAs, string $message, bool $canLikeOwnPost = null) + public function can_dislike_a_post_if_liked_and_allowed(int $postId, ?int $authenticatedAs, string $message, ?bool $canLikeOwnPost = null) { if (! is_null($canLikeOwnPost)) { $this->setting('flarum-likes.like_own_post', $canLikeOwnPost); diff --git a/extensions/likes/tests/phpunit.integration.xml b/extensions/likes/tests/phpunit.integration.xml index e3e14eab99..849ceb516e 100644 --- a/extensions/likes/tests/phpunit.integration.xml +++ b/extensions/likes/tests/phpunit.integration.xml @@ -1,7 +1,7 @@ config = $config; } diff --git a/extensions/package-manager/tests/phpunit.integration.xml b/extensions/package-manager/tests/phpunit.integration.xml index b637aadabd..76a5e16dd0 100644 --- a/extensions/package-manager/tests/phpunit.integration.xml +++ b/extensions/package-manager/tests/phpunit.integration.xml @@ -1,7 +1,7 @@ last_posted_at = optional($discussion)->last_posted_at; $this->last_posted_discussion_id = optional($discussion)->id; diff --git a/extensions/tags/src/TagRepository.php b/extensions/tags/src/TagRepository.php index 063941ed24..6f5b555e64 100644 --- a/extensions/tags/src/TagRepository.php +++ b/extensions/tags/src/TagRepository.php @@ -32,7 +32,7 @@ public function queryVisibleTo(?User $actor = null): Builder * Find a tag by ID, optionally making sure it is visible to a certain * user, or throw an exception. */ - public function findOrFail(int $id, User $actor = null): Tag + public function findOrFail(int $id, ?User $actor = null): Tag { $query = Tag::where('id', $id); @@ -45,7 +45,7 @@ public function findOrFail(int $id, User $actor = null): Tag * * @return Collection */ - public function all(User $user = null): Collection + public function all(?User $user = null): Collection { $query = Tag::query(); @@ -55,7 +55,7 @@ public function all(User $user = null): Collection /** * Get the ID of a tag with the given slug. */ - public function getIdForSlug(string $slug, User $user = null): ?int + public function getIdForSlug(string $slug, ?User $user = null): ?int { $query = Tag::where('slug', $slug); diff --git a/extensions/tags/tests/phpunit.integration.xml b/extensions/tags/tests/phpunit.integration.xml index e3e14eab99..849ceb516e 100644 --- a/extensions/tags/tests/phpunit.integration.xml +++ b/extensions/tags/tests/phpunit.integration.xml @@ -1,7 +1,7 @@ resourceClass))->isAbstract()) { $container->extend('flarum.api.resources', function (array $resources) { diff --git a/framework/core/src/Extend/Auth.php b/framework/core/src/Extend/Auth.php index 7013e1a1f6..6e5e711240 100644 --- a/framework/core/src/Extend/Auth.php +++ b/framework/core/src/Extend/Auth.php @@ -58,7 +58,7 @@ public function removePasswordChecker(string $identifier): self return $this; } - public function extend(Container $container, Extension $extension = null): void + public function extend(Container $container, ?Extension $extension = null): void { $container->extend('flarum.user.password_checkers', function ($passwordCheckers) use ($container) { foreach ($this->removePasswordCheckers as $identifier) { diff --git a/framework/core/src/Extend/Conditional.php b/framework/core/src/Extend/Conditional.php index 98a2db3cb5..2e04855ced 100644 --- a/framework/core/src/Extend/Conditional.php +++ b/framework/core/src/Extend/Conditional.php @@ -86,7 +86,7 @@ public function when(callable|bool $condition, callable|string $extenders): self * @param Extension|null $extension * @return void */ - public function extend(Container $container, Extension $extension = null): void + public function extend(Container $container, ?Extension $extension = null): void { foreach ($this->conditions as $condition) { if (is_callable($condition['condition'])) { diff --git a/framework/core/src/Extend/Console.php b/framework/core/src/Extend/Console.php index f4ce68da5a..b05f233e8b 100644 --- a/framework/core/src/Extend/Console.php +++ b/framework/core/src/Extend/Console.php @@ -57,7 +57,7 @@ public function schedule(string $command, callable|string $callback, array $args return $this; } - public function extend(Container $container, Extension $extension = null): void + public function extend(Container $container, ?Extension $extension = null): void { $container->extend('flarum.console.commands', function ($existingCommands) { return array_merge($existingCommands, $this->addCommands); diff --git a/framework/core/src/Extend/Csrf.php b/framework/core/src/Extend/Csrf.php index a60033af47..761b4cff8e 100644 --- a/framework/core/src/Extend/Csrf.php +++ b/framework/core/src/Extend/Csrf.php @@ -29,7 +29,7 @@ public function exemptRoute(string $routeName): self return $this; } - public function extend(Container $container, Extension $extension = null): void + public function extend(Container $container, ?Extension $extension = null): void { $container->extend('flarum.http.csrfExemptPaths', function ($existingExemptPaths) { return array_merge($existingExemptPaths, $this->csrfExemptRoutes); diff --git a/framework/core/src/Extend/ErrorHandling.php b/framework/core/src/Extend/ErrorHandling.php index 15b1d1f42f..f15f9e5ddb 100644 --- a/framework/core/src/Extend/ErrorHandling.php +++ b/framework/core/src/Extend/ErrorHandling.php @@ -108,7 +108,7 @@ public function reporter(string $reporterClass): self return $this; } - public function extend(Container $container, Extension $extension = null): void + public function extend(Container $container, ?Extension $extension = null): void { if (count($this->statuses)) { $container->extend('flarum.error.statuses', function ($statuses) { diff --git a/framework/core/src/Extend/Event.php b/framework/core/src/Extend/Event.php index d3a443887e..2c0c3e8786 100644 --- a/framework/core/src/Extend/Event.php +++ b/framework/core/src/Extend/Event.php @@ -56,7 +56,7 @@ public function subscribe(string $subscriber): self return $this; } - public function extend(Container $container, Extension $extension = null): void + public function extend(Container $container, ?Extension $extension = null): void { $events = $container->make(Dispatcher::class); diff --git a/framework/core/src/Extend/ExtenderInterface.php b/framework/core/src/Extend/ExtenderInterface.php index f6ecf91558..9a5ff30066 100644 --- a/framework/core/src/Extend/ExtenderInterface.php +++ b/framework/core/src/Extend/ExtenderInterface.php @@ -14,5 +14,5 @@ interface ExtenderInterface { - public function extend(Container $container, Extension $extension = null): void; + public function extend(Container $container, ?Extension $extension = null): void; } diff --git a/framework/core/src/Extend/Filesystem.php b/framework/core/src/Extend/Filesystem.php index a6357b5f13..301c43c8b7 100644 --- a/framework/core/src/Extend/Filesystem.php +++ b/framework/core/src/Extend/Filesystem.php @@ -77,7 +77,7 @@ public function driver(string $name, string $driverClass): self return $this; } - public function extend(Container $container, Extension $extension = null): void + public function extend(Container $container, ?Extension $extension = null): void { $container->extend('flarum.filesystem.disks', function ($existingDisks) use ($container) { foreach ($this->disks as $name => $disk) { diff --git a/framework/core/src/Extend/Formatter.php b/framework/core/src/Extend/Formatter.php index 4e3f24964f..2c4855b976 100644 --- a/framework/core/src/Extend/Formatter.php +++ b/framework/core/src/Extend/Formatter.php @@ -116,7 +116,7 @@ public function render(callable|string $callback): self return $this; } - public function extend(Container $container, Extension $extension = null): void + public function extend(Container $container, ?Extension $extension = null): void { $container->extend('flarum.formatter', function ($formatter, $container) { foreach ($this->configurationCallbacks as $callback) { diff --git a/framework/core/src/Extend/Frontend.php b/framework/core/src/Extend/Frontend.php index ef05abe898..55888621dc 100644 --- a/framework/core/src/Extend/Frontend.php +++ b/framework/core/src/Extend/Frontend.php @@ -217,7 +217,7 @@ public function extraDocumentClasses(string|array|callable $classes): self return $this->extraDocumentAttributes(['class' => $classes]); } - public function extend(Container $container, Extension $extension = null): void + public function extend(Container $container, ?Extension $extension = null): void { $this->registerAssets($container, $this->getModuleName($extension)); $this->registerRoutes($container); diff --git a/framework/core/src/Extend/LanguagePack.php b/framework/core/src/Extend/LanguagePack.php index 5626c35d9f..9f8a5d4419 100644 --- a/framework/core/src/Extend/LanguagePack.php +++ b/framework/core/src/Extend/LanguagePack.php @@ -36,7 +36,7 @@ public function __construct( ) { } - public function extend(Container $container, Extension $extension = null): void + public function extend(Container $container, ?Extension $extension = null): void { if (is_null($extension)) { throw new InvalidArgumentException( diff --git a/framework/core/src/Extend/Link.php b/framework/core/src/Extend/Link.php index 6163c9a860..13eff72fbb 100644 --- a/framework/core/src/Extend/Link.php +++ b/framework/core/src/Extend/Link.php @@ -36,7 +36,7 @@ public function setTarget(Closure $callable): self return $this; } - public function extend(Container $container, Extension $extension = null): void + public function extend(Container $container, ?Extension $extension = null): void { $siteUrl = $container->make(Config::class)->url(); diff --git a/framework/core/src/Extend/Locales.php b/framework/core/src/Extend/Locales.php index 3fe4910322..83bed9eac9 100644 --- a/framework/core/src/Extend/Locales.php +++ b/framework/core/src/Extend/Locales.php @@ -25,7 +25,7 @@ public function __construct( ) { } - public function extend(Container $container, Extension $extension = null): void + public function extend(Container $container, ?Extension $extension = null): void { $container->resolving( LocaleManager::class, diff --git a/framework/core/src/Extend/Mail.php b/framework/core/src/Extend/Mail.php index 3a9cbd100e..99d556243a 100644 --- a/framework/core/src/Extend/Mail.php +++ b/framework/core/src/Extend/Mail.php @@ -31,7 +31,7 @@ public function driver(string $identifier, string $driver): self return $this; } - public function extend(Container $container, Extension $extension = null): void + public function extend(Container $container, ?Extension $extension = null): void { $container->extend('mail.supported_drivers', function ($existingDrivers) { return array_merge($existingDrivers, $this->drivers); diff --git a/framework/core/src/Extend/Middleware.php b/framework/core/src/Extend/Middleware.php index 021b504b9e..877cda0f90 100644 --- a/framework/core/src/Extend/Middleware.php +++ b/framework/core/src/Extend/Middleware.php @@ -104,7 +104,7 @@ public function insertAfter(string $originalMiddleware, string $newMiddleware): return $this; } - public function extend(Container $container, Extension $extension = null): void + public function extend(Container $container, ?Extension $extension = null): void { $container->extend("flarum.$this->frontend.middleware", function ($existingMiddleware) { foreach ($this->addMiddlewares as $addMiddleware) { diff --git a/framework/core/src/Extend/Model.php b/framework/core/src/Extend/Model.php index e0b30fbd34..3197ea726b 100644 --- a/framework/core/src/Extend/Model.php +++ b/framework/core/src/Extend/Model.php @@ -177,7 +177,7 @@ public function relationship(string $name, callable|string $callback): self return $this; } - public function extend(Container $container, Extension $extension = null): void + public function extend(Container $container, ?Extension $extension = null): void { foreach ($this->customRelations as $name => $callback) { /** @var class-string $modelClass */ diff --git a/framework/core/src/Extend/ModelPrivate.php b/framework/core/src/Extend/ModelPrivate.php index 5b44b0f299..3b63e12b79 100644 --- a/framework/core/src/Extend/ModelPrivate.php +++ b/framework/core/src/Extend/ModelPrivate.php @@ -65,7 +65,7 @@ public function checker(callable|string $callback): self return $this; } - public function extend(Container $container, Extension $extension = null): void + public function extend(Container $container, ?Extension $extension = null): void { if (! class_exists($this->modelClass)) { return; diff --git a/framework/core/src/Extend/ModelUrl.php b/framework/core/src/Extend/ModelUrl.php index 80ef5f824a..1560242c44 100644 --- a/framework/core/src/Extend/ModelUrl.php +++ b/framework/core/src/Extend/ModelUrl.php @@ -41,7 +41,7 @@ public function addSlugDriver(string $identifier, string $driver): self return $this; } - public function extend(Container $container, Extension $extension = null): void + public function extend(Container $container, ?Extension $extension = null): void { if ($this->slugDrivers) { $container->extend('flarum.http.slugDrivers', function ($existingDrivers) { diff --git a/framework/core/src/Extend/ModelVisibility.php b/framework/core/src/Extend/ModelVisibility.php index 8cf885640c..21bd3e19e2 100644 --- a/framework/core/src/Extend/ModelVisibility.php +++ b/framework/core/src/Extend/ModelVisibility.php @@ -92,7 +92,7 @@ public function scopeAll(callable|string $callback): self return $this; } - public function extend(Container $container, Extension $extension = null): void + public function extend(Container $container, ?Extension $extension = null): void { if (! class_exists($this->modelClass)) { return; diff --git a/framework/core/src/Extend/Notification.php b/framework/core/src/Extend/Notification.php index 6a9f5f86ed..4386fe1d51 100644 --- a/framework/core/src/Extend/Notification.php +++ b/framework/core/src/Extend/Notification.php @@ -71,7 +71,7 @@ public function beforeSending(callable|string $callback): self return $this; } - public function extend(Container $container, Extension $extension = null): void + public function extend(Container $container, ?Extension $extension = null): void { $container->extend('flarum.notification.blueprints', function ($existingBlueprints) { $existingBlueprints = array_merge($existingBlueprints, $this->blueprints); diff --git a/framework/core/src/Extend/Policy.php b/framework/core/src/Extend/Policy.php index a134784e18..ff1ab6c891 100644 --- a/framework/core/src/Extend/Policy.php +++ b/framework/core/src/Extend/Policy.php @@ -50,7 +50,7 @@ public function modelPolicy(string $modelClass, string $policy): self return $this; } - public function extend(Container $container, Extension $extension = null): void + public function extend(Container $container, ?Extension $extension = null): void { $container->extend('flarum.policies', function ($existingPolicies) { foreach ($this->modelPolicies as $modelClass => $addPolicies) { diff --git a/framework/core/src/Extend/Post.php b/framework/core/src/Extend/Post.php index 78e515c219..27282a4d23 100644 --- a/framework/core/src/Extend/Post.php +++ b/framework/core/src/Extend/Post.php @@ -31,7 +31,7 @@ public function type(string $postType): self return $this; } - public function extend(Container $container, Extension $extension = null): void + public function extend(Container $container, ?Extension $extension = null): void { foreach ($this->postTypes as $postType) { PostModel::setModel($postType::$type, $postType); diff --git a/framework/core/src/Extend/Routes.php b/framework/core/src/Extend/Routes.php index 5e6e2d3fe3..a2f7192924 100644 --- a/framework/core/src/Extend/Routes.php +++ b/framework/core/src/Extend/Routes.php @@ -169,7 +169,7 @@ public function remove(string $name): self return $this; } - public function extend(Container $container, Extension $extension = null): void + public function extend(Container $container, ?Extension $extension = null): void { if (empty($this->routes) && empty($this->removedRoutes)) { return; diff --git a/framework/core/src/Extend/SearchDriver.php b/framework/core/src/Extend/SearchDriver.php index 3e4a227652..4e1e545ac9 100644 --- a/framework/core/src/Extend/SearchDriver.php +++ b/framework/core/src/Extend/SearchDriver.php @@ -131,7 +131,7 @@ public function addMutator(string $searcherClass, callable|string $callback): se return $this; } - public function extend(Container $container, Extension $extension = null): void + public function extend(Container $container, ?Extension $extension = null): void { $container->extend('flarum.search.drivers', function (array $oldDrivers) { $oldDrivers[$this->driverClass] = array_merge( diff --git a/framework/core/src/Extend/SearchIndex.php b/framework/core/src/Extend/SearchIndex.php index 277ad55f8b..c31a6f9d1f 100644 --- a/framework/core/src/Extend/SearchIndex.php +++ b/framework/core/src/Extend/SearchIndex.php @@ -30,7 +30,7 @@ public function indexer(string $resourceClass, string $indexerClass): self return $this; } - public function extend(Container $container, Extension $extension = null): void + public function extend(Container $container, ?Extension $extension = null): void { if (empty($this->indexers)) { return; diff --git a/framework/core/src/Extend/ServiceProvider.php b/framework/core/src/Extend/ServiceProvider.php index d42416a87d..58f98781c4 100644 --- a/framework/core/src/Extend/ServiceProvider.php +++ b/framework/core/src/Extend/ServiceProvider.php @@ -34,7 +34,7 @@ public function register(string $serviceProviderClass): self return $this; } - public function extend(Container $container, Extension $extension = null): void + public function extend(Container $container, ?Extension $extension = null): void { $app = $container->make('flarum'); diff --git a/framework/core/src/Extend/Session.php b/framework/core/src/Extend/Session.php index c7ed580bb1..a44971571e 100644 --- a/framework/core/src/Extend/Session.php +++ b/framework/core/src/Extend/Session.php @@ -34,7 +34,7 @@ public function driver(string $name, string $driverClass): self return $this; } - public function extend(Container $container, Extension $extension = null): void + public function extend(Container $container, ?Extension $extension = null): void { $container->extend('flarum.session.drivers', function ($drivers) { return array_merge($drivers, $this->drivers); diff --git a/framework/core/src/Extend/Settings.php b/framework/core/src/Extend/Settings.php index bc72e6d867..9543b9653b 100644 --- a/framework/core/src/Extend/Settings.php +++ b/framework/core/src/Extend/Settings.php @@ -114,7 +114,7 @@ public function resetJsCacheFor(string $setting): self return $this; } - public function extend(Container $container, Extension $extension = null): void + public function extend(Container $container, ?Extension $extension = null): void { if (! empty($this->defaults)) { $container->extend('flarum.settings.default', function (Collection $defaults) { diff --git a/framework/core/src/Extend/Theme.php b/framework/core/src/Extend/Theme.php index a70a186b55..d75244eb8b 100644 --- a/framework/core/src/Extend/Theme.php +++ b/framework/core/src/Extend/Theme.php @@ -136,7 +136,7 @@ public function addCustomLessVariable(string $variableName, callable $value): se return $this; } - public function extend(Container $container, Extension $extension = null): void + public function extend(Container $container, ?Extension $extension = null): void { $container->extend('flarum.frontend.custom_less_functions', function (array $customFunctions) { return array_merge($customFunctions, $this->customFunctions); diff --git a/framework/core/src/Extend/ThrottleApi.php b/framework/core/src/Extend/ThrottleApi.php index ce05332c10..006b3db8d8 100644 --- a/framework/core/src/Extend/ThrottleApi.php +++ b/framework/core/src/Extend/ThrottleApi.php @@ -59,7 +59,7 @@ public function remove(string $name): self return $this; } - public function extend(Container $container, Extension $extension = null): void + public function extend(Container $container, ?Extension $extension = null): void { $container->extend('flarum.api.throttlers', function ($throttlers) use ($container) { $throttlers = array_diff_key($throttlers, array_flip($this->removeThrottlers)); diff --git a/framework/core/src/Extend/User.php b/framework/core/src/Extend/User.php index f429258f4b..1b76322f59 100644 --- a/framework/core/src/Extend/User.php +++ b/framework/core/src/Extend/User.php @@ -72,7 +72,7 @@ public function registerPreference(string $key, ?callable $transformer = null, m return $this; } - public function extend(Container $container, Extension $extension = null): void + public function extend(Container $container, ?Extension $extension = null): void { $container->extend('flarum.user.display_name.supported_drivers', function ($existingDrivers) { return array_merge($existingDrivers, $this->displayNameDrivers); diff --git a/framework/core/src/Extend/Validator.php b/framework/core/src/Extend/Validator.php index 282736e9c3..a845404986 100644 --- a/framework/core/src/Extend/Validator.php +++ b/framework/core/src/Extend/Validator.php @@ -48,7 +48,7 @@ public function configure(callable|string $callback): self return $this; } - public function extend(Container $container, Extension $extension = null): void + public function extend(Container $container, ?Extension $extension = null): void { $container->resolving($this->validatorClass, function ($validator, $container) { foreach ($this->configurationCallbacks as $callback) { diff --git a/framework/core/src/Extend/View.php b/framework/core/src/Extend/View.php index a71420736b..71c9f5e971 100644 --- a/framework/core/src/Extend/View.php +++ b/framework/core/src/Extend/View.php @@ -64,7 +64,7 @@ public function extendNamespace(string $namespace, array|string $hints): self return $this; } - public function extend(Container $container, Extension $extension = null): void + public function extend(Container $container, ?Extension $extension = null): void { $container->resolving(Factory::class, function (FactoryImplementation $view) { foreach ($this->namespaces as $namespace => $hints) { diff --git a/framework/core/src/Foundation/Application.php b/framework/core/src/Foundation/Application.php index 600e86076d..bc191d9a5d 100644 --- a/framework/core/src/Foundation/Application.php +++ b/framework/core/src/Foundation/Application.php @@ -57,7 +57,7 @@ public function config(string $key, mixed $default = null): mixed return $config[$key] ?? $default; } - public function url(string $path = null): string + public function url(?string $path = null): string { $config = $this->make('flarum.config'); $url = (string) $config->url(); diff --git a/framework/core/src/Foundation/Console/InfoCommand.php b/framework/core/src/Foundation/Console/InfoCommand.php index d3967e1521..06b9c6e791 100644 --- a/framework/core/src/Foundation/Console/InfoCommand.php +++ b/framework/core/src/Foundation/Console/InfoCommand.php @@ -101,7 +101,7 @@ private function getExtensionTable(): Table * If the package seems to be a Git version, we extract the currently * checked out commit using the command line. */ - private function findPackageVersion(string $path, string $fallback = null): ?string + private function findPackageVersion(string $path, ?string $fallback = null): ?string { if (file_exists("$path/.git")) { $cwd = getcwd(); diff --git a/framework/core/src/Foundation/DispatchEventsTrait.php b/framework/core/src/Foundation/DispatchEventsTrait.php index 04aca149ce..0f5f2a8e93 100644 --- a/framework/core/src/Foundation/DispatchEventsTrait.php +++ b/framework/core/src/Foundation/DispatchEventsTrait.php @@ -16,7 +16,7 @@ trait DispatchEventsTrait /** * Dispatch all events for an entity. */ - public function dispatchEventsFor(mixed $entity, User $actor = null): void + public function dispatchEventsFor(mixed $entity, ?User $actor = null): void { if (! method_exists($entity, 'releaseEvents')) { throw new \InvalidArgumentException( diff --git a/framework/core/src/Frontend/Compiler/Source/SourceCollector.php b/framework/core/src/Frontend/Compiler/Source/SourceCollector.php index 4ebf78fdca..04ac3bd3f4 100644 --- a/framework/core/src/Frontend/Compiler/Source/SourceCollector.php +++ b/framework/core/src/Frontend/Compiler/Source/SourceCollector.php @@ -26,7 +26,7 @@ public function __construct( */ protected array $sources = []; - public function addFile(string $file, string $extensionId = null): static + public function addFile(string $file, ?string $extensionId = null): static { $this->sources[] = $this->validateSourceType( new FileSource($file, $extensionId) diff --git a/framework/core/src/Install/Console/UserDataProvider.php b/framework/core/src/Install/Console/UserDataProvider.php index 7e58774d9f..f62bd0046b 100644 --- a/framework/core/src/Install/Console/UserDataProvider.php +++ b/framework/core/src/Install/Console/UserDataProvider.php @@ -119,7 +119,7 @@ private function getSettings(): array ]; } - private function ask(string $question, string $default = null): mixed + private function ask(string $question, ?string $default = null): mixed { $question = new Question("$question ", $default); diff --git a/framework/core/src/Mail/MutateEmail.php b/framework/core/src/Mail/MutateEmail.php index b668ce401e..eca8187b95 100644 --- a/framework/core/src/Mail/MutateEmail.php +++ b/framework/core/src/Mail/MutateEmail.php @@ -15,10 +15,10 @@ class MutateEmail { public function handle(MessageSending $event): bool { - if (! empty($link = $event->data['unsubscribeLink'])) { + if (! empty($event->data['unsubscribeLink'])) { $headers = $event->message->getHeaders(); - $headers->addTextHeader('List-Unsubscribe', '<'.$link.'>'); + $headers->addTextHeader('List-Unsubscribe', '<'.$event->data['unsubscribeLink'].'>'); } return true; diff --git a/framework/core/src/Post/MergeableInterface.php b/framework/core/src/Post/MergeableInterface.php index 19e59bd57a..e12caee178 100644 --- a/framework/core/src/Post/MergeableInterface.php +++ b/framework/core/src/Post/MergeableInterface.php @@ -26,5 +26,5 @@ interface MergeableInterface * unsuccessful, this should be the current model instance. Otherwise, * it should be the model that was merged into. */ - public function saveAfter(Post $previous = null): static; + public function saveAfter(?Post $previous = null): static; } diff --git a/framework/core/tests/integration/api/users/GroupSearchTest.php b/framework/core/tests/integration/api/users/GroupSearchTest.php index 75d453fb17..f02a2bb983 100644 --- a/framework/core/tests/integration/api/users/GroupSearchTest.php +++ b/framework/core/tests/integration/api/users/GroupSearchTest.php @@ -210,7 +210,7 @@ public function admin_can_select_multiple_groups_and_hidden() $this->assertEqualsCanonicalizing([1, 99, 4, 5, 6], array_column($responseBodyContents['included'], 'id')); } - private function createRequest(array $group, int $userId = null) + private function createRequest(array $group, ?int $userId = null) { $auth = $userId ? ['authenticatedAs' => $userId] : []; diff --git a/framework/core/tests/integration/extenders/PostTest.php b/framework/core/tests/integration/extenders/PostTest.php index 1201639b6c..dd6cc74ad1 100644 --- a/framework/core/tests/integration/extenders/PostTest.php +++ b/framework/core/tests/integration/extenders/PostTest.php @@ -40,7 +40,7 @@ class PostTestCustomPost extends AbstractEventPost implements MergeableInterface { public static string $type = 'customPost'; - public function saveAfter(Post $previous = null): static + public function saveAfter(?Post $previous = null): static { $this->save(); diff --git a/framework/core/tests/phpunit.integration.xml b/framework/core/tests/phpunit.integration.xml index e3e14eab99..c03c29b2bb 100644 --- a/framework/core/tests/phpunit.integration.xml +++ b/framework/core/tests/phpunit.integration.xml @@ -1,10 +1,12 @@ 'http://flarum.test' diff --git a/framework/core/tests/unit/Locale/TranslatorTest.php b/framework/core/tests/unit/Locale/TranslatorTest.php index 8fb63bb7b6..5563944e20 100644 --- a/framework/core/tests/unit/Locale/TranslatorTest.php +++ b/framework/core/tests/unit/Locale/TranslatorTest.php @@ -11,6 +11,7 @@ use Flarum\Locale\Translator; use Flarum\Testing\unit\TestCase; +use PHPUnit\Framework\Attributes\Test; use Symfony\Component\Translation\Loader\ArrayLoader; use Symfony\Component\Translation\MessageCatalogueInterface; @@ -23,7 +24,7 @@ class TranslatorTest extends TestCase * translator works in the same way as JS translator. */ - /** @test */ + #[Test] public function placeholders_encoding() { $translator = new Translator('en'); @@ -37,7 +38,7 @@ public function placeholders_encoding() $this->assertSame("test1 test2 ' test2 test1", $translator->trans('test1', ['placeholder' => $translator->trans('test2', ['placeholder' => "'"])])); } - /** @test */ + #[Test] public function missing_placeholders() { $translator = new Translator('en'); @@ -49,7 +50,7 @@ public function missing_placeholders() $this->assertSame('test1 {placeholder} test1', $translator->trans('test1', [])); } - /** @test */ + #[Test] public function escaped_placeholders() { $translator = new Translator('en'); @@ -61,7 +62,7 @@ public function escaped_placeholders() $this->assertSame("test1 ' {placeholder} test1", $translator->trans('test3', ['placeholder' => "'"])); } - /** @test */ + #[Test] public function plural_rules() { $translator = new Translator('en'); @@ -74,7 +75,7 @@ public function plural_rules() $this->assertSame('Page 2 - A & B', $translator->trans('test4', ['forumName' => 'A & B', 'pageNumber' => 2])); } - /** @test */ + #[Test] public function plural_rules_2() { $translator = new Translator('pl'); diff --git a/php-packages/testing/src/integration/Extend/BeginTransactionAndSetDatabase.php b/php-packages/testing/src/integration/Extend/BeginTransactionAndSetDatabase.php index fe919da306..c0059c84bc 100644 --- a/php-packages/testing/src/integration/Extend/BeginTransactionAndSetDatabase.php +++ b/php-packages/testing/src/integration/Extend/BeginTransactionAndSetDatabase.php @@ -27,7 +27,7 @@ public function __construct(callable $setDbOnTestCase) $this->setDbOnTestCase = $setDbOnTestCase; } - public function extend(Container $container, Extension $extension = null): void + public function extend(Container $container, ?Extension $extension = null): void { /** @var Connection $db */ $db = $container->make(ConnectionInterface::class); diff --git a/php-packages/testing/src/integration/Extend/OverrideExtensionManagerForTests.php b/php-packages/testing/src/integration/Extend/OverrideExtensionManagerForTests.php index 8d477a2eb6..3e1b988074 100644 --- a/php-packages/testing/src/integration/Extend/OverrideExtensionManagerForTests.php +++ b/php-packages/testing/src/integration/Extend/OverrideExtensionManagerForTests.php @@ -27,7 +27,7 @@ public function __construct($extensions) $this->extensions = $extensions; } - public function extend(Container $container, Extension $extension = null): void + public function extend(Container $container, ?Extension $extension = null): void { $container->when(ExtensionManagerIncludeCurrent::class)->needs('$enabledIds')->give($this->extensions); if (count($this->extensions)) { diff --git a/php-packages/testing/src/integration/Extend/SetSettingsBeforeBoot.php b/php-packages/testing/src/integration/Extend/SetSettingsBeforeBoot.php index bbf6044880..f1029b2d86 100644 --- a/php-packages/testing/src/integration/Extend/SetSettingsBeforeBoot.php +++ b/php-packages/testing/src/integration/Extend/SetSettingsBeforeBoot.php @@ -26,7 +26,7 @@ public function __construct($settings) $this->settings = $settings; } - public function extend(Container $container, Extension $extension = null): void + public function extend(Container $container, ?Extension $extension = null): void { if (count($this->settings)) { $settings = $container->make(SettingsRepositoryInterface::class); diff --git a/php-packages/testing/tests/tests/phpunit.integration.xml b/php-packages/testing/tests/tests/phpunit.integration.xml index 5f2ed2eb9b..0fa3fdb798 100644 --- a/php-packages/testing/tests/tests/phpunit.integration.xml +++ b/php-packages/testing/tests/tests/phpunit.integration.xml @@ -1,7 +1,7 @@