watoki/factory — pull request #5 by jwoschitz (2014-04-13 19:39:34+00:00)
Title: Added test to document behaviour for property annotation injection inheritance

I wanted to look into https://github.com/watoki/factory/issues/1 and added a test for it.

It seems that it is already supported:
```php
namespace watoki\factory;

class Injector {

/* ... */

public function injectPropertyAnnotations($object, $filter, \ReflectionClass $context = null) {
$classReflection = $context ? : new \ReflectionClass($object);

while ($classReflection) {
$resolver = new ClassResolver($classReflection);

$matches = array();
preg_match_all('/@property\s+(\S+)\s+\$?(\S+).*/', $classReflection->getDocComment(), $matches);

foreach ($matches[0] as $i => $match) {
if (!$filter(trim($match))) {
continue;
}

$this->injectProperty($object, $matches[2][$i], $resolver->resolve($matches[1][$i]));
}

$classReflection = $classReflection->getParentClass();
}
}
}
```

The last line assigns the reflection class of the parent as the current scope to parse the property annotations. This code loops until the full object graph has been traversed.

The enhancement mentioned above is therefore already implemented.