Browse Source

Fix phpstan issues

Bubka 8 months ago
parent
commit
c409d48bf8

+ 1 - 1
app/Http/Controllers/Auth/WebAuthnRegisterController.php

@@ -39,7 +39,7 @@ class WebAuthnRegisterController extends Controller
     {
         $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();
     }

+ 7 - 5
app/Http/Middleware/AddContentSecurityPolicyHeaders.php

@@ -21,15 +21,17 @@ class AddContentSecurityPolicyHeaders
 
             $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,
             ]);

+ 1 - 1
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()
     {

+ 2 - 2
app/Models/Group.php

@@ -106,7 +106,7 @@ class Group extends Model
     /**
      * Get the TwoFAccounts of the group.
      *
-     * @return \Illuminate\Database\Eloquent\Relations\HasMany<TwoFAccount>
+     * @return \Illuminate\Database\Eloquent\Relations\HasMany<\App\Models\TwoFAccount, $this>
      */
     public function twofaccounts()
     {
@@ -116,7 +116,7 @@ class Group extends Model
     /**
      * 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()
     {

+ 1 - 1
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
     {

+ 2 - 2
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<AuthLog>
+     * @return \Illuminate\Database\Eloquent\Relations\MorphMany<\App\Models\AuthLog, $this>
      */
     public function authentications()
     {
@@ -56,7 +56,7 @@ trait HasAuthenticationLog
     /**
      * Get the user's latest authentication
      *
-     * @return \Illuminate\Database\Eloquent\Relations\MorphOne<AuthLog>
+     * @return \Illuminate\Database\Eloquent\Relations\MorphOne<\App\Models\AuthLog, $this>
      */
     public function latestAuthentication()
     {

+ 3 - 3
app/Models/TwoFAccount.php

@@ -227,7 +227,7 @@ class TwoFAccount extends Model implements Sortable
     /**
      * 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 @@ class TwoFAccount extends Model implements Sortable
     /**
      * 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 @@ class TwoFAccount extends Model implements Sortable
     }
 
     /**
-     * @return \Illuminate\Database\Eloquent\Builder<TwoFAccount>
+     * @return \Illuminate\Database\Eloquent\Builder<static>
      */
     public function buildSortQuery()
     {

+ 2 - 2
app/Models/User.php

@@ -242,7 +242,7 @@ class User extends Authenticatable implements HasLocalePreference, WebAuthnAuthe
     /**
      * Get the TwoFAccounts of the user.
      *
-     * @return \Illuminate\Database\Eloquent\Relations\HasMany<TwoFAccount>
+     * @return \Illuminate\Database\Eloquent\Relations\HasMany<\App\Models\TwoFAccount, $this>
      */
     public function twofaccounts()
     {
@@ -252,7 +252,7 @@ class User extends Authenticatable implements HasLocalePreference, WebAuthnAuthe
     /**
      * Get the Groups of the user.
      *
-     * @return \Illuminate\Database\Eloquent\Relations\HasMany<Group>
+     * @return \Illuminate\Database\Eloquent\Relations\HasMany<\App\Models\Group, $this>
      */
     public function groups()
     {