src/PoFile.php
public function mergeEntry(PoEntry $newEntry): bool
    {
        $key = $this->createKeyFromEntry($newEntry);

        // keyed entries only
        if (empty($key)) {
            return false;
        }

        if (isset($this->entries[$key])) {
            $existingEntry = $this->entries[$key];
            $mergeTokens = array(PoTokens::REFERENCE, PoTokens::EXTRACTED_COMMENTS);
            foreach ($mergeTokens as $type) {
                $toMerge = $newEntry->get($type);
                if (!empty($toMerge)) {
                    $toMerge = is_array($toMerge) ? $toMerge : array($toMerge);
                    foreach ($toMerge as $value) {
                        $existingEntry->add($type, $value);
                    }
                }
            }
        } else {
            $this->entries[$key] = $newEntry;
        }
        return true;
    }
public function mergeEntry(PoEntry $newEntry): bool
    {
        $key = $this->createKeyFromEntry($newEntry);

        // keyed entries only
        if (empty($key)) {
            return false;
        }

        if (isset($this->entries[$key])) {
            $existingEntry = $this->entries[$key];
            $mergeTokens = array(PoTokens::REFERENCE, PoTokens::EXTRACTED_COMMENTS);
            foreach ($mergeTokens as $type) {
                $toMerge = $newEntry->get($type);
                if (!empty($toMerge)) {
                    $toMerge = is_array($toMerge) ? $toMerge : array($toMerge);
                    foreach ($toMerge as $value) {
                        $existingEntry->add($type, $value);
                    }
                }
            }
        } else {
            $this->entries[$key] = $newEntry;
        }
        return true;
    }
public function mergeEntry ( PoEntry $ newEntry ) : bool { $ key = $ this -> createKeyFromEntry ( $ newEntry ) ; // keyed entries only if ( empty ( $ key ) ) { return false ; } if ( isset ( $ this -> entries [ $ key ] ) ) { $ existingEntry = $ this -> entries [ $ key ] ; $ mergeTokens = array ( PoTokens :: REFERENCE , PoTokens :: EXTRACTED_COMMENTS ) ; foreach ( $ mergeTokens as $ type ) { $ toMerge = $ newEntry -> get ( $ type ) ; if ( ! empty ( $ toMerge ) ) { $ toMerge = is_array ( $ toMerge ) ? $ toMerge : array ( $ toMerge ) ; foreach ( $ toMerge as $ value ) { $ existingEntry -> add ( $ type , $ value ) ; } } } } else { $ this -> entries [ $ key ] = $ newEntry ; } return true ; }
Merge an entry with any existing entry with the same key. If the key does
not exist, add the entry, otherwise merge comments, references, and flags.

This is intended for use in building a POT, where the handling of translated
strings is not a factor.

@param PoEntry $newEntry the PoEntry to merge

@return boolean true if merged or added, false if not
Merge an entry with any existing entry with the same key . If the key does not exist add the entry otherwise merge comments references and flags .