CodeExtension
extends AbstractExtension
in package
Twig extension relate to PHP code and used by the profiler and the default exception templates.
Tags
Table of Contents
- $charset : mixed
- $fileLinkFormat : mixed
- $projectDir : mixed
- __construct() : mixed
- abbrClass() : mixed
- abbrMethod() : mixed
- fileExcerpt() : string
- Returns an excerpt of a code file around the given line number.
- formatArgs() : string
- Formats an array as a string.
- formatArgsAsText() : string
- Formats an array as a string.
- formatFile() : string
- Formats a file path.
- formatFileFromText() : mixed
- getFileLink() : string|false
- Returns the link for a given file/line pair.
- getFileRelative() : string|null
- getFilters() : array<string|int, TwigFilter>
- Returns a list of filters to add to the existing list.
- getFunctions() : array<string|int, TwigFunction>
- Returns a list of functions to add to the existing list.
- getName() : mixed
- {@inheritdoc}
- getNodeVisitors() : array<string|int, NodeVisitorInterface>
- Returns the node visitor instances to add to the existing list.
- getOperators() : array<string|int, array<string|int, mixed>>
- Returns a list of operators to add to the existing list.
- getTests() : array<string|int, TwigTest>
- Returns a list of tests to add to the existing list.
- getTokenParsers() : array<string|int, TokenParserInterface>
- Returns the token parser instances to add to the existing list.
- fixCodeMarkup() : mixed
Properties
$charset
private
mixed
$charset
$fileLinkFormat
private
mixed
$fileLinkFormat
$projectDir
private
mixed
$projectDir
Methods
__construct()
public
__construct(string|FileLinkFormatter $fileLinkFormat, string $projectDir, string $charset) : mixed
Parameters
- $fileLinkFormat : string|FileLinkFormatter
-
The format for links to source files
- $projectDir : string
-
The project directory
- $charset : string
-
The charset
Return values
mixed —abbrClass()
public
abbrClass(mixed $class) : mixed
Parameters
- $class : mixed
Return values
mixed —abbrMethod()
public
abbrMethod(mixed $method) : mixed
Parameters
- $method : mixed
Return values
mixed —fileExcerpt()
Returns an excerpt of a code file around the given line number.
public
fileExcerpt(string $file, int $line[, int $srcContext = 3 ]) : string
Parameters
- $file : string
-
A file path
- $line : int
-
The selected line number
- $srcContext : int = 3
-
The number of displayed lines around or -1 for the whole file
Return values
string —An HTML string
formatArgs()
Formats an array as a string.
public
formatArgs(array<string|int, mixed> $args) : string
Parameters
- $args : array<string|int, mixed>
-
The argument array
Return values
string —formatArgsAsText()
Formats an array as a string.
public
formatArgsAsText(array<string|int, mixed> $args) : string
Parameters
- $args : array<string|int, mixed>
-
The argument array
Return values
string —formatFile()
Formats a file path.
public
formatFile(string $file, int $line[, string $text = null ]) : string
Parameters
- $file : string
-
An absolute file path
- $line : int
-
The line number
- $text : string = null
-
Use this text for the link rather than the file path
Return values
string —formatFileFromText()
public
formatFileFromText(mixed $text) : mixed
Parameters
- $text : mixed
Return values
mixed —getFileLink()
Returns the link for a given file/line pair.
public
getFileLink(string $file, int $line) : string|false
Parameters
- $file : string
-
An absolute file path
- $line : int
-
The line number
Return values
string|false —A link or false
getFileRelative()
public
getFileRelative(string $file) : string|null
Parameters
- $file : string
Return values
string|null —getFilters()
Returns a list of filters to add to the existing list.
public
getFilters() : array<string|int, TwigFilter>
Return values
array<string|int, TwigFilter> —getFunctions()
Returns a list of functions to add to the existing list.
public
getFunctions() : array<string|int, TwigFunction>
Return values
array<string|int, TwigFunction> —getName()
{@inheritdoc}
public
getName() : mixed
Return values
mixed —getNodeVisitors()
Returns the node visitor instances to add to the existing list.
public
getNodeVisitors() : array<string|int, NodeVisitorInterface>
Return values
array<string|int, NodeVisitorInterface> —getOperators()
Returns a list of operators to add to the existing list.
public
getOperators() : array<string|int, array<string|int, mixed>>
Return values
array<string|int, array<string|int, mixed>> —First array of unary operators, second array of binary operators
getTests()
Returns a list of tests to add to the existing list.
public
getTests() : array<string|int, TwigTest>
Return values
array<string|int, TwigTest> —getTokenParsers()
Returns the token parser instances to add to the existing list.
public
getTokenParsers() : array<string|int, TokenParserInterface>
Return values
array<string|int, TokenParserInterface> —fixCodeMarkup()
protected
static fixCodeMarkup(mixed $line) : mixed
Parameters
- $line : mixed