Closed jrmajor closed 3 years ago
This is fantastic @jrmajor! Thank you!
I'm definitely happy to drop PHP 7.4 and DTO v2 support and tag this as a major release.
Was there any reason this PR is still a draft? I'd be happy to merge and tag this.
@jessarcher This PR is ready and can be merged.
Before you tag a new major, I'd like to propose one more breaking change. We can implement Arrayable
and Jsonable
interfaces in castable DTO. It already has toJson()
/toArray()
methods, it just doesn't implement those interfaces. It would make toJson()
/toArray()
collection methods work properly for collections of DTOs and allow returning DTOs from controllers to return a JSON response. Please let me know, if you would accept a PR for that.
@jrmajor Thanks again for your work!
I'm happy for you to implement Arrayable
and Jsonable
. I can't at the moment think why that would be a breaking change, but I'll wait for your PR before tagging 2.0 :slightly_smiling_face:
I can't at the moment think why that would be a breaking change
Laravel treats objects with these interfaces differently, for example if you called toArray()
on Laravel Collection
of DTOs, previously it would return an array of DTOs, and now DTOs would also be converted to arrays.
I've allowed
spatie/data-transfer-object:^3.0
incomposer.json
and updated test workflow to run tests for both versions.One test fails because DTOs now throw the native
TypeError
(and a few other errors) instead of theDataTransferObjectError
. Are you OK with different errors being thrown, or do you want to tag a new major release?Edit: I think it should definitely be a major release.