diff --git a/.github/workflows/REUSABLE_backend.yml b/.github/workflows/REUSABLE_backend.yml index 0b4a837e38..54c0475a19 100644 --- a/.github/workflows/REUSABLE_backend.yml +++ b/.github/workflows/REUSABLE_backend.yml @@ -32,7 +32,7 @@ on: type: string required: false # Keep PHP versions synced with build-install-packages.yml - default: '["8.2", "8.3"]' + default: '["8.2", "8.3", "8.4"]' php_extensions: description: PHP extensions to install. diff --git a/.github/workflows/build-install-packages.yml b/.github/workflows/build-install-packages.yml index 5ecdd320fc..b7dd2928c6 100644 --- a/.github/workflows/build-install-packages.yml +++ b/.github/workflows/build-install-packages.yml @@ -6,7 +6,7 @@ on: env: VERSION: ${{ github.event.release.tag_name }} - PHP_VERSIONS: '8.2 8.3' + PHP_VERSIONS: '8.2 8.3 8.4' INSTALL_PACKAGES_INPUTS: '{ "flarum_version": "{0}", "php_versions": "{1}" }' jobs: 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 @@ traitDispatchEventsFor($entity, $actor); diff --git a/framework/core/src/Database/Exception/MigrationKeyMissing.php b/framework/core/src/Database/Exception/MigrationKeyMissing.php index 6e9b36771a..343b9785af 100644 --- a/framework/core/src/Database/Exception/MigrationKeyMissing.php +++ b/framework/core/src/Database/Exception/MigrationKeyMissing.php @@ -13,13 +13,13 @@ class MigrationKeyMissing extends Exception { - public function __construct(protected string $direction, string $file = null) + public function __construct(protected string $direction, ?string $file = null) { $fileNameWithSpace = $file ? ' '.realpath($file) : ''; parent::__construct("Migration file $fileNameWithSpace should contain an array with up/down (looking for $direction)"); } - public function withFile(string $file = null): self + public function withFile(string $file): self { return new self($this->direction, $file); } diff --git a/framework/core/src/Discussion/Discussion.php b/framework/core/src/Discussion/Discussion.php index 699e20f175..7cfb7699e3 100644 --- a/framework/core/src/Discussion/Discussion.php +++ b/framework/core/src/Discussion/Discussion.php @@ -117,7 +117,7 @@ public static function boot() /** * Start a new discussion. Raises the DiscussionWasStarted event. */ - public static function start(?string $title, User $user, self $model = null): self + public static function start(?string $title, User $user, ?self $model = null): self { $discussion = $model ?? new static; diff --git a/framework/core/src/Extend/ApiResource.php b/framework/core/src/Extend/ApiResource.php index 66e6e9f2ec..bdd682de99 100644 --- a/framework/core/src/Extend/ApiResource.php +++ b/framework/core/src/Extend/ApiResource.php @@ -59,7 +59,7 @@ public function endpoints(callable|string $endpoints): self * @param array $endpoints must be an array of names of the endpoints. * @param callable|class-string|null $condition a callable that returns a boolean or a string that represents whether this should be applied. */ - public function removeEndpoints(array $endpoints, callable|string $condition = null): self + public function removeEndpoints(array $endpoints, callable|string|null $condition = null): self { $this->removeEndpoints[] = [$endpoints, $condition]; @@ -99,7 +99,7 @@ public function fields(callable|string $fields): self * @param array $fields must be an array of field names. * @param callable|class-string|null $condition a callable that returns a boolean or a string that represents whether this should be applied. */ - public function removeFields(array $fields, callable|string $condition = null): self + public function removeFields(array $fields, callable|string|null $condition = null): self { $this->removeFields[] = [$fields, $condition]; @@ -139,7 +139,7 @@ public function sorts(callable|string $sorts): self * @param array $sorts must be an array of sort names. * @param callable|class-string|null $condition a callable that returns a boolean or a string that represents whether this should be applied. */ - public function removeSorts(array $sorts, callable|string $condition = null): self + public function removeSorts(array $sorts, callable|string|null $condition = null): self { $this->removeSorts[] = [$sorts, $condition]; @@ -161,7 +161,7 @@ public function sort(string|array $sort, callable|string $mutator): self return $this; } - public function extend(Container $container, Extension $extension = null): void + public function extend(Container $container, ?Extension $extension = null): void { if (! (new ReflectionClass($this->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..fb166f531a 100644 --- a/framework/core/src/Extend/Frontend.php +++ b/framework/core/src/Extend/Frontend.php @@ -101,7 +101,7 @@ public function jsDirectory(string $path): self * * @return self */ - public function route(string $path, string $name, callable|string $content = null): self + public function route(string $path, string $name, callable|string|null $content = null): self { $this->routes[] = compact('path', 'name', 'content'); @@ -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..68a9555d28 100644 --- a/framework/core/src/Extend/Settings.php +++ b/framework/core/src/Extend/Settings.php @@ -43,7 +43,7 @@ class Settings implements ExtenderInterface * * @return self */ - public function serializeToForum(string $attributeName, string $key, callable|string $callback = null): self + public function serializeToForum(string $attributeName, string $key, callable|string|null $callback = null): self { $this->settings[$key] = compact('attributeName', 'callback'); @@ -94,7 +94,7 @@ public function resetWhen(string $key, callable|string $callback): self * * @return self */ - public function registerLessConfigVar(string $configName, string $key, callable|string $callback = null): self + public function registerLessConfigVar(string $configName, string $key, callable|string|null $callback = null): self { $this->lessConfigs[$configName] = compact('key', 'callback'); @@ -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..f878e42b1d 100644 --- a/framework/core/src/Extend/Theme.php +++ b/framework/core/src/Extend/Theme.php @@ -48,7 +48,7 @@ public function overrideLessImport(string $file, string $newFilePath, ?string $e * @param string|null $extensionId : If overriding an extension file, specify its ID, for example: `flarum-tags`. * @return self */ - public function overrideFileSource(string $file, string $newFilePath, string $extensionId = null): self + public function overrideFileSource(string $file, string $newFilePath, ?string $extensionId = null): self { $this->fileSourceOverrides[] = compact('file', 'newFilePath', 'extensionId'); @@ -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/Extension/Exception/ExtensionBootError.php b/framework/core/src/Extension/Exception/ExtensionBootError.php index 2a75698e24..8d673493a8 100644 --- a/framework/core/src/Extension/Exception/ExtensionBootError.php +++ b/framework/core/src/Extension/Exception/ExtensionBootError.php @@ -18,7 +18,7 @@ class ExtensionBootError extends Exception public function __construct( public Extension $extension, public object $extender, - Throwable $previous = null + ?Throwable $previous = null ) { $extenderClass = $extender::class; diff --git a/framework/core/src/Formatter/Formatter.php b/framework/core/src/Formatter/Formatter.php index 2dbc97c5cd..9434019fd1 100644 --- a/framework/core/src/Formatter/Formatter.php +++ b/framework/core/src/Formatter/Formatter.php @@ -63,7 +63,7 @@ public function addRenderingCallback(callable $callback): void $this->renderingCallbacks[] = $callback; } - public function parse(string $text, mixed $context = null, User $user = null): string + public function parse(string $text, mixed $context = null, ?User $user = null): string { $parser = $this->getParser($context); @@ -81,7 +81,7 @@ public function parse(string $text, mixed $context = null, User $user = null): s return $parser->parse($text); } - public function render(string $xml, mixed $context = null, ServerRequestInterface $request = null): string + public function render(string $xml, mixed $context = null, ?ServerRequestInterface $request = null): string { $renderer = $this->getRenderer(); 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/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 4ebf78fdca..66cb52be4a 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) @@ -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..8de6b3b61a 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(); @@ -192,7 +192,7 @@ public function scopeWhereValid(Builder $query, ?Carbon $date = null): void /** * This query scope is intended to be used on the base AccessToken object to query for expired tokens of any type. */ - public function scopeWhereExpired(Builder $query, Carbon $date = null): void + public function scopeWhereExpired(Builder $query, ?Carbon $date = null): void { if (is_null($date)) { $date = Carbon::now(); diff --git a/framework/core/src/Http/RouteHandlerFactory.php b/framework/core/src/Http/RouteHandlerFactory.php index 79d431e74e..d12e9a71b0 100644 --- a/framework/core/src/Http/RouteHandlerFactory.php +++ b/framework/core/src/Http/RouteHandlerFactory.php @@ -66,12 +66,12 @@ public function toFrontend(string $frontend, callable|string|null $content = nul }); } - public function toForum(string $content = null): Closure + 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/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/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/Mail/Mailer.php b/framework/core/src/Mail/Mailer.php index dbdd0e87f8..a70359e0e3 100644 --- a/framework/core/src/Mail/Mailer.php +++ b/framework/core/src/Mail/Mailer.php @@ -21,7 +21,7 @@ public function __construct( string $name, Factory $views, TransportInterface $transport, - Dispatcher $events = null, + ?Dispatcher $events, protected SettingsRepositoryInterface $settings ) { parent::__construct($name, $views, $transport, $events); diff --git a/framework/core/src/Mail/MutateEmail.php b/framework/core/src/Mail/MutateEmail.php index b668ce401e..677282b6f5 100644 --- a/framework/core/src/Mail/MutateEmail.php +++ b/framework/core/src/Mail/MutateEmail.php @@ -15,10 +15,12 @@ class MutateEmail { public function handle(MessageSending $event): bool { - if (! empty($link = $event->data['unsubscribeLink'])) { + $unsubscribeLink = $event->data['unsubscribeLink'] ?? null; + + if ($unsubscribeLink) { $headers = $event->message->getHeaders(); - $headers->addTextHeader('List-Unsubscribe', '<'.$link.'>'); + $headers->addTextHeader('List-Unsubscribe', '<'.$unsubscribeLink.'>'); } return true; diff --git a/framework/core/src/Post/DiscussionRenamedPost.php b/framework/core/src/Post/DiscussionRenamedPost.php index 0866ad7046..98900d8889 100644 --- a/framework/core/src/Post/DiscussionRenamedPost.php +++ b/framework/core/src/Post/DiscussionRenamedPost.php @@ -21,7 +21,7 @@ class DiscussionRenamedPost extends AbstractEventPost implements MergeableInterf { public static string $type = 'discussionRenamed'; - public function saveAfter(Post $previous = null): static + public function saveAfter(?Post $previous = null): static { // If the previous post is another 'discussion renamed' post, and it's // by the same user, then we can merge this post into it. If we find 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/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/User.php b/framework/core/src/User/User.php index e8e0c1f939..a22bff8c48 100644 --- a/framework/core/src/User/User.php +++ b/framework/core/src/User/User.php @@ -650,7 +650,7 @@ public static function setHasher(Hasher $hasher): void * * @internal */ - public static function registerPreference(string $key, callable $transformer = null, mixed $default = null): void + public static function registerPreference(string $key, ?callable $transformer = null, mixed $default = null): void { static::$preferences[$key] = compact('transformer', 'default'); } diff --git a/framework/core/src/User/UserRepository.php b/framework/core/src/User/UserRepository.php index c5a43032ad..ae0f087dba 100644 --- a/framework/core/src/User/UserRepository.php +++ b/framework/core/src/User/UserRepository.php @@ -33,7 +33,7 @@ public function query(): Builder * * @throws \Illuminate\Database\Eloquent\ModelNotFoundException */ - public function findOrFail(int|string $id, User $actor = null): Model + public function findOrFail(int|string $id, ?User $actor = null): Model { $query = $this->query()->where('id', $id); @@ -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,14 +75,14 @@ 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); return $this->scopeVisibleTo($query, $actor)->value('id'); } - public function getIdsForUsernames(array $usernames, User $actor = null): array + public function getIdsForUsernames(array $usernames, ?User $actor = null): array { $query = $this->query()->whereIn('username', $usernames); @@ -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); 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 @@