doctrine/mongodb-odm — pull request #704 by lemoinem (2013-11-15 21:27:48+00:00)
Title: Fix Annotation Driver always overriding inherited fields informations

Given two document classes:

```php
/**
* @ODM\Document
*/
class Parent
{
/**
* @ODM\String
*/
protected $parent;
}

/**
* @ODM\Document
*/
class Child
{
/**
* @ODM\String
*/
protected $child;
}
```

Then, if we fetch the ClassMetadata for Child:
`$class = $dm->getClassMetadata(‘Child’);`

The child class rightly has two fields (`parent` and `child`), both `strings` and so on. However, two markers are missing from the field mapping on the parent field: `declared` and `inherited`. This implies that `$class->isInheritedField(‘parent’)` will return false and the Metadata is unreliable.

Although this is not much of a big deal in the most common use cases, as soon as you need to hook in the ClassMetadata Loading to customize fields handling, you need to declare your fields private so they are not part of the child classes and are not returned by the annotation reader. This also have a negative performance impact since we end up parsing non-private inherited fields repeatedly for no good reasons.

Here is the fix for this behaviour, along with an additional PHPUnit TestCase for it.
I took special care to keep the desired behaviour related to https://github.com/doctrine/mongodb-odm/issues/435