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

Add asArray option to recursively transform into arrays #10

Merged
merged 2 commits into from
Aug 27, 2015

Conversation

fcastilloes
Copy link

As you commented in #8 you wanted this functionality optional I added it disabled by default in this PR.

else
{
// Fallback for stdClass objects
return json_decode(json_encode($val), true);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think array casting with return (array) $val; would do the same in less time.

@Art4 Art4 added this to the 0.4 milestone Aug 27, 2015
@Art4
Copy link
Owner

Art4 commented Aug 27, 2015

Looks good to me. 👍 But please replace the json_decode/encode line with array casting.

And some tests for objectTransform() would be nice. 😄

@fcastilloes
Copy link
Author

An array cast doesn't work with nested stdClass, which would not be transformed to array. See this:

https://gist.github.com/fcastillo-es/03305bbbd51f5ed00b8f

That would cause failure with valid meta members. Tell me what you think about it. I'll take care of the tests meanwhile.

@Art4
Copy link
Owner

Art4 commented Aug 27, 2015

You are right, I've forgotten about nested classes. Alright then.

@fcastilloes
Copy link
Author

Ok, I added some tests. Basically duplicating all the assertSame assertions with fullArray true. Also added an assertion to each integration test. I think this is enough.

By the way, I think I messed up a commit when trying to rebase and maybe I should create another pull request to have a clean history. Tell me when you can.

@Art4
Copy link
Owner

Art4 commented Aug 27, 2015

Thanks! Looks goot to me.

By the way, I think I messed up a commit when trying to rebase

I thinks thats not a problem. You rebased your commit from #9.

Art4 added a commit that referenced this pull request Aug 27, 2015
Add asArray() option to recursively transform into arrays
@Art4 Art4 merged commit f6723b2 into Art4:master Aug 27, 2015
@fcastilloes fcastilloes deleted the recursive-as-array branch August 27, 2015 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants