NOW MANAGED ON CODEBERG
PHPStan: Fixed larastan loading and address some level2 issues
Dan Brownc13fd2a9e69f
diff --git a/.gitignore b/.gitignoreindex bdc523530..55cc0557b 100644--- a/.gitignore+++ b/.gitignore@@ -29,4 +29,5 @@ webpack-stats.json.phpunit.result.cache.DS_Storephpstan.neon-esbuild-meta.json\ No newline at end of file+esbuild-meta.json+.phpactor.jsondiff --git a/app/Activity/Models/Activity.php b/app/Activity/Models/Activity.phpindex 9e4cb7858..5fad9f1d3 100644--- a/app/Activity/Models/Activity.php+++ b/app/Activity/Models/Activity.php@@ -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;/**diff --git a/app/Entities/Tools/PageContent.php b/app/Entities/Tools/PageContent.phpindex 552427f46..6a89ff626 100644--- a/app/Entities/Tools/PageContent.php+++ b/app/Entities/Tools/PageContent.php@@ -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);diff --git a/app/Entities/Tools/PageIncludeParser.php b/app/Entities/Tools/PageIncludeParser.phpindex f1fbfba03..dad7c29e6 100644--- a/app/Entities/Tools/PageIncludeParser.php+++ b/app/Entities/Tools/PageIncludeParser.php@@ -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);}diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.phpindex 6a4420056..61e126327 100644--- a/app/Exceptions/Handler.php+++ b/app/Exceptions/Handler.php@@ -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;diff --git a/app/Permissions/PermissionApplicator.php b/app/Permissions/PermissionApplicator.phpindex 7b62ac0a7..ce4a543fd 100644--- a/app/Permissions/PermissionApplicator.php+++ b/app/Permissions/PermissionApplicator.php@@ -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())diff --git a/app/References/ReferenceUpdater.php b/app/References/ReferenceUpdater.phpindex 82505e8ab..248937339 100644--- a/app/References/ReferenceUpdater.php+++ b/app/References/ReferenceUpdater.php@@ -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);}diff --git a/app/Theming/ThemeEvents.php b/app/Theming/ThemeEvents.phpindex 3d8cd4167..ff9e86e16 100644--- a/app/Theming/ThemeEvents.php+++ b/app/Theming/ThemeEvents.php@@ -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';diff --git a/phpstan.neon.dist b/phpstan.neon.distindex 936d5a91a..5fec36c2f 100644--- a/phpstan.neon.dist+++ b/phpstan.neon.dist@@ -1,5 +1,5 @@includes:- - ./vendor/nunomaduro/larastan/extension.neon+ - ./vendor/larastan/larastan/extension.neonparameters: