protected function AnnotationObject::doMerge in Markdown 8.2
Merges values with this plugin.
Parameters
array|\Traversable $values: The values to merge.
array $excludedProperties: Optional. The properties to exclude when merging values.
Return value
static
2 calls to AnnotationObject::doMerge()
- AnnotationObject::merge in src/
Annotation/ AnnotationObject.php - Merges values with this plugin.
- AnnotationObject::__construct in src/
Annotation/ AnnotationObject.php - AnnotationObject constructor.
File
- src/
Annotation/ AnnotationObject.php, line 197
Class
- AnnotationObject
- Base annotation class for retrieving the annotation as an object.
Namespace
Drupal\markdown\AnnotationCode
protected function doMerge($values, array $excludedProperties = []) {
if ($values instanceof \Traversable) {
$values = iterator_to_array($values);
}
if (!is_array($values)) {
return $this;
}
if ($excludedProperties) {
$excludedProperties = array_unique($excludedProperties);
}
foreach ($values as $key => $value) {
// Skip excluded properties.
if ($excludedProperties && in_array($key, $excludedProperties, TRUE)) {
continue;
}
if ($key === 'id' && !$value instanceof Identifier) {
$value = new Identifier($value);
}
if (property_exists($this, $key) || $key[0] === '_') {
if (is_array($value)) {
$existing = $this
->offsetGet($key);
if (is_array($existing)) {
$value = NestedArray::mergeDeep($existing, $value);
}
}
if (isset($value)) {
$this
->offsetSet($key, $value);
}
}
}
return $this;
}