]> BookStack Code Mirror - bookstack/commitdiff
Done a round of phpstan fixes
authorDan Brown <redacted>
Sat, 6 Nov 2021 00:32:01 +0000 (00:32 +0000)
committerDan Brown <redacted>
Sat, 6 Nov 2021 00:32:01 +0000 (00:32 +0000)
24 files changed:
app/Actions/CommentRepo.php
app/Auth/Access/Guards/LdapSessionGuard.php
app/Auth/Access/Ldap.php
app/Console/Commands/ResetMfa.php
app/Entities/Models/Chapter.php
app/Entities/Models/Deletion.php
app/Entities/Models/Page.php
app/Entities/Models/PageRevision.php
app/Entities/Tools/PageEditActivity.php
app/Entities/Tools/SearchRunner.php
app/Entities/Tools/SiblingFetcher.php
app/Entities/Tools/SlugGenerator.php
app/Http/Controllers/Auth/ConfirmEmailController.php
app/Http/Controllers/Controller.php
app/Http/Controllers/FavouriteController.php
app/Http/Middleware/CheckUserHasPermission.php
app/Interfaces/Sluggable.php
app/Model.php
app/Traits/HasCreatorAndUpdater.php
app/Traits/HasOwner.php
app/Uploads/ImageRepo.php
app/Uploads/ImageService.php
app/Util/HtmlContentFilter.php
phpstan.neon.dist

index 8121dfc5cf807b2fb95c2d714e9e7203c7480314..8061c4542e7a86fe2f4d080677e1b1300bfd7372 100644 (file)
@@ -90,8 +90,9 @@ class CommentRepo
      */
     protected function getNextLocalId(Entity $entity): int
     {
      */
     protected function getNextLocalId(Entity $entity): int
     {
-        $comments = $entity->comments(false)->orderBy('local_id', 'desc')->first();
+        /** @var Comment $comment */
+        $comment = $entity->comments(false)->orderBy('local_id', 'desc')->first();
 
 
-        return ($comments->local_id ?? 0) + 1;
+        return ($comment->local_id ?? 0) + 1;
     }
 }
     }
 }
index 7f6965937a19929a43124c508de406e8c61eb90a..078487224b20b5fa3b547cf536d8c3fb7aa69c22 100644 (file)
@@ -94,7 +94,7 @@ class LdapSessionGuard extends ExternalBaseSessionGuard
         }
 
         // Attach avatar if non-existent
         }
 
         // Attach avatar if non-existent
-        if (is_null($user->avatar)) {
+        if (!$user->avatar()->exists()) {
             $this->ldapService->saveAndAttachAvatar($user, $userDetails);
         }
 
             $this->ldapService->saveAndAttachAvatar($user, $userDetails);
         }
 
index b5c70e498c0b4581dae5b6772ecee6f4c20696ca..6259de0ae9b6cbdd9113dfc759ab12ac5030f20f 100644 (file)
@@ -10,14 +10,10 @@ namespace BookStack\Auth\Access;
 class Ldap
 {
     /**
 class Ldap
 {
     /**
-     * Connect to a LDAP server.
-     *
-     * @param string $hostName
-     * @param int    $port
-     *
+     * Connect to an LDAP server.
      * @return resource
      */
      * @return resource
      */
-    public function connect($hostName, $port)
+    public function connect(string $hostName, int $port)
     {
         return ldap_connect($hostName, $port);
     }
     {
         return ldap_connect($hostName, $port);
     }
@@ -26,12 +22,9 @@ class Ldap
      * Set the value of a LDAP option for the given connection.
      *
      * @param resource $ldapConnection
      * Set the value of a LDAP option for the given connection.
      *
      * @param resource $ldapConnection
-     * @param int      $option
      * @param mixed    $value
      * @param mixed    $value
-     *
-     * @return bool
      */
      */
-    public function setOption($ldapConnection, $option, $value)
+    public function setOption($ldapConnection, int $option, $value): bool
     {
         return ldap_set_option($ldapConnection, $option, $value);
     }
     {
         return ldap_set_option($ldapConnection, $option, $value);
     }
@@ -47,12 +40,9 @@ class Ldap
     /**
      * Set the version number for the given ldap connection.
      *
     /**
      * Set the version number for the given ldap connection.
      *
-     * @param $ldapConnection
-     * @param $version
-     *
-     * @return bool
+     * @param resource $ldapConnection
      */
      */
-    public function setVersion($ldapConnection, $version)
+    public function setVersion($ldapConnection, int $version): bool
     {
         return $this->setOption($ldapConnection, LDAP_OPT_PROTOCOL_VERSION, $version);
     }
     {
         return $this->setOption($ldapConnection, LDAP_OPT_PROTOCOL_VERSION, $version);
     }
index 031bec04bf280dd451eda8755db54be322c32c81..9074a4a46f2e7bff2ec57dc46869b85c31985d06 100644 (file)
@@ -49,9 +49,10 @@ class ResetMfa extends Command
             return 1;
         }
 
             return 1;
         }
 
-        /** @var User $user */
         $field = $id ? 'id' : 'email';
         $value = $id ?: $email;
         $field = $id ? 'id' : 'email';
         $value = $id ?: $email;
+
+        /** @var User $user */
         $user = User::query()
             ->where($field, '=', $value)
             ->first();
         $user = User::query()
             ->where($field, '=', $value)
             ->first();
index abf496b44b38e9d3c300f1389b45e62e7c68cf45..75630832b46a77d626afba127f676d4b48f4a8b3 100644 (file)
@@ -3,13 +3,14 @@
 namespace BookStack\Entities\Models;
 
 use Illuminate\Database\Eloquent\Factories\HasFactory;
 namespace BookStack\Entities\Models;
 
 use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Relations\HasMany;
 use Illuminate\Support\Collection;
 
 /**
  * Class Chapter.
  *
  * @property Collection<Page> $pages
 use Illuminate\Support\Collection;
 
 /**
  * Class Chapter.
  *
  * @property Collection<Page> $pages
- * @property mixed description
+ * @property string $description
  */
 class Chapter extends BookChild
 {
  */
 class Chapter extends BookChild
 {
@@ -22,12 +23,8 @@ class Chapter extends BookChild
 
     /**
      * Get the pages that this chapter contains.
 
     /**
      * Get the pages that this chapter contains.
-     *
-     * @param string $dir
-     *
-     * @return mixed
      */
      */
-    public function pages($dir = 'ASC')
+    public function pages(string $dir = 'ASC'): HasMany
     {
         return $this->hasMany(Page::class)->orderBy('priority', $dir);
     }
     {
         return $this->hasMany(Page::class)->orderBy('priority', $dir);
     }
@@ -35,7 +32,7 @@ class Chapter extends BookChild
     /**
      * Get the url of this chapter.
      */
     /**
      * Get the url of this chapter.
      */
-    public function getUrl($path = ''): string
+    public function getUrl(string $path = ''): string
     {
         $parts = [
             'books',
     {
         $parts = [
             'books',
index dab89ce37427e82d372ced42cc5bcd2090322e89..3face841b1890cdafc398c3374ec7d217b50675e 100644 (file)
@@ -9,7 +9,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
 use Illuminate\Database\Eloquent\Relations\MorphTo;
 
 /**
 use Illuminate\Database\Eloquent\Relations\MorphTo;
 
 /**
- * @property Model deletable
+ * @property Model $deletable
  */
 class Deletion extends Model implements Loggable
 {
  */
 class Deletion extends Model implements Loggable
 {
@@ -22,7 +22,7 @@ class Deletion extends Model implements Loggable
     }
 
     /**
     }
 
     /**
-     * The the user that performed the deletion.
+     * Get the user that performed the deletion.
      */
     public function deleter(): BelongsTo
     {
      */
     public function deleter(): BelongsTo
     {
@@ -48,7 +48,11 @@ class Deletion extends Model implements Loggable
     {
         $deletable = $this->deletable()->first();
 
     {
         $deletable = $this->deletable()->first();
 
-        return "Deletion ({$this->id}) for {$deletable->getType()} ({$deletable->id}) {$deletable->name}";
+        if ($deletable instanceof Entity) {
+            return "Deletion ({$this->id}) for {$deletable->getType()} ({$deletable->id}) {$deletable->name}";
+        }
+
+        return "Deletion ({$this->id})";
     }
 
     /**
     }
 
     /**
index fbe0db41b4cbfc48952604a6cf7827b9943585a4..27d5dc6a43de5b68a39ede4942b91c43f24357ed 100644 (file)
@@ -106,7 +106,7 @@ class Page extends BookChild
     /**
      * Get the url of this page.
      */
     /**
      * Get the url of this page.
      */
-    public function getUrl($path = ''): string
+    public function getUrl(string $path = ''): string
     {
         $parts = [
             'books',
     {
         $parts = [
             'books',
index b994e7a04ceec606e56757362e87a74372311dad..336fd67da155eb267a01e533429cc1b6748c9355 100644 (file)
@@ -22,6 +22,8 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
  * @property string $html
  * @property int    $revision_number
  * @property Page   $page
  * @property string $html
  * @property int    $revision_number
  * @property Page   $page
+ *
+ * @property-read ?User $createdBy
  */
 class PageRevision extends Model
 {
  */
 class PageRevision extends Model
 {
index ef6c085ac72c54e086442f80f7be532ba31fe442..9981a6ed7ae2f6fa7742729f9d01ed34ddb0af68 100644 (file)
@@ -35,7 +35,13 @@ class PageEditActivity
         $pageDraftEdits = $this->activePageEditingQuery(60)->get();
         $count = $pageDraftEdits->count();
 
         $pageDraftEdits = $this->activePageEditingQuery(60)->get();
         $count = $pageDraftEdits->count();
 
-        $userMessage = $count > 1 ? trans('entities.pages_draft_edit_active.start_a', ['count' => $count]) : trans('entities.pages_draft_edit_active.start_b', ['userName' => $pageDraftEdits->first()->createdBy->name]);
+        $userMessage = trans('entities.pages_draft_edit_active.start_a', ['count' => $count]);
+        if ($count === 1) {
+            /** @var PageRevision $firstDraft */
+            $firstDraft = $pageDraftEdits->first();
+            $userMessage = trans('entities.pages_draft_edit_active.start_b', ['userName' => $firstDraft->createdBy->name ?? '']);
+        }
+
         $timeMessage = trans('entities.pages_draft_edit_active.time_b', ['minCount'=> 60]);
 
         return trans('entities.pages_draft_edit_active.message', ['start' => $userMessage, 'time' => $timeMessage]);
         $timeMessage = trans('entities.pages_draft_edit_active.time_b', ['minCount'=> 60]);
 
         return trans('entities.pages_draft_edit_active.message', ['start' => $userMessage, 'time' => $timeMessage]);
index df566eb0b30b1769658659205e8a214e7fce61dc..223494d46e5c759a7bbd5b2d6207db31bbbcecb5 100644 (file)
@@ -47,7 +47,7 @@ class SearchRunner
     /**
      * Search all entities in the system.
      * The provided count is for each entity to search,
     /**
      * Search all entities in the system.
      * The provided count is for each entity to search,
-     * Total returned could can be larger and not guaranteed.
+     * Total returned could be larger and not guaranteed.
      */
     public function searchEntities(SearchOptions $searchOpts, string $entityType = 'all', int $page = 1, int $count = 20, string $action = 'view'): array
     {
      */
     public function searchEntities(SearchOptions $searchOpts, string $entityType = 'all', int $page = 1, int $count = 20, string $action = 'view'): array
     {
@@ -68,11 +68,15 @@ class SearchRunner
             if (!in_array($entityType, $entityTypes)) {
                 continue;
             }
             if (!in_array($entityType, $entityTypes)) {
                 continue;
             }
+
             $search = $this->searchEntityTable($searchOpts, $entityType, $page, $count, $action);
             $search = $this->searchEntityTable($searchOpts, $entityType, $page, $count, $action);
+            /** @var int $entityTotal */
             $entityTotal = $this->searchEntityTable($searchOpts, $entityType, $page, $count, $action, true);
             $entityTotal = $this->searchEntityTable($searchOpts, $entityType, $page, $count, $action, true);
-            if ($entityTotal > $page * $count) {
+
+            if ($entityTotal > ($page * $count)) {
                 $hasMore = true;
             }
                 $hasMore = true;
             }
+
             $total += $entityTotal;
             $results = $results->merge($search);
         }
             $total += $entityTotal;
             $results = $results->merge($search);
         }
index e9dad0e134f4f0629182e064e97f68d8b9193328..249e0038eeb8d086c25b3c308a973c265d1c628d 100644 (file)
@@ -5,6 +5,7 @@ namespace BookStack\Entities\Tools;
 use BookStack\Entities\EntityProvider;
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Bookshelf;
 use BookStack\Entities\EntityProvider;
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Bookshelf;
+use BookStack\Entities\Models\Page;
 use Illuminate\Support\Collection;
 
 class SiblingFetcher
 use Illuminate\Support\Collection;
 
 class SiblingFetcher
@@ -18,18 +19,18 @@ class SiblingFetcher
         $entities = [];
 
         // Page in chapter
         $entities = [];
 
         // Page in chapter
-        if ($entity->isA('page') && $entity->chapter) {
+        if ($entity instanceof Page && $entity->chapter) {
             $entities = $entity->chapter->getVisiblePages();
         }
 
         // Page in book or chapter
             $entities = $entity->chapter->getVisiblePages();
         }
 
         // Page in book or chapter
-        if (($entity->isA('page') && !$entity->chapter) || $entity->isA('chapter')) {
+        if (($entity instanceof Page && !$entity->chapter) || $entity->isA('chapter')) {
             $entities = $entity->book->getDirectChildren();
         }
 
         // Book
         // Gets just the books in a shelf if shelf is in context
             $entities = $entity->book->getDirectChildren();
         }
 
         // Book
         // Gets just the books in a shelf if shelf is in context
-        if ($entity->isA('book')) {
+        if ($entity instanceof Book) {
             $contextShelf = (new ShelfContext())->getContextualShelfForBook($entity);
             if ($contextShelf) {
                 $entities = $contextShelf->visibleBooks()->get();
             $contextShelf = (new ShelfContext())->getContextualShelfForBook($entity);
             if ($contextShelf) {
                 $entities = $contextShelf->visibleBooks()->get();
@@ -38,8 +39,8 @@ class SiblingFetcher
             }
         }
 
             }
         }
 
-        // Shelve
-        if ($entity->isA('bookshelf')) {
+        // Shelf
+        if ($entity instanceof Bookshelf) {
             $entities = Bookshelf::visible()->get();
         }
 
             $entities = Bookshelf::visible()->get();
         }
 
index 52e5700da24b94c9e1e6fb31d744f9958f189834..e715f769fd5bdbbdac0215ad48b8972b8c7f1e05 100644 (file)
@@ -4,13 +4,14 @@ namespace BookStack\Entities\Tools;
 
 use BookStack\Entities\Models\BookChild;
 use BookStack\Interfaces\Sluggable;
 
 use BookStack\Entities\Models\BookChild;
 use BookStack\Interfaces\Sluggable;
+use BookStack\Model;
 use Illuminate\Support\Str;
 
 class SlugGenerator
 {
     /**
      * Generate a fresh slug for the given entity.
 use Illuminate\Support\Str;
 
 class SlugGenerator
 {
     /**
      * Generate a fresh slug for the given entity.
-     * The slug will generated so it does not conflict within the same parent item.
+     * The slug will be generated so that it doesn't conflict within the same parent item.
      */
     public function generate(Sluggable $model): string
     {
      */
     public function generate(Sluggable $model): string
     {
@@ -38,6 +39,7 @@ class SlugGenerator
     /**
      * Check if a slug is already in-use for this
      * type of model within the same parent.
     /**
      * Check if a slug is already in-use for this
      * type of model within the same parent.
+     * @param Sluggable&Model $model
      */
     protected function slugInUse(string $slug, Sluggable $model): bool
     {
      */
     protected function slugInUse(string $slug, Sluggable $model): bool
     {
index c5466aecd5ae8c11e735798bdd7c7ce7c59314b5..3e7d4a8368974979970d71a25aaace5863be94c7 100644 (file)
@@ -10,10 +10,7 @@ use BookStack\Exceptions\UserTokenExpiredException;
 use BookStack\Exceptions\UserTokenNotFoundException;
 use BookStack\Http\Controllers\Controller;
 use Exception;
 use BookStack\Exceptions\UserTokenNotFoundException;
 use BookStack\Http\Controllers\Controller;
 use Exception;
-use Illuminate\Http\RedirectResponse;
 use Illuminate\Http\Request;
 use Illuminate\Http\Request;
-use Illuminate\Routing\Redirector;
-use Illuminate\View\View;
 
 class ConfirmEmailController extends Controller
 {
 
 class ConfirmEmailController extends Controller
 {
@@ -57,33 +54,23 @@ class ConfirmEmailController extends Controller
     /**
      * Confirms an email via a token and logs the user into the system.
      *
     /**
      * Confirms an email via a token and logs the user into the system.
      *
-     * @param $token
-     *
      * @throws ConfirmationEmailException
      * @throws Exception
      * @throws ConfirmationEmailException
      * @throws Exception
-     *
-     * @return RedirectResponse|Redirector
      */
      */
-    public function confirm($token)
+    public function confirm(string $token)
     {
         try {
             $userId = $this->emailConfirmationService->checkTokenAndGetUserId($token);
     {
         try {
             $userId = $this->emailConfirmationService->checkTokenAndGetUserId($token);
-        } catch (Exception $exception) {
-            if ($exception instanceof UserTokenNotFoundException) {
-                $this->showErrorNotification(trans('errors.email_confirmation_invalid'));
-
-                return redirect('/register');
-            }
-
-            if ($exception instanceof UserTokenExpiredException) {
-                $user = $this->userRepo->getById($exception->userId);
-                $this->emailConfirmationService->sendConfirmation($user);
-                $this->showErrorNotification(trans('errors.email_confirmation_expired'));
+        } catch (UserTokenNotFoundException $exception) {
+            $this->showErrorNotification(trans('errors.email_confirmation_invalid'));
 
 
-                return redirect('/register/confirm');
-            }
+            return redirect('/register');
+        } catch (UserTokenExpiredException $exception) {
+            $user = $this->userRepo->getById($exception->userId);
+            $this->emailConfirmationService->sendConfirmation($user);
+            $this->showErrorNotification(trans('errors.email_confirmation_expired'));
 
 
-            throw $exception;
+            return redirect('/register/confirm');
         }
 
         $user = $this->userRepo->getById($userId);
         }
 
         $user = $this->userRepo->getById($userId);
@@ -99,10 +86,6 @@ class ConfirmEmailController extends Controller
 
     /**
      * Resend the confirmation email.
 
     /**
      * Resend the confirmation email.
-     *
-     * @param Request $request
-     *
-     * @return View
      */
     public function resend(Request $request)
     {
      */
     public function resend(Request $request)
     {
index df450d051af79f697a0d32e867cebabf56bf9b4f..047e0bed944ba0509ab88c841686acfd2d990809 100644 (file)
@@ -165,7 +165,7 @@ abstract class Controller extends BaseController
     /**
      * Log an activity in the system.
      *
     /**
      * Log an activity in the system.
      *
-     * @param string|Loggable
+     * @param $detail string|Loggable
      */
     protected function logActivity(string $type, $detail = ''): void
     {
      */
     protected function logActivity(string $type, $detail = ''): void
     {
index c8ba3078ce6aeba181a00431667f69495f792a58..8643073c953fe50e59318268f3ba8faed3e474d1 100644 (file)
@@ -66,7 +66,7 @@ class FavouriteController extends Controller
      * @throws \Illuminate\Validation\ValidationException
      * @throws \Exception
      */
      * @throws \Illuminate\Validation\ValidationException
      * @throws \Exception
      */
-    protected function getValidatedModelFromRequest(Request $request): Favouritable
+    protected function getValidatedModelFromRequest(Request $request): Entity
     {
         $modelInfo = $this->validate($request, [
             'type' => ['required', 'string'],
     {
         $modelInfo = $this->validate($request, [
             'type' => ['required', 'string'],
index 4a6a06468d17e025aa2545dd0f7769237acd6cca..b5678e734fb69b541bc759bfac44314d8b5eaf73 100644 (file)
@@ -12,7 +12,7 @@ class CheckUserHasPermission
      *
      * @param \Illuminate\Http\Request $request
      * @param \Closure                 $next
      *
      * @param \Illuminate\Http\Request $request
      * @param \Closure                 $next
-     * @param                          $permission
+     * @param string                   $permission
      *
      * @return mixed
      */
      *
      * @return mixed
      */
index 24ee1bab2f6faba7ce131ad96134f815377cc738..2d56e847e388fcca3993d4ecb35f77f302106d10 100644 (file)
@@ -2,18 +2,12 @@
 
 namespace BookStack\Interfaces;
 
 
 namespace BookStack\Interfaces;
 
-use Illuminate\Database\Eloquent\Builder;
-
 /**
 /**
- * Interface Sluggable.
- *
  * Assigned to models that can have slugs.
  * Must have the below properties.
  *
  * @property int    $id
  * @property string $name
  * Assigned to models that can have slugs.
  * Must have the below properties.
  *
  * @property int    $id
  * @property string $name
- *
- * @method Builder newQuery
  */
 interface Sluggable
 {
  */
 interface Sluggable
 {
index 8520060f442efe78beed4a7a8159302e1f39f896..bd524332cde77b6dea2f6dcba05966dbde7d0571 100644 (file)
@@ -9,12 +9,9 @@ class Model extends EloquentModel
     /**
      * Provides public access to get the raw attribute value from the model.
      * Used in areas where no mutations are required but performance is critical.
     /**
      * Provides public access to get the raw attribute value from the model.
      * Used in areas where no mutations are required but performance is critical.
-     *
-     * @param $key
-     *
      * @return mixed
      */
      * @return mixed
      */
-    public function getRawAttribute($key)
+    public function getRawAttribute(string $key)
     {
         return parent::getAttributeFromArray($key);
     }
     {
         return parent::getAttributeFromArray($key);
     }
index a48936bc8e87414d1bee22fcfcb63cb56d54d8aa..7c60be750059d048251c6ee41574d3b962e5b7c1 100644 (file)
@@ -6,8 +6,8 @@ use BookStack\Auth\User;
 use Illuminate\Database\Eloquent\Relations\BelongsTo;
 
 /**
 use Illuminate\Database\Eloquent\Relations\BelongsTo;
 
 /**
- * @property int created_by
- * @property int updated_by
+ * @property int $created_by
+ * @property int $updated_by
  */
 trait HasCreatorAndUpdater
 {
  */
 trait HasCreatorAndUpdater
 {
index 6700ff4df21184940095c77c6e4cab08391cb2bf..c0fefafa9cb7dc6fa60a6fd325b98e973ab1c669 100644 (file)
@@ -6,7 +6,7 @@ use BookStack\Auth\User;
 use Illuminate\Database\Eloquent\Relations\BelongsTo;
 
 /**
 use Illuminate\Database\Eloquent\Relations\BelongsTo;
 
 /**
- * @property int owned_by
+ * @property int $owned_by
  */
 trait HasOwner
 {
  */
 trait HasOwner
 {
index 2a4ea424f395ca6281ee181324d62ff6ac86600d..494ff3ac0d02c703d06be0a8c58785b3132e0520 100644 (file)
@@ -236,7 +236,7 @@ class ImageRepo
             ->get(['id', 'name', 'slug', 'book_id']);
 
         foreach ($pages as $page) {
             ->get(['id', 'name', 'slug', 'book_id']);
 
         foreach ($pages as $page) {
-            $page->url = $page->getUrl();
+            $page->setAttribute('url', $page->getUrl());
         }
 
         return $pages->all();
         }
 
         return $pages->all();
index 6d4902589c5e9eb46d0a936d9cc20c205b03b1f4..b8477eb4034df5ef3f2d1eef1a10b571bb613ccb 100644 (file)
@@ -8,6 +8,7 @@ use Exception;
 use Illuminate\Contracts\Cache\Repository as Cache;
 use Illuminate\Contracts\Filesystem\FileNotFoundException;
 use Illuminate\Contracts\Filesystem\Filesystem as Storage;
 use Illuminate\Contracts\Cache\Repository as Cache;
 use Illuminate\Contracts\Filesystem\FileNotFoundException;
 use Illuminate\Contracts\Filesystem\Filesystem as Storage;
+use Illuminate\Filesystem\FilesystemAdapter;
 use Illuminate\Filesystem\FilesystemManager;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Log;
 use Illuminate\Filesystem\FilesystemManager;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Log;
@@ -436,10 +437,12 @@ class ImageService
      */
     public function pathExistsInLocalSecure(string $imagePath): bool
     {
      */
     public function pathExistsInLocalSecure(string $imagePath): bool
     {
+        /** @var FilesystemAdapter $disk */
         $disk = $this->getStorageDisk('gallery');
 
         // Check local_secure is active
         return $this->usingSecureImages()
         $disk = $this->getStorageDisk('gallery');
 
         // Check local_secure is active
         return $this->usingSecureImages()
+            && $disk instanceof FilesystemAdapter
             // Check the image file exists
             && $disk->exists($imagePath)
             // Check the file is likely an image file
             // Check the image file exists
             && $disk->exists($imagePath)
             // Check the file is likely an image file
index 1943aa7802c81d6edb7707bc0f7d211d45514839..08dde7048320f93b8f7a98fdfb536b4480ef7b73 100644 (file)
@@ -4,6 +4,7 @@ namespace BookStack\Util;
 
 use DOMAttr;
 use DOMDocument;
 
 use DOMAttr;
 use DOMDocument;
+use DOMElement;
 use DOMNodeList;
 use DOMXPath;
 
 use DOMNodeList;
 use DOMXPath;
 
@@ -92,7 +93,9 @@ class HtmlContentFilter
         /** @var DOMAttr $attr */
         foreach ($attrs as $attr) {
             $attrName = $attr->nodeName;
         /** @var DOMAttr $attr */
         foreach ($attrs as $attr) {
             $attrName = $attr->nodeName;
-            $attr->parentNode->removeAttribute($attrName);
+            /** @var DOMElement $parentNode */
+            $parentNode = $attr->parentNode;
+            $parentNode->removeAttribute($attrName);
         }
     }
 }
         }
     }
 }
index 815b1c187a7ac8c32e3820398004348315ed422c..f3aa47e12f3e06f8e39aa48c4c3bcac280106f84 100644 (file)
@@ -15,7 +15,7 @@ parameters:
       - bootstrap/phpstan.php
 
     ignoreErrors:
       - bootstrap/phpstan.php
 
     ignoreErrors:
-#        - '#Unsafe usage of new static#'
+    #  - '#PHPDoc tag @throws with type .*?Psr\\SimpleCache\\InvalidArgumentException.*? is not subtype of Throwable#'
 
     excludePaths:
         - ./Config/**/*.php
 
     excludePaths:
         - ./Config/**/*.php