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

mergeProperties() public méthode

Prevents overwriting properties that are already configured.
public mergeProperties ( object $object )
$object object
    public function mergeProperties($object)
    {
        $defaultValues = get_class_vars(get_class($this));
        $currentValues = get_object_vars($this);
        foreach ($object as $property => $value) {
            if ($property === '_context') {
                continue;
            }
            if ($currentValues[$property] === $defaultValues[$property]) {
                // Overwrite default values
                $this->{$property} = $value;
                continue;
            }
            if ($property === '_unmerged') {
                $this->_unmerged = array_merge($this->_unmerged, $value);
                continue;
            }
            if ($currentValues[$property] !== $value) {
                // New value is not the same?
                if ($defaultValues[$property] === $value) {
                    // but is the same as the default?
                    continue;
                    // Keep current, no notice
                }
                $identity = method_exists($object, 'identity') ? $object->identity() : get_class($object);
                $context1 = $this->_context;
                $context2 = property_exists($object, '_context') ? $object->_context : 'unknown';
                if (is_object($this->{$property}) && $this->{$property} instanceof AbstractAnnotation) {
                    $context1 = $this->{$property}->_context;
                }
                Logger::warning('Multiple definitions for ' . $identity . '->' . $property . "\n     Using: " . $context1 . "\n  Skipping: " . $context2);
            }
        }
    }