protected function mergeFromArray(array $array)
    {
        // Just call the setters for the field names
        foreach ($array as $key => $value) {
            $field = $this->desc->getFieldByName($key);
            if (is_null($field)) {
                throw new \UnexpectedValueException(
                    'Invalid message property: ' . $key);
            }
            $setter = $field->getSetter();
            if ($field->isMap()) {
                $valueField = $field->getMessageType()->getFieldByName('value');
                if (!is_null($valueField) && $valueField->isWrapperType()) {
                    self::normalizeArrayElementsToMessageType($value, $valueField->getMessageType()->getClass());
                }
            } elseif ($field->isWrapperType()) {
                $class = $field->getMessageType()->getClass();
                if ($field->isRepeated()) {
                    self::normalizeArrayElementsToMessageType($value, $class);
                } else {
                    self::normalizeToMessageType($value, $class);
                }
            }
            $this->$setter($value);
        }
    }
protected function mergeFromArray(array $array)
    {
        // Just call the setters for the field names
        foreach ($array as $key => $value) {
            $field = $this->desc->getFieldByName($key);
            if (is_null($field)) {
                throw new \UnexpectedValueException(
                    'Invalid message property: ' . $key);
            }
            $setter = $field->getSetter();
            if ($field->isMap()) {
                $valueField = $field->getMessageType()->getFieldByName('value');
                if (!is_null($valueField) && $valueField->isWrapperType()) {
                    self::normalizeArrayElementsToMessageType($value, $valueField->getMessageType()->getClass());
                }
            } elseif ($field->isWrapperType()) {
                $class = $field->getMessageType()->getClass();
                if ($field->isRepeated()) {
                    self::normalizeArrayElementsToMessageType($value, $class);
                } else {
                    self::normalizeToMessageType($value, $class);
                }
            }
            $this->$setter($value);
        }
    }
protected function mergeFromArray ( array $ array ) { // Just call the setters for the field names foreach ( $ array as $ key => $ value ) { $ field = $ this -> desc -> getFieldByName ( $ key ) ; if ( is_null ( $ field ) ) { throw new \ UnexpectedValueException ( 'Invalid message property: ' . $ key ) ; } $ setter = $ field -> getSetter ( ) ; if ( $ field -> isMap ( ) ) { $ valueField = $ field -> getMessageType ( ) -> getFieldByName ( 'value' ) ; if ( ! is_null ( $ valueField ) && $ valueField -> isWrapperType ( ) ) { self :: normalizeArrayElementsToMessageType ( $ value , $ valueField -> getMessageType ( ) -> getClass ( ) ) ; } } elseif ( $ field -> isWrapperType ( ) ) { $ class = $ field -> getMessageType ( ) -> getClass ( ) ; if ( $ field -> isRepeated ( ) ) { self :: normalizeArrayElementsToMessageType ( $ value , $ class ) ; } else { self :: normalizeToMessageType ( $ value , $ class ) ; } } $ this -> $ setter ( $ value ) ; } }
Populates the message from a user-supplied PHP array. Array keys
correspond to Message properties and nested message properties.

Example:
```
$message->mergeFromArray([
'name' => 'This is a message name',
'interval' => [
'startTime' => time() - 60,
'endTime' => time(),
]
]);
```

This method will trigger an error if it is passed data that cannot
be converted to the correct type. For example, a StringValue field
must receive data that is either a string or a StringValue object.

@param array $array An array containing message properties and values.
@return null.
Populates the message from a user - supplied PHP array . Array keys correspond to Message properties and nested message properties .