-
-
Notifications
You must be signed in to change notification settings - Fork 211
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
throw Uncastable results in "Cannot throw objects that do not implement Throwable" from a custom Cast #685
Comments
This looks to be a documentation issue. If you look at the included casts they all return |
@TomAdam thanks a lot! That was probably it. Maybe you also know how to provide multiple casts for the property as they mention in the "try other casts (if available)" part there? |
If someone else also wanders about "try other casts (if available)" part, so far I've only found out that if you return This means that if you have something like this (as in the initial message's example): #[WithCast(StringCast::class)]
public StringDto|string $myString, and the UPD: It turns out it will not go to the So writing |
✏️ Describe the bug
Per docs it says you need to
throw Uncastable::create();
to tell the package to try other casts, but the real result is that for PHP 8.2 it throws an\Error
with the messageCannot throw objects that do not implement Throwable
. Not to mention every static analysis tells me it's wrong.↪️ To Reproduce
Create a custom cast -> use it so that it definitely throws Uncastable.
✅ Expected behavior
The Uncastable class to implement \Thorwable.
By the way how to achieve this "other casts" thing? I've tried to add another
#[WithCast(...)]
but it results in an \Error with messageAttribute "Spatie\LaravelData\Attributes\WithCast" must not be repeated
.🖥️ Versions
Laravel: v10.22.0
Laravel Data: 4.1.0
PHP: 8.2.4
The text was updated successfully, but these errors were encountered: