]> BookStack Code Mirror - bookstack/commitdiff
PHPStan: Fixed larastan loading and address some level2 issues
authorDan Brown <redacted>
Sun, 10 Dec 2023 14:58:05 +0000 (14:58 +0000)
committerDan Brown <redacted>
Sun, 10 Dec 2023 14:58:05 +0000 (14:58 +0000)
.gitignore
app/Activity/Models/Activity.php
app/Entities/Tools/PageContent.php
app/Entities/Tools/PageIncludeParser.php
app/Exceptions/Handler.php
app/Permissions/PermissionApplicator.php
app/References/ReferenceUpdater.php
app/Theming/ThemeEvents.php
phpstan.neon.dist

index bdc523530f9175454a367f6d7dfa7a734e92bb33..55cc0557b8cae37a6d43840238b9eb06cb7b9cc0 100644 (file)
@@ -29,4 +29,5 @@ webpack-stats.json
 .phpunit.result.cache
 .DS_Store
 phpstan.neon
-esbuild-meta.json
\ No newline at end of file
+esbuild-meta.json
+.phpactor.json
index 9e4cb785864e32a60bfbcd7fa01a428022748ea1..5fad9f1d3a288630e790b96503508da3d19e7a95 100644 (file)
@@ -9,6 +9,7 @@ use BookStack\Users\Models\User;
 use Illuminate\Database\Eloquent\Relations\BelongsTo;
 use Illuminate\Database\Eloquent\Relations\HasMany;
 use Illuminate\Database\Eloquent\Relations\MorphTo;
+use Illuminate\Support\Carbon;
 use Illuminate\Support\Str;
 
 /**
index 552427f4626d474557d3f45fb24d1fa2d5fe01a4..6a89ff626317aaade96c87ceab584703eeb97b06 100644 (file)
@@ -62,6 +62,7 @@ class PageContent
 
         // Get all img elements with image data blobs
         $imageNodes = $doc->queryXPath('//img[contains(@src, \'data:image\')]');
+        /** @var DOMElement $imageNode */
         foreach ($imageNodes as $imageNode) {
             $imageSrc = $imageNode->getAttribute('src');
             $newUrl = $this->base64ImageUriToUploadedImageUrl($imageSrc, $updater);
index f1fbfba03278c8ad1d2589986284bcf2bb5b0913..dad7c29e60ee3392de7b6d56726fee5455074eb5 100644 (file)
@@ -72,8 +72,8 @@ class PageIncludeParser
         $includeTags = [];
 
         /** @var DOMNode $node */
-        /** @var DOMNode $childNode */
         foreach ($includeHosts as $node) {
+            /** @var DOMNode $childNode */
             foreach ($node->childNodes as $childNode) {
                 if ($childNode->nodeName === '#text') {
                     array_push($includeTags, ...$this->splitTextNodesAtTags($childNode));
@@ -174,8 +174,8 @@ class PageIncludeParser
         $parentNode->parentNode->insertBefore($parentClone, $parentNode);
         $parentClone->removeAttribute('id');
 
-        /** @var DOMNode $child */
         for ($i = 0; $i < $splitPos; $i++) {
+            /** @var DOMNode $child */
             $child = $children[$i];
             $parentClone->appendChild($child);
         }
index 6a44200568c96db4eeed5b71c3ffcf480a1eba39..61e1263273bbf6dac1cd759109320e9b63e00bf3 100644 (file)
@@ -9,6 +9,7 @@ use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
 use Illuminate\Http\Exceptions\PostTooLargeException;
 use Illuminate\Http\JsonResponse;
 use Illuminate\Http\Request;
+use Illuminate\Http\Response;
 use Illuminate\Validation\ValidationException;
 use Symfony\Component\ErrorHandler\Error\FatalError;
 use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
@@ -42,7 +43,7 @@ class Handler extends ExceptionHandler
      * If it returns a response, that will be provided back to the request
      * upon an out of memory event.
      *
-     * @var ?callable<?\Illuminate\Http\Response>
+     * @var ?callable(): ?Response
      */
     protected $onOutOfMemory = null;
 
index 7b62ac0a7eb2b250735a2a29aac799f3db83ceac..ce4a543fd8374e5882fe032cb82152f7dfdb70e2 100644 (file)
@@ -25,7 +25,7 @@ class PermissionApplicator
     /**
      * Checks if an entity has a restriction set upon it.
      *
-     * @param HasCreatorAndUpdater|HasOwner $ownable
+     * @param Model&(HasCreatorAndUpdater|HasOwner) $ownable
      */
     public function checkOwnableUserAccess(Model $ownable, string $permission): bool
     {
@@ -160,10 +160,9 @@ class PermissionApplicator
 
         $joinQuery = function ($query) use ($entityProvider) {
             $first = true;
-            /** @var Builder $query */
             foreach ($entityProvider->all() as $entity) {
+                /** @var Builder $query */
                 $entityQuery = function ($query) use ($entity) {
-                    /** @var Builder $query */
                     $query->select(['id', 'deleted_at'])
                         ->selectRaw("'{$entity->getMorphClass()}' as type")
                         ->from($entity->getTable())
index 82505e8ab89081b9fb528f050249795d980b9164..248937339d9335f24346e05c5840bf6ec7d710bb 100644 (file)
@@ -42,6 +42,7 @@ class ReferenceUpdater
             $chapters = $entity->chapters()->get(['id']);
             $children = $pages->concat($chapters);
             foreach ($children as $bookChild) {
+                /** @var Reference[] $childRefs */
                 $childRefs = $this->referenceFetcher->getPageReferencesToEntity($bookChild)->values()->all();
                 array_push($references, ...$childRefs);
             }
index 3d8cd416789b48b039b6e63b85a6e3c1e794a013..ff9e86e16f12fe845a8e42c2ed12fc3ca30c2b22 100644 (file)
@@ -101,7 +101,7 @@ class ThemeEvents
      * Called when standard web (browser/non-api) app routes are registered.
      * Provides an app router, so you can register your own web routes.
      *
-     * @param \Illuminate\Routing\Router
+     * @param \Illuminate\Routing\Router $router
      */
     const ROUTES_REGISTER_WEB = 'routes_register_web';
 
@@ -111,7 +111,7 @@ class ThemeEvents
      * These are routes that typically require login to access (unless the instance is made public).
      * Provides an app router, so you can register your own web routes.
      *
-     * @param \Illuminate\Routing\Router
+     * @param \Illuminate\Routing\Router $router
      */
     const ROUTES_REGISTER_WEB_AUTH = 'routes_register_web_auth';
 
index 936d5a91a04daca998dc9da428a98a5040b299da..5fec36c2f08f2f9a8e646d214da5c2ea54511460 100644 (file)
@@ -1,5 +1,5 @@
 includes:
-    - ./vendor/nunomaduro/larastan/extension.neon
+    - ./vendor/larastan/larastan/extension.neon
 
 parameters: