From 1bce650debb8a27b75734ba30d5a496b7a31a72e Mon Sep 17 00:00:00 2001 From: Justin Obara Date: Thu, 11 Jan 2024 10:11:19 -0500 Subject: [PATCH] style: run php formatting --- app/Http/Middleware/EnsureEmailIsVerified.php | 2 +- app/Livewire/ManageAccounts.php | 2 +- app/Livewire/Prompt.php | 2 +- app/Models/Invitation.php | 2 +- app/Models/MatchingStrategy.php | 4 ++-- app/Rules/UniqueUserEmail.php | 2 +- app/View/Components/AppLayout.php | 2 +- app/View/Components/Banner.php | 2 +- app/View/Components/Interpretation.php | 2 +- app/View/Components/TranslationPicker.php | 2 +- app/helpers.php | 14 +++++++------- tests/Feature/MatchingStrategyTest.php | 2 +- tests/Feature/NotificationListTest.php | 2 +- tests/Feature/TranslationTest.php | 4 ++-- 14 files changed, 22 insertions(+), 22 deletions(-) diff --git a/app/Http/Middleware/EnsureEmailIsVerified.php b/app/Http/Middleware/EnsureEmailIsVerified.php index a072512c6..d61d2591e 100644 --- a/app/Http/Middleware/EnsureEmailIsVerified.php +++ b/app/Http/Middleware/EnsureEmailIsVerified.php @@ -14,7 +14,7 @@ class EnsureEmailIsVerified /** * Handle an incoming request. */ - public function handle(Request $request, Closure $next, string $redirectToRoute = null): Response|RedirectResponse|null + public function handle(Request $request, Closure $next, ?string $redirectToRoute = null): Response|RedirectResponse|null { if (! $request->user() || ($request->user() instanceof MustVerifyEmail && diff --git a/app/Livewire/ManageAccounts.php b/app/Livewire/ManageAccounts.php index a5d610171..358a93871 100644 --- a/app/Livewire/ManageAccounts.php +++ b/app/Livewire/ManageAccounts.php @@ -50,7 +50,7 @@ public function render() ->layout('layouts.app', ['bodyClass' => 'page', 'headerClass' => 'stack', 'pageWidth' => 'wide']); } - public function flash(string $message, string $interpretation = null) + public function flash(string $message, ?string $interpretation = null) { $this->dispatch('clear-flash-message'); session()->flash('message', $message); diff --git a/app/Livewire/Prompt.php b/app/Livewire/Prompt.php index 882cc2e56..bf30786f6 100644 --- a/app/Livewire/Prompt.php +++ b/app/Livewire/Prompt.php @@ -24,7 +24,7 @@ class Prompt extends Component public ?string $interpretationNameSpace; - public function mount(mixed $model, string $modelPath, string $heading, string $description, string $actionLabel, string $actionUrl, int $level = 3, string $interpretationName = null, string $interpretationNameSpace = null) + public function mount(mixed $model, string $modelPath, string $heading, string $description, string $actionLabel, string $actionUrl, int $level = 3, ?string $interpretationName = null, ?string $interpretationNameSpace = null) { $this->model = $model; $this->modelPath = $modelPath; diff --git a/app/Models/Invitation.php b/app/Models/Invitation.php index bedbc8fae..64ed42a93 100644 --- a/app/Models/Invitation.php +++ b/app/Models/Invitation.php @@ -29,7 +29,7 @@ public function email(): Attribute ); } - public function accept(string $type = null): void + public function accept(?string $type = null): void { if ($type) { if ($type === 'individual') { diff --git a/app/Models/MatchingStrategy.php b/app/Models/MatchingStrategy.php index 7236431bb..0ddd8e747 100644 --- a/app/Models/MatchingStrategy.php +++ b/app/Models/MatchingStrategy.php @@ -188,7 +188,7 @@ public function detachClusters(array $clusters) /** * Synchronize associations with identities from a single identity cluster. */ - public function syncRelatedIdentities(IdentityCluster $cluster, int|array $identities, string $weight = null, bool $detaching = true): void + public function syncRelatedIdentities(IdentityCluster $cluster, int|array $identities, ?string $weight = null, bool $detaching = true): void { if (! is_array($identities)) { $identities = [$identities]; @@ -206,7 +206,7 @@ public function syncRelatedIdentities(IdentityCluster $cluster, int|array $ident } } - public function syncMutuallyExclusiveIdentities(IdentityCluster $cluster, int|array $identities, array $mutuallyExclusiveClusters, bool $detachLanguages = true, string $weight = null, bool $detaching = true): void + public function syncMutuallyExclusiveIdentities(IdentityCluster $cluster, int|array $identities, array $mutuallyExclusiveClusters, bool $detachLanguages = true, ?string $weight = null, bool $detaching = true): void { if (! is_array($identities)) { $identities = [$identities]; diff --git a/app/Rules/UniqueUserEmail.php b/app/Rules/UniqueUserEmail.php index 78a6d4b2f..543badc6a 100644 --- a/app/Rules/UniqueUserEmail.php +++ b/app/Rules/UniqueUserEmail.php @@ -14,7 +14,7 @@ class UniqueUserEmail implements InvokableRule // Can use the $id and $idColumn to define a model to ignore. Similar to how Laravel's unique validation rule works // see: https://laravel.com/docs/10.x/validation#rule-unique - public function __construct(mixed $id = null, string $idColumn = null) + public function __construct(mixed $id = null, ?string $idColumn = null) { $this->id = $id; $this->idColumn = $idColumn ?? 'id'; diff --git a/app/View/Components/AppLayout.php b/app/View/Components/AppLayout.php index 507f2d4a4..230cf7b37 100644 --- a/app/View/Components/AppLayout.php +++ b/app/View/Components/AppLayout.php @@ -13,7 +13,7 @@ class AppLayout extends Component public ?string $pageWidth; - public function __construct(string $bodyClass = 'page', string $headerClass = 'stack', string $pageWidth = null) + public function __construct(string $bodyClass = 'page', string $headerClass = 'stack', ?string $pageWidth = null) { $this->bodyClass = $bodyClass; $this->headerClass = $headerClass; diff --git a/app/View/Components/Banner.php b/app/View/Components/Banner.php index 283b2df92..76c1010f3 100644 --- a/app/View/Components/Banner.php +++ b/app/View/Components/Banner.php @@ -11,7 +11,7 @@ class Banner extends Component public ?string $icon; - public function __construct(string $type = 'info', string $icon = null) + public function __construct(string $type = 'info', ?string $icon = null) { $this->type = $type; diff --git a/app/View/Components/Interpretation.php b/app/View/Components/Interpretation.php index 17810ebf5..c64c98b8b 100644 --- a/app/View/Components/Interpretation.php +++ b/app/View/Components/Interpretation.php @@ -30,7 +30,7 @@ class Interpretation extends Component * * @return void */ - public function __construct(string $name, string $namespace = null) + public function __construct(string $name, ?string $namespace = null) { $this->name = $name; $this->namespace = $namespace; diff --git a/app/View/Components/TranslationPicker.php b/app/View/Components/TranslationPicker.php index 4e1150ae8..93775c9fd 100644 --- a/app/View/Components/TranslationPicker.php +++ b/app/View/Components/TranslationPicker.php @@ -12,7 +12,7 @@ class TranslationPicker extends Component public array $availableLanguages; - public function __construct(array $languages = null, array $availableLanguages = null) + public function __construct(?array $languages = null, ?array $availableLanguages = null) { $this->languages = $languages ?? get_supported_locales(false); $this->availableLanguages = $availableLanguages ?? Options::forArray(get_available_languages(true, false))->nullable(__('Choose a languageā€¦'))->toArray(); diff --git a/app/helpers.php b/app/helpers.php index 957b107e8..47929afb8 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -15,7 +15,7 @@ * @param string|null $key The setting key. * @param mixed|null $default A default value for the setting. */ - function settings(string $key = null, mixed $default = null): mixed + function settings(?string $key = null, mixed $default = null): mixed { return app(GeneralSettings::class)->$key ?? $default; } @@ -209,7 +209,7 @@ function to_written_languages(array $codes): array * @param bool $capitalize Whether the returned language exonym should be capitalized. * @return null|string The localized name of the locale, if found. */ - function get_language_exonym(string $code, string $locale = null, bool $capitalize = true, bool $acronym = false): ?string + function get_language_exonym(string $code, ?string $locale = null, bool $capitalize = true, bool $acronym = false): ?string { $locale ??= locale(); @@ -244,7 +244,7 @@ function get_language_exonym(string $code, string $locale = null, bool $capitali * * See: https://github.com/spatie/laravel-sluggable/discussions/228 */ - function localized_route_for_locale(string $name, mixed $parameters, string $locale = null, bool $absolute = true): string + function localized_route_for_locale(string $name, mixed $parameters, ?string $locale = null, bool $absolute = true): string { // dd(is_null($locale), $locale === $locale); if (is_null($locale) || $locale === locale()) { @@ -271,7 +271,7 @@ function localized_route_for_locale(string $name, mixed $parameters, string $loc * would be the same as calling the `getName` method on the route directly. If no route is passed in, it will attempt * to use the current route. */ - function route_name(Route $route = null, bool $localized = false): ?string + function route_name(?Route $route = null, bool $localized = false): ?string { $route ??= RouteFacade::getCurrentRoute(); $routeName = $route->getName(); @@ -367,7 +367,7 @@ function html_replacements(string $string, array $replacements = []): string } if (! function_exists('safe_markdown')) { - function safe_markdown(string $string, array $replacements = [], string $locale = null, bool $inline = false): HtmlString + function safe_markdown(string $string, array $replacements = [], ?string $locale = null, bool $inline = false): HtmlString { $markdownFuncName = $inline ? 'inlineMarkdown' : 'markdown'; @@ -379,7 +379,7 @@ function safe_markdown(string $string, array $replacements = [], string $locale } if (! function_exists('safe_inlineMarkdown')) { - function safe_inlineMarkdown(string $string, array $replacements = [], string $locale = null): HtmlString + function safe_inlineMarkdown(string $string, array $replacements = [], ?string $locale = null): HtmlString { return safe_markdown($string, $replacements, $locale, true); } @@ -412,7 +412,7 @@ function orientation_link(string $userType): string * @param string|null $locale The requested locale for the setting to be returned in * @param mixed|null $default A default value for the setting. */ - function settings_localized(string $key = null, string $locale = null, mixed $default = null): mixed + function settings_localized(?string $key = null, ?string $locale = null, mixed $default = null): mixed { $locale = to_written_language($locale ?? config('app.locale')); $settings = settings($key, []); diff --git a/tests/Feature/MatchingStrategyTest.php b/tests/Feature/MatchingStrategyTest.php index fa49c8b29..7cb9067f2 100644 --- a/tests/Feature/MatchingStrategyTest.php +++ b/tests/Feature/MatchingStrategyTest.php @@ -140,7 +140,7 @@ expect(array_values($matchingStrategy->disability_and_deaf_group_summary))->toEqual($expected); })->with('matchingStrategyDisabilityAndDeafGroupSummary'); -test('matching strategy other identities summary accessor', function ($data, array $identities, array $expected = null) { +test('matching strategy other identities summary accessor', function ($data, array $identities, ?array $expected = null) { $this->seed(LanguageSeeder::class); $matchingStrategy = MatchingStrategy::factory()->create($data); $expectedIdentities = []; diff --git a/tests/Feature/NotificationListTest.php b/tests/Feature/NotificationListTest.php index 3032e1d3f..9a08c1d4d 100644 --- a/tests/Feature/NotificationListTest.php +++ b/tests/Feature/NotificationListTest.php @@ -134,7 +134,7 @@ expect($organization->isNotifying($nullUser))->toBeFalse(); }); -test('add notificationable validation errors', function ($data, array $errors = null) { +test('add notificationable validation errors', function ($data, ?array $errors = null) { $user = User::factory()->create(); $organization = Organization::factory()->create(['name' => ['en' => 'Umbrella Corporation'], 'published_at' => now()]); diff --git a/tests/Feature/TranslationTest.php b/tests/Feature/TranslationTest.php index d645799f6..b8c00ddd8 100644 --- a/tests/Feature/TranslationTest.php +++ b/tests/Feature/TranslationTest.php @@ -21,7 +21,7 @@ expect(flash()->message)->toBe(__('Language :language added.', ['language' => get_language_exonym('asl')])); }); -test('add translation validation errors', function ($data, array $errors = null) { +test('add translation validation errors', function ($data, ?array $errors = null) { $individual = Individual::factory()->create([ 'name' => 'Tester', 'roles' => ['consultant'], @@ -62,7 +62,7 @@ expect(flash()->message)->toBe(__('Language :language removed.', ['language' => get_language_exonym('fr')])); }); -test('destroy translation validation errors', function ($data, array $errors = null) { +test('destroy translation validation errors', function ($data, ?array $errors = null) { $individual = Individual::factory()->create([ 'name' => 'Tester', 'roles' => ['consultant'],