protected static function compact( array $lists, $outerSep ) {
		$consolidated = [];
		foreach ( $lists as $list ) {
			if ( !$list instanceof WrappedStringList ) {
				// Probably WrappedString or regular string,
				// Not mergable as a list, but may be merged as a string
				// later by WrappedString::compact.
				$consolidated[] = $list;
				continue;
			}
			if ( $list->sep === $outerSep ) {
				$consolidated = array_merge(
					$consolidated,
					self::compact( $list->wraps, $outerSep )
				);
			} else {
				$consolidated[] = $list;
			}
		}

		return WrappedString::compact( $consolidated );
	}
protected static function compact( array $lists, $outerSep ) {
		$consolidated = [];
		foreach ( $lists as $list ) {
			if ( !$list instanceof WrappedStringList ) {
				// Probably WrappedString or regular string,
				// Not mergable as a list, but may be merged as a string
				// later by WrappedString::compact.
				$consolidated[] = $list;
				continue;
			}
			if ( $list->sep === $outerSep ) {
				$consolidated = array_merge(
					$consolidated,
					self::compact( $list->wraps, $outerSep )
				);
			} else {
				$consolidated[] = $list;
			}
		}

		return WrappedString::compact( $consolidated );
	}
protected static function compact ( array $ lists , $ outerSep ) { $ consolidated = [ ] ; foreach ( $ lists as $ list ) { if ( ! $ list instanceof WrappedStringList ) { // Probably WrappedString or regular string, // Not mergable as a list, but may be merged as a string // later by WrappedString::compact. $ consolidated [ ] = $ list ; continue ; } if ( $ list -> sep === $ outerSep ) { $ consolidated = array_merge ( $ consolidated , self :: compact ( $ list -> wraps , $ outerSep ) ) ; } else { $ consolidated [ ] = $ list ; } } return WrappedString :: compact ( $ consolidated ) ; }
Merge consecutive lists with the same separator.

Does not modify the given array or any of the objects in it.

@param array $lists Array containing string, WrappedString or WrappedStringList
@param string $outerSep Separator that the caller intends to use when joining the strings
@return string[] Compacted list to be treated as strings
(may contain WrappedString and WrappedStringList objects)
Merge consecutive lists with the same separator .