Skip to content

Commit

Permalink
chore: update to php 8.4 (#763)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyrch authored Dec 8, 2024
1 parent 7be14cb commit 2a856c3
Show file tree
Hide file tree
Showing 227 changed files with 1,671 additions and 1,648 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
steps:
- uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
php-version: '8.4.1'
tools: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, phpunit
- uses: actions/checkout@v3
- name: Copy .env
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
steps:
- uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
php-version: '8.4.1'
tools: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, phpunit
- uses: actions/checkout@v3
- name: Copy .env
Expand Down
2 changes: 1 addition & 1 deletion .styleci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 8.2
version: 8.4.1
preset: laravel
finder:
not-name:
Expand Down
2 changes: 1 addition & 1 deletion app/Actions/Discord/DiscordMessageAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function makeMessage(array $fields): array
$embeds = [];

foreach (Arr::get($fields, DiscordMessage::ATTRIBUTE_EMBEDS) as $embed) {
$newEmbed = (new DiscordEmbed())
$newEmbed = new DiscordEmbed()
->setTitle(Arr::get($embed, DiscordEmbed::ATTRIBUTE_TITLE) ?? '')
->setDescription(Arr::get($embed, DiscordEmbed::ATTRIBUTE_DESCRIPTION) ?? '')
->setColor(hexdec(Arr::get($embed, DiscordEmbed::ATTRIBUTE_COLOR) ?? ''))
Expand Down
6 changes: 0 additions & 6 deletions app/Actions/Discord/DiscordThreadAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Storage;

/**
* Class DiscordThreadAction.
Expand All @@ -31,11 +30,6 @@ public function handle(Anime $anime, array $fields): ?Exception

$anime->name = Arr::get($fields, 'name');

/** @var \Illuminate\Filesystem\FilesystemAdapter $fs */
$fs = Storage::disk(Config::get('image.disk'));

$anime->images->each(fn ($image) => Arr::set($image, 'link', $fs->url($image->path)));

$animeArray = $anime->toArray();

Arr::set($animeArray, Anime::ATTRIBUTE_SEASON, $anime->season->localize());
Expand Down
5 changes: 0 additions & 5 deletions app/Actions/Discord/DiscordVideoNotificationAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace App\Actions\Discord;

use App\Models\Wiki\Image;
use App\Models\Wiki\Video;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Support\Arr;
Expand Down Expand Up @@ -55,10 +54,6 @@ public function handle(Collection $videos, array $fields): void
$anime->load('discordthread');
}

$anime->images->each(function (Image $image) use ($fs) {
Arr::set($image, 'link', $fs->url($image->path));
});

$videoArray = $video->toArray();

Arr::set($videoArray, Video::ATTRIBUTE_SOURCE, $video->source->localize());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected function setUp(): void
$this->fillForm(fn (Anime $record): array => ['name' => $record->getName()]);

$this->action(function (Anime $record, array $data) {
$action = (new DiscordThreadActionAction())->handle($record, $data);
$action = new DiscordThreadActionAction()->handle($record, $data);

if ($action instanceof Exception) {
$this->failedLog($action);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function setUp(): void
ResourceSite::WIKI,
]);

$this->action(fn (Anime $record, array $data) => (new AttachResourceActionAction($record, $data, $this->sites))->handle());
$this->action(fn (Anime $record, array $data) => new AttachResourceActionAction($record, $data, $this->sites)->handle());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function setUp(): void
ResourceSite::WIKI,
]);

$this->action(fn (Artist $record, array $data) => (new AttachResourceActionAction($record, $data, $this->sites))->handle());
$this->action(fn (Artist $record, array $data) => new AttachResourceActionAction($record, $data, $this->sites)->handle());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function setUp(): void

$this->authorize('create', Image::class);

$this->action(fn (BaseModel $record, array $data) => (new AttachImageActionAction($record, $data, $this->facets))->handle());
$this->action(fn (BaseModel $record, array $data) => new AttachImageActionAction($record, $data, $this->facets)->handle());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected function setUp(): void
ResourceSite::AMAZON_MUSIC,
]);

$this->action(fn (Song $record, array $data) => (new AttachResourceActionAction($record, $data, $this->sites))->handle());
$this->action(fn (Song $record, array $data) => new AttachResourceActionAction($record, $data, $this->sites)->handle());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected function setUp(): void
ResourceSite::MAL,
]);

$this->action(fn (Studio $record, array $data) => (new AttachResourceActionAction($record, $data, $this->sites))->handle());
$this->action(fn (Studio $record, array $data) => new AttachResourceActionAction($record, $data, $this->sites)->handle());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Concerns/Filament/HasTabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ trait HasTabs
{
/**
* Get the tabs for an array key-mapped.
*
*
* @param class-string<BaseTab>[] $tabClasses
* @return array
*/
Expand Down
2 changes: 1 addition & 1 deletion app/Filament/Components/Columns/BelongsToColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function reload(): void
return "<p style='color: rgb(64, 184, 166);'>{$nameLimited}</p>";
});

return (new $this->resource)::getUrl('view', ['record' => $record]);
return $this->resource::getUrl('view', ['record' => $record]);
});
}

Expand Down
8 changes: 4 additions & 4 deletions app/Filament/Components/Fields/BelongsTo.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected function reload(): void

if ($this->showCreateOption) {
$this->createOptionForm(fn (Form $form) => $resource::form($form)->getComponents());
$this->createOptionUsing(fn (array $data) => (new $model)::query()->create($data)->getKey());
$this->createOptionUsing(fn (array $data) => $model::query()->create($data)->getKey());
}
}
}
Expand Down Expand Up @@ -85,12 +85,12 @@ protected function tryScout(string $model): static
{
$this->allowHtml();
$this->searchable();
$this->getOptionLabelUsing(fn ($state) => static::getSearchLabelWithBlade((new $model)::find($state)));
$this->getOptionLabelUsing(fn ($state) => static::getSearchLabelWithBlade($model::find($state)));

if (in_array(Searchable::class, class_uses_recursive($model))) {
return $this
->getSearchResultsUsing(function (string $search) use ($model) {
return (new $model)::search($search)
return $model::search($search)
->take(25)
->get()
->mapWithKeys(fn (BaseModel $model) => [$model->getKey() => static::getSearchLabelWithBlade($model)])
Expand All @@ -100,7 +100,7 @@ protected function tryScout(string $model): static

return $this
->getSearchResultsUsing(function (string $search) use ($model) {
return (new $model)::query()
return $model::query()
->where($this->resource->getRecordTitleAttribute(), ComparisonOperator::LIKE->value, "%$search%")
->take(25)
->get()
Expand Down
4 changes: 2 additions & 2 deletions app/Filament/Components/Fields/Select.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public function useScout(string $model, ?string $loadRelation = null): static
return $this
->allowHtml()
->searchable()
->getOptionLabelUsing(fn ($state) => BelongsTo::getSearchLabelWithBlade((new $model)::find($state)))
->getOptionLabelUsing(fn ($state) => BelongsTo::getSearchLabelWithBlade($model::find($state)))
->getSearchResultsUsing(function (string $search) use ($model, $loadRelation) {
return (new $model)::search($search)
return $model::search($search)
->take(25)
->get()
->load($loadRelation ?? [])
Expand Down
2 changes: 1 addition & 1 deletion app/Filament/Components/Infolist/TextEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function urlToRelated(string $resourceRelated, string $relation, ?bool $s
return "<p style='color: rgb(64, 184, 166);'>{$name}</p>";
});

return (new $resourceRelated)::getUrl('view', ['record' => $record]);
return $resourceRelated::getUrl('view', ['record' => $record]);
});
}

Expand Down
4 changes: 2 additions & 2 deletions app/Filament/RelationManagers/BaseRelationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function table(Table $table): Table
$pivot = current($record->getRelations());
$createdAtField = Arr::get($pivot->getAttributes(), BasePivot::ATTRIBUTE_CREATED_AT);
if (!$createdAtField) return '-';
return (new DateTime($createdAtField))->format('M j, Y H:i:s');
return new DateTime($createdAtField)->format('M j, Y H:i:s');
}),

TextColumn::make(BasePivot::ATTRIBUTE_UPDATED_AT)
Expand All @@ -67,7 +67,7 @@ public function table(Table $table): Table
$pivot = current($record->getRelations());
$updatedAtField = Arr::get($pivot->getAttributes(), BasePivot::ATTRIBUTE_UPDATED_AT);
if (!$updatedAtField) return '-';
return (new DateTime($updatedAtField))->format('M j, Y H:i:s');
return new DateTime($updatedAtField)->format('M j, Y H:i:s');
}),
],
))
Expand Down
2 changes: 1 addition & 1 deletion app/Filament/Resources/Base/BaseViewResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class BaseViewResource extends ViewRecord
*/
protected function getHeaderActions(): array
{
$pages = (new static::$resource)::getPages();
$pages = static::$resource::getPages();

if (Arr::has($pages, 'edit')) {
$editPage = $pages['edit']->getPage();
Expand Down
2 changes: 1 addition & 1 deletion app/Filament/Resources/Discord/DiscordThread.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public static function form(Form $form): Form
->required()
->rules(['required'])
->live()
->afterStateUpdated(fn (Set $set, string $state) => $set(DiscordThreadModel::ATTRIBUTE_NAME, Arr::get((new DiscordThreadAction())->get($state), 'thread.name'))),
->afterStateUpdated(fn (Set $set, string $state) => $set(DiscordThreadModel::ATTRIBUTE_NAME, Arr::get(new DiscordThreadAction()->get($state), 'thread.name'))),

TextInput::make(DiscordThreadModel::ATTRIBUTE_NAME)
->label(__('filament.fields.discord_thread.name.name'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function getForm(Form $form): Form

$component->hint(null);

$message = (new DiscordMessageAction())->get($state);
$message = new DiscordMessageAction()->get($state);

$set(DiscordMessage::ATTRIBUTE_CONTENT, Arr::get($message, DiscordMessage::ATTRIBUTE_CONTENT));

Expand Down
5 changes: 3 additions & 2 deletions app/Http/Api/Field/Wiki/Audio/AudioLinkField.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use App\Http\Api\Field\Field;
use App\Http\Api\Query\Query;
use App\Http\Api\Schema\Schema;
use App\Models\Wiki\Audio;
use Illuminate\Database\Eloquent\Model;

/**
Expand All @@ -22,7 +23,7 @@ class AudioLinkField extends Field implements RenderableField
*/
public function __construct(Schema $schema)
{
parent::__construct($schema, 'link');
parent::__construct($schema, Audio::ATTRIBUTE_LINK);
}

/**
Expand All @@ -46,6 +47,6 @@ public function shouldRender(Query $query): bool
*/
public function render(Model $model): string
{
return route('audio.show', $model);
return $model->getAttribute($this->getColumn());
}
}
8 changes: 2 additions & 6 deletions app/Http/Api/Field/Wiki/Image/ImageLinkField.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
use App\Http\Api\Schema\Schema;
use App\Models\Wiki\Image;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Storage;

/**
* Class ImageLinkField.
Expand All @@ -25,7 +23,7 @@ class ImageLinkField extends Field implements RenderableField
*/
public function __construct(Schema $schema)
{
parent::__construct($schema, 'link');
parent::__construct($schema, Image::ATTRIBUTE_LINK);
}

/**
Expand All @@ -49,8 +47,6 @@ public function shouldRender(Query $query): bool
*/
public function render(Model $model): string
{
$fs = Storage::disk(Config::get('image.disk'));

return $fs->url($model->getAttribute(Image::ATTRIBUTE_PATH));
return $model->getAttribute($this->getColumn());
}
}
2 changes: 1 addition & 1 deletion app/Http/Api/Field/Wiki/Image/ImagePathField.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ public function shouldSelect(Query $query, Schema $schema): bool
$criteria = $query->getFieldCriteria($this->schema->type());

// The link field is dependent on this field to build the url.
return parent::shouldSelect($query, $schema) || $criteria->isAllowedField('link');
return parent::shouldSelect($query, $schema) || $criteria->isAllowedField(Image::ATTRIBUTE_LINK);
}
}
5 changes: 3 additions & 2 deletions app/Http/Api/Field/Wiki/Video/VideoLinkField.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use App\Http\Api\Field\Field;
use App\Http\Api\Query\Query;
use App\Http\Api\Schema\Schema;
use App\Models\Wiki\Video;
use Illuminate\Database\Eloquent\Model;

/**
Expand All @@ -22,7 +23,7 @@ class VideoLinkField extends Field implements RenderableField
*/
public function __construct(Schema $schema)
{
parent::__construct($schema, 'link');
parent::__construct($schema, Video::ATTRIBUTE_LINK);
}

/**
Expand All @@ -46,6 +47,6 @@ public function shouldRender(Query $query): bool
*/
public function render(Model $model): string
{
return route('video.show', $model);
return $model->getAttribute($this->getColumn());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function index(IndexRequest $request, IndexAction $action): ExternalProfi

$userId = Auth::id();
if ($userId) {
$builder->orWhere(ExternalProfile::ATTRIBUTE_USER, Auth::id());
$builder->orWhereBelongsTo(Auth::user());
}

$externalprofiles = $query->hasSearchCriteria()
Expand Down
4 changes: 2 additions & 2 deletions app/Models/Admin/ActionLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* @property string|null $exception
* @property Carbon|null $finished_at
* @property ActionLogStatus $status
* @property morphs $target
* @property Model $target
* @property int $user_id
* @property User $user
*/
Expand Down Expand Up @@ -66,7 +66,7 @@ class ActionLog extends Model implements Nameable, HasSubtitle
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
* @var list<string>
*/
protected $fillable = [
ActionLog::ATTRIBUTE_BATCH_ID,
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Admin/Announcement.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Announcement extends BaseModel
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
* @var list<string>
*/
protected $fillable = [
Announcement::ATTRIBUTE_CONTENT,
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Admin/Dump.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Dump extends BaseModel
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
* @var list<string>
*/
protected $fillable = [
Dump::ATTRIBUTE_PATH,
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Admin/Feature.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Feature extends Model
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
* @var list<string>
*/
protected $fillable = [
Feature::ATTRIBUTE_VALUE,
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Admin/FeaturedTheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class FeaturedTheme extends BaseModel
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
* @var list<string>
*/
protected $fillable = [
FeaturedTheme::ATTRIBUTE_END_AT,
Expand Down
Loading

0 comments on commit 2a856c3

Please sign in to comment.