HighlightPhpHighlighter
in package
implements
Highlighter
FinalYes
This class delegates to the Highlighter library the task of highlighting code blocks, adds extra features, and makes sure that errors result in a log line instead of an exception.
Table of Contents
Interfaces
Properties
- $highlighter : Highlighter
- $languageAliases : array<string|int, mixed>
- $logger : LoggerInterface
Methods
- __construct() : mixed
- __invoke() : HighlightResult
- escapeForbiddenCharactersInsideCodeBlock() : string
- Code blocks are displayed in "<pre>" tags, which has some reserved characters: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/pre
Properties
$highlighter
private
Highlighter
$highlighter
$languageAliases
private
array<string|int, mixed>
$languageAliases
= ['terminal' => 'bash']
$logger
private
LoggerInterface
$logger
Methods
__construct()
public
__construct(Highlighter $highlighter, LoggerInterface $logger[, array<string, string> $languageAliases = ['terminal' => 'bash'] ]) : mixed
Parameters
- $highlighter : Highlighter
- $logger : LoggerInterface
- $languageAliases : array<string, string> = ['terminal' => 'bash']
-
a map of language aliases to their actual language, for instance "attribute" => "php"
__invoke()
public
__invoke(string $language, string $code, mixed $debugInformation) : HighlightResult
Parameters
- $language : string
- $code : string
- $debugInformation : mixed
-
array<string, string|null>
Return values
HighlightResultescapeForbiddenCharactersInsideCodeBlock()
Code blocks are displayed in "<pre>" tags, which has some reserved characters: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/pre
private
escapeForbiddenCharactersInsideCodeBlock(string $code) : string
Parameters
- $code : string