-
Notifications
You must be signed in to change notification settings - Fork 358
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
fix: correctly set the schema ID when passing it as assoc array #769
base: master
Are you sure you want to change the base?
Conversation
@dkarlovi I think this PR could be accepted. If you could just do a rebase and add a changelog entry in Maybe good to know we are seeing multiple issues being reported with associative arrays, which is a concept that doesn't live in JSON. With those two facts we're seeing if we should deprecate the associative array support in the next mayor version |
I'm all for deprecating the support as mentioned before. 👍 |
if (is_object($schema) && property_exists($schema, 'id')) { | ||
$schemaURI = $schema->id; | ||
} elseif (is_array($schema) && array_key_exists('id', $schema)) { | ||
$schemaURI = $schema['id']; | ||
} else { | ||
$schemaURI = SchemaStorage::INTERNAL_PROVIDED_SCHEMA_URI; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe I've learned something more about the codebase today. These changes should be done respecting the CHECK_MODE_TYPE_CAST
. Doing either a loose type check or a strict type check. I believe the following would do so (but requires some testing as well)
if (is_object($schema) && property_exists($schema, 'id')) { | |
$schemaURI = $schema->id; | |
} elseif (is_array($schema) && array_key_exists('id', $schema)) { | |
$schemaURI = $schema['id']; | |
} else { | |
$schemaURI = SchemaStorage::INTERNAL_PROVIDED_SCHEMA_URI; | |
} | |
$schemaURI = SchemaStorage::INTERNAL_PROVIDED_SCHEMA_URI; | |
if ($this->factory->getTypeCheck()::propertyExists($schema, 'id')) { | |
$schemaURI = $this->factory->getTypeCheck()::propertyGet($schema, 'id'); | |
} |
Closes #767.