<commit_before><?php

namespace Doctrine\Search\Serializer;

use Doctrine\Search\SerializerInterface;
use JMS\Serializer\SerializerBuilder;
use JMS\Serializer\SerializationContext;
use JMS\Serializer\Naming\IdenticalPropertyNamingStrategy;

class JMSSerializer implements SerializerInterface
{
    protected $serializer;
    protected $context;

    public function __construct(SerializationContext $context = null)
    {
        $this->context = $context;
        $this->serializer = SerializerBuilder::create()
            ->setPropertyNamingStrategy(new IdenticalPropertyNamingStrategy())
            ->addDefaultHandlers()
       	   ->build();	
    }

    public function serialize($object)
    {
        $context = $this->context ? clone $this->context : null; 
        return json_decode($this->serializer->serialize($object, 'json', $context), true);
    }
}<commit_msg>Update to JMS Serializer to allow manual override<commit_after><?php

namespace Doctrine\Search\Serializer;

use Doctrine\Search\SerializerInterface;
use JMS\Serializer\SerializerBuilder;
use JMS\Serializer\SerializationContext;
use JMS\Serializer\Naming\SerializedNameAnnotationStrategy;
use JMS\Serializer\Naming\IdenticalPropertyNamingStrategy;

class JMSSerializer implements SerializerInterface
{
    protected $serializer;
    protected $context;

    public function __construct(SerializationContext $context = null)
    {
        $this->context = $context;
        $this->serializer = SerializerBuilder::create()
            ->setPropertyNamingStrategy(new SerializedNameAnnotationStrategy(new IdenticalPropertyNamingStrategy()))
            ->addDefaultHandlers()
       	   ->build();	
    }

    public function serialize($object)
    {
        $context = $this->context ? clone $this->context : null; 
        return json_decode($this->serializer->serialize($object, 'json', $context), true);
    }
}
{'fraction_non_alphanumeric': 0.1037037037037037, 'fraction_numerical': 0.0, 'mean_word_length': 4.002645502645502, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5556219', 'n_tokens_mistral': 499, 'n_tokens_neox': 493, 'n_words': 100}