I'm attempting to use the hash type for a Document. When I'm creating an object there isn't a problem, but the moment I attempt to retrieve a document, I get an "Array to string conversion".
I've simplified the document. This Array to string conversion only started occurring when I added this hash property.
Looking at symfony's dump messages, it seems to be coming from the hydrator.
Any ideas why Doctrine is attempting to convert the data to a string?
class MyDocument
{
/**
* @MongoDB\Id
*/
protected $id;
/**
* @MongoDB\Field(type="hash")
*/
protected $value = array();
}
Somewhere in one of my services:
$product =
$this->container->get('doctrine_mongodb')
->getRepository('XTradBundle:Traduction')
->findAll();
Stack Trace:
in var\cache\dev\doctrine\odm\mongodb\Hydrators\WeBSurgTradBundleDocumentTraductionHydrator.php at line 84 -
if (isset($data['value']) || (! empty($this->class->fieldMappings['value']['nullable']) && array_key_exists('value', $data))) {
$value = $data['value'];
if ($value !== null) {
//Why is it converting it to a string here?
$return = (string) $value;
} else {
$return = null;
}
Would seem that $value
in protected $value = array();
is a reserved name. Simply naming it to something else solved the problem.