Skip to content

Commit

Permalink
bump phpstan to v2
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmajor committed Nov 15, 2024
1 parent 74889f6 commit e8525c2
Show file tree
Hide file tree
Showing 14 changed files with 151 additions and 91 deletions.
3 changes: 3 additions & 0 deletions app/Images/Cover.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ protected static function pathPrefix(): string
return 'covers';
}

/**
* @return HasMany<Tale, $this>
*/
public function tales(): HasMany
{
return $this->hasMany(Tale::class, 'cover_filename', 'filename');
Expand Down
3 changes: 3 additions & 0 deletions app/Images/Photo.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ public function crop(): ArtistPhotoCrop
return $this->crop;
}

/**
* @return HasMany<Artist, $this>
*/
public function artists(): HasMany
{
return $this->hasMany(Artist::class, 'photo_filename', 'filename');
Expand Down
3 changes: 3 additions & 0 deletions app/Images/Values/ArtistFaceCrop.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

use Illuminate\Contracts\Support\Arrayable;

/**
* @implements Arrayable<string, mixed>
*/
final class ArtistFaceCrop implements Arrayable
{
public function __construct(
Expand Down
8 changes: 8 additions & 0 deletions app/Images/Values/ArtistPhotoCrop.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
use Psl\Json;
use Psl\Type;

/**
* @implements Arrayable<string, mixed>
*/
final class ArtistPhotoCrop implements Arrayable, Castable
{
public function __construct(
Expand Down Expand Up @@ -39,9 +42,14 @@ public function toArray(): array

/**
* @param array<never> $arguments
*
* @return CastsAttributes<self, self>
*/
public static function castUsing(array $arguments): CastsAttributes
{
/**
* @implements CastsAttributes<self, self>
*/
return new class implements CastsAttributes {
/**
* @param array<string, mixed> $attributes
Expand Down
33 changes: 27 additions & 6 deletions app/Models/Artist.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -27,7 +28,9 @@
*/
final class Artist extends Model
{
/** @use HasFactory<ArtistFactory> */
use HasFactory;

use HasSlug;

/** @var list<string> */
Expand Down Expand Up @@ -87,6 +90,9 @@ public function getWikipediaUrlAttribute(): ?string
return $this->wikipedia ? app(Wikipedia::class)->url($this->wikipedia) : null;
}

/**
* @return BelongsTo<Photo, $this>
*/
public function photo(): BelongsTo
{
return $this->belongsTo(Photo::class);
Expand Down Expand Up @@ -123,20 +129,32 @@ public function discogsPhoto(string $type = 'normal'): ?string
};
}

/**
* @return BelongsToMany<Tale, $this>
*/
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<Tale, $this>
*/
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;
}

/**
Expand All @@ -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([
Expand Down
33 changes: 27 additions & 6 deletions app/Models/Tale.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -24,7 +25,9 @@
*/
final class Tale extends Model
{
/** @use HasFactory<TaleFactory> */
use HasFactory;

use HasSlug;

/** @var list<string> */
Expand Down Expand Up @@ -57,25 +60,40 @@ public function getDiscogsUrlAttribute(): ?string
return $this->discogs ? app(Discogs::class)->releaseUrl($this->discogs) : null;
}

/**
* @return BelongsTo<Cover, $this>
*/
public function cover(): BelongsTo
{
return $this->belongsTo(Cover::class);
}

/**
* @return BelongsToMany<Artist, $this>
*/
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<Artist, $this>
*/
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;
}

/**
Expand Down Expand Up @@ -168,6 +186,9 @@ public function syncCredits(array $credits): void
}
}

/**
* @param Builder<$this> $query
*/
public function scopeWithActorsPopularity(Builder $query): void
{
$query->addSelect([
Expand Down
3 changes: 3 additions & 0 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<UserFactory> */
use HasFactory;

use Notifiable;

public $timestamps = false;
Expand Down
3 changes: 3 additions & 0 deletions app/Values/CreditData.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

use Illuminate\Contracts\Support\Arrayable;

/**
* @implements Arrayable<string, mixed>
*/
final class CreditData implements Arrayable
{
public function __construct(
Expand Down
3 changes: 3 additions & 0 deletions app/Values/Discogs/Artist.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

use Illuminate\Contracts\Support\Arrayable;

/**
* @implements Arrayable<string, mixed>
*/
final class Artist implements Arrayable
{
public function __construct(
Expand Down
3 changes: 3 additions & 0 deletions app/Values/FilmPolski/Artist.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

use Illuminate\Contracts\Support\Arrayable;

/**
* @implements Arrayable<string, mixed>
*/
final class Artist implements Arrayable
{
public function __construct(
Expand Down
3 changes: 3 additions & 0 deletions app/Values/Wikipedia/Artist.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

use Illuminate\Contracts\Support\Arrayable;

/**
* @implements Arrayable<string, mixed>
*/
final class Artist implements Arrayable
{
public function __construct(
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading

0 comments on commit e8525c2

Please sign in to comment.