Returns true if the STDOUT supports colorization.

@codeCoverageIgnore
@link https://github.com/symfony/Console/blob/master/Output/StreamOutput.php#L94
@param mixed $stream
@return bool
195047
public static function isColorsSupported($stream = STDOUT): bool
    {
        if ('Hyper' === getenv('TERM_PROGRAM')) {
            return true;
        }

        try {
            if (\DIRECTORY_SEPARATOR === '\\') {
                return (
                        function_exists('sapi_windows_vt100_support')
                        && @sapi_windows_vt100_support($stream)
                    ) || getenv('ANSICON') !== false
                    || getenv('ConEmuANSI') == 'ON'
                    || getenv('TERM') == 'xterm';
            }

            if (\function_exists('stream_isatty')) {
                return @stream_isatty($stream);
            }

            if (\function_exists('posix_isatty')) {
                return @posix_isatty($stream);
            }

            $stat = @fstat($stream);

            // Check if formatted mode is S_IFCHR
            return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
        } catch (\Throwable $e) {
            return false;
        }
    }
736403
public function stream_write($data)
    {
        if (self::READONLY === $this->mode) {
            return 0;
        }

        if ($this->content->isWritable(vfsStream::getCurrentUser(), vfsStream::getCurrentGroup()) === false) {
            return 0;
        }

        return $this->content->write($data);
    }
1280314
public function write($data)
    {
        if (!$this->alive) {
            Daemon::log('Attempt to write to dead IOStream (' . get_class($this) . ')');
            return false;
        }
        if (!isset($this->bevWrite)) {
            return false;
        }
        if (!mb_orig_strlen($data)) {
            return true;
        }
        $this->writing = true;
        Daemon::$noError = true;
        if (!$this->bevWrite->write($data) || !Daemon::$noError) {
            $this->close();
            return false;
        }
        return true;
    }
1224887
public function endRecording($stream)
    {
        $parts = explode('/', $this->streamserver_config[$stream->getRtmpServer()]['rtmp_url']);
        $rtmp_app = end($parts);
        $success = $this->record(
            $this->streamserver_config[$stream->getRtmpServer()]['rtmp_control'],
            $rtmp_app,
            $stream->getUniqID(),
            false
        );
        if ($success) {
            $stream->setTechnicalStatus(Stream::STATE_ENDED);
            $this->em->persist($stream);
            $this->em->flush();

            // $event = new EndRecordingStreamEvent($stream);
            // $this->dispatcher->dispatch(
            //     OktolabMediaEvent::STREAM_END_RECORDING,
            //     $event
            // );
            return true;
        }
        return false;
    }
155537
public function compile(Stream $stream)
    {
        // Parse the request
        $request    = CodeGeneratorRequest::fromStream($stream, $this->config);
        $response   = new CodeGeneratorResponse();
        $context    = $this->createContext($request);
        $entities   = $context->getEntities();
        $options    = $context->getOptions();
        $generator  = new Generator($context);

        // whether or not it will renegerate classes with new extensions
        $regenerate   = false;
        $hasExtension = $context->hasProtobufExtension();

        // Run each entity
        foreach ($entities as $key => $entity) {
            $generateImported = $options->getGenerateImported();
            $isFileToGenerate = $entity->isFileToGenerate();

            // Only compile those given to generate, not the imported ones
            if ( ! $generateImported && ! $isFileToGenerate) {
                $this->logger->debug(sprintf('Skipping generation of imported class "%s"', $entity->getClass()));

                continue;
            }

            $this->logger->info(sprintf('Generating class "%s"', $entity->getClass()));

            $generator->visit($entity);

            $file    = new File();
            $path    = $entity->getPath();
            $content = $entity->getContent();

            $file->setName($path);
            $file->setContent($content);

            $response->addFile($file);

            if ($hasExtension && $this->loadEntityClass($entity)) {
                $regenerate = true;
            }
        }

        if ($regenerate) {

            $this->logger->info('Regenerating classes with new extensions');

            $stream->seek(0);

            // Renegerate classes with new extensions
            return $this->compile($stream);
        }

        $this->logger->info('Generation completed.');

        // Finally serialize the response object
        return $response->toStream($this->config);
    }
829967
protected function _msgText($stream, $data)
    {
        if ($data instanceof Horde_Stream) {
            if ($stream) {
                $data->rewind();
                return $data->stream;
            }
            return strval($data);
        }

        if (is_resource($data)) {
            rewind($data);
            return $stream
                ? $data
                : stream_get_contents($data);
        }

        if (!$stream) {
            return strval($data);
        }

        $tmp = fopen('php://temp', 'w+');

        if (!is_null($data)) {
            fwrite($tmp, $data);
            rewind($tmp);
        }

        return $tmp;
    }
228742
protected function initStream($stream)
    {
        expect_type(
            $stream,
            ['stream resource', 'string'],
            \TypeError::class,
            "Expected stream resource or uri (string), %s given"
        );

        if (is_string($stream)) {
            $stream = $this->openStream($stream);
        }

        $meta = stream_get_meta_data($stream);

        if ($meta['mode'] === 'r') {
            throw new \InvalidArgumentException("Stream \"{$meta['uri']}\" is not writable");
        }

        return $stream;
    }
333455
public function setStream(PsrStreamInterface $stream)
	{
		$this->stream = $stream;
		$this->error = UPLOAD_ERR_OK;
		
		return true;
	}
659000
public function initFromStream($stream)
    {
        if (!$stream instanceof StreamInterface) {
            $stream = new Stream($stream);
        }

        try {
            $offset = $stream->tell();
        } catch (\RuntimeException $e) {
            $offset = 0;
        }

        $shouldAndCanSeek = $offset !== 0 && $stream->isSeekable();

        if ($shouldAndCanSeek) {
            $stream->rewind();
        }

        try {
            $data = $stream->getContents();
        } catch (\RuntimeException $e) {
            $data = null;
        }

        if ($shouldAndCanSeek) {
            $stream->seek($offset);
        }

        if ($data) {
            return $this->initFromBinary($data);
        }

        throw new \Intervention\Image\Exception\NotReadableException(
            "Unable to init from given stream"
        );
    }
565529
public function stream_write($data)
    {
        if ($this->_upload === null) {
            return false;
        }
        $this->_upload->addContent($data);
        $result = StringHelper::byteLength($data);
        $this->_pointerOffset += $result;
        return $result;
    }
537067
private function decorateStream(string $encoding, StreamInterface $stream)
    {
        if ('chunked' === strtolower($encoding)) {
            return new Encoding\DechunkStream($stream);
        }

        if ('deflate' === strtolower($encoding)) {
            return new Encoding\DecompressStream($stream);
        }

        if ('gzip' === strtolower($encoding)) {
            return new Encoding\GzipDecodeStream($stream);
        }

        return false;
    }
263796
public static function getStreamExt($stream)
    {
        try {
            if (is_readable($stream)) {
                $stream = file_get_contents($stream);
            }
        } catch (\Exception $e) {
        }

        $fileInfo = new finfo(FILEINFO_MIME);

        $mime = strstr($fileInfo->buffer($stream), ';', true);

        return isset(self::$extensionMap[$mime]) ? self::$extensionMap[$mime] : self::getExtBySignature($stream);
    }
223907
private function isXml($stream)
    {
        $stream->rewind();
        $previousValue = libxml_use_internal_errors(true);
        $isXml = simplexml_load_string($stream->getContents());
        libxml_use_internal_errors($previousValue);

        return $isXml;
    }
97403
public function stream_read($count)
    {
        if ($this->stream_eof()) {
            return false;
        }

        $out = '';
        $tmp = &$this->_data[$this->_datapos];

        while ($count) {
            if (!is_resource($tmp['fp'])) {
                return false;
            }

            $curr_read = min($count, $tmp['l'] - $tmp['p']);
            $out .= fread($tmp['fp'], $curr_read);
            $count -= $curr_read;
            $this->_position += $curr_read;

            if ($this->_position == $this->_length) {
                if ($count) {
                    $this->_ateof = true;
                    break;
                } else {
                    $tmp['p'] += $curr_read;
                }
            } elseif ($count) {
                if (!isset($this->_data[++$this->_datapos])) {
                    return false;
                }
                $tmp = &$this->_data[$this->_datapos];
                rewind($tmp['fp']);
                $tmp['p'] = 0;
            } else {
                $tmp['p'] += $curr_read;
            }
        }

        return $out;
    }
617846
public function isStream()
    {
        if ($this->data instanceof StreamInterface) {
            return true;
        }

        if (!is_resource($this->data)) {
            return false;
        }

        if (get_resource_type($this->data) !== 'stream') {
            return false;
        }

        return true;
    }
1025110
static public function shouldColorize($colored = null) {
		return self::$_enabled === true ||
			(self::$_enabled !== false &&
				($colored === true ||
					($colored !== false && Streams::isTty())));
	}
356621
public static function isSupportColor(): bool
    {
        if (DIRECTORY_SEPARATOR === '\\') {
            return
                '10.0.10586' === PHP_WINDOWS_VERSION_MAJOR . '.' . PHP_WINDOWS_VERSION_MINOR . '.' . PHP_WINDOWS_VERSION_BUILD
                || false !== getenv('ANSICON')
                || 'ON' === getenv('ConEmuANSI')
                || 'xterm' === getenv('TERM')// || 'cygwin' === getenv('TERM')
                ;
        }

        if (!\defined('STDOUT')) {
            return false;
        }

        return self::isInteractive(STDOUT);
    }