protected function mergeMessages($source = null, string $caller = 'ModuleConfig'): void
    {
        $source = is_object($source) ? $source : new stdClass();

        if ($source instanceof InvalidArgumentException) {
            $this->errors = array_merge($this->errors, $this->formatMessages($source->getMessage(), $caller));

            return;
        }

        if ($source instanceof ErrorAwareInterface) {
            $this->errors = array_merge($this->errors, $this->formatMessages($source->getErrors(), $caller));
            $this->warnings = array_merge($this->warnings, $this->formatMessages($source->getWarnings(), $caller));

            return;
        }

        $this->errors[] = "Cannot merge messages from [" . get_class($source) . "]";
    }
protected function mergeMessages($source = null, string $caller = 'ModuleConfig'): void
    {
        $source = is_object($source) ? $source : new stdClass();

        if ($source instanceof InvalidArgumentException) {
            $this->errors = array_merge($this->errors, $this->formatMessages($source->getMessage(), $caller));

            return;
        }

        if ($source instanceof ErrorAwareInterface) {
            $this->errors = array_merge($this->errors, $this->formatMessages($source->getErrors(), $caller));
            $this->warnings = array_merge($this->warnings, $this->formatMessages($source->getWarnings(), $caller));

            return;
        }

        $this->errors[] = "Cannot merge messages from [" . get_class($source) . "]";
    }
protected function mergeMessages ( $ source = null , string $ caller = 'ModuleConfig' ) : void { $ source = is_object ( $ source ) ? $ source : new stdClass ( ) ; if ( $ source instanceof InvalidArgumentException ) { $ this -> errors = array_merge ( $ this -> errors , $ this -> formatMessages ( $ source -> getMessage ( ) , $ caller ) ) ; return ; } if ( $ source instanceof ErrorAwareInterface ) { $ this -> errors = array_merge ( $ this -> errors , $ this -> formatMessages ( $ source -> getErrors ( ) , $ caller ) ) ; $ this -> warnings = array_merge ( $ this -> warnings , $ this -> formatMessages ( $ source -> getWarnings ( ) , $ caller ) ) ; return ; } $ this -> errors [ ] = "Cannot merge messages from [" . get_class ( $ source ) . "]" ; }
Merge warning and error messages

Merge warning and error messages from a given source
object into our warnings and messages.

@param object $source Source object (ideally one using ErrorTrait)
@param string $caller Caller that generated a message
@return void
Merge warning and error messages