Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Add custom arguments to the CastWith attribute #199

Merged
merged 1 commit into from
Apr 30, 2021

Conversation

xico42
Copy link
Contributor

@xico42 xico42 commented Apr 22, 2021

Custom arguments can be used to provide metadata and extra context for
the user-defined casters.

This can be used, for example, to create generic array casters.

Fixes #193

Custom arguments can be used to provide metadata and extra context for
the user-defined casters.

This can be used, for example, to create generic array casters.

Fixes #193
@jaulz
Copy link

jaulz commented Apr 27, 2021

@brendt any chance to merge this soon? 😊

It would be also cool if it could automatically pass the type from the comment (i.e. /** @var \Spatie\DataTransferObject\Tests\Foo[] */) but that's maybe a separate PR?

@brendt
Copy link
Contributor

brendt commented Apr 28, 2021

I'll try to look at it this week :)

@brendt brendt merged commit 1bb0465 into spatie:master Apr 30, 2021
@brendt
Copy link
Contributor

brendt commented Apr 30, 2021

I'm going to add a few more additions myself before tagging:

  • I'm thinking of adding GenericArrayCaster to the package itself
  • I'll spread the args again when passed to the caster

@brendt
Copy link
Contributor

brendt commented Apr 30, 2021

@fcoedno would you mind reviewing my commit? 0df542e

@aidan-casey
Copy link
Collaborator

@brendt - Is there any reason to not add a check for whether the type implements ArrayAccess in the GenericArrayCaster?

@xico42
Copy link
Contributor Author

xico42 commented Apr 30, 2021

@brendt it looks great. Looking forward to seeing it in the next release.

@brendt
Copy link
Contributor

brendt commented May 3, 2021

@aidan-casey good question, I copied that part from the original PR… would you like to send a PR to improve it? Otherwise I'll try to look at it this week :)

@aidan-casey
Copy link
Collaborator

@brendt - I am happy to create a PR for it, just wasn't sure if it was something you purposely didn't want in the package.

I'll draft something up soon.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
4 participants