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

Breadcrumb

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

function HttpDownloader::outputWarnings

@internal

Parameters

array{warning?: string, info?: string, warning-versions?: string, info-versions?: string, warnings?: array<array{versions: string, message: string}>, infos?: array<array{versions: string, message: string}>} $data:

5 calls to HttpDownloader::outputWarnings()
ComposerRepository::asyncFetchFile in vendor/composer/composer/src/Composer/Repository/ComposerRepository.php
@phpstan-return PromiseInterface<array<mixed>|true> true if the response was a 304 and the cache is fresh, otherwise it returns the decoded json
ComposerRepository::fetchFile in vendor/composer/composer/src/Composer/Repository/ComposerRepository.php
ComposerRepository::fetchFileIfLastModified in vendor/composer/composer/src/Composer/Repository/ComposerRepository.php
CurlDownloader::tick in vendor/composer/composer/src/Composer/Util/Http/CurlDownloader.php
RemoteFilesystem::get in vendor/composer/composer/src/Composer/Util/RemoteFilesystem.php
Get file content or copy action.

File

vendor/composer/composer/src/Composer/Util/HttpDownloader.php, line 441

Class

HttpDownloader
@author Jordi Boggiano <j.boggiano@seld.be> @phpstan-type Request array{url: non-empty-string, options: mixed[], copyTo: string|null} @phpstan-type Job array{id: int, status: int, request: Request, sync: bool, origin: string, resolve?: callable,…

Namespace

Composer\Util

Code

public static function outputWarnings(IOInterface $io, string $url, $data) : void {
    $cleanMessage = static function ($msg) use ($io) {
        if (!$io->isDecorated()) {
            $msg = Preg::replace('{' . chr(27) . '\\[[;\\d]*m}u', '', $msg);
        }
        return $msg;
    };
    // legacy warning/info keys
    foreach ([
        'warning',
        'info',
    ] as $type) {
        if (empty($data[$type])) {
            continue;
        }
        if (!empty($data[$type . '-versions'])) {
            $versionParser = new VersionParser();
            $constraint = $versionParser->parseConstraints($data[$type . '-versions']);
            $composer = new Constraint('==', $versionParser->normalize(Composer::getVersion()));
            if (!$constraint->matches($composer)) {
                continue;
            }
        }
        $io->writeError('<' . $type . '>' . ucfirst($type) . ' from ' . Url::sanitize($url) . ': ' . $cleanMessage($data[$type]) . '</' . $type . '>');
    }
    // modern Composer 2.2+ format with support for multiple warning/info messages
    foreach ([
        'warnings',
        'infos',
    ] as $key) {
        if (empty($data[$key])) {
            continue;
        }
        $versionParser = new VersionParser();
        foreach ($data[$key] as $spec) {
            $type = substr($key, 0, -1);
            $constraint = $versionParser->parseConstraints($spec['versions']);
            $composer = new Constraint('==', $versionParser->normalize(Composer::getVersion()));
            if (!$constraint->matches($composer)) {
                continue;
            }
            $io->writeError('<' . $type . '>' . ucfirst($type) . ' from ' . Url::sanitize($url) . ': ' . $cleanMessage($spec['message']) . '</' . $type . '>');
        }
    }
}
RSS feed
Powered by Drupal