Open
Description
This concerns the error message
PHP Fatal error: Uncaught exception 'MongoException' with message 'zero-length keys are not allowed, did you use $ with double quotes?'
I believe in all of the three following scenarios:
- If you have an
@ODM\EmbeddedDocument
with an@ODM\Field
ivar with atype="hash"
annotation but it's actually set to an array-like associative array (integer keys, contiguous from0
to somen
) - The reverse case: if you have an
@ODM\EmbeddedDocument
with an@ODM\Field
ivar with atype="collection"
annotation but it's actually set to a map-like associative array - If you have an
@ODM\EmbeddedDocument
with an@ODM\Field
ivar with atype="collection"
annotation, and fill it with@ODM\EmbeddedDocument
s (instead of annotating it with@ODM\EmbedMany
) (not 100% this is the exception thrown in this case but I think so?)
It would be nice if the exception were to detail which instance variable is the offending one, in which class -- as it currently stands, it's rather unhelpful and time-consuming to debug.
Given how PHP associative arrays unfortunately basically don't distinguish at all between being maps or arrays, as you probably know, it's a pretty easy mistake to make to think you have an array and it's actually map (or the opposite), since it's not enforced at the type level.
Thanks for your attention to this matter! :)