static public function columns() {
		static $columns;

		if ( getenv( 'PHP_CLI_TOOLS_TEST_SHELL_COLUMNS_RESET' ) ) {
			$columns = null;
		}
		if ( null === $columns ) {
			if ( function_exists( 'exec' ) ) {
				if ( self::is_windows() ) {
					// Cater for shells such as Cygwin and Git bash where `mode CON` returns an incorrect value for columns.
					if ( ( $shell = getenv( 'SHELL' ) ) && preg_match( '/(?:bash|zsh)(?:\.exe)?$/', $shell ) && getenv( 'TERM' ) ) {
						$columns = (int) exec( 'tput cols' );
					}
					if ( ! $columns ) {
						$return_var = -1;
						$output = array();
						exec( 'mode CON', $output, $return_var );
						if ( 0 === $return_var && $output ) {
							// Look for second line ending in ": <number>" (searching for "Columns:" will fail on non-English locales).
							if ( preg_match( '/:\s*[0-9]+\n[^:]+:\s*([0-9]+)\n/', implode( "\n", $output ), $matches ) ) {
								$columns = (int) $matches[1];
							}
						}
					}
				} else {
					if ( ! ( $columns = (int) getenv( 'COLUMNS' ) ) ) {
						$size = exec( '/usr/bin/env stty size 2>/dev/null' );
						if ( '' !== $size && preg_match( '/[0-9]+ ([0-9]+)/', $size, $matches ) ) {
							$columns = (int) $matches[1];
						}
						if ( ! $columns ) {
							if ( getenv( 'TERM' ) ) {
								$columns = (int) exec( '/usr/bin/env tput cols 2>/dev/null' );
							}
						}
					}
				}
			}

			if ( ! $columns ) {
				$columns = 80; // default width of cmd window on Windows OS
			}
		}

		return $columns;
	}
static public function columns() {
		static $columns;

		if ( getenv( 'PHP_CLI_TOOLS_TEST_SHELL_COLUMNS_RESET' ) ) {
			$columns = null;
		}
		if ( null === $columns ) {
			if ( function_exists( 'exec' ) ) {
				if ( self::is_windows() ) {
					// Cater for shells such as Cygwin and Git bash where `mode CON` returns an incorrect value for columns.
					if ( ( $shell = getenv( 'SHELL' ) ) && preg_match( '/(?:bash|zsh)(?:\.exe)?$/', $shell ) && getenv( 'TERM' ) ) {
						$columns = (int) exec( 'tput cols' );
					}
					if ( ! $columns ) {
						$return_var = -1;
						$output = array();
						exec( 'mode CON', $output, $return_var );
						if ( 0 === $return_var && $output ) {
							// Look for second line ending in ": <number>" (searching for "Columns:" will fail on non-English locales).
							if ( preg_match( '/:\s*[0-9]+\n[^:]+:\s*([0-9]+)\n/', implode( "\n", $output ), $matches ) ) {
								$columns = (int) $matches[1];
							}
						}
					}
				} else {
					if ( ! ( $columns = (int) getenv( 'COLUMNS' ) ) ) {
						$size = exec( '/usr/bin/env stty size 2>/dev/null' );
						if ( '' !== $size && preg_match( '/[0-9]+ ([0-9]+)/', $size, $matches ) ) {
							$columns = (int) $matches[1];
						}
						if ( ! $columns ) {
							if ( getenv( 'TERM' ) ) {
								$columns = (int) exec( '/usr/bin/env tput cols 2>/dev/null' );
							}
						}
					}
				}
			}

			if ( ! $columns ) {
				$columns = 80; // default width of cmd window on Windows OS
			}
		}

		return $columns;
	}
static public function columns ( ) { static $ columns ; if ( getenv ( 'PHP_CLI_TOOLS_TEST_SHELL_COLUMNS_RESET' ) ) { $ columns = null ; } if ( null === $ columns ) { if ( function_exists ( 'exec' ) ) { if ( self :: is_windows ( ) ) { // Cater for shells such as Cygwin and Git bash where `mode CON` returns an incorrect value for columns. if ( ( $ shell = getenv ( 'SHELL' ) ) && preg_match ( '/(?:bash|zsh)(?:\.exe)?$/' , $ shell ) && getenv ( 'TERM' ) ) { $ columns = ( int ) exec ( 'tput cols' ) ; } if ( ! $ columns ) { $ return_var = - 1 ; $ output = array ( ) ; exec ( 'mode CON' , $ output , $ return_var ) ; if ( 0 === $ return_var && $ output ) { // Look for second line ending in ": <number>" (searching for "Columns:" will fail on non-English locales). if ( preg_match ( '/:\s*[0-9]+\n[^:]+:\s*([0-9]+)\n/' , implode ( "\n" , $ output ) , $ matches ) ) { $ columns = ( int ) $ matches [ 1 ] ; } } } } else { if ( ! ( $ columns = ( int ) getenv ( 'COLUMNS' ) ) ) { $ size = exec ( '/usr/bin/env stty size 2>/dev/null' ) ; if ( '' !== $ size && preg_match ( '/[0-9]+ ([0-9]+)/' , $ size , $ matches ) ) { $ columns = ( int ) $ matches [ 1 ] ; } if ( ! $ columns ) { if ( getenv ( 'TERM' ) ) { $ columns = ( int ) exec ( '/usr/bin/env tput cols 2>/dev/null' ) ; } } } } } if ( ! $ columns ) { $ columns = 80 ; // default width of cmd window on Windows OS } } return $ columns ; }
Returns the number of columns the current shell has for display.

@return int  The number of columns.
@todo Test on more systems.
Returns the number of columns the current shell has for display .