PHPStan: Fixed larastan loading and address some level2 issues
This commit is contained in:
parent
45ce7a7126
commit
c13fd2a9e6
9 changed files with 14 additions and 10 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -29,4 +29,5 @@ webpack-stats.json
|
||||||
.phpunit.result.cache
|
.phpunit.result.cache
|
||||||
.DS_Store
|
.DS_Store
|
||||||
phpstan.neon
|
phpstan.neon
|
||||||
esbuild-meta.json
|
esbuild-meta.json
|
||||||
|
.phpactor.json
|
||||||
|
|
|
@ -9,6 +9,7 @@ use BookStack\Users\Models\User;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -62,6 +62,7 @@ class PageContent
|
||||||
|
|
||||||
// Get all img elements with image data blobs
|
// Get all img elements with image data blobs
|
||||||
$imageNodes = $doc->queryXPath('//img[contains(@src, \'data:image\')]');
|
$imageNodes = $doc->queryXPath('//img[contains(@src, \'data:image\')]');
|
||||||
|
/** @var DOMElement $imageNode */
|
||||||
foreach ($imageNodes as $imageNode) {
|
foreach ($imageNodes as $imageNode) {
|
||||||
$imageSrc = $imageNode->getAttribute('src');
|
$imageSrc = $imageNode->getAttribute('src');
|
||||||
$newUrl = $this->base64ImageUriToUploadedImageUrl($imageSrc, $updater);
|
$newUrl = $this->base64ImageUriToUploadedImageUrl($imageSrc, $updater);
|
||||||
|
|
|
@ -72,8 +72,8 @@ class PageIncludeParser
|
||||||
$includeTags = [];
|
$includeTags = [];
|
||||||
|
|
||||||
/** @var DOMNode $node */
|
/** @var DOMNode $node */
|
||||||
/** @var DOMNode $childNode */
|
|
||||||
foreach ($includeHosts as $node) {
|
foreach ($includeHosts as $node) {
|
||||||
|
/** @var DOMNode $childNode */
|
||||||
foreach ($node->childNodes as $childNode) {
|
foreach ($node->childNodes as $childNode) {
|
||||||
if ($childNode->nodeName === '#text') {
|
if ($childNode->nodeName === '#text') {
|
||||||
array_push($includeTags, ...$this->splitTextNodesAtTags($childNode));
|
array_push($includeTags, ...$this->splitTextNodesAtTags($childNode));
|
||||||
|
@ -174,8 +174,8 @@ class PageIncludeParser
|
||||||
$parentNode->parentNode->insertBefore($parentClone, $parentNode);
|
$parentNode->parentNode->insertBefore($parentClone, $parentNode);
|
||||||
$parentClone->removeAttribute('id');
|
$parentClone->removeAttribute('id');
|
||||||
|
|
||||||
/** @var DOMNode $child */
|
|
||||||
for ($i = 0; $i < $splitPos; $i++) {
|
for ($i = 0; $i < $splitPos; $i++) {
|
||||||
|
/** @var DOMNode $child */
|
||||||
$child = $children[$i];
|
$child = $children[$i];
|
||||||
$parentClone->appendChild($child);
|
$parentClone->appendChild($child);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||||
use Illuminate\Http\Exceptions\PostTooLargeException;
|
use Illuminate\Http\Exceptions\PostTooLargeException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Response;
|
||||||
use Illuminate\Validation\ValidationException;
|
use Illuminate\Validation\ValidationException;
|
||||||
use Symfony\Component\ErrorHandler\Error\FatalError;
|
use Symfony\Component\ErrorHandler\Error\FatalError;
|
||||||
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
|
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
|
* If it returns a response, that will be provided back to the request
|
||||||
* upon an out of memory event.
|
* upon an out of memory event.
|
||||||
*
|
*
|
||||||
* @var ?callable<?\Illuminate\Http\Response>
|
* @var ?callable(): ?Response
|
||||||
*/
|
*/
|
||||||
protected $onOutOfMemory = null;
|
protected $onOutOfMemory = null;
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ class PermissionApplicator
|
||||||
/**
|
/**
|
||||||
* Checks if an entity has a restriction set upon it.
|
* 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
|
public function checkOwnableUserAccess(Model $ownable, string $permission): bool
|
||||||
{
|
{
|
||||||
|
@ -160,10 +160,9 @@ class PermissionApplicator
|
||||||
|
|
||||||
$joinQuery = function ($query) use ($entityProvider) {
|
$joinQuery = function ($query) use ($entityProvider) {
|
||||||
$first = true;
|
$first = true;
|
||||||
/** @var Builder $query */
|
|
||||||
foreach ($entityProvider->all() as $entity) {
|
foreach ($entityProvider->all() as $entity) {
|
||||||
|
/** @var Builder $query */
|
||||||
$entityQuery = function ($query) use ($entity) {
|
$entityQuery = function ($query) use ($entity) {
|
||||||
/** @var Builder $query */
|
|
||||||
$query->select(['id', 'deleted_at'])
|
$query->select(['id', 'deleted_at'])
|
||||||
->selectRaw("'{$entity->getMorphClass()}' as type")
|
->selectRaw("'{$entity->getMorphClass()}' as type")
|
||||||
->from($entity->getTable())
|
->from($entity->getTable())
|
||||||
|
|
|
@ -42,6 +42,7 @@ class ReferenceUpdater
|
||||||
$chapters = $entity->chapters()->get(['id']);
|
$chapters = $entity->chapters()->get(['id']);
|
||||||
$children = $pages->concat($chapters);
|
$children = $pages->concat($chapters);
|
||||||
foreach ($children as $bookChild) {
|
foreach ($children as $bookChild) {
|
||||||
|
/** @var Reference[] $childRefs */
|
||||||
$childRefs = $this->referenceFetcher->getPageReferencesToEntity($bookChild)->values()->all();
|
$childRefs = $this->referenceFetcher->getPageReferencesToEntity($bookChild)->values()->all();
|
||||||
array_push($references, ...$childRefs);
|
array_push($references, ...$childRefs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,7 +101,7 @@ class ThemeEvents
|
||||||
* Called when standard web (browser/non-api) app routes are registered.
|
* Called when standard web (browser/non-api) app routes are registered.
|
||||||
* Provides an app router, so you can register your own web routes.
|
* 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';
|
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).
|
* 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.
|
* 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';
|
const ROUTES_REGISTER_WEB_AUTH = 'routes_register_web_auth';
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
includes:
|
includes:
|
||||||
- ./vendor/nunomaduro/larastan/extension.neon
|
- ./vendor/larastan/larastan/extension.neon
|
||||||
|
|
||||||
parameters:
|
parameters:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue