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

Breadcrumb

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

function ConsoleIO::doOverwrite

Parameters

string[]|string $messages:

2 calls to ConsoleIO::doOverwrite()
ConsoleIO::overwrite in vendor/composer/composer/src/Composer/IO/ConsoleIO.php
@inheritDoc
ConsoleIO::overwriteError in vendor/composer/composer/src/Composer/IO/ConsoleIO.php
@inheritDoc

File

vendor/composer/composer/src/Composer/IO/ConsoleIO.php, line 202

Class

ConsoleIO
The Input/Output helper.

Namespace

Composer\IO

Code

private function doOverwrite($messages, bool $newline, ?int $size, bool $stderr, int $verbosity) : void {
    // messages can be an array, let's convert it to string anyway
    $messages = implode($newline ? "\n" : '', (array) $messages);
    // since overwrite is supposed to overwrite last message...
    if (!isset($size)) {
        // removing possible formatting of lastMessage with strip_tags
        $size = strlen(strip_tags($stderr ? $this->lastMessageErr : $this->lastMessage));
    }
    // ...let's fill its length with backspaces
    $this->doWrite(str_repeat("\x08", $size), false, $stderr, $verbosity);
    // write the new message
    $this->doWrite($messages, false, $stderr, $verbosity);
    // In cmd.exe on Win8.1 (possibly 10?), the line can not be cleared, so we need to
    // track the length of previous output and fill it with spaces to make sure the line is cleared.
    // See https://github.com/composer/composer/pull/5836 for more details
    $fill = $size - strlen(strip_tags($messages));
    if ($fill > 0) {
        // whitespace whatever has left
        $this->doWrite(str_repeat(' ', $fill), false, $stderr, $verbosity);
        // move the cursor back
        $this->doWrite(str_repeat("\x08", $fill), false, $stderr, $verbosity);
    }
    if ($newline) {
        $this->doWrite('', true, $stderr, $verbosity);
    }
    if ($stderr) {
        $this->lastMessageErr = $messages;
    }
    else {
        $this->lastMessage = $messages;
    }
}

API Navigation

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