private function show_packages( $context, $packages, $assoc_args ) {
		if ( 'list' === $context ) {
			$default_fields = [
				'name',
				'authors',
				'version',
				'update',
				'update_version',
			];
		} elseif ( 'browse' === $context ) {
			$default_fields = [
				'name',
				'description',
				'authors',
				'version',
			];
		}
		$defaults   = [
			'fields' => implode( ',', $default_fields ),
			'format' => 'table',
		];
		$assoc_args = array_merge( $defaults, $assoc_args );

		$composer = $this->get_composer();
		$list     = [];
		foreach ( $packages as $package ) {
			$name = $package->getPrettyName();
			if ( isset( $list[ $name ] ) ) {
				$list[ $name ]['version'][] = $package->getPrettyVersion();
			} else {
				$package_output                = [];
				$package_output['name']        = $package->getPrettyName();
				$package_output['description'] = $package->getDescription();
				$package_output['authors']     = implode( ', ', array_column( (array) $package->getAuthors(), 'name' ) );
				$package_output['version']     = [ $package->getPrettyVersion() ];
				$update                        = 'none';
				$update_version                = '';
				if ( 'list' === $context ) {
					try {
						$latest = $this->find_latest_package( $package, $composer, null );
						if ( $latest && $latest->getFullPrettyVersion() !== $package->getFullPrettyVersion() ) {
							$update         = 'available';
							$update_version = $latest->getPrettyVersion();
						}
					} catch ( Exception $e ) {
						WP_CLI::warning( $e->getMessage() );
						$update         = 'error';
						$update_version = $update;
					}
				}
				$package_output['update']         = $update;
				$package_output['update_version'] = $update_version;
				$package_output['pretty_name']    = $package->getPrettyName(); // Deprecated but kept for BC with package-command 1.0.8.
				$list[ $package_output['name'] ]  = $package_output;
			}
		}

		$list = array_map(
			function( $package ) {
				$package['version'] = implode( ', ', $package['version'] );
				return $package;
			},
			$list
		);

		ksort( $list );
		if ( 'ids' === $assoc_args['format'] ) {
			$list = array_keys( $list );
		}
		Utils\format_items( $assoc_args['format'], $list, $assoc_args['fields'] );
	}
private function show_packages( $context, $packages, $assoc_args ) {
		if ( 'list' === $context ) {
			$default_fields = [
				'name',
				'authors',
				'version',
				'update',
				'update_version',
			];
		} elseif ( 'browse' === $context ) {
			$default_fields = [
				'name',
				'description',
				'authors',
				'version',
			];
		}
		$defaults   = [
			'fields' => implode( ',', $default_fields ),
			'format' => 'table',
		];
		$assoc_args = array_merge( $defaults, $assoc_args );

		$composer = $this->get_composer();
		$list     = [];
		foreach ( $packages as $package ) {
			$name = $package->getPrettyName();
			if ( isset( $list[ $name ] ) ) {
				$list[ $name ]['version'][] = $package->getPrettyVersion();
			} else {
				$package_output                = [];
				$package_output['name']        = $package->getPrettyName();
				$package_output['description'] = $package->getDescription();
				$package_output['authors']     = implode( ', ', array_column( (array) $package->getAuthors(), 'name' ) );
				$package_output['version']     = [ $package->getPrettyVersion() ];
				$update                        = 'none';
				$update_version                = '';
				if ( 'list' === $context ) {
					try {
						$latest = $this->find_latest_package( $package, $composer, null );
						if ( $latest && $latest->getFullPrettyVersion() !== $package->getFullPrettyVersion() ) {
							$update         = 'available';
							$update_version = $latest->getPrettyVersion();
						}
					} catch ( Exception $e ) {
						WP_CLI::warning( $e->getMessage() );
						$update         = 'error';
						$update_version = $update;
					}
				}
				$package_output['update']         = $update;
				$package_output['update_version'] = $update_version;
				$package_output['pretty_name']    = $package->getPrettyName(); // Deprecated but kept for BC with package-command 1.0.8.
				$list[ $package_output['name'] ]  = $package_output;
			}
		}

		$list = array_map(
			function( $package ) {
				$package['version'] = implode( ', ', $package['version'] );
				return $package;
			},
			$list
		);

		ksort( $list );
		if ( 'ids' === $assoc_args['format'] ) {
			$list = array_keys( $list );
		}
		Utils\format_items( $assoc_args['format'], $list, $assoc_args['fields'] );
	}
private function show_packages ( $ context , $ packages , $ assoc_args ) { if ( 'list' === $ context ) { $ default_fields = [ 'name' , 'authors' , 'version' , 'update' , 'update_version' , ] ; } elseif ( 'browse' === $ context ) { $ default_fields = [ 'name' , 'description' , 'authors' , 'version' , ] ; } $ defaults = [ 'fields' => implode ( ',' , $ default_fields ) , 'format' => 'table' , ] ; $ assoc_args = array_merge ( $ defaults , $ assoc_args ) ; $ composer = $ this -> get_composer ( ) ; $ list = [ ] ; foreach ( $ packages as $ package ) { $ name = $ package -> getPrettyName ( ) ; if ( isset ( $ list [ $ name ] ) ) { $ list [ $ name ] [ 'version' ] [ ] = $ package -> getPrettyVersion ( ) ; } else { $ package_output = [ ] ; $ package_output [ 'name' ] = $ package -> getPrettyName ( ) ; $ package_output [ 'description' ] = $ package -> getDescription ( ) ; $ package_output [ 'authors' ] = implode ( ', ' , array_column ( ( array ) $ package -> getAuthors ( ) , 'name' ) ) ; $ package_output [ 'version' ] = [ $ package -> getPrettyVersion ( ) ] ; $ update = 'none' ; $ update_version = '' ; if ( 'list' === $ context ) { try { $ latest = $ this -> find_latest_package ( $ package , $ composer , null ) ; if ( $ latest && $ latest -> getFullPrettyVersion ( ) !== $ package -> getFullPrettyVersion ( ) ) { $ update = 'available' ; $ update_version = $ latest -> getPrettyVersion ( ) ; } } catch ( Exception $ e ) { WP_CLI :: warning ( $ e -> getMessage ( ) ) ; $ update = 'error' ; $ update_version = $ update ; } } $ package_output [ 'update' ] = $ update ; $ package_output [ 'update_version' ] = $ update_version ; $ package_output [ 'pretty_name' ] = $ package -> getPrettyName ( ) ; // Deprecated but kept for BC with package-command 1.0.8. $ list [ $ package_output [ 'name' ] ] = $ package_output ; } } $ list = array_map ( function ( $ package ) { $ package [ 'version' ] = implode ( ', ' , $ package [ 'version' ] ) ; return $ package ; } , $ list ) ; ksort ( $ list ) ; if ( 'ids' === $ assoc_args [ 'format' ] ) { $ list = array_keys ( $ list ) ; } Utils \ format_items ( $ assoc_args [ 'format' ] , $ list , $ assoc_args [ 'fields' ] ) ; }
Displays a set of packages

@param string $context
@param array
@param array
Displays a set of packages