diff --git a/extensions/akismet/tests/phpunit.integration.xml b/extensions/akismet/tests/phpunit.integration.xml index e3e14eab9..849ceb516 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 @@ class LikePostTest extends TestCase #[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 @@ class LikePostTest extends TestCase #[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 e3e14eab9..849ceb516 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 b637aadab..76a5e16dd 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 063941ed2..6f5b555e6 100644 --- a/extensions/tags/src/TagRepository.php +++ b/extensions/tags/src/TagRepository.php @@ -32,7 +32,7 @@ class TagRepository * 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 @@ class TagRepository * * @return Collection */ - public function all(User $user = null): Collection + public function all(?User $user = null): Collection { $query = Tag::query(); @@ -55,7 +55,7 @@ class TagRepository /** * 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 e3e14eab9..849ceb516 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 6e9b36771..73e25c339 100644 --- a/framework/core/src/Database/Exception/MigrationKeyMissing.php +++ b/framework/core/src/Database/Exception/MigrationKeyMissing.php @@ -13,13 +13,13 @@ use Exception; 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 = null): self { return new self($this->direction, $file); } diff --git a/framework/core/src/Discussion/Discussion.php b/framework/core/src/Discussion/Discussion.php index 699e20f17..7cfb7699e 100644 --- a/framework/core/src/Discussion/Discussion.php +++ b/framework/core/src/Discussion/Discussion.php @@ -117,7 +117,7 @@ class Discussion extends AbstractModel /** * 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 66e6e9f2e..bdd682de9 100644 --- a/framework/core/src/Extend/ApiResource.php +++ b/framework/core/src/Extend/ApiResource.php @@ -59,7 +59,7 @@ class ApiResource implements ExtenderInterface * @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 @@ class ApiResource implements ExtenderInterface * @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 @@ class ApiResource implements ExtenderInterface * @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 @@ class ApiResource implements ExtenderInterface 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 7013e1a1f..6e5e71124 100644 --- a/framework/core/src/Extend/Auth.php +++ b/framework/core/src/Extend/Auth.php @@ -58,7 +58,7 @@ class Auth implements ExtenderInterface 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 98a2db3cb..2e04855ce 100644 --- a/framework/core/src/Extend/Conditional.php +++ b/framework/core/src/Extend/Conditional.php @@ -86,7 +86,7 @@ class Conditional implements ExtenderInterface * @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 f4ce68da5..b05f233e8 100644 --- a/framework/core/src/Extend/Console.php +++ b/framework/core/src/Extend/Console.php @@ -57,7 +57,7 @@ class Console implements ExtenderInterface 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 a60033af4..761b4cff8 100644 --- a/framework/core/src/Extend/Csrf.php +++ b/framework/core/src/Extend/Csrf.php @@ -29,7 +29,7 @@ class Csrf implements ExtenderInterface 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 15b1d1f42..f15f9e5dd 100644 --- a/framework/core/src/Extend/ErrorHandling.php +++ b/framework/core/src/Extend/ErrorHandling.php @@ -108,7 +108,7 @@ class ErrorHandling implements ExtenderInterface 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 d3a443887..2c0c3e878 100644 --- a/framework/core/src/Extend/Event.php +++ b/framework/core/src/Extend/Event.php @@ -56,7 +56,7 @@ class Event implements ExtenderInterface 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 f6ecf9155..9a5ff3006 100644 --- a/framework/core/src/Extend/ExtenderInterface.php +++ b/framework/core/src/Extend/ExtenderInterface.php @@ -14,5 +14,5 @@ use Illuminate\Contracts\Container\Container; 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 a6357b5f1..301c43c8b 100644 --- a/framework/core/src/Extend/Filesystem.php +++ b/framework/core/src/Extend/Filesystem.php @@ -77,7 +77,7 @@ class Filesystem implements ExtenderInterface 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 4e3f24964..2c4855b97 100644 --- a/framework/core/src/Extend/Formatter.php +++ b/framework/core/src/Extend/Formatter.php @@ -116,7 +116,7 @@ class Formatter implements ExtenderInterface, LifecycleInterface 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 ef05abe89..fb166f531 100644 --- a/framework/core/src/Extend/Frontend.php +++ b/framework/core/src/Extend/Frontend.php @@ -101,7 +101,7 @@ class Frontend implements ExtenderInterface * * @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 @@ class Frontend implements ExtenderInterface 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 5626c35d9..9f8a5d441 100644 --- a/framework/core/src/Extend/LanguagePack.php +++ b/framework/core/src/Extend/LanguagePack.php @@ -36,7 +36,7 @@ class LanguagePack implements ExtenderInterface, LifecycleInterface ) { } - 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 6163c9a86..13eff72fb 100644 --- a/framework/core/src/Extend/Link.php +++ b/framework/core/src/Extend/Link.php @@ -36,7 +36,7 @@ class Link implements ExtenderInterface 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 3fe491032..83bed9eac 100644 --- a/framework/core/src/Extend/Locales.php +++ b/framework/core/src/Extend/Locales.php @@ -25,7 +25,7 @@ class Locales implements ExtenderInterface, LifecycleInterface ) { } - 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 3a9cbd100..99d556243 100644 --- a/framework/core/src/Extend/Mail.php +++ b/framework/core/src/Extend/Mail.php @@ -31,7 +31,7 @@ class Mail implements ExtenderInterface 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 021b504b9..877cda0f9 100644 --- a/framework/core/src/Extend/Middleware.php +++ b/framework/core/src/Extend/Middleware.php @@ -104,7 +104,7 @@ class Middleware implements ExtenderInterface 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 e0b30fbd3..3197ea726 100644 --- a/framework/core/src/Extend/Model.php +++ b/framework/core/src/Extend/Model.php @@ -177,7 +177,7 @@ class Model implements ExtenderInterface 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 5b44b0f29..3b63e12b7 100644 --- a/framework/core/src/Extend/ModelPrivate.php +++ b/framework/core/src/Extend/ModelPrivate.php @@ -65,7 +65,7 @@ class ModelPrivate implements ExtenderInterface 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 80ef5f824..1560242c4 100644 --- a/framework/core/src/Extend/ModelUrl.php +++ b/framework/core/src/Extend/ModelUrl.php @@ -41,7 +41,7 @@ class ModelUrl implements ExtenderInterface 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 8cf885640..21bd3e19e 100644 --- a/framework/core/src/Extend/ModelVisibility.php +++ b/framework/core/src/Extend/ModelVisibility.php @@ -92,7 +92,7 @@ class ModelVisibility implements ExtenderInterface 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 6a9f5f86e..4386fe1d5 100644 --- a/framework/core/src/Extend/Notification.php +++ b/framework/core/src/Extend/Notification.php @@ -71,7 +71,7 @@ class Notification implements ExtenderInterface 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 a134784e1..ff1ab6c89 100644 --- a/framework/core/src/Extend/Policy.php +++ b/framework/core/src/Extend/Policy.php @@ -50,7 +50,7 @@ class Policy implements ExtenderInterface 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 78e515c21..27282a4d2 100644 --- a/framework/core/src/Extend/Post.php +++ b/framework/core/src/Extend/Post.php @@ -31,7 +31,7 @@ class Post implements ExtenderInterface 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 5e6e2d3fe..a2f719292 100644 --- a/framework/core/src/Extend/Routes.php +++ b/framework/core/src/Extend/Routes.php @@ -169,7 +169,7 @@ class Routes implements ExtenderInterface 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 3e4a22765..4e1e545ac 100644 --- a/framework/core/src/Extend/SearchDriver.php +++ b/framework/core/src/Extend/SearchDriver.php @@ -131,7 +131,7 @@ class SearchDriver implements ExtenderInterface 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 277ad55f8..c31a6f9d1 100644 --- a/framework/core/src/Extend/SearchIndex.php +++ b/framework/core/src/Extend/SearchIndex.php @@ -30,7 +30,7 @@ class SearchIndex implements ExtenderInterface 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 d42416a87..58f98781c 100644 --- a/framework/core/src/Extend/ServiceProvider.php +++ b/framework/core/src/Extend/ServiceProvider.php @@ -34,7 +34,7 @@ class ServiceProvider implements ExtenderInterface 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 c7ed580bb..a44971571 100644 --- a/framework/core/src/Extend/Session.php +++ b/framework/core/src/Extend/Session.php @@ -34,7 +34,7 @@ class Session implements ExtenderInterface 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 bc72e6d86..68a9555d2 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 @@ class Settings implements ExtenderInterface * * @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 @@ class Settings implements ExtenderInterface 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 a70a186b5..f878e42b1 100644 --- a/framework/core/src/Extend/Theme.php +++ b/framework/core/src/Extend/Theme.php @@ -48,7 +48,7 @@ class Theme implements ExtenderInterface * @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 @@ class Theme implements ExtenderInterface 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 ce05332c1..006b3db8d 100644 --- a/framework/core/src/Extend/ThrottleApi.php +++ b/framework/core/src/Extend/ThrottleApi.php @@ -59,7 +59,7 @@ class ThrottleApi implements ExtenderInterface 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 f429258f4..1b76322f5 100644 --- a/framework/core/src/Extend/User.php +++ b/framework/core/src/Extend/User.php @@ -72,7 +72,7 @@ class User implements ExtenderInterface 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 282736e9c..a84540498 100644 --- a/framework/core/src/Extend/Validator.php +++ b/framework/core/src/Extend/Validator.php @@ -48,7 +48,7 @@ class Validator implements ExtenderInterface 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 a71420736..71c9f5e97 100644 --- a/framework/core/src/Extend/View.php +++ b/framework/core/src/Extend/View.php @@ -64,7 +64,7 @@ class View implements ExtenderInterface, LifecycleInterface 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 2a75698e2..8d673493a 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 2dbc97c5c..9434019fd 100644 --- a/framework/core/src/Formatter/Formatter.php +++ b/framework/core/src/Formatter/Formatter.php @@ -63,7 +63,7 @@ class Formatter $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 @@ class Formatter 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 600e86076..bc191d9a5 100644 --- a/framework/core/src/Foundation/Application.php +++ b/framework/core/src/Foundation/Application.php @@ -57,7 +57,7 @@ class Application extends IlluminateContainer implements LaravelApplication 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 d3967e152..06b9c6e79 100644 --- a/framework/core/src/Foundation/Console/InfoCommand.php +++ b/framework/core/src/Foundation/Console/InfoCommand.php @@ -101,7 +101,7 @@ class InfoCommand extends AbstractCommand * 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 04aca149c..0f5f2a8e9 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 6de2d5fdf..b479096dd 100644 --- a/framework/core/src/Frontend/Assets.php +++ b/framework/core/src/Frontend/Assets.php @@ -86,7 +86,7 @@ class Assets $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 4ebf78fdc..66cb52be4 100644 --- a/framework/core/src/Frontend/Compiler/Source/SourceCollector.php +++ b/framework/core/src/Frontend/Compiler/Source/SourceCollector.php @@ -26,7 +26,7 @@ class SourceCollector */ 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 @@ class SourceCollector 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 15f7a8c56..8de6b3b61 100644 --- a/framework/core/src/Http/AccessToken.php +++ b/framework/core/src/Http/AccessToken.php @@ -107,7 +107,7 @@ class AccessToken extends AbstractModel * 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 @@ class AccessToken extends AbstractModel /** * 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 79d431e74..d12e9a71b 100644 --- a/framework/core/src/Http/RouteHandlerFactory.php +++ b/framework/core/src/Http/RouteHandlerFactory.php @@ -66,12 +66,12 @@ class RouteHandlerFactory }); } - 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 7e58774d9..f62bd0046 100644 --- a/framework/core/src/Install/Console/UserDataProvider.php +++ b/framework/core/src/Install/Console/UserDataProvider.php @@ -119,7 +119,7 @@ class UserDataProvider implements DataProviderInterface ]; } - 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 2bae99c86..100943a14 100644 --- a/framework/core/src/Locale/LocaleManager.php +++ b/framework/core/src/Locale/LocaleManager.php @@ -49,7 +49,7 @@ class LocaleManager 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 80f3b3c97..8f548a87d 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 dbdd0e87f..a70359e0e 100644 --- a/framework/core/src/Mail/Mailer.php +++ b/framework/core/src/Mail/Mailer.php @@ -21,7 +21,7 @@ class Mailer extends IlluminateMailer 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 b668ce401..eca8187b9 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/DiscussionRenamedPost.php b/framework/core/src/Post/DiscussionRenamedPost.php index 0866ad704..98900d888 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 19e59bd57..e12caee17 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 056a056f0..6ac36c71d 100644 --- a/framework/core/src/Post/PostRepository.php +++ b/framework/core/src/Post/PostRepository.php @@ -53,7 +53,7 @@ class PostRepository * 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 @@ class PostRepository * @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 7865c8601..ade155ba2 100644 --- a/framework/core/src/User/AvatarValidator.php +++ b/framework/core/src/User/AvatarValidator.php @@ -90,7 +90,7 @@ class AvatarValidator extends AbstractValidator } } - 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 e8e0c1f93..a22bff8c4 100644 --- a/framework/core/src/User/User.php +++ b/framework/core/src/User/User.php @@ -650,7 +650,7 @@ class User extends AbstractModel * * @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 c5a43032a..ae0f087db 100644 --- a/framework/core/src/User/UserRepository.php +++ b/framework/core/src/User/UserRepository.php @@ -33,7 +33,7 @@ class UserRepository * * @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 @@ class UserRepository * * @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 @@ class UserRepository 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 @@ class UserRepository * 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 @@ class UserRepository /** * @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 75d453fb1..f02a2bb98 100644 --- a/framework/core/tests/integration/api/users/GroupSearchTest.php +++ b/framework/core/tests/integration/api/users/GroupSearchTest.php @@ -210,7 +210,7 @@ class GroupSearchTest extends TestCase $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 1201639b6..dd6cc74ad 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 e3e14eab9..c03c29b2b 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 8fb63bb7b..5563944e2 100644 --- a/framework/core/tests/unit/Locale/TranslatorTest.php +++ b/framework/core/tests/unit/Locale/TranslatorTest.php @@ -11,6 +11,7 @@ namespace Flarum\Tests\unit\Locale; 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 @@ class TranslatorTest extends TestCase $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 @@ class TranslatorTest extends TestCase $this->assertSame('test1 {placeholder} test1', $translator->trans('test1', [])); } - /** @test */ + #[Test] public function escaped_placeholders() { $translator = new Translator('en'); @@ -61,7 +62,7 @@ class TranslatorTest extends TestCase $this->assertSame("test1 ' {placeholder} test1", $translator->trans('test3', ['placeholder' => "'"])); } - /** @test */ + #[Test] public function plural_rules() { $translator = new Translator('en'); @@ -74,7 +75,7 @@ class TranslatorTest extends TestCase $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 fe919da30..c0059c84b 100644 --- a/php-packages/testing/src/integration/Extend/BeginTransactionAndSetDatabase.php +++ b/php-packages/testing/src/integration/Extend/BeginTransactionAndSetDatabase.php @@ -27,7 +27,7 @@ class BeginTransactionAndSetDatabase implements ExtenderInterface $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 8d477a2eb..3e1b98807 100644 --- a/php-packages/testing/src/integration/Extend/OverrideExtensionManagerForTests.php +++ b/php-packages/testing/src/integration/Extend/OverrideExtensionManagerForTests.php @@ -27,7 +27,7 @@ class OverrideExtensionManagerForTests implements ExtenderInterface $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 bbf604488..f1029b2d8 100644 --- a/php-packages/testing/src/integration/Extend/SetSettingsBeforeBoot.php +++ b/php-packages/testing/src/integration/Extend/SetSettingsBeforeBoot.php @@ -26,7 +26,7 @@ class SetSettingsBeforeBoot implements ExtenderInterface $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 5f2ed2eb9..0fa3fdb79 100644 --- a/php-packages/testing/tests/tests/phpunit.integration.xml +++ b/php-packages/testing/tests/tests/phpunit.integration.xml @@ -1,7 +1,7 @@