Swagger\Annotations\AbstractAnnotation::merge PHP Méthode

merge() public méthode

Annotations that couldn't be merged are added to the _unmerged array.
public merge ( AbstractAnnotation[] $annotations, boolean $ignore = false ) : AbstractAnnotation[]
$annotations AbstractAnnotation[]
$ignore boolean Ignore unmerged annotations
Résultat AbstractAnnotation[] The unmerged annotations
    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;
    }