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

Breadcrumb

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

function Common::prepareForOutput

Prepares token content for output to screen.

Replaces invisible characters so they are visible. On non-Windows operating systems it will also colour the invisible characters.

Parameters

string $content The content to prepare.:

string[] $exclude A list of characters to leave invisible.: Can contain \r, \n, \t and a space.

Return value

string

11 calls to Common::prepareForOutput()
Code::generateFileReport in vendor/squizlabs/php_codesniffer/src/Reports/Code.php
Generate a partial report for a single processed file.
Comment::tokenizeString in vendor/squizlabs/php_codesniffer/src/Tokenizers/Comment.php
Creates an array of tokens when given some PHP code.
File::process in vendor/squizlabs/php_codesniffer/src/Files/File.php
Starts the stack traversal and tells listeners when tokens are found.
Fixer::replaceToken in vendor/squizlabs/php_codesniffer/src/Fixer.php
Replace the entire contents of a token.
Fixer::revertToken in vendor/squizlabs/php_codesniffer/src/Fixer.php
Reverts the previous fix made to a token.

... See full list

File

vendor/squizlabs/php_codesniffer/src/Util/Common.php, line 279

Class

Common

Namespace

PHP_CodeSniffer\Util

Code

public static function prepareForOutput($content, $exclude = []) {
    if (stripos(PHP_OS, 'WIN') === 0) {
        if (in_array("\r", $exclude, true) === false) {
            $content = str_replace("\r", '\\r', $content);
        }
        if (in_array("\n", $exclude, true) === false) {
            $content = str_replace("\n", '\\n', $content);
        }
        if (in_array("\t", $exclude, true) === false) {
            $content = str_replace("\t", '\\t', $content);
        }
    }
    else {
        if (in_array("\r", $exclude, true) === false) {
            $content = str_replace("\r", "\x1b[30;1m\\r\x1b[0m", $content);
        }
        if (in_array("\n", $exclude, true) === false) {
            $content = str_replace("\n", "\x1b[30;1m\\n\x1b[0m", $content);
        }
        if (in_array("\t", $exclude, true) === false) {
            $content = str_replace("\t", "\x1b[30;1m\\t\x1b[0m", $content);
        }
        if (in_array(' ', $exclude, true) === false) {
            $content = str_replace(' ', "\x1b[30;1m·\x1b[0m", $content);
        }
    }
    
    //end if
    return $content;
}
RSS feed
Powered by Drupal