Skip to content

Improve deprecated-forms-set and add a new deprecated-forms-get rule#18

Merged
PovilasKorop merged 1 commit into
mainfrom
issue/17
Feb 19, 2026
Merged

Improve deprecated-forms-set and add a new deprecated-forms-get rule#18
PovilasKorop merged 1 commit into
mainfrom
issue/17

Conversation

@krekas
Copy link
Copy Markdown
Collaborator

@krekas krekas commented Feb 19, 2026

  • Add deprecated-forms-get rule to detect use Filament\Forms\Get and callable $get patterns
  • Enhance deprecated-forms-set rule to also detect callable $set in closures
  • Make AddsImport trait violations silent so import-related fixes no longer clutter the output

Before / After

Running filacheck on this code:

<?php

use Filament\Schemas\Components\TextInput;

class TestResource
{
    public function form(): array
    {
        return [
            TextInput::make('name')
                ->afterStateUpdated(function (callable $set, callable $get) {
                    $set('slug', Str::slug($get('name')));
                }),
        ];
    }
}

Before (noisy output with import warnings):

✗ deprecated-forms-set
    Line 11: Parameter `$set` should be typed as `Set` instead of `callable`.
    Line 1:  Missing import: use Filament\Schemas\Components\Utilities\Set;

✗ deprecated-forms-get
    Line 11: Parameter `$get` should be typed as `Get` instead of `callable`.
    Line 1:  Missing import: use Filament\Schemas\Components\Utilities\Get;

Issues: 4 warning(s)

After (clean output, import warnings are silent):

✗ deprecated-forms-set
    Line 11: Parameter `$set` should be typed as `Set` instead of `callable`.

✗ deprecated-forms-get
    Line 11: Parameter `$get` should be typed as `Get` instead of `callable`.

Issues: 2 warning(s)

Running filacheck --fix still silently adds the imports and produces:

<?php

use Filament\Schemas\Components\TextInput;
use Filament\Schemas\Components\Utilities\Get;
use Filament\Schemas\Components\Utilities\Set;

class TestResource
{
    public function form(): array
    {
        return [
            TextInput::make('name')
                ->afterStateUpdated(function (Set $set, Get $get) {
                    $set('slug', Str::slug($get('name')));
                }),
        ];
    }
}

Resolves #17

@PovilasKorop PovilasKorop merged commit 1ca8d80 into main Feb 19, 2026
@PovilasKorop PovilasKorop deleted the issue/17 branch February 19, 2026 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Detect incorrect type hints for $set and $get closure parameters

2 participants