From 8cc9fd4f1c73fb8df23dc1ae68a7057a946f30ef Mon Sep 17 00:00:00 2001 From: ildyria Date: Mon, 10 Jun 2024 10:36:35 +0200 Subject: [PATCH 1/3] composer update --- composer.lock | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/composer.lock b/composer.lock index 6d339c2a2d2..884ce9c9aa6 100644 --- a/composer.lock +++ b/composer.lock @@ -62,16 +62,16 @@ }, { "name": "aws/aws-sdk-php", - "version": "3.311.0", + "version": "3.311.2", "source": { "type": "git", "url": "https://github.com/aws/aws-sdk-php.git", - "reference": "3e1cc8fe522eae7deca8b7753c573c2c69444705" + "reference": "731cd73062909594c5f7443413c4c4c40ed1c25c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/3e1cc8fe522eae7deca8b7753c573c2c69444705", - "reference": "3e1cc8fe522eae7deca8b7753c573c2c69444705", + "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/731cd73062909594c5f7443413c4c4c40ed1c25c", + "reference": "731cd73062909594c5f7443413c4c4c40ed1c25c", "shasum": "" }, "require": { @@ -151,9 +151,9 @@ "support": { "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80", "issues": "https://github.com/aws/aws-sdk-php/issues", - "source": "https://github.com/aws/aws-sdk-php/tree/3.311.0" + "source": "https://github.com/aws/aws-sdk-php/tree/3.311.2" }, - "time": "2024-06-05T18:07:37+00:00" + "time": "2024-06-07T18:05:33+00:00" }, { "name": "bepsvpt/secure-headers", @@ -3522,31 +3522,31 @@ }, { "name": "lychee-org/nestedset", - "version": "v8.0.0", + "version": "v8.1.0", "source": { "type": "git", "url": "https://github.com/LycheeOrg/laravel-nestedset.git", - "reference": "eb7480b40c0d16dbf16f10fb66cf303e2546b34d" + "reference": "92a00e9f89013275cb5831b3a6a2aa70267ad86d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/LycheeOrg/laravel-nestedset/zipball/eb7480b40c0d16dbf16f10fb66cf303e2546b34d", - "reference": "eb7480b40c0d16dbf16f10fb66cf303e2546b34d", + "url": "https://api.github.com/repos/LycheeOrg/laravel-nestedset/zipball/92a00e9f89013275cb5831b3a6a2aa70267ad86d", + "reference": "92a00e9f89013275cb5831b3a6a2aa70267ad86d", "shasum": "" }, "require": { "illuminate/database": "^10.0", "illuminate/events": "^10.0", "illuminate/support": "^10.0", - "php": "^8.1" + "php": "^8.2" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.3", - "lychee-org/phpstan-lychee": "^1.0", + "lychee-org/phpstan-lychee": "^1.0.4", "nunomaduro/larastan": "^2.0", "orchestra/testbench": "^8.0", "php-parallel-lint/php-parallel-lint": "^1.2", - "phpunit/phpunit": "^9.5.20" + "phpunit/phpunit": "^10.5" }, "type": "library", "extra": { @@ -3583,9 +3583,9 @@ "nsm" ], "support": { - "source": "https://github.com/LycheeOrg/laravel-nestedset/tree/v8.0.0" + "source": "https://github.com/LycheeOrg/laravel-nestedset/tree/v8.1.0" }, - "time": "2023-02-15T15:05:23+00:00" + "time": "2024-06-10T08:23:54+00:00" }, { "name": "lychee-org/php-exif", From 7f4b4d271be1c115a6e25a30f953615cbed87163 Mon Sep 17 00:00:00 2001 From: ildyria Date: Mon, 10 Jun 2024 12:07:37 +0200 Subject: [PATCH 2/3] more fixes --- app/Actions/Albums/Top.php | 6 +++--- app/Actions/Albums/Tree.php | 8 ++++---- app/Actions/Search/AlbumSearch.php | 1 - app/Factories/AlbumFactory.php | 2 -- app/Http/Requests/Album/AddAlbumRequest.php | 5 ++--- app/Http/Requests/Album/DeleteTrackRequest.php | 4 +++- app/Http/Requests/Album/MoveAlbumsRequest.php | 1 + .../Requests/Album/SetAlbumCoverRequest.php | 5 ++++- .../Requests/Album/SetAlbumHeaderRequest.php | 5 ++++- .../Requests/Album/SetAlbumLicenseRequest.php | 5 ++++- .../Requests/Album/SetAlbumTrackRequest.php | 4 +++- .../Requests/Import/ImportFromUrlRequest.php | 1 + .../Requests/Import/ImportServerRequest.php | 1 + .../Requests/Photo/DuplicatePhotosRequest.php | 1 + app/Http/Requests/Photo/MovePhotosRequest.php | 1 + .../Components/Forms/Album/SearchAlbum.php | 8 ++++---- app/Models/Album.php | 6 +++++- app/Models/Builders/AlbumBuilder.php | 17 +++++++++++++++-- app/Relations/HasManyChildAlbums.php | 1 - composer.lock | 12 ++++++------ .../2020_12_26_153220_nested_set_for_albums.php | 2 +- .../NestedSetForAlbums_AlbumModel.php | 1 + .../RefactorAlbumModel_AlbumModel.php | 3 +++ phpstan.neon | 5 ++--- 24 files changed, 69 insertions(+), 36 deletions(-) diff --git a/app/Actions/Albums/Top.php b/app/Actions/Albums/Top.php index 1e028e5b3ad..a1c6a4e89f5 100644 --- a/app/Actions/Albums/Top.php +++ b/app/Actions/Albums/Top.php @@ -20,7 +20,6 @@ use Illuminate\Support\Collection as BaseCollection; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Gate; -use Kalnoy\Nestedset\QueryBuilder as NsQueryBuilder; class Top { @@ -82,14 +81,14 @@ public function get(): TopAlbumsResource ->orderBy($this->sorting->column, $this->sorting->order) ->get(); - /** @var NsQueryBuilder $query */ + /** @return AlbumBuilder $query */ $query = $this->albumQueryPolicy ->applyVisibilityFilter(Album::query()->with(['access_permissions', 'owner'])->whereIsRoot()); $userID = Auth::id(); if ($userID !== null) { // For authenticated users we group albums by ownership. - /** @var BaseCollection $albums */ + /** @phpstan-ignore-next-line */ $albums = (new SortingDecorator($query)) ->orderBy(ColumnSortingType::OWNER_ID, OrderSortingType::ASC) ->orderBy($this->sorting->column, $this->sorting->order) @@ -106,6 +105,7 @@ public function get(): TopAlbumsResource // For anonymous users we don't want to implicitly expose // ownership via sorting. /** @var BaseCollection */ + /** @phpstan-ignore-next-line */ $albums = (new SortingDecorator($query)) ->orderBy($this->sorting->column, $this->sorting->order) ->get(); diff --git a/app/Actions/Albums/Tree.php b/app/Actions/Albums/Tree.php index f666376e71e..27ea1549170 100644 --- a/app/Actions/Albums/Tree.php +++ b/app/Actions/Albums/Tree.php @@ -62,9 +62,9 @@ public function get(): AlbumForestResource } $query->orderBy($this->sorting->column, $this->sorting->order); - /** @var NsCollection $albums */ + /** @var NsCollection $albums */ $albums = $query->get(); - /** @var ?NsCollection $sharedAlbums */ + /** @var ?NsCollection $sharedAlbums */ $sharedAlbums = null; $userID = Auth::id(); if ($userID !== null) { @@ -75,8 +75,8 @@ public function get(): AlbumForestResource // (sub)-tree and then `toTree` will return garbage as it does // not find connected paths within `$albums` or `$sharedAlbums`, // resp. - /** @var NsCollection $albums */ - /** @var ?NsCollection $sharedAlbums */ + /** @var NsCollection $albums */ + /** @var ?NsCollection $sharedAlbums */ list($albums, $sharedAlbums) = $albums->partition(fn (Album $album) => $album->owner_id === $userID); } diff --git a/app/Actions/Search/AlbumSearch.php b/app/Actions/Search/AlbumSearch.php index 0ce9b6a08d6..7b0a47dae3b 100644 --- a/app/Actions/Search/AlbumSearch.php +++ b/app/Actions/Search/AlbumSearch.php @@ -64,7 +64,6 @@ public function queryAlbums(array $terms): Collection $sorting = AlbumSortingCriterion::createDefault(); - /** @phpstan-ignore-next-line */ return (new SortingDecorator($albumQuery)) ->orderBy($sorting->column, $sorting->order) ->get(); diff --git a/app/Factories/AlbumFactory.php b/app/Factories/AlbumFactory.php index 0aba502ced5..10f29c2b003 100644 --- a/app/Factories/AlbumFactory.php +++ b/app/Factories/AlbumFactory.php @@ -78,8 +78,6 @@ public function findBaseAlbumOrFail(string $albumID, bool $withRelations = true) } try { - // PHPStan does not understand that `findOrFail` returns `BaseAlbum`, but assumes that it returns `Model` - // @phpstan-ignore-next-line return $albumQuery->findOrFail($albumID); } catch (ModelNotFoundException) { try { diff --git a/app/Http/Requests/Album/AddAlbumRequest.php b/app/Http/Requests/Album/AddAlbumRequest.php index ab9cbdc7f11..ff81a4b78e2 100644 --- a/app/Http/Requests/Album/AddAlbumRequest.php +++ b/app/Http/Requests/Album/AddAlbumRequest.php @@ -40,12 +40,11 @@ public function rules(): array */ protected function processValidatedValues(array $values, array $files): void { + /** @var string|null */ $parentAlbumID = $values[RequestAttribute::PARENT_ID_ATTRIBUTE]; $this->parentAlbum = $parentAlbumID === null ? null : - Album::query()->findOrFail( - $values[RequestAttribute::PARENT_ID_ATTRIBUTE] - ); + Album::query()->findOrFail($parentAlbumID); $this->title = $values[RequestAttribute::TITLE_ATTRIBUTE]; } } diff --git a/app/Http/Requests/Album/DeleteTrackRequest.php b/app/Http/Requests/Album/DeleteTrackRequest.php index 9221e30cb5d..74ef4449767 100644 --- a/app/Http/Requests/Album/DeleteTrackRequest.php +++ b/app/Http/Requests/Album/DeleteTrackRequest.php @@ -28,6 +28,8 @@ public function rules(): array */ protected function processValidatedValues(array $values, array $files): void { - $this->album = Album::query()->findOrFail($values[RequestAttribute::ALBUM_ID_ATTRIBUTE]); + /** @var string|null */ + $albumID = $values[RequestAttribute::ALBUM_ID_ATTRIBUTE]; + $this->album = Album::query()->findOrFail($albumID); } } diff --git a/app/Http/Requests/Album/MoveAlbumsRequest.php b/app/Http/Requests/Album/MoveAlbumsRequest.php index d3b2e98cca4..be77eb4d26f 100644 --- a/app/Http/Requests/Album/MoveAlbumsRequest.php +++ b/app/Http/Requests/Album/MoveAlbumsRequest.php @@ -42,6 +42,7 @@ protected function processValidatedValues(array $values, array $files): void $this->album = $id === null ? null : Album::findOrFail($id); + /** @phpstan-ignore-next-line */ $this->albums = Album::findOrFail($ids); } } diff --git a/app/Http/Requests/Album/SetAlbumCoverRequest.php b/app/Http/Requests/Album/SetAlbumCoverRequest.php index cf120c5e92e..9055c43088d 100644 --- a/app/Http/Requests/Album/SetAlbumCoverRequest.php +++ b/app/Http/Requests/Album/SetAlbumCoverRequest.php @@ -43,7 +43,10 @@ public function rules(): array */ protected function processValidatedValues(array $values, array $files): void { - $this->album = Album::query()->findOrFail($values[RequestAttribute::ALBUM_ID_ATTRIBUTE]); + /** @var string|null */ + $albumID = $values[RequestAttribute::ALBUM_ID_ATTRIBUTE]; + + $this->album = Album::query()->findOrFail($albumID); /** @var ?string $photoID */ $photoID = $values[RequestAttribute::PHOTO_ID_ATTRIBUTE]; $this->photo = $photoID === null ? null : Photo::query()->findOrFail($photoID); diff --git a/app/Http/Requests/Album/SetAlbumHeaderRequest.php b/app/Http/Requests/Album/SetAlbumHeaderRequest.php index abd5f9922bb..40be67cfa51 100644 --- a/app/Http/Requests/Album/SetAlbumHeaderRequest.php +++ b/app/Http/Requests/Album/SetAlbumHeaderRequest.php @@ -43,7 +43,10 @@ public function rules(): array */ protected function processValidatedValues(array $values, array $files): void { - $this->album = Album::query()->findOrFail($values[RequestAttribute::ALBUM_ID_ATTRIBUTE]); + /** @var string|null */ + $albumID = $values[RequestAttribute::ALBUM_ID_ATTRIBUTE]; + + $this->album = Album::query()->findOrFail($albumID); /** @var ?string $photoID */ $photoID = $values[RequestAttribute::PHOTO_ID_ATTRIBUTE]; $this->photo = $photoID === null ? null : Photo::query()->findOrFail($photoID); diff --git a/app/Http/Requests/Album/SetAlbumLicenseRequest.php b/app/Http/Requests/Album/SetAlbumLicenseRequest.php index a05c0c32c9b..f54a3c82dbf 100644 --- a/app/Http/Requests/Album/SetAlbumLicenseRequest.php +++ b/app/Http/Requests/Album/SetAlbumLicenseRequest.php @@ -32,7 +32,10 @@ public function rules(): array */ protected function processValidatedValues(array $values, array $files): void { - $this->album = Album::query()->findOrFail($values[RequestAttribute::ALBUM_ID_ATTRIBUTE]); + /** @var string|null */ + $albumID = $values[RequestAttribute::ALBUM_ID_ATTRIBUTE]; + + $this->album = Album::query()->findOrFail($albumID); $this->license = LicenseType::tryFrom($values[RequestAttribute::LICENSE_ATTRIBUTE]); } } diff --git a/app/Http/Requests/Album/SetAlbumTrackRequest.php b/app/Http/Requests/Album/SetAlbumTrackRequest.php index 85986de4bef..a9f60f6be81 100644 --- a/app/Http/Requests/Album/SetAlbumTrackRequest.php +++ b/app/Http/Requests/Album/SetAlbumTrackRequest.php @@ -35,7 +35,9 @@ public function rules(): array */ protected function processValidatedValues(array $values, array $files): void { - $this->album = Album::query()->findOrFail($values[RequestAttribute::ALBUM_ID_ATTRIBUTE]); + /** @var string|null */ + $albumID = $values[RequestAttribute::ALBUM_ID_ATTRIBUTE]; + $this->album = Album::query()->findOrFail($albumID); $this->file = $files[self::FILE_ATTRIBUTE]; } diff --git a/app/Http/Requests/Import/ImportFromUrlRequest.php b/app/Http/Requests/Import/ImportFromUrlRequest.php index ef62eb996c9..d0030c9fa00 100644 --- a/app/Http/Requests/Import/ImportFromUrlRequest.php +++ b/app/Http/Requests/Import/ImportFromUrlRequest.php @@ -33,6 +33,7 @@ public function rules(): array */ protected function processValidatedValues(array $values, array $files): void { + /** @var string|null */ $albumID = $values[RequestAttribute::ALBUM_ID_ATTRIBUTE]; $this->album = $albumID === null ? null : diff --git a/app/Http/Requests/Import/ImportServerRequest.php b/app/Http/Requests/Import/ImportServerRequest.php index c9602530e46..f5973ef00cb 100644 --- a/app/Http/Requests/Import/ImportServerRequest.php +++ b/app/Http/Requests/Import/ImportServerRequest.php @@ -44,6 +44,7 @@ public function rules(): array */ protected function processValidatedValues(array $values, array $files): void { + /** @var string|null */ $albumID = $values[RequestAttribute::ALBUM_ID_ATTRIBUTE]; $this->album = $albumID === null ? null : diff --git a/app/Http/Requests/Photo/DuplicatePhotosRequest.php b/app/Http/Requests/Photo/DuplicatePhotosRequest.php index 9e4c708306a..0964b5cdf51 100644 --- a/app/Http/Requests/Photo/DuplicatePhotosRequest.php +++ b/app/Http/Requests/Photo/DuplicatePhotosRequest.php @@ -37,6 +37,7 @@ protected function processValidatedValues(array $values, array $files): void $this->photos = Photo::query() ->with(['size_variants']) ->findOrFail($photosIDs); + /** @var string|null */ $targetAlbumID = $values[RequestAttribute::ALBUM_ID_ATTRIBUTE]; $this->album = $targetAlbumID === null ? null : diff --git a/app/Http/Requests/Photo/MovePhotosRequest.php b/app/Http/Requests/Photo/MovePhotosRequest.php index ade8dddd8d7..13d66ef4163 100644 --- a/app/Http/Requests/Photo/MovePhotosRequest.php +++ b/app/Http/Requests/Photo/MovePhotosRequest.php @@ -36,6 +36,7 @@ protected function processValidatedValues(array $values, array $files): void $photosIDs = $values[RequestAttribute::PHOTO_IDS_ATTRIBUTE]; $this->photos = Photo::query() ->findOrFail($photosIDs); + /** @var string|null */ $targetAlbumID = $values[RequestAttribute::ALBUM_ID_ATTRIBUTE]; $this->album = $targetAlbumID === null ? null : Album::query()->findOrFail($targetAlbumID); } diff --git a/app/Livewire/Components/Forms/Album/SearchAlbum.php b/app/Livewire/Components/Forms/Album/SearchAlbum.php index ae781f4edea..a6ed83d9022 100644 --- a/app/Livewire/Components/Forms/Album/SearchAlbum.php +++ b/app/Livewire/Components/Forms/Album/SearchAlbum.php @@ -88,9 +88,9 @@ private function getAlbumsListWithPath(?int $lft, ?int $rgt, ?string $parent_id) $query = (new SortingDecorator($unfiltered)) ->orderBy($sorting->column, $sorting->order); - /** @var NsCollection $albums */ + /** @var NsCollection $albums */ $albums = $query->get(); - /** @var NsCollection $tree */ + /** @var NsCollection $tree */ $tree = $albums->toTree(null); $flat_tree = $this->flatten($tree); @@ -115,8 +115,8 @@ private function getAlbumsListWithPath(?int $lft, ?int $rgt, ?string $parent_id) /** * Flatten the tree and create bread crumb paths. * - * @param NsCollection|Collection $collection - * @param string $prefix + * @param NsCollection|Collection $collection + * @param string $prefix * * @return TAlbumSaved[] */ diff --git a/app/Models/Album.php b/app/Models/Album.php index 5ecfc94d270..976e7b042fb 100644 --- a/app/Models/Album.php +++ b/app/Models/Album.php @@ -123,9 +123,12 @@ * @method static AlbumBuilder|Album withoutRoot() * * // * @mixin \Eloquent + * + * @implements Node */ class Album extends BaseAlbum implements Node { + /** @phpstan-use NodeTrait */ use NodeTrait; use ToArrayThrowsNotImplemented; use HasFactory; @@ -220,13 +223,14 @@ public function children(): HasManyChildAlbums /** * Get query for descendants of the node. * - * @return DescendantsRelation + * @return DescendantsRelation * * @throws QueryBuilderException */ public function descendants(): DescendantsRelation { try { + /** @var DescendantsRelation */ return new DescendantsRelation($this->newQuery(), $this); } catch (\Throwable $e) { throw new QueryBuilderException($e); diff --git a/app/Models/Builders/AlbumBuilder.php b/app/Models/Builders/AlbumBuilder.php index c6c2773c770..9a9c09ff8ba 100644 --- a/app/Models/Builders/AlbumBuilder.php +++ b/app/Models/Builders/AlbumBuilder.php @@ -47,6 +47,8 @@ * @method $this whereNotIn(string $column, mixed $values, string $boolean = 'and') * @method $this whereNull(string|array $columns, string $boolean = 'and', bool $not = false) * @method $this orderByDesc($column) + * + * @extends NSQueryBuilder */ class AlbumBuilder extends NSQueryBuilder { @@ -94,14 +96,13 @@ public function getModels($columns = ['*']): array // The parent method returns a `Model[]`, but we must return // `Album[]` and we know that this is indeed the case as we have // queried for albums - // @phpstan-ignore-next-line return parent::getModels($columns); } /** * Get statistics of errors of the tree. * - * @return array + * @return array{oddness:int,duplicates:int,wrong_parent:int,missing_parent:int} * * @throws QueryBuilderException */ @@ -266,4 +267,16 @@ private function applyVisibilityConditioOnPhotos(Builder $countQuery, AlbumQuery return $countQuery->where($visibilitySubQuery); } + + /** + * Scope limits query to select just root node. + * + * @return AlbumBuilder + */ + public function whereIsRoot(): AlbumBuilder + { + $this->query->whereNull($this->model->getParentIdName()); + + return $this; + } } diff --git a/app/Relations/HasManyChildAlbums.php b/app/Relations/HasManyChildAlbums.php index 6f03967fb36..6293f96207e 100644 --- a/app/Relations/HasManyChildAlbums.php +++ b/app/Relations/HasManyChildAlbums.php @@ -30,7 +30,6 @@ public function __construct(Album $owningAlbum) $this->albumQueryPolicy = resolve(AlbumQueryPolicy::class); $this->sorting = $owningAlbum->album_sorting ?? AlbumSortingCriterion::createDefault(); parent::__construct( - /** @phpstan-ignore-next-line */ $owningAlbum->newQuery(), $owningAlbum, 'parent_id', diff --git a/composer.lock b/composer.lock index 884ce9c9aa6..a7d62e738eb 100644 --- a/composer.lock +++ b/composer.lock @@ -3522,16 +3522,16 @@ }, { "name": "lychee-org/nestedset", - "version": "v8.1.0", + "version": "v8.1.1", "source": { "type": "git", "url": "https://github.com/LycheeOrg/laravel-nestedset.git", - "reference": "92a00e9f89013275cb5831b3a6a2aa70267ad86d" + "reference": "f9601affe48e111579db16d0f9d85c39809c120e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/LycheeOrg/laravel-nestedset/zipball/92a00e9f89013275cb5831b3a6a2aa70267ad86d", - "reference": "92a00e9f89013275cb5831b3a6a2aa70267ad86d", + "url": "https://api.github.com/repos/LycheeOrg/laravel-nestedset/zipball/f9601affe48e111579db16d0f9d85c39809c120e", + "reference": "f9601affe48e111579db16d0f9d85c39809c120e", "shasum": "" }, "require": { @@ -3583,9 +3583,9 @@ "nsm" ], "support": { - "source": "https://github.com/LycheeOrg/laravel-nestedset/tree/v8.1.0" + "source": "https://github.com/LycheeOrg/laravel-nestedset/tree/v8.1.1" }, - "time": "2024-06-10T08:23:54+00:00" + "time": "2024-06-10T09:16:44+00:00" }, { "name": "lychee-org/php-exif", diff --git a/database/migrations/2020_12_26_153220_nested_set_for_albums.php b/database/migrations/2020_12_26_153220_nested_set_for_albums.php index 3d4f7ce74c9..57c1d0a81ed 100644 --- a/database/migrations/2020_12_26_153220_nested_set_for_albums.php +++ b/database/migrations/2020_12_26_153220_nested_set_for_albums.php @@ -26,7 +26,7 @@ public function up(): void $table->index([self::LEFT, self::RIGHT]); }); - NestedSetForAlbums_AlbumModel::query()->fixTree(); /** @phpstan-ignore-line */ + NestedSetForAlbums_AlbumModel::query()->fixTree(); } /** diff --git a/database/migrations/TemporaryModels/NestedSetForAlbums_AlbumModel.php b/database/migrations/TemporaryModels/NestedSetForAlbums_AlbumModel.php index 83150415901..0a177b7772f 100644 --- a/database/migrations/TemporaryModels/NestedSetForAlbums_AlbumModel.php +++ b/database/migrations/TemporaryModels/NestedSetForAlbums_AlbumModel.php @@ -19,6 +19,7 @@ */ class NestedSetForAlbums_AlbumModel extends Model { + /** @phpstan-use NodeTrait */ use NodeTrait; protected $table = 'albums'; diff --git a/database/migrations/TemporaryModels/RefactorAlbumModel_AlbumModel.php b/database/migrations/TemporaryModels/RefactorAlbumModel_AlbumModel.php index a4e12540874..df1ff72b782 100644 --- a/database/migrations/TemporaryModels/RefactorAlbumModel_AlbumModel.php +++ b/database/migrations/TemporaryModels/RefactorAlbumModel_AlbumModel.php @@ -17,9 +17,12 @@ * low-level DB queries when necessary. * Unfortunately, we need the `fixTree()` algorithm and there is no * implementation which uses low-level DB queries. + * + * @implements Node */ class RefactorAlbumModel_AlbumModel extends Model implements Node { + /** @phpstan-use NodeTrait */ use NodeTrait; protected $table = 'albums'; diff --git a/phpstan.neon b/phpstan.neon index 159f9b5800f..5256b551666 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -61,11 +61,11 @@ parameters: - app/Eloquent/FixedQueryBuilderTrait.php - '#Parameter \#1 \$models .* of method .*::initRelation\(\) should be contravariant with parameter \$models .* of method .*::initRelation\(\)#' - '#Parameter \#(1|2) \$(models|albums|photos|results) .* of method .*::(match|addEagerConstraints)\(\) should be contravariant with parameter \$(models|albums|photos|results) .* of method .*::(match|addEagerConstraints)\(\)#' - - '#Parameter .* of method .*::partition\(\) expects \(callable\(.*\): bool\)\|Illuminate\\Database\\Eloquent\\Model\|string, Closure\(.*\): bool given.#' + # - '#Parameter .* of method .*::partition\(\) expects \(callable\(.*\): bool\)\|Illuminate\\Database\\Eloquent\\Model\|string, Closure\(.*\): bool given.#' - '#Parameter .* of method .*::performInsert\(\) should be contravariant with parameter .* of method .*::performInsert\(\)#' - '#Parameter .* of method .*::replicate\(\) should be contravariant with parameter .* of method .*::replicate\(\)#' - '#Parameter .* of method .*::save\(\) should be contravariant with parameter .* of method .*::save\(\)#' - - '#Parameter .* of method .*::newEloquentBuilder\(\) should be contravariant with parameter .* of method Kalnoy\\Nestedset\\Node::newEloquentBuilder\(\)#' + - '#Parameter .* of method .*::newEloquentBuilder\(\) should be contravariant with parameter .* of method Kalnoy\\Nestedset\\Node<.*>::newEloquentBuilder\(\)#' - '#Parameter .* of method .*::performUpdate\(\) should be contravariant with parameter .* of method .*::performUpdate\(\)#' - '#Parameter .* of method .*::isDirty\(\) should be contravariant with parameter .* of method .*::isDirty\(\)#' @@ -78,7 +78,6 @@ parameters: - '#Dynamic call to static method Illuminate\\Foundation\\Application::getCachedRoutesPath\(\).#' - - '#Property .* \(App\\Models\\.*(\|null)?\) does not accept (Illuminate\\Database\\Eloquent\\Collection\|)?Illuminate\\Database\\Eloquent\\Model(\|null)?.#' - '#Access to an undefined property Laragear\\WebAuthn\\Models\\WebAuthnCredential::\$authenticatable_id#' # False positive as stub code for PHP has not yet been updated to 2nd parameter, see https://github.com/php/doc-en/issues/1529 and https://www.php.net/imagick.writeimagefile From 7c918937336ef2dcfbd3085a8239cf2328db7476 Mon Sep 17 00:00:00 2001 From: ildyria Date: Mon, 10 Jun 2024 12:24:45 +0200 Subject: [PATCH 3/3] fix annotation + interface --- .../TemporaryModels/NestedSetForAlbums_AlbumModel.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/database/migrations/TemporaryModels/NestedSetForAlbums_AlbumModel.php b/database/migrations/TemporaryModels/NestedSetForAlbums_AlbumModel.php index 0a177b7772f..b22a90cc798 100644 --- a/database/migrations/TemporaryModels/NestedSetForAlbums_AlbumModel.php +++ b/database/migrations/TemporaryModels/NestedSetForAlbums_AlbumModel.php @@ -1,6 +1,7 @@ */ -class NestedSetForAlbums_AlbumModel extends Model +class NestedSetForAlbums_AlbumModel extends Model implements Node { /** @phpstan-use NodeTrait */ use NodeTrait;