Documentation

AsTwigTest
in package

FinalYes

Registers a method as template test.

The first argument is the value to test and the other arguments are the arguments passed to the test in the template.

#[AsTwigTest(name: 'foo')]
public function fooTest($value, $arg1 = null) { ... }

{% if value is foo(arg1) %}
Tags
see
TwigTest
Attributes
#[Attribute]
\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE

Table of Contents

Properties

$deprecationInfo  : DeprecatedCallableInfo|null
$name  : string
$needsCharset  : bool|null
$needsContext  : bool|null
$needsEnvironment  : bool|null

Methods

__construct()  : mixed

Properties

$needsCharset

public bool|null $needsCharset = null

$needsContext

public bool|null $needsContext = null

$needsEnvironment

public bool|null $needsEnvironment = null

Methods

__construct()

public __construct(non-empty-string $name[, bool|null $needsCharset = null ][, bool|null $needsEnvironment = null ][, bool|null $needsContext = null ][, DeprecatedCallableInfo|null $deprecationInfo = null ]) : mixed
Parameters
$name : non-empty-string

The name of the test in Twig

$needsCharset : bool|null = null

Whether the test needs the charset passed as the first argument

$needsEnvironment : bool|null = null

Whether the test needs the environment passed as the first argument, or after the charset

$needsContext : bool|null = null

Whether the test needs the context array passed as the first argument, or after the charset and the environment

$deprecationInfo : DeprecatedCallableInfo|null = null

Information about the deprecation


        
On this page

Search results