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

Collection id check for getIdFromData #325

Conversation

countless-integers
Copy link

Expands the id in collection check to include dummy type check. Believe it or not I've run into an issue that could be remedied by this.

@@ -358,7 +358,7 @@ protected function parseRelationships($includedData)
*/
protected function getIdFromData(array $data)
{
if (!array_key_exists('id', $data)) {
if (!array_key_exists('id', $data) || (!is_string($data['id']) && !is_numeric($data['id']))) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we'd like to accept anything that can be cast as a string. We'd want to check something along the lines of is_scalar or implements __toString(). I don't see any reason not to allow string-able ids.

Copy link
Author

Choose a reason for hiding this comment

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

Makes sense to me. I've updated the PR. Unfortunately that condition will not win any beauty pageants... I've added more test cases as well.

@KorvinSzanto
Copy link
Contributor

Hi @countless-integers, would you mind reopening this PR against the new separate JSON:API Serializer repo? That way we can get this released in 1.0 with commit credit to you.

@KorvinSzanto KorvinSzanto added this to the 1.0.0 milestone Jul 4, 2019
@KorvinSzanto KorvinSzanto added this to To do in v1.0.0 May 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
v1.0.0
  
To do
Development

Successfully merging this pull request may close these issues.

None yet

3 participants