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

[BUGFIX] Cast empty schema arrays to object #409

Merged

Conversation

erayd
Copy link
Contributor

@erayd erayd commented Apr 5, 2017

What

  • Cast empty schema arrays to object.
  • Use function_exists instead of checking the PHP version.
  • Move array->object casts into SchemaConstraint & SchemaStorage.

Why

$message .= ': ' . json_last_error_msg();
}
throw new InvalidArgumentException($message);
}

return json_decode($json);
return (object) json_decode($json);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will only do a shallow cast. Is that intended?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's deliberate. The JSON functions are already handling the deep cast - my understanding of this bug is that it's a shallow-cast problem only (that's the way it was reported).

Copy link

Choose a reason for hiding this comment

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

Yes, it is. json_decode already does the deep cast.

@shmax
Copy link
Collaborator

shmax commented Apr 5, 2017

LGTM

@erayd erayd changed the title Cast empty schema arrays to object [BUGFIX] Cast empty schema arrays to object Apr 11, 2017
@erayd erayd mentioned this pull request Apr 12, 2017
Copy link
Collaborator

@bighappyface bighappyface left a comment

Choose a reason for hiding this comment

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

+1

@bighappyface bighappyface merged commit 549b4af into jsonrainbow:6.0.0-dev May 5, 2017
erayd added a commit to erayd/json-schema that referenced this pull request May 5, 2017
* Cast root to object

* Use function_exists to allow polyfill compatibility

* Move array->object conversion to SchemaConstraint & SchemaStorage

Fixes issue jsonrainbow#408
bighappyface pushed a commit that referenced this pull request May 16, 2017
* Split $objectDefinition into $schema and $properties (#411)

Object validation attempts to use a single variable to store both the
object definition, and its properties. This causes validation to be
incomplete where "properties" is not set, but "additionalProperties" is.

This commit fixes both bugs in issue #353.

* Issue-414: Allow The Option of T or space for Date time. (#415)

* Testcase for minProperties with properties defined (#416)

+ Fix Test

* Tweak phpdocumentor dependency to avoid install conflicts (#421)

* [BUGFIX] Cast empty schema arrays to object (#409)

* Cast root to object

* Use function_exists to allow polyfill compatibility

* Move array->object conversion to SchemaConstraint & SchemaStorage

Fixes issue #408

* fix bug when applying defaults for array items when the schema is for (#405)

all items and add support for minItems when applying defaults

* [BUGFIX] Split "uri" format into "uri" & "uri-reference", fix meta-schema bug (#419)

* Split "uri" format into "uri" and "uri-reference"

* Correct format for id & $ref in draft-03/04 meta-schemas

See json-schema-org/JSON-Schema-Test-Suite#177 (comment)
@erayd erayd deleted the bugfix-407-emptyarrayschema branch June 8, 2017 21:54
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.

4 participants