Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Fix type error in Asset #15274

Merged
merged 2 commits into from
Jan 10, 2025
Merged

bug: Fix type error in Asset #15274

merged 2 commits into from
Jan 10, 2025

Conversation

davidyell
Copy link
Contributor

Description

The $path class property is null by default but the accessor method can't return null which causes a TypeError

Visual changes

None

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.

@davidyell
Copy link
Contributor Author

Seems there is more upstream code which seems to always assume this is not null, due to the accessor method. So perhaps the real fix is to not allow a null at all, or default to string /

@danharrin
Copy link
Member

Can you hint at how you got here, what were you doing when you encountered this problem? I just need a bit more context really

@davidyell
Copy link
Contributor Author

So I was trying to ensure that my Laravel 11 apps app.js was included into the Filament layout.

Then I found myself over here https://filamentphp.com/docs/3.x/support/assets#registering-javascript-files

Which gives the code example of

use Filament\Support\Assets\Js;
 
FilamentAsset::register([
    Js::make('custom-script', __DIR__ . '/../../resources/js/custom.js'),
]);

So I tried that, but then found that if I omitted the $path param, I got a TypeError.

@danharrin danharrin added the bug Something isn't working label Jan 10, 2025
@danharrin danharrin added this to the v3 milestone Jan 10, 2025
@danharrin
Copy link
Member

Yeah honestly not really sure how this code happened, seems suspicious. Thanks

@danharrin danharrin merged commit cc95f8a into filamentphp:3.x Jan 10, 2025
@davidyell davidyell deleted the patch-1 branch January 10, 2025 10:22
@danharrin
Copy link
Member

I found why this needs to be optional (only just noticed PHPStan didn't run because it wasn't approved here, would have caught it)

return Theme::make('app')->html($this->theme);

I am going to revert this and allow null to be returned from getPath() instead

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
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants