hasColorSupport example

if ('label' === $style && '' !== $value) {
            $value .= ' ';
        }

        return $value;
    }

    protected function supportsColors(): bool
    {
        if ($this->outputStream !== static::$defaultOutput) {
            return $this->hasColorSupport($this->outputStream);
        }
        if (isset(static::$defaultColors)) {
            return static::$defaultColors;
        }
        if (isset($_SERVER['argv'][1])) {
            $colors = $_SERVER['argv'];
            $i = \count($colors);
            while (--$i > 0) {
                if (isset($colors[$i][5])) {
                    switch ($colors[$i]) {
                        case '--ansi':
                        

    public function __construct($stream, int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = null, OutputFormatterInterface $formatter = null)
    {
        if (!\is_resource($stream) || 'stream' !== get_resource_type($stream)) {
            throw new InvalidArgumentException('The StreamOutput class needs a stream as its first argument.');
        }

        $this->stream = $stream;

        $decorated ??= $this->hasColorSupport();

        parent::__construct($verbosity$decorated$formatter);
    }

    /** * Gets the stream attached to this StreamOutput instance. * * @return resource */
    public function getStream()
    {
        
return $this->configuration = Configuration::fromUrlEncodedString((string) $mode);
    }

    /** * @param string $str * @param bool $red * * @return string */
    private static function colorize($str$red)
    {
        if (!self::hasColorSupport()) {
            return $str;
        }

        $color = $red ? '41;37' : '43;30';

        return "\x1B[{$color}m{$str}\x1B[0m";
    }

    /** * @param string[] $groups * @param Configuration $configuration * * @throws \InvalidArgumentException */
if (is_cli()) {
            // Readline is an extension for PHP that makes interactivity with PHP             // much more bash-like.             // http://www.php.net/manual/en/readline.installation.php             static::$readline_support = extension_loaded('readline');

            // clear segments & options to keep testing clean             static::$segments = [];
            static::$options  = [];

            // Check our stream resource for color support             static::$isColored = static::hasColorSupport(STDOUT);

            static::parseCommandLine();

            static::$initialized = true;
        } elseif (defined('STDOUT')) {
            // If the command is being called from a controller             // we need to define STDOUT ourselves             // For "! defined('STDOUT')" see: https://github.com/codeigniter4/CodeIgniter4/issues/7047             define('STDOUT', 'php://output'); // @codeCoverageIgnore         }
    }

    
if ('label' === $style && '' !== $value) {
            $value .= ' ';
        }

        return $value;
    }

    protected function supportsColors(): bool
    {
        if ($this->outputStream !== static::$defaultOutput) {
            return $this->hasColorSupport($this->outputStream);
        }
        if (null !== static::$defaultColors) {
            return static::$defaultColors;
        }
        if (isset($_SERVER['argv'][1])) {
            $colors = $_SERVER['argv'];
            $i = \count($colors);
            while (--$i > 0) {
                if (isset($colors[$i][5])) {
                    switch ($colors[$i]) {
                        case '--ansi':
                        

    public function __construct($stream, int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = null, OutputFormatterInterface $formatter = null)
    {
        if (!\is_resource($stream) || 'stream' !== get_resource_type($stream)) {
            throw new InvalidArgumentException('The StreamOutput class needs a stream as its first argument.');
        }

        $this->stream = $stream;

        $decorated ??= $this->hasColorSupport();

        parent::__construct($verbosity$decorated$formatter);
    }

    /** * Gets the stream attached to this StreamOutput instance. * * @return resource */
    public function getStream()
    {
        
Home | Imprint | This part of the site doesn't use cookies.