CodeExtension
extends AbstractExtension
in package
FinalYes
Twig extension relate to PHP code and used by the profiler and the default exception templates.
Tags
Table of Contents
Properties
- $charset : string
- $fileLinkFormat : string|FileLinkFormatter|array<string|int, mixed>|false
- $projectDir : string
Methods
- __construct() : mixed
- abbrClass() : string
- abbrMethod() : string
- fileExcerpt() : string|null
- 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() : string
- getFileLink() : string|false
- 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.
- 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() : string
Properties
$charset
private
string
$charset
$fileLinkFormat
private
string|FileLinkFormatter|array<string|int, mixed>|false
$fileLinkFormat
$projectDir
private
string
$projectDir
Methods
__construct()
public
__construct(string|FileLinkFormatter $fileLinkFormat, string $projectDir, string $charset) : mixed
Parameters
- $fileLinkFormat : string|FileLinkFormatter
- $projectDir : string
- $charset : string
abbrClass()
public
abbrClass(string $class) : string
Parameters
- $class : string
Return values
stringabbrMethod()
public
abbrMethod(string $method) : string
Parameters
- $method : string
Return values
stringfileExcerpt()
Returns an excerpt of a code file around the given line number.
public
fileExcerpt(string $file, int $line[, int $srcContext = 3 ]) : string|null
Parameters
- $file : string
- $line : int
- $srcContext : int = 3
Return values
string|nullformatArgs()
Formats an array as a string.
public
formatArgs(array<string|int, mixed> $args) : string
Parameters
- $args : array<string|int, mixed>
Return values
stringformatArgsAsText()
Formats an array as a string.
public
formatArgsAsText(array<string|int, mixed> $args) : string
Parameters
- $args : array<string|int, mixed>
Return values
stringformatFile()
Formats a file path.
public
formatFile(string $file, int $line[, string $text = null ]) : string
Parameters
- $file : string
- $line : int
- $text : string = null
Return values
stringformatFileFromText()
public
formatFileFromText(string $text) : string
Parameters
- $text : string
Return values
stringgetFileLink()
public
getFileLink(string $file, int $line) : string|false
Parameters
- $file : string
- $line : int
Return values
string|falsegetFileRelative()
public
getFileRelative(string $file) : string|null
Parameters
- $file : string
Return values
string|nullgetFilters()
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>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(string $line) : string
Parameters
- $line : string