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

Typecast when serializing primitive types #15

Merged
merged 3 commits into from
Dec 19, 2012

Conversation

baldurrensch
Copy link

I have noticed that the serializer does not fully enforce primitive types. I am not sure whether that is desired or not.

@schmittjoh
Copy link
Owner

With the new type handling, I think this makes sense.

Could you add some tests for this?

* @param string $primitiveType
* @param mixed $data
*/
public function testSerializationCastsType($primitiveType, $data)
Copy link
Owner

Choose a reason for hiding this comment

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

Maybe I'm missing something, but this does not seem to actually test that the data was cast, no?

I think you need to add something like assertInternalType.

Copy link
Author

Choose a reason for hiding this comment

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

Good point, it was really just testing that the correct visitXXX() function would be called. I have since moved the function into the JsonSerializationTest, as the function is in the abstract GenericSerializationVisitor, so we can only test it in one of the concrete classes.

One more thing. I noticed that one of the functions in there is called visitDouble() where the PHP internal type is actually called float. Should we rename the function (in a seperate PR of course). Or add a wrapper visitFloat() that just calls the other one?

- Removed the fairly useless test from GraphNavigator
- Added them to JsonSerialization
schmittjoh added a commit that referenced this pull request Dec 19, 2012
Typecast when serializing primitive types
@schmittjoh schmittjoh merged commit b8f87c9 into schmittjoh:master Dec 19, 2012
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.

3 participants