Documentation

TwigFunction extends AbstractTwigCallable
in package

FinalYes

Represents a template function.

Tags
author

Fabien Potencier fabien@symfony.com

see
https://twig.symfony.com/doc/templates.html#functions

Table of Contents

Properties

$options  : mixed

Methods

__construct()  : mixed
__toString()  : string
getAlternative()  : string|null
getArguments()  : array<string|int, mixed>
getCallable()  : callable|array{class-string, string}|null
getDeprecatedVersion()  : string
getDeprecatingPackage()  : string
getDynamicName()  : string
getMinimalNumberOfRequiredArguments()  : int
getName()  : string
getNodeClass()  : string
getParserCallable()  : callable|null
getSafe()  : array<string|int, mixed>|null
getType()  : string
isDeprecated()  : bool
isVariadic()  : bool
needsCharset()  : bool
needsContext()  : bool
needsEnvironment()  : bool
setArguments()  : void
triggerDeprecation()  : void
withDynamicArguments()  : static

Properties

Methods

__construct()

public __construct(string $name[, callable|array{class-string, string}|null $callable = null ][, array<string|int, mixed> $options = [] ]) : mixed
Parameters
$name : string
$callable : callable|array{class-string, string}|null = null

A callable implementing the function. If null, you need to overwrite the "node_class" option to customize compilation.

$options : array<string|int, mixed> = []

getAlternative()

public getAlternative() : string|null

since Twig 3.15

Return values
string|null

getArguments()

public getArguments() : array<string|int, mixed>
Return values
array<string|int, mixed>

getCallable()

public getCallable() : callable|array{class-string, string}|null
Return values
callable|array{class-string, string}|null

getDeprecatedVersion()

public getDeprecatedVersion() : string

since Twig 3.15

Return values
string

getDeprecatingPackage()

public getDeprecatingPackage() : string

since Twig 3.15

Return values
string

getMinimalNumberOfRequiredArguments()

public getMinimalNumberOfRequiredArguments() : int
Return values
int

getParserCallable()

public getParserCallable() : callable|null
Return values
callable|null

getSafe()

public getSafe(Node $functionArgs) : array<string|int, mixed>|null
Parameters
$functionArgs : Node
Return values
array<string|int, mixed>|null

getType()

public getType() : string
Return values
string

setArguments()

public setArguments(array<string|int, mixed> $arguments) : void

since Twig 3.12, use withDynamicArguments() instead

Parameters
$arguments : array<string|int, mixed>

triggerDeprecation()

public triggerDeprecation([string|null $file = null ][, int|null $line = null ]) : void
Parameters
$file : string|null = null
$line : int|null = null

withDynamicArguments()

public withDynamicArguments(string $name, string $dynamicName, array<string|int, mixed> $arguments) : static
Parameters
$name : string
$dynamicName : string
$arguments : array<string|int, mixed>
Return values
static

        
On this page

Search results