Skip to content

Commit

Permalink
Install Rector
Browse files Browse the repository at this point in the history
  • Loading branch information
danharrin committed Feb 4, 2025
1 parent 3c56920 commit fc3ce96
Show file tree
Hide file tree
Showing 66 changed files with 136 additions and 125 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
public function up(): void
{
Schema::create('exports', function (Blueprint $table) {
Schema::create('exports', function (Blueprint $table): void {
$table->id();
$table->timestamp('completed_at')->nullable();
$table->string('file_disk');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
public function up(): void
{
Schema::create('failed_import_rows', function (Blueprint $table) {
Schema::create('failed_import_rows', function (Blueprint $table): void {
$table->id();
$table->json('data');
$table->foreignId('import_id')->constrained()->cascadeOnDelete();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
public function up(): void
{
Schema::create('imports', function (Blueprint $table) {
Schema::create('imports', function (Blueprint $table): void {
$table->id();
$table->timestamp('completed_at')->nullable();
$table->string('file_name');
Expand Down
2 changes: 1 addition & 1 deletion packages/actions/src/AssociateAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ protected function setUp(): void
/** @var BelongsTo $inverseRelationship */
$inverseRelationship = $table->getInverseRelationshipFor($record);

$this->process(function () use ($inverseRelationship, $record, $relationship) {
$this->process(function () use ($inverseRelationship, $record, $relationship): void {
$inverseRelationship->associate($relationship->getParent());
$record->save();
}, [
Expand Down
2 changes: 1 addition & 1 deletion packages/actions/src/AttachAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ protected function setUp(): void
$this->record($record);
}

$this->process(function () use ($data, $record, $relationship) {
$this->process(function () use ($data, $record, $relationship): void {
$relationship->attach(
$record,
Arr::only($data, $relationship->getPivotColumns()),
Expand Down
2 changes: 1 addition & 1 deletion packages/actions/src/Concerns/CanBeMounted.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function mountUsing(?Closure $callback): static
*/
public function fillForm(array | Closure $data): static
{
$this->mountUsing(function (?Schema $form) use ($data) {
$this->mountUsing(function (?Schema $form) use ($data): void {
$form?->fill($this->evaluate($data));
});

Expand Down
2 changes: 1 addition & 1 deletion packages/actions/src/Concerns/CanExportRecords.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ protected function setUp(): void
...$action->getExporter()::getOptionsFormComponents(),
]);

$this->action(function (ExportAction | ExportBulkAction $action, array $data, Component $livewire) {
$this->action(function (ExportAction | ExportBulkAction $action, array $data, Component $livewire): void {
$exporter = $action->getExporter();

if ($livewire instanceof HasTable) {
Expand Down
2 changes: 1 addition & 1 deletion packages/actions/src/Concerns/InteractsWithActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public function callMountedAction(array $arguments = []): mixed
if ($this->mountedActionHasSchema(mountedAction: $action)) {
$action->callBeforeFormValidated();

$schema->getState(afterValidate: function (array $state) use ($action, $schemaState) {
$schema->getState(afterValidate: function (array $state) use ($action, $schemaState): void {
$action->callAfterFormValidated();

$action->formData([
Expand Down
2 changes: 1 addition & 1 deletion packages/actions/src/EditAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected function setUp(): void
});

$this->action(function (): void {
$this->process(function (array $data, HasActions & HasSchemas $livewire, Model $record, ?Table $table) {
$this->process(function (array $data, HasActions & HasSchemas $livewire, Model $record, ?Table $table): void {
$relationship = $table?->getRelationship();

$translatableContentDriver = $livewire->makeFilamentTranslatableContentDriver();
Expand Down
2 changes: 1 addition & 1 deletion packages/actions/src/Exports/Concerns/CanFormatState.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function formatState(mixed $state): mixed
}

if (filled($suffix)) {
$state = $state . $suffix;
$state .= $suffix;
}

return $state;
Expand Down
2 changes: 1 addition & 1 deletion packages/actions/src/Exports/Downloaders/CsvDownloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function __invoke(Export $export): StreamedResponse
abort(404);
}

return response()->streamDownload(function () use ($disk, $directory) {
return response()->streamDownload(function () use ($disk, $directory): void {
echo $disk->get($directory . DIRECTORY_SEPARATOR . 'headers.csv');

flush();
Expand Down
4 changes: 2 additions & 2 deletions packages/actions/src/Exports/Downloaders/XlsxDownloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __invoke(Export $export): StreamedResponse

$csvDelimiter = $export->exporter::getCsvDelimiter();

$writeRowsFromFile = function (string $file) use ($csvDelimiter, $disk, $writer) {
$writeRowsFromFile = function (string $file) use ($csvDelimiter, $disk, $writer): void {
$csvReader = CsvReader::createFromStream($disk->readStream($file));
$csvReader->setDelimiter($csvDelimiter);
$csvResults = Statement::create()->process($csvReader);
Expand All @@ -41,7 +41,7 @@ public function __invoke(Export $export): StreamedResponse
}
};

return response()->streamDownload(function () use ($disk, $directory, $fileName, $writer, $writeRowsFromFile) {
return response()->streamDownload(function () use ($disk, $directory, $fileName, $writer, $writeRowsFromFile): void {
$writer->openToBrowser($fileName);

$writeRowsFromFile($directory . DIRECTORY_SEPARATOR . 'headers.csv');
Expand Down
2 changes: 1 addition & 1 deletion packages/actions/src/Exports/Jobs/CreateXlsxFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function handle(): void

$csvDelimiter = $this->exporter::getCsvDelimiter();

$writeRowsFromFile = function (string $file, ?Style $style = null) use ($csvDelimiter, $disk, $writer) {
$writeRowsFromFile = function (string $file, ?Style $style = null) use ($csvDelimiter, $disk, $writer): void {
$csvReader = CsvReader::createFromStream($disk->readStream($file));
$csvReader->setDelimiter($csvDelimiter);
$csvResults = Statement::create()->process($csvReader);
Expand Down
2 changes: 1 addition & 1 deletion packages/actions/src/Exports/Jobs/ExportCsv.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function handle(): void

$filePath = $this->export->getFileDirectory() . DIRECTORY_SEPARATOR . str_pad(strval($this->page), 16, '0', STR_PAD_LEFT) . '.csv';

DB::transaction(function () use ($csv, $filePath, $processedRows, $successfulRows) {
DB::transaction(function () use ($csv, $filePath, $processedRows, $successfulRows): void {
$this->export::query()
->whereKey($this->export->getKey())
->lockForUpdate()
Expand Down
2 changes: 1 addition & 1 deletion packages/actions/src/Exports/Jobs/PrepareCsvExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function handle(): void
// in case it contains attributes that are not serializable, such as binary columns.
$this->export->unsetRelation('user');

$dispatchRecords = function (array $records) use ($exportCsvJob, &$page, &$totalRows) {
$dispatchRecords = function (array $records) use ($exportCsvJob, &$page, &$totalRows): void {
$recordsCount = count($records);

if (($totalRows + $recordsCount) > $this->export->total_rows) {
Expand Down
10 changes: 5 additions & 5 deletions packages/actions/src/ImportAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ protected function setUp(): void
->placeholder(__('filament-actions::import.modal.form.file.placeholder'))
->acceptedFileTypes(['text/csv', 'text/x-csv', 'application/csv', 'application/x-csv', 'text/comma-separated-values', 'text/x-comma-separated-values', 'text/plain', 'application/vnd.ms-excel'])
->rules($action->getFileValidationRules())
->afterStateUpdated(function (FileUpload $component, Component $livewire, Set $set, ?TemporaryUploadedFile $state) use ($action) {
->afterStateUpdated(function (FileUpload $component, Component $livewire, Set $set, ?TemporaryUploadedFile $state) use ($action): void {
if (! $state instanceof TemporaryUploadedFile) {
return;
}
Expand Down Expand Up @@ -179,7 +179,7 @@ protected function setUp(): void
->visible(fn (Get $get): bool => $get('file') instanceof TemporaryUploadedFile),
], $action->getImporter()::getOptionsFormComponents()));

$this->action(function (ImportAction $action, array $data) {
$this->action(function (ImportAction $action, array $data): void {
/** @var TemporaryUploadedFile $csvFile */
$csvFile = $data['file'];

Expand Down Expand Up @@ -271,7 +271,7 @@ protected function setUp(): void
filled($jobBatchName = $importer->getJobBatchName()),
fn (PendingBatch $batch) => $batch->name($jobBatchName),
)
->finally(function () use ($authGuard, $columnMap, $import, $jobConnection, $options) {
->finally(function () use ($authGuard, $columnMap, $import, $jobConnection, $options): void {
$import->touch('completed_at');

event(new ImportCompleted($import, $columnMap, $options));
Expand Down Expand Up @@ -373,7 +373,7 @@ protected function setUp(): void

$csv->insertAll($exampleRows);

return response()->streamDownload(function () use ($csv) {
return response()->streamDownload(function () use ($csv): void {
$csv->setOutputBOM(Bom::Utf8);

echo $csv->toString();
Expand Down Expand Up @@ -601,7 +601,7 @@ public function getFileValidationRules(): array
$fileRules = [
'extensions:csv,txt',
File::types(['csv', 'txt'])->rules([
function (string $attribute, mixed $value, Closure $fail) {
function (string $attribute, mixed $value, Closure $fail): void {
$csvStream = $this->getUploadedFileStream($value);

if (! $csvStream) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function __invoke(Request $request, Import $import): StreamedResponse
'error' => $failedImportRow->validation_error ?? __('filament-actions::import.failure_csv.system_error'),
]));

return response()->streamDownload(function () use ($csv) {
return response()->streamDownload(function () use ($csv): void {
foreach ($csv->chunk(1000) as $offset => $chunk) {
echo $chunk;

Expand Down
2 changes: 1 addition & 1 deletion packages/actions/src/Imports/ImportColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ public function getDataValidationRules(): array
$rules = $this->evaluate($this->dataValidationRules);

if ($this->hasRelationship()) {
$rules[] = function (string $attribute, mixed $state, Closure $fail) {
$rules[] = function (string $attribute, mixed $state, Closure $fail): void {
if (blank($state)) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/actions/src/Imports/Jobs/ImportCsv.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function handle(): void

$rows = is_array($this->rows) ? $this->rows : unserialize(base64_decode($this->rows));

DB::transaction(function () use (&$processedRows, $rows, &$successfulRows) {
DB::transaction(function () use (&$processedRows, $rows, &$successfulRows): void {
foreach ($rows as $row) {
$row = $this->utf8Encode($row);

Expand Down
2 changes: 1 addition & 1 deletion packages/actions/src/ReplicateAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected function setUp(): void
});

$this->action(function () {
$result = $this->process(function (array $data, Model $record) {
$result = $this->process(function (array $data, Model $record): void {
$this->replica = $record->replicate($this->getExcludedAttributes());

$this->replica->fill($data);
Expand Down
2 changes: 1 addition & 1 deletion packages/actions/src/RestoreBulkAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ protected function setUp(): void
$this->modalIcon(FilamentIcon::resolve('actions::restore-action.modal') ?? Heroicon::OutlinedArrowUturnLeft);

$this->action(fn () => $this->processIndividualRecords(
static function (Model $record) {
static function (Model $record): void {
if (! method_exists($record, 'restore')) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/forms/src/Components/CheckboxList.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected function setUp(): void

$this->default([]);

$this->afterStateHydrated(static function (CheckboxList $component, $state) {
$this->afterStateHydrated(static function (CheckboxList $component, $state): void {
if (is_array($state)) {
return;
}
Expand Down Expand Up @@ -196,7 +196,7 @@ public function relationship(string | Closure | null $name = null, string | Clos
);
});

$this->saveRelationshipsUsing(static function (CheckboxList $component, ?array $state) use ($modifyQueryUsing) {
$this->saveRelationshipsUsing(static function (CheckboxList $component, ?array $state) use ($modifyQueryUsing): void {
$relationship = $component->getRelationship();

if ($modifyQueryUsing) {
Expand Down
2 changes: 1 addition & 1 deletion packages/forms/src/Components/Concerns/CanBeValidated.php
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ public function unique(string | Closure | null $table = null, string | Closure |
public function distinct(bool | Closure $condition = true): static
{
$this->rule(static function (Field $component, mixed $state) {
return function (string $attribute, mixed $value, Closure $fail) use ($component, $state) {
return function (string $attribute, mixed $value, Closure $fail) use ($component, $state): void {
if (blank($state)) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function fixIndistinctState(bool | Closure $condition = true): static
$this->distinct($condition);
$this->live(condition: $condition);

$this->afterStateUpdated(static function (Component $component, mixed $state, Set $set) use ($condition) {
$this->afterStateUpdated(static function (Component $component, mixed $state, Set $set) use ($condition): void {
if (! $component->evaluate($condition)) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/forms/src/Components/MorphToSelect.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function getDefaultChildComponents(): array
->native($this->isNative())
->required($isRequired)
->live()
->afterStateUpdated(function (Set $set) use ($keyColumn) {
->afterStateUpdated(function (Set $set) use ($keyColumn): void {
$set($keyColumn, null);
$this->callAfterStateUpdated();
}),
Expand All @@ -112,7 +112,7 @@ public function getDefaultChildComponents(): array
$this->isLive(),
fn (Select $component) => $component->live(onBlur: $this->isLiveOnBlur()),
)
->afterStateUpdated(function () {
->afterStateUpdated(function (): void {
$this->callAfterStateUpdated();
}),
];
Expand Down
6 changes: 3 additions & 3 deletions packages/forms/src/Components/Repeater.php
Original file line number Diff line number Diff line change
Expand Up @@ -913,21 +913,21 @@ public function relationship(string | Closure | null $name = null, ?Closure $mod
$this->relationship = $name ?? $this->getName();
$this->modifyRelationshipQueryUsing = $modifyQueryUsing;

$this->afterStateHydrated(function (Repeater $component) {
$this->afterStateHydrated(function (Repeater $component): void {
if (! is_array($component->hydratedDefaultState)) {
return;
}

$component->mergeHydratedDefaultStateWithItemsState();
});

$this->loadStateFromRelationshipsUsing(static function (Repeater $component) {
$this->loadStateFromRelationshipsUsing(static function (Repeater $component): void {
$component->clearCachedExistingRecords();

$component->fillFromRelationship();
});

$this->saveRelationshipsUsing(static function (Repeater $component, HasForms $livewire, ?array $state) {
$this->saveRelationshipsUsing(static function (Repeater $component, HasForms $livewire, ?array $state): void {
if (! is_array($state)) {
$state = [];
}
Expand Down
8 changes: 4 additions & 4 deletions packages/forms/src/Components/Select.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public function getCreateOptionAction(): ?Action
$component->getRelationship() ? $component->getRelationship()->getModel()::class : null,
));
})
->action(static function (Action $action, array $arguments, Select $component, array $data, Schema $form) {
->action(static function (Action $action, array $arguments, Select $component, array $data, Schema $form): void {
if (! $component->getCreateOptionUsing()) {
throw new Exception("Select field [{$component->getStatePath()}] must have a [createOptionUsing()] closure set.");
}
Expand Down Expand Up @@ -442,7 +442,7 @@ public function getEditOptionAction(): ?Action
);
})
->fillForm($this->getEditOptionActionFormData())
->action(static function (Action $action, array $arguments, Select $component, array $data, Schema $form) {
->action(static function (Action $action, array $arguments, Select $component, array $data, Schema $form): void {
if (! $component->getUpdateOptionUsing()) {
throw new Exception("Select field [{$component->getStatePath()}] must have a [updateOptionUsing()] closure set.");
}
Expand Down Expand Up @@ -998,7 +998,7 @@ public function relationship(string | Closure | null $name = null, string | Clos
->toArray();
});

$this->saveRelationshipsUsing(static function (Select $component, Model $record, $state) use ($modifyQueryUsing) {
$this->saveRelationshipsUsing(static function (Select $component, Model $record, $state) use ($modifyQueryUsing): void {
$relationship = $component->getRelationship();

if (
Expand Down Expand Up @@ -1075,7 +1075,7 @@ public function relationship(string | Closure | null $name = null, string | Clos
return $component->getSelectedRecord()?->attributesToArray();
});

$this->updateOptionUsing(static function (array $data, Schema $form) {
$this->updateOptionUsing(static function (array $data, Schema $form): void {
$form->getRecord()?->update($data);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ public function formatState(mixed $state): mixed
$suffix = e($suffix);
}

$state = $state . $suffix;
$state .= $suffix;
}

return $isHtml ? new HtmlString($state) : $state;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function packageBooted(): void

Livewire::component('notifications', Notifications::class);

on('dehydrate', function (Component $component) {
on('dehydrate', function (Component $component): void {
if (! Livewire::isLivewireRequest()) {
return;
}
Expand Down
Loading

0 comments on commit fc3ce96

Please sign in to comment.