$serializer = SerializerBuilder::create()
->setSerializationContextFactory(function () {
return \JMS\Serializer\SerializationContext::create()
->setSerializeNull(true)
;
})
->setDeserializationContextFactory(function () {
return \JMS\Serializer\DeserializationContext::create()
->setSerializeNull(true)
;
})
->setAnnotationReader($annotationReader)
->setPropertyNamingStrategy(new SerializedNameImportantThanPropertyNameStrategy())
->build();
Ignoring some parent classes: CComponent, CModel, CActiveRecord
$class = new \ReflectionClass($serializer);
$property = $class->getProperty('navigator');
$property->setAccessible(true);
$navigator = $property->getValue($serializer);
$class = new \ReflectionClass($navigator);
$property = $class->getProperty('metadataFactory');
$property->setAccessible(true);
$metadataFactory = $property->getValue($navigator);
$class = new \ReflectionClass($metadataFactory);
$property = $class->getProperty('loadedClassMetadata');
$property->setAccessible(true);
$property->setValue($metadataFactory, [
'CComponent' => new NullMetadata(new \stdClass()),
'CModel' => new NullMetadata(new \stdClass()),
'CActiveRecord' => new NullMetadata(new \stdClass()),
]);