-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Description
Package
filament/filament
Package Version
v5.2.1
Laravel Version
v12
Livewire Version
v4
PHP Version
PHP 8.5.2
Problem description
In src/Resources/Concerns/HasTabs.php on line 75, array_key_exists($this->activeTab, $tabs) is called while $this->activeTab is null. PHP 8.5 deprecates passing null as the key parameter to array_key_exists():
Warning: Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead
This warning fires repeatedly on every table page load, causing noticeable performance degradation due to the volume of warnings generated.
Expected behavior
No deprecation warning should be triggered. The null value of $this->activeTab should be caught before reaching array_key_exists().
Steps to reproduce
- Use PHP 8.5
- Create any resource with a ListRecords page that has a table
- Do not define any tabs (use the default empty getTabs())
- Load the list page
- Observe repeated deprecation warnings in the log:
Warning: Using null as the key parameter for array_key_exists() is deprecated in vendor/filament/filament/src/Resources/Concerns/HasTabs.php on line 75
The issue is in modifyQueryWithActiveTab(). The guard on line 69 (blank(filled($this->activeTab))) should prevent null from reaching line 75, but it doesn't in all cases. A simple fix:
// Line 75, before:
if (! array_key_exists($this->activeTab, $tabs)) {
// After:
if ($this->activeTab === null || ! array_key_exists($this->activeTab, $tabs)) {
Reproduction repository (issue will be closed if this is not valid)
https://github.com/gldrenthe89/filamentv5-php-deprication-warning
Relevant log output
warning – Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead in /vendor/filament/filament/src/Resources/Concerns/HasTabs.php on line 75Metadata
Metadata
Assignees
Labels
Type
Projects
Status