schmittjoh/serializer — pull request #166 by holtkamp (2013-10-13 14:25:05+00:00)
Title: Discriminator related metadata overwritten by subsequent MetadataDriver in DriverChain

While trying to configure discriminator-related settings for the serialization/deserialization using the XmlDriver which processes .xml files in a specified metadata directory, it seemed the indicated settings were lost somehow.

It turned out they were overruled by the settings defined in the AnnotationDriver, which comes after the XmlDriver in the DriverChain:

```php
$metadataDriver = new DriverChain(array(
new YamlDriver($fileLocator),
new XmlDriver($fileLocator),
new AnnotationDriver($annotationReader),
));
```

Settings that are already 'set' by the XmlDriver, are overruled by the AnnotationDriver, which results in 'empty' / null-like values.

```php
["discriminatorDisabled"] => bool(false)
["discriminatorBaseClass"] => NULL
["discriminatorFieldName"] => NULL
["discriminatorValue"] => NULL
["discriminatorMap"] => array(0) {}
```

The ClassMetadata::merge() function seems not to respect the discriminator-related properties.

NOTE: for me this approach works, but additional testing might be appropriate!