original_string: 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;
  	}
code: 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;
  	}
code_tokens: 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 ; }
docstring: 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[]
docstring_tokens: Merges metadata of multiple doctrine entities .