Adding more built-in casters #6
Replies: 3 comments
-
Hi @mauriciovillam, In case of the For the |
Beta Was this translation helpful? Give feedback.
-
Looks good, however, one of the use cases I had for ArrayCaster is setting the default value to an empty array
Edit nov. 8: This issue may be resolved in PHP 8.1 due to being able to use new in initializers. (https://stitcher.io/blog/php-81-new-in-initializers) On the other hand, DataCollection with annotated Data models in the same namespace are not resolved correctly. I'm getting this error:
If I change it to this it works:
The problem seems to occur in https://github.com/spatie/laravel-data/tree/main/src/Support/DataProperty.php:151. I see that this problem has already been foreseen with a TODO comment. We are probably re-inventing the wheel there and need to delegate the class' namespace resolver logic to an utility class/library. You can see a similar discussion here: php-annotations/php-annotations#15. |
Beta Was this translation helpful? Give feedback.
-
Hi @mauriciovillam, The problem should be solved by using version 1.1.0 of the package, it now has built in support for classes without FQN's 🎉 As for the initializer problem, yeah PHP 8.1 is only two weeks away from us, I think that would be the best solution to tackle this issue. |
Beta Was this translation helpful? Give feedback.
-
Hello,
I'm currently moving my project from spatie/data-transfer-object to spatie/laravel-data. I noticed that this project includes a cast by default (DateTimeInterface), wouldn't it be a good idea to implement spatie/data-transfer-object's ArrayCaster and the equivalent of DataTransferObjectCaster?
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions