src/MultiLanguageWrapper/ClassValidator.php
public function merge(string $returnTypeClass, $existingInstance, $newInstance)
    {
        if ($existingInstance === null) {
            return $newInstance;
        }
        if (array_key_exists($returnTypeClass, $this->getRequiredFields()) && $newInstance !== null) {
            foreach ($this->getRequiredFields()[$returnTypeClass] as $property) {
                if (is_array($existingInstance)) {
                    $existingInstanceSize = sizeof($existingInstance);
                    for ($index = 0; $index < $existingInstanceSize; $index++) {
                        if ($existingInstance[$index]->{$property} === null) {
                            $existingInstance[$index]->{$property} = $newInstance[$index]->{$property};
                        }
                    }
                } elseif ($existingInstance->{$property} === null) {
                    $existingInstance->{$property} = $newInstance->{$property};
                }
            }
        }
        return $existingInstance;
    }
public function merge(string $returnTypeClass, $existingInstance, $newInstance)
    {
        if ($existingInstance === null) {
            return $newInstance;
        }
        if (array_key_exists($returnTypeClass, $this->getRequiredFields()) && $newInstance !== null) {
            foreach ($this->getRequiredFields()[$returnTypeClass] as $property) {
                if (is_array($existingInstance)) {
                    $existingInstanceSize = sizeof($existingInstance);
                    for ($index = 0; $index < $existingInstanceSize; $index++) {
                        if ($existingInstance[$index]->{$property} === null) {
                            $existingInstance[$index]->{$property} = $newInstance[$index]->{$property};
                        }
                    }
                } elseif ($existingInstance->{$property} === null) {
                    $existingInstance->{$property} = $newInstance->{$property};
                }
            }
        }
        return $existingInstance;
    }
public function merge ( string $ returnTypeClass , $ existingInstance , $ newInstance ) { if ( $ existingInstance === null ) { return $ newInstance ; } if ( array_key_exists ( $ returnTypeClass , $ this -> getRequiredFields ( ) ) && $ newInstance !== null ) { foreach ( $ this -> getRequiredFields ( ) [ $ returnTypeClass ] as $ property ) { if ( is_array ( $ existingInstance ) ) { $ existingInstanceSize = sizeof ( $ existingInstance ) ; for ( $ index = 0 ; $ index < $ existingInstanceSize ; $ index ++ ) { if ( $ existingInstance [ $ index ] -> { $ property } === null ) { $ existingInstance [ $ index ] -> { $ property } = $ newInstance [ $ index ] -> { $ property } ; } } } elseif ( $ existingInstance -> { $ property } === null ) { $ existingInstance -> { $ property } = $ newInstance -> { $ property } ; } } } return $ existingInstance ; }
Merges two instances together by replacing missing values that are required.

@param string       $returnTypeClass  The class type of the instances.
@param object|array $existingInstance The instance that already exists.
@param object|array $newInstance      The instance to be merged.

@return mixed
Merges two instances together by replacing missing values that are required .