From e8525c2895dfd83c54c3c1ca6b3ea7c683c2cd07 Mon Sep 17 00:00:00 2001 From: Jeremiasz Major Date: Fri, 15 Nov 2024 15:31:36 +0100 Subject: [PATCH] bump phpstan to v2 --- app/Images/Cover.php | 3 + app/Images/Photo.php | 3 + app/Images/Values/ArtistFaceCrop.php | 3 + app/Images/Values/ArtistPhotoCrop.php | 8 ++ app/Models/Artist.php | 33 +++++-- app/Models/Tale.php | 33 +++++-- app/Models/User.php | 3 + app/Values/CreditData.php | 3 + app/Values/Discogs/Artist.php | 3 + app/Values/FilmPolski/Artist.php | 3 + app/Values/Wikipedia/Artist.php | 3 + composer.json | 10 +- composer.lock | 132 ++++++++++++-------------- phpstan.neon | 2 +- 14 files changed, 151 insertions(+), 91 deletions(-) diff --git a/app/Images/Cover.php b/app/Images/Cover.php index c3e31535..71f5ba53 100644 --- a/app/Images/Cover.php +++ b/app/Images/Cover.php @@ -34,6 +34,9 @@ protected static function pathPrefix(): string return 'covers'; } + /** + * @return HasMany + */ public function tales(): HasMany { return $this->hasMany(Tale::class, 'cover_filename', 'filename'); diff --git a/app/Images/Photo.php b/app/Images/Photo.php index 02e75110..01e932cf 100644 --- a/app/Images/Photo.php +++ b/app/Images/Photo.php @@ -59,6 +59,9 @@ public function crop(): ArtistPhotoCrop return $this->crop; } + /** + * @return HasMany + */ public function artists(): HasMany { return $this->hasMany(Artist::class, 'photo_filename', 'filename'); diff --git a/app/Images/Values/ArtistFaceCrop.php b/app/Images/Values/ArtistFaceCrop.php index 502b178a..cf0dcdff 100644 --- a/app/Images/Values/ArtistFaceCrop.php +++ b/app/Images/Values/ArtistFaceCrop.php @@ -4,6 +4,9 @@ use Illuminate\Contracts\Support\Arrayable; +/** + * @implements Arrayable + */ final class ArtistFaceCrop implements Arrayable { public function __construct( diff --git a/app/Images/Values/ArtistPhotoCrop.php b/app/Images/Values/ArtistPhotoCrop.php index fe26d450..b07bd76b 100644 --- a/app/Images/Values/ArtistPhotoCrop.php +++ b/app/Images/Values/ArtistPhotoCrop.php @@ -8,6 +8,9 @@ use Psl\Json; use Psl\Type; +/** + * @implements Arrayable + */ final class ArtistPhotoCrop implements Arrayable, Castable { public function __construct( @@ -39,9 +42,14 @@ public function toArray(): array /** * @param array $arguments + * + * @return CastsAttributes */ public static function castUsing(array $arguments): CastsAttributes { + /** + * @implements CastsAttributes + */ return new class implements CastsAttributes { /** * @param array $attributes diff --git a/app/Models/Artist.php b/app/Models/Artist.php index 0ccb0321..bca17ca4 100644 --- a/app/Models/Artist.php +++ b/app/Models/Artist.php @@ -9,6 +9,7 @@ use App\Values\CreditType; use App\Values\Discogs\DiscogsPhotos; use App\Values\FilmPolski\PhotoGroup; +use Database\Factories\ArtistFactory; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Collection as EloquentCollection; use Illuminate\Database\Eloquent\Factories\HasFactory; @@ -27,7 +28,9 @@ */ final class Artist extends Model { + /** @use HasFactory */ use HasFactory; + use HasSlug; /** @var list */ @@ -87,6 +90,9 @@ public function getWikipediaUrlAttribute(): ?string return $this->wikipedia ? app(Wikipedia::class)->url($this->wikipedia) : null; } + /** + * @return BelongsTo + */ public function photo(): BelongsTo { return $this->belongsTo(Photo::class); @@ -123,20 +129,32 @@ public function discogsPhoto(string $type = 'normal'): ?string }; } + /** + * @return BelongsToMany + */ public function asActor(): BelongsToMany { - return $this->belongsToMany(Tale::class, 'tales_actors') + $relation = $this->belongsToMany(Tale::class, 'tales_actors') ->using(Actor::class)->as('credit') - ->withPivot('characters', 'credit_nr')->withTimestamps() - ->orderBy('year')->orderBy('title'); + ->withPivot('characters', 'credit_nr')->withTimestamps(); + + $relation->orderBy('year')->orderBy('title'); + + return $relation; } + /** + * @return BelongsToMany + */ public function credits(): BelongsToMany { - return $this->belongsToMany(Tale::class, 'credits') + $relation = $this->belongsToMany(Tale::class, 'credits') ->using(Credit::class)->as('credit') - ->withPivot('id', 'type', 'as', 'nr')->withTimestamps() - ->orderBy('year')->orderBy('title'); + ->withPivot('id', 'type', 'as', 'nr')->withTimestamps(); + + $relation->orderBy('year')->orderBy('title'); + + return $relation; } /** @@ -159,6 +177,9 @@ public function orderedCredits(): Collection ->groupBy(fn (Tale $t) => $t->credit->type->label()); } + /** + * @param Builder<$this> $query + */ public function scopeCountAppearances(Builder $query): void { $query->addSelect([ diff --git a/app/Models/Tale.php b/app/Models/Tale.php index e583e2b6..8e3005fa 100644 --- a/app/Models/Tale.php +++ b/app/Models/Tale.php @@ -6,6 +6,7 @@ use App\Services\Discogs; use App\Values\CreditData; use App\Values\CreditType; +use Database\Factories\TaleFactory; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Collection as EloquentCollection; use Illuminate\Database\Eloquent\Factories\HasFactory; @@ -24,7 +25,9 @@ */ final class Tale extends Model { + /** @use HasFactory */ use HasFactory; + use HasSlug; /** @var list */ @@ -57,25 +60,40 @@ public function getDiscogsUrlAttribute(): ?string return $this->discogs ? app(Discogs::class)->releaseUrl($this->discogs) : null; } + /** + * @return BelongsTo + */ public function cover(): BelongsTo { return $this->belongsTo(Cover::class); } + /** + * @return BelongsToMany + */ public function actors(): BelongsToMany { - return $this->belongsToMany(Artist::class, 'tales_actors') + $relation = $this->belongsToMany(Artist::class, 'tales_actors') ->using(Actor::class)->as('credit') - ->withPivot('characters', 'credit_nr')->withTimestamps() - ->orderBy('tales_actors.credit_nr'); + ->withPivot('characters', 'credit_nr')->withTimestamps(); + + $relation->getQuery()->orderBy('tales_actors.credit_nr'); + + return $relation; } + /** + * @return BelongsToMany + */ public function credits(): BelongsToMany { - return $this->belongsToMany(Artist::class, 'credits') + $relation = $this->belongsToMany(Artist::class, 'credits') ->using(Credit::class)->as('credit') - ->withPivot('id', 'type', 'as', 'nr')->withTimestamps() - ->orderBy('credits.nr'); + ->withPivot('id', 'type', 'as', 'nr')->withTimestamps(); + + $relation->getQuery()->orderBy('credits.nr'); + + return $relation; } /** @@ -168,6 +186,9 @@ public function syncCredits(array $credits): void } } + /** + * @param Builder<$this> $query + */ public function scopeWithActorsPopularity(Builder $query): void { $query->addSelect([ diff --git a/app/Models/User.php b/app/Models/User.php index 2423c3dc..1e73ef8d 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -2,13 +2,16 @@ namespace App\Models; +use Database\Factories\UserFactory; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; final class User extends Authenticatable { + /** @use HasFactory */ use HasFactory; + use Notifiable; public $timestamps = false; diff --git a/app/Values/CreditData.php b/app/Values/CreditData.php index 51336fb8..c499a3fc 100644 --- a/app/Values/CreditData.php +++ b/app/Values/CreditData.php @@ -4,6 +4,9 @@ use Illuminate\Contracts\Support\Arrayable; +/** + * @implements Arrayable + */ final class CreditData implements Arrayable { public function __construct( diff --git a/app/Values/Discogs/Artist.php b/app/Values/Discogs/Artist.php index 41ba4af1..7f7bba21 100644 --- a/app/Values/Discogs/Artist.php +++ b/app/Values/Discogs/Artist.php @@ -4,6 +4,9 @@ use Illuminate\Contracts\Support\Arrayable; +/** + * @implements Arrayable + */ final class Artist implements Arrayable { public function __construct( diff --git a/app/Values/FilmPolski/Artist.php b/app/Values/FilmPolski/Artist.php index e44bd895..43559c08 100644 --- a/app/Values/FilmPolski/Artist.php +++ b/app/Values/FilmPolski/Artist.php @@ -4,6 +4,9 @@ use Illuminate\Contracts\Support\Arrayable; +/** + * @implements Arrayable + */ final class Artist implements Arrayable { public function __construct( diff --git a/app/Values/Wikipedia/Artist.php b/app/Values/Wikipedia/Artist.php index e2e6cbd3..8fabfbe1 100644 --- a/app/Values/Wikipedia/Artist.php +++ b/app/Values/Wikipedia/Artist.php @@ -4,6 +4,9 @@ use Illuminate\Contracts\Support\Arrayable; +/** + * @implements Arrayable + */ final class Artist implements Arrayable { public function __construct( diff --git a/composer.json b/composer.json index 8cae3d21..3f2a98fa 100644 --- a/composer.json +++ b/composer.json @@ -37,13 +37,13 @@ "brianium/paratest": "^7.6", "fakerphp/faker": "^1.24", "jrmajor/cs": "^0.6.0", - "larastan/larastan": "^2.9", + "larastan/larastan": "^3.0", "mockery/mockery": "^1.6", "nunomaduro/collision": "^8.5", - "php-standard-library/phpstan-extension": "^1.1", - "phpstan/phpstan": "^1.12", - "phpstan/phpstan-mockery": "^1.1", - "phpstan/phpstan-phpunit": "^1.4", + "php-standard-library/phpstan-extension": "^2.0", + "phpstan/phpstan": "^2.0", + "phpstan/phpstan-mockery": "^2.0", + "phpstan/phpstan-phpunit": "^2.0", "phpunit/phpunit": "^11.3", "spatie/invade": "^2.1", "spatie/laravel-ignition": "^2.8", diff --git a/composer.lock b/composer.lock index 9b34ea2f..7b9a7cf8 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "8b6e60030c72553a9488fd19b6a433b3", + "content-hash": "a16da968f069412625e5d620a7bdad1a", "packages": [ { "name": "aws/aws-crt-php", @@ -9233,40 +9233,40 @@ }, { "name": "larastan/larastan", - "version": "v2.9.11", + "version": "v3.0.0", "source": { "type": "git", "url": "https://github.com/larastan/larastan.git", - "reference": "54eccd35d1732b9ee4392c25aec606a6a9c521e7" + "reference": "88f46e3f2cd9d2a14dba13ef293b822a75832e62" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/larastan/larastan/zipball/54eccd35d1732b9ee4392c25aec606a6a9c521e7", - "reference": "54eccd35d1732b9ee4392c25aec606a6a9c521e7", + "url": "https://api.github.com/repos/larastan/larastan/zipball/88f46e3f2cd9d2a14dba13ef293b822a75832e62", + "reference": "88f46e3f2cd9d2a14dba13ef293b822a75832e62", "shasum": "" }, "require": { "ext-json": "*", - "illuminate/console": "^9.52.16 || ^10.28.0 || ^11.16", - "illuminate/container": "^9.52.16 || ^10.28.0 || ^11.16", - "illuminate/contracts": "^9.52.16 || ^10.28.0 || ^11.16", - "illuminate/database": "^9.52.16 || ^10.28.0 || ^11.16", - "illuminate/http": "^9.52.16 || ^10.28.0 || ^11.16", - "illuminate/pipeline": "^9.52.16 || ^10.28.0 || ^11.16", - "illuminate/support": "^9.52.16 || ^10.28.0 || ^11.16", - "php": "^8.0.2", + "illuminate/console": "^11.15.0", + "illuminate/container": "^11.15.0", + "illuminate/contracts": "^11.15.0", + "illuminate/database": "^11.15.0", + "illuminate/http": "^11.15.0", + "illuminate/pipeline": "^11.15.0", + "illuminate/support": "^11.15.0", + "php": "^8.2", "phpmyadmin/sql-parser": "^5.9.0", - "phpstan/phpstan": "^1.12.5" + "phpstan/phpstan": "^2.0.0" }, "require-dev": { "doctrine/coding-standard": "^12.0", - "laravel/framework": "^9.52.16 || ^10.28.0 || ^11.16", - "mockery/mockery": "^1.5.1", - "nikic/php-parser": "^4.19.1", - "orchestra/canvas": "^7.11.1 || ^8.11.0 || ^9.0.2", - "orchestra/testbench-core": "^7.33.0 || ^8.13.0 || ^9.0.9", - "phpstan/phpstan-deprecation-rules": "^1.2", - "phpunit/phpunit": "^9.6.13 || ^10.5.16" + "laravel/framework": "^11.15.0", + "mockery/mockery": "^1.6", + "nikic/php-parser": "^5.3", + "orchestra/canvas": "^v9.1.3", + "orchestra/testbench-core": "^9.5.2", + "phpstan/phpstan-deprecation-rules": "^2.0.0", + "phpunit/phpunit": "^10.5.16" }, "suggest": { "orchestra/testbench": "Using Larastan for analysing a package needs Testbench" @@ -9314,27 +9314,15 @@ ], "support": { "issues": "https://github.com/larastan/larastan/issues", - "source": "https://github.com/larastan/larastan/tree/v2.9.11" + "source": "https://github.com/larastan/larastan/tree/v3.0.0" }, "funding": [ - { - "url": "https://www.paypal.com/paypalme/enunomaduro", - "type": "custom" - }, { "url": "https://github.com/canvural", "type": "github" - }, - { - "url": "https://github.com/nunomaduro", - "type": "github" - }, - { - "url": "https://www.patreon.com/nunomaduro", - "type": "patreon" } ], - "time": "2024-11-11T23:11:00+00:00" + "time": "2024-11-15T09:38:34+00:00" }, { "name": "loophp/phposinfo", @@ -9821,21 +9809,21 @@ }, { "name": "php-standard-library/phpstan-extension", - "version": "1.1.0", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/php-standard-library/phpstan-extension.git", - "reference": "6a13576490fbeb406dcfba473d2277efda0575c7" + "reference": "e3e77739a205a8825d56fb9495620923b20ca9fc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-standard-library/phpstan-extension/zipball/6a13576490fbeb406dcfba473d2277efda0575c7", - "reference": "6a13576490fbeb406dcfba473d2277efda0575c7", + "url": "https://api.github.com/repos/php-standard-library/phpstan-extension/zipball/e3e77739a205a8825d56fb9495620923b20ca9fc", + "reference": "e3e77739a205a8825d56fb9495620923b20ca9fc", "shasum": "" }, "require": { "php": "^7.4 || ^8.0", - "phpstan/phpstan": "^1.12" + "phpstan/phpstan": "^2.0" }, "conflict": { "azjezz/psl": "<1.6||>=4.0" @@ -9845,8 +9833,8 @@ "composer/semver": "^3.3", "nikic/php-parser": "^4.14.0", "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/phpstan-phpunit": "^1.4.0", - "phpstan/phpstan-strict-rules": "^1.6.0", + "phpstan/phpstan-phpunit": "^2.0", + "phpstan/phpstan-strict-rules": "^2.0", "phpunit/phpunit": "^9.6" }, "type": "phpstan-extension", @@ -9869,9 +9857,9 @@ "description": "PHPStan PSL extension", "support": { "issues": "https://github.com/php-standard-library/phpstan-extension/issues", - "source": "https://github.com/php-standard-library/phpstan-extension/tree/1.1.0" + "source": "https://github.com/php-standard-library/phpstan-extension/tree/2.0.0" }, - "time": "2024-09-04T19:33:28+00:00" + "time": "2024-11-11T13:31:12+00:00" }, { "name": "phpdocumentor/reflection-common", @@ -10120,20 +10108,20 @@ }, { "name": "phpstan/phpstan", - "version": "1.12.10", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "fc463b5d0fe906dcf19689be692c65c50406a071" + "reference": "ab4e9b4415a5fc9e4d27f7fe16c8bc9d067dcd6d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/fc463b5d0fe906dcf19689be692c65c50406a071", - "reference": "fc463b5d0fe906dcf19689be692c65c50406a071", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/ab4e9b4415a5fc9e4d27f7fe16c8bc9d067dcd6d", + "reference": "ab4e9b4415a5fc9e4d27f7fe16c8bc9d067dcd6d", "shasum": "" }, "require": { - "php": "^7.2|^8.0" + "php": "^7.4|^8.0" }, "conflict": { "phpstan/phpstan-shim": "*" @@ -10174,33 +10162,32 @@ "type": "github" } ], - "time": "2024-11-11T15:37:09+00:00" + "time": "2024-11-11T15:43:04+00:00" }, { "name": "phpstan/phpstan-mockery", - "version": "1.1.3", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan-mockery.git", - "reference": "98cac6e256b4ee60fdeb26a7dd81bb271b454e80" + "reference": "89a949d0ac64298e88b7c7fa00caee565c198394" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-mockery/zipball/98cac6e256b4ee60fdeb26a7dd81bb271b454e80", - "reference": "98cac6e256b4ee60fdeb26a7dd81bb271b454e80", + "url": "https://api.github.com/repos/phpstan/phpstan-mockery/zipball/89a949d0ac64298e88b7c7fa00caee565c198394", + "reference": "89a949d0ac64298e88b7c7fa00caee565c198394", "shasum": "" }, "require": { - "php": "^7.2 || ^8.0", - "phpstan/phpstan": "^1.12" + "php": "^7.4 || ^8.0", + "phpstan/phpstan": "^2.0" }, "require-dev": { "mockery/mockery": "^1.6.11", - "nikic/php-parser": "^4.13.0", "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/phpstan-phpunit": "^1.4", - "phpstan/phpstan-strict-rules": "^1.6", - "phpunit/phpunit": "^9.5" + "phpstan/phpstan-phpunit": "^2.0", + "phpstan/phpstan-strict-rules": "^2.0", + "phpunit/phpunit": "^9.6" }, "type": "phpstan-extension", "extra": { @@ -10222,36 +10209,35 @@ "description": "PHPStan Mockery extension", "support": { "issues": "https://github.com/phpstan/phpstan-mockery/issues", - "source": "https://github.com/phpstan/phpstan-mockery/tree/1.1.3" + "source": "https://github.com/phpstan/phpstan-mockery/tree/2.0.0" }, - "time": "2024-09-11T15:47:29+00:00" + "time": "2024-10-14T03:18:12+00:00" }, { "name": "phpstan/phpstan-phpunit", - "version": "1.4.0", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan-phpunit.git", - "reference": "f3ea021866f4263f07ca3636bf22c64be9610c11" + "reference": "4b6ad7fab8683ff4efd7887ba26ef8ee171c7475" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/f3ea021866f4263f07ca3636bf22c64be9610c11", - "reference": "f3ea021866f4263f07ca3636bf22c64be9610c11", + "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/4b6ad7fab8683ff4efd7887ba26ef8ee171c7475", + "reference": "4b6ad7fab8683ff4efd7887ba26ef8ee171c7475", "shasum": "" }, "require": { - "php": "^7.2 || ^8.0", - "phpstan/phpstan": "^1.11" + "php": "^7.4 || ^8.0", + "phpstan/phpstan": "^2.0" }, "conflict": { "phpunit/phpunit": "<7.0" }, "require-dev": { - "nikic/php-parser": "^4.13.0", "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/phpstan-strict-rules": "^1.5.1", - "phpunit/phpunit": "^9.5" + "phpstan/phpstan-strict-rules": "^2.0", + "phpunit/phpunit": "^9.6" }, "type": "phpstan-extension", "extra": { @@ -10274,9 +10260,9 @@ "description": "PHPUnit extensions and rules for PHPStan", "support": { "issues": "https://github.com/phpstan/phpstan-phpunit/issues", - "source": "https://github.com/phpstan/phpstan-phpunit/tree/1.4.0" + "source": "https://github.com/phpstan/phpstan-phpunit/tree/2.0.1" }, - "time": "2024-04-20T06:39:00+00:00" + "time": "2024-11-12T12:48:00+00:00" }, { "name": "phpunit/php-code-coverage", diff --git a/phpstan.neon b/phpstan.neon index 808baab6..cdcc7e2c 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -13,7 +13,6 @@ parameters: stubFiles: - phpstan.stub ignoreErrors: - - identifier: missingType.generics - '#^Access to an undefined property App\\Models\\Actor\|App\\Models\\Credit::\$(as|characters|credit_nr|nr|type)\.$#' - '#^Access to an undefined property App\\Models\\Artist::\$appearances\.$#' - '#^Access to an undefined property App\\Models\\Tale::\$popularity\.$#' @@ -24,6 +23,7 @@ parameters: includes: - vendor/phpstan/phpstan/conf/bleedingEdge.neon - vendor/larastan/larastan/extension.neon + - vendor/nesbot/carbon/extension.neon - vendor/php-standard-library/phpstan-extension/extension.neon - vendor/phpstan/phpstan-mockery/extension.neon - vendor/phpstan/phpstan-phpunit/extension.neon