php/commands/src/CLI_Alias_Command.php
private function build_aliases( $aliases, $alias, $assoc_args, $is_grouping, $grouping = '', $is_update = false ) {

		if ( $is_grouping ) {
			$valid_assoc_args = array( 'config', 'grouping' );
			$invalid_args     = array_diff( array_keys( $assoc_args ), $valid_assoc_args );

			// Check for invalid args.
			if ( ! empty( $invalid_args ) ) {
				$args_info = implode( ',', $invalid_args );
				WP_CLI::error( "--grouping argument works alone. Found invalid arg(s) '$args_info'." );
			}
		}

		if ( $is_update ) {
			$this->validate_alias_type( $aliases, $alias, $assoc_args, $grouping );
		}

		if ( ! $is_grouping ) {
			foreach ( $assoc_args as $key => $value ) {
				if ( strpos( $key, 'set-' ) !== false ) {
					$alias_key_info = explode( '-', $key );
					$alias_key      = empty( $alias_key_info[1] ) ? '' : $alias_key_info[1];
					if ( ! empty( $alias_key ) && ! empty( $value ) ) {
						$aliases[ $alias ][ $alias_key ] = $value;
					}
				}
			}
		} else {

			if ( ! empty( $grouping ) ) {
				$group_alias_list  = explode( ',', $grouping );
				$group_alias       = array_map(
					function ( $current_alias ) {
						return '@' . ltrim( $current_alias, '@' );
					},
					$group_alias_list
				);
				$aliases[ $alias ] = $group_alias;
			}
		}

		return $aliases;
	}
private function build_aliases( $aliases, $alias, $assoc_args, $is_grouping, $grouping = '', $is_update = false ) {

		if ( $is_grouping ) {
			$valid_assoc_args = array( 'config', 'grouping' );
			$invalid_args     = array_diff( array_keys( $assoc_args ), $valid_assoc_args );

			// Check for invalid args.
			if ( ! empty( $invalid_args ) ) {
				$args_info = implode( ',', $invalid_args );
				WP_CLI::error( "--grouping argument works alone. Found invalid arg(s) '$args_info'." );
			}
		}

		if ( $is_update ) {
			$this->validate_alias_type( $aliases, $alias, $assoc_args, $grouping );
		}

		if ( ! $is_grouping ) {
			foreach ( $assoc_args as $key => $value ) {
				if ( strpos( $key, 'set-' ) !== false ) {
					$alias_key_info = explode( '-', $key );
					$alias_key      = empty( $alias_key_info[1] ) ? '' : $alias_key_info[1];
					if ( ! empty( $alias_key ) && ! empty( $value ) ) {
						$aliases[ $alias ][ $alias_key ] = $value;
					}
				}
			}
		} else {

			if ( ! empty( $grouping ) ) {
				$group_alias_list  = explode( ',', $grouping );
				$group_alias       = array_map(
					function ( $current_alias ) {
						return '@' . ltrim( $current_alias, '@' );
					},
					$group_alias_list
				);
				$aliases[ $alias ] = $group_alias;
			}
		}

		return $aliases;
	}
private function build_aliases ( $ aliases , $ alias , $ assoc_args , $ is_grouping , $ grouping = '' , $ is_update = false ) { if ( $ is_grouping ) { $ valid_assoc_args = array ( 'config' , 'grouping' ) ; $ invalid_args = array_diff ( array_keys ( $ assoc_args ) , $ valid_assoc_args ) ; // Check for invalid args. if ( ! empty ( $ invalid_args ) ) { $ args_info = implode ( ',' , $ invalid_args ) ; WP_CLI :: error ( "--grouping argument works alone. Found invalid arg(s) '$args_info'." ) ; } } if ( $ is_update ) { $ this -> validate_alias_type ( $ aliases , $ alias , $ assoc_args , $ grouping ) ; } if ( ! $ is_grouping ) { foreach ( $ assoc_args as $ key => $ value ) { if ( strpos ( $ key , 'set-' ) !== false ) { $ alias_key_info = explode ( '-' , $ key ) ; $ alias_key = empty ( $ alias_key_info [ 1 ] ) ? '' : $ alias_key_info [ 1 ] ; if ( ! empty ( $ alias_key ) && ! empty ( $ value ) ) { $ aliases [ $ alias ] [ $ alias_key ] = $ value ; } } } } else { if ( ! empty ( $ grouping ) ) { $ group_alias_list = explode ( ',' , $ grouping ) ; $ group_alias = array_map ( function ( $ current_alias ) { return '@' . ltrim ( $ current_alias , '@' ) ; } , $ group_alias_list ) ; $ aliases [ $ alias ] = $ group_alias ; } } return $ aliases ; }
Return aliases array.

@param array  $aliases     Current aliases data.
@param string $alias       Name of alias.
@param array  $key_args    Associative arguments.
@param bool   $is_grouping Check if its a grouping operation.
@param string $grouping    Grouping value.
@param bool   $is_update   Is this an update operation?

@return mixed
Return aliases array .