Skip to content

Commit

Permalink
PHPStan: Fixed larastan loading and address some level2 issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ssddanbrown committed Dec 10, 2023
1 parent 45ce7a7 commit c13fd2a
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ webpack-stats.json
.phpunit.result.cache
.DS_Store
phpstan.neon
esbuild-meta.json
esbuild-meta.json
.phpactor.json
1 change: 1 addition & 0 deletions app/Activity/Models/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
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;

/**
Expand Down
1 change: 1 addition & 0 deletions app/Entities/Tools/PageContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ protected function extractBase64ImagesFromHtml(string $htmlText, User $updater):

// 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);
Expand Down
4 changes: 2 additions & 2 deletions app/Entities/Tools/PageIncludeParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ protected function locateAndIsolateIncludeTags(): array
$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));
Expand Down Expand Up @@ -174,8 +174,8 @@ protected function splitNodeAtChildNode(DOMElement $parentNode, DOMNode $domNode
$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);
}
Expand Down
3 changes: 2 additions & 1 deletion app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
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;
Expand Down Expand Up @@ -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;

Expand Down
5 changes: 2 additions & 3 deletions app/Permissions/PermissionApplicator.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function __construct(
/**
* 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
{
Expand Down Expand Up @@ -160,10 +160,9 @@ public function filterDeletedFromEntityRelationQuery(Builder $query, string $tab

$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())
Expand Down
1 change: 1 addition & 0 deletions app/References/ReferenceUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ protected function getReferencesToUpdate(Entity $entity): array
$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);
}
Expand Down
4 changes: 2 additions & 2 deletions app/Theming/ThemeEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
includes:
- ./vendor/nunomaduro/larastan/extension.neon
- ./vendor/larastan/larastan/extension.neon

parameters:

Expand Down

0 comments on commit c13fd2a

Please sign in to comment.