src/Doctrine/Console/Commands/MetadataMerger.php
public function merge(array $metadata): array
	{
		$tables = [];
		foreach ($metadata as $entity) {
			$tables[$entity->getTableName()][] = $entity;
		}

		$merged = [];
		foreach ($tables as $table => $metadata) {

			if (count($metadata) === 1) {
				$merged[] = array_shift($metadata);
				continue;
			}

			$primary = $this->resolvePrimaryMetadata($metadata);
			foreach ($metadata as $secondary) {
				$primary = $this->mergeMetadata($primary, $secondary);
			}

			$primary->fieldMappings = $this->mappingCleanup($primary->fieldMappings);
			$primary->associationMappings = $this->mappingCleanup($primary->associationMappings);
			$merged[] = $primary;
		}

		return $merged;
	}
public function merge(array $metadata): array
	{
		$tables = [];
		foreach ($metadata as $entity) {
			$tables[$entity->getTableName()][] = $entity;
		}

		$merged = [];
		foreach ($tables as $table => $metadata) {

			if (count($metadata) === 1) {
				$merged[] = array_shift($metadata);
				continue;
			}

			$primary = $this->resolvePrimaryMetadata($metadata);
			foreach ($metadata as $secondary) {
				$primary = $this->mergeMetadata($primary, $secondary);
			}

			$primary->fieldMappings = $this->mappingCleanup($primary->fieldMappings);
			$primary->associationMappings = $this->mappingCleanup($primary->associationMappings);
			$merged[] = $primary;
		}

		return $merged;
	}
public function merge ( array $ metadata ) : array { $ tables = [ ] ; foreach ( $ metadata as $ entity ) { $ tables [ $ entity -> getTableName ( ) ] [ ] = $ entity ; } $ merged = [ ] ; foreach ( $ tables as $ table => $ metadata ) { if ( count ( $ metadata ) === 1 ) { $ merged [ ] = array_shift ( $ metadata ) ; continue ; } $ primary = $ this -> resolvePrimaryMetadata ( $ metadata ) ; foreach ( $ metadata as $ secondary ) { $ primary = $ this -> mergeMetadata ( $ primary , $ secondary ) ; } $ primary -> fieldMappings = $ this -> mappingCleanup ( $ primary -> fieldMappings ) ; $ primary -> associationMappings = $ this -> mappingCleanup ( $ primary -> associationMappings ) ; $ merged [ ] = $ primary ; } return $ merged ; }
Merges metadata of multiple doctrine entities.

Input metadata can contain duplicit tables. If so, metadata for
the same table will be merged into one.

@param ClassMetadata[] $metadata

@return ClassMetadata[]
Merges metadata of multiple doctrine entities .