Skip to content

Fix TypeError when Blade::getPath() returns null during view caching#150

Merged
taylorotwell merged 3 commits intolivewire:mainfrom
chriscupas:fix-null-path-in-fragment-alias
Jan 28, 2026
Merged

Fix TypeError when Blade::getPath() returns null during view caching#150
taylorotwell merged 3 commits intolivewire:mainfrom
chriscupas:fix-null-path-in-fragment-alias

Conversation

@chriscupas
Copy link
Contributor

Description

This PR fixes a TypeError that occurs during php artisan optimize when caching views with Livewire Volt components.

Problem

The FragmentAlias::encode() method expects a non-null string for the $path parameter, but Blade::getPath() can return null in certain cases during view compilation, causing:

TypeError: Livewire\Volt\FragmentAlias::encode(): Argument #2 ($path) must be of type string, null given

Solution

  • Change the $path parameter type from string to ?string
  • Handle null paths by defaulting to an empty string in the JSON encoding

Testing

Verified that php artisan view:cache and php artisan optimize now work without errors.

c.cupas and others added 3 commits January 27, 2026 16:52
Allow the path parameter in FragmentAlias::encode() to be nullable and handle null paths by defaulting to an empty string. This prevents TypeError when caching views with Volt components where the path is not available.
Add ignoreErrors for ComponentRegistry class references that are internal to Livewire and not available during static analysis.
@taylorotwell taylorotwell merged commit 4aa52b9 into livewire:main Jan 28, 2026
1 of 21 checks passed
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.

2 participants