public function merge($annotations, $ignore = false)
{
$unmerged = [];
$nestedContext = new Context(['nested' => $this], $this->_context);
foreach ($annotations as $annotation) {
$found = false;
foreach (static::$_nested as $class => $property) {
if ($annotation instanceof $class) {
if (is_array($property)) {
// Append to an array?
$property = $property[0];
if ($this->{$property} === null) {
$this->{$property} = [];
}
array_push($this->{$property}, $this->nested($annotation, $nestedContext));
$found = true;
} elseif ($this->{$property} === null) {
$this->{$property} = $this->nested($annotation, $nestedContext);
$found = true;
}
break;
}
}
if ($found === false) {
$unmerged[] = $annotation;
}
}
if (!$ignore) {
foreach ($unmerged as $annotation) {
$this->_unmerged[] = $this->nested($annotation, $nestedContext);
}
}
return $unmerged;
}