Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Console.php

function Console::isInteractive

Returns if the file descriptor is an interactive terminal or not.

Normally, we want to use a resource as a parameter, yet sadly it's not always available, eg when running code in interactive console (`php -a`), STDIN/STDOUT/STDERR constants are not defined.

Parameters

int|resource $fileDescriptor:

2 calls to Console::isInteractive()
Console::getNumberOfColumns in vendor/sebastian/environment/src/Console.php
Returns the number of columns of the terminal.
Console::hasColorSupport in vendor/sebastian/environment/src/Console.php
Returns true if STDOUT supports colorization.

File

vendor/sebastian/environment/src/Console.php, line 105

Class

Console

Namespace

SebastianBergmann\Environment

Code

public function isInteractive($fileDescriptor = self::STDOUT) : bool {
    if (is_resource($fileDescriptor)) {
        if (function_exists('stream_isatty') && @stream_isatty($fileDescriptor)) {
            return true;
        }
        if (function_exists('fstat')) {
            $stat = @fstat(STDOUT);
            return $stat && 020000 === ($stat['mode'] & 0170000);
        }
        return false;
    }
    return function_exists('posix_isatty') && @posix_isatty($fileDescriptor);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal