From c409d48bf8f3f6cc2af29d30798856b031f5afec Mon Sep 17 00:00:00 2001 From: Bubka <858858+Bubka@users.noreply.github.com> Date: Sat, 23 Nov 2024 14:29:31 +0100 Subject: [PATCH] Fix phpstan issues --- .../Controllers/Auth/WebAuthnRegisterController.php | 2 +- .../Middleware/AddContentSecurityPolicyHeaders.php | 12 +++++++----- app/Models/AuthLog.php | 2 +- app/Models/Group.php | 4 ++-- app/Models/Icon.php | 2 +- app/Models/Traits/HasAuthenticationLog.php | 4 ++-- app/Models/TwoFAccount.php | 6 +++--- app/Models/User.php | 4 ++-- 8 files changed, 19 insertions(+), 17 deletions(-) diff --git a/app/Http/Controllers/Auth/WebAuthnRegisterController.php b/app/Http/Controllers/Auth/WebAuthnRegisterController.php index 303d34714..3ab1fe6d1 100644 --- a/app/Http/Controllers/Auth/WebAuthnRegisterController.php +++ b/app/Http/Controllers/Auth/WebAuthnRegisterController.php @@ -39,7 +39,7 @@ public function register(AttestedRequest $request) : Response { $request->save(); - Log::info(sprintf('User ID #%s registered a new security device', $request->user()->id)); + Log::info(sprintf('User ID #%s registered a new security device', $request->user()->id)); /** @phpstan-ignore property.notFound */ return response()->noContent(); } diff --git a/app/Http/Middleware/AddContentSecurityPolicyHeaders.php b/app/Http/Middleware/AddContentSecurityPolicyHeaders.php index 7ef78c19b..80d00aee4 100644 --- a/app/Http/Middleware/AddContentSecurityPolicyHeaders.php +++ b/app/Http/Middleware/AddContentSecurityPolicyHeaders.php @@ -21,15 +21,17 @@ public function handle(Request $request, Closure $next) : Response $assetUrl = config('app.asset_url') != config('app.url') ? config('app.asset_url') : ''; - $directives['script-src'] = "script-src 'nonce-" . Vite::cspNonce() . "' " . $assetUrl . ";"; + $directives['script-src'] = "script-src 'nonce-" . Vite::cspNonce() . "' " . $assetUrl . ';'; $directives['script-src-elem'] = "script-src-elem 'nonce-" . Vite::cspNonce() . "' " . $assetUrl . " 'strict-dynamic';"; - $directives['style-src'] = "style-src 'self' " . $assetUrl . " 'unsafe-inline';"; - $directives['connect-src'] = "connect-src 'self';"; - $directives['img-src'] = "img-src 'self' data: " . $assetUrl . ";"; - $directives['object-src'] = "object-src 'none';"; + $directives['style-src'] = "style-src 'self' " . $assetUrl . " 'unsafe-inline';"; + $directives['connect-src'] = "connect-src 'self';"; + $directives['img-src'] = "img-src 'self' data: " . $assetUrl . ';'; + $directives['object-src'] = "object-src 'none';"; $csp = implode(' ', $directives); + /** @disregard Undefined function */ + /** @phpstan-ignore-next-line */ return $next($request)->withHeaders([ 'Content-Security-Policy' => $csp, ]); diff --git a/app/Models/AuthLog.php b/app/Models/AuthLog.php index bb174dbb6..731b64f40 100644 --- a/app/Models/AuthLog.php +++ b/app/Models/AuthLog.php @@ -101,7 +101,7 @@ class AuthLog extends Model /** * MorphTo relation to get the associated authenticatable user * - * @return MorphTo<\Illuminate\Database\Eloquent\Model, AuthLog> + * @return \Illuminate\Database\Eloquent\Relations\MorphTo<\Illuminate\Database\Eloquent\Model, $this> */ public function authenticatable() { diff --git a/app/Models/Group.php b/app/Models/Group.php index 88ff1db8a..67b06aa5b 100644 --- a/app/Models/Group.php +++ b/app/Models/Group.php @@ -106,7 +106,7 @@ protected static function boot() /** * Get the TwoFAccounts of the group. * - * @return \Illuminate\Database\Eloquent\Relations\HasMany + * @return \Illuminate\Database\Eloquent\Relations\HasMany<\App\Models\TwoFAccount, $this> */ public function twofaccounts() { @@ -116,7 +116,7 @@ public function twofaccounts() /** * Get the user that owns the group. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\App\Models\User, \App\Models\Group> + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\App\Models\User, $this> */ public function user() { diff --git a/app/Models/Icon.php b/app/Models/Icon.php index 2f90119d8..e3ee2a233 100644 --- a/app/Models/Icon.php +++ b/app/Models/Icon.php @@ -58,7 +58,7 @@ class Icon extends Model /** * Get the twofaccount that owns the icon. * - * @return BelongsTo<\App\Models\TwoFAccount, \App\Models\Icon> + * @return BelongsTo<\App\Models\TwoFAccount, $this> */ public function twofaccount() : BelongsTo { diff --git a/app/Models/Traits/HasAuthenticationLog.php b/app/Models/Traits/HasAuthenticationLog.php index 6de118942..cf8dd4729 100644 --- a/app/Models/Traits/HasAuthenticationLog.php +++ b/app/Models/Traits/HasAuthenticationLog.php @@ -32,7 +32,7 @@ trait HasAuthenticationLog /** * Get all user's authentications from the auth log * - * @return \Illuminate\Database\Eloquent\Relations\MorphMany + * @return \Illuminate\Database\Eloquent\Relations\MorphMany<\App\Models\AuthLog, $this> */ public function authentications() { @@ -56,7 +56,7 @@ public function authenticationsByPeriod(int $period = 1) /** * Get the user's latest authentication * - * @return \Illuminate\Database\Eloquent\Relations\MorphOne + * @return \Illuminate\Database\Eloquent\Relations\MorphOne<\App\Models\AuthLog, $this> */ public function latestAuthentication() { diff --git a/app/Models/TwoFAccount.php b/app/Models/TwoFAccount.php index 8307a84b6..d0792c863 100644 --- a/app/Models/TwoFAccount.php +++ b/app/Models/TwoFAccount.php @@ -227,7 +227,7 @@ protected static function boot() /** * Get the user that owns the twofaccount. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\App\Models\User, \App\Models\TwoFAccount> + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\App\Models\User, $this> */ public function user() { @@ -237,7 +237,7 @@ public function user() /** * Get the relation between the icon resource and the model. * - * @return HasOne<\App\Models\Icon> + * @return HasOne<\App\Models\Icon, $this> */ public function iconResource() : HasOne { @@ -658,7 +658,7 @@ private function initGenerator() : void } /** - * @return \Illuminate\Database\Eloquent\Builder + * @return \Illuminate\Database\Eloquent\Builder */ public function buildSortQuery() { diff --git a/app/Models/User.php b/app/Models/User.php index 77d7760d9..47a97dfa4 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -242,7 +242,7 @@ static function ($query) use ($id) { /** * Get the TwoFAccounts of the user. * - * @return \Illuminate\Database\Eloquent\Relations\HasMany + * @return \Illuminate\Database\Eloquent\Relations\HasMany<\App\Models\TwoFAccount, $this> */ public function twofaccounts() { @@ -252,7 +252,7 @@ public function twofaccounts() /** * Get the Groups of the user. * - * @return \Illuminate\Database\Eloquent\Relations\HasMany + * @return \Illuminate\Database\Eloquent\Relations\HasMany<\App\Models\Group, $this> */ public function groups() {