Skip to content

Fix method name reference in InteractsWithSchemas trait and add tests for schema resolution#18972

Merged
danharrin merged 4 commits intofilamentphp:4.xfrom
mmuqiitf:fix/schemas-reflection-fallback
Jan 21, 2026
Merged

Fix method name reference in InteractsWithSchemas trait and add tests for schema resolution#18972
danharrin merged 4 commits intofilamentphp:4.xfrom
mmuqiitf:fix/schemas-reflection-fallback

Conversation

@mmuqiitf
Copy link
Contributor

Description

The Issue

Fixes #18971
This PR addresses a ReflectionException that occurs when using the HasFiltersSchema trait (or any schema fallback convention) in a component and providing the fallback method (e.g., filtersSchema()) without defining the primary method (e.g., filters()).

The InteractsWithSchemas::cacheSchema() method correctly identifies the fallback method name but incorrectly uses the original $name variable when instantiating the ReflectionMethod. This causes a crash during Livewire AJAX updates, particularly when interacting with searchable() components inside filters, as Filament attempts to reflect on a method that doesn't exist.

The Fix

I have also added a comprehensive regression test in tests/src/Schemas/InteractsWithSchemasTest.php to ensure that:

  1. Primary method names (e.g., test()) continue to work.
  2. Fallback method names (e.g., testSchema()) resolve correctly.
  3. Fallback methods without parameters also work.

Visual changes

N/A - This is a backend reflection fix.

Functional changes

  • Code style has been fixed by running the composer cs command.
  • Changes have been tested to not break existing functionality.
  • Documentation is up-to-date.

@github-project-automation github-project-automation bot moved this to Todo in Roadmap Jan 15, 2026
@danharrin danharrin added the bug Something isn't working label Jan 15, 2026
@danharrin danharrin added this to the v4 milestone Jan 15, 2026
@github-project-automation github-project-automation bot moved this from Todo to In Progress in Roadmap Jan 21, 2026
@danharrin danharrin merged commit 82ee1b0 into filamentphp:4.x Jan 21, 2026
@github-project-automation github-project-automation bot moved this from In Progress to Done in Roadmap Jan 21, 2026
@mmuqiitf mmuqiitf deleted the fix/schemas-reflection-fallback branch January 23, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

ReflectionException: Method filters() does not exist when using HasFiltersSchema and searchable() components

2 participants