mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-24 15:06:26 +00:00
Let's no deprecate the attribute function yet
This commit is contained in:
+4
-3
@@ -11,9 +11,8 @@ Functions
|
||||
* The ``twig_test_iterable`` function is deprecated; use the native PHP
|
||||
``is_iterable`` function instead.
|
||||
|
||||
* The ``attribute`` function is deprecated as of Twig 3.15 and will be removed
|
||||
in Twig 4.0. Use the ``.`` operator instead and wrap the name with
|
||||
parenthesis:
|
||||
* The ``attribute`` function is deprecated as of Twig 3.15. Use the ``.``
|
||||
operator instead and wrap the name with parenthesis:
|
||||
|
||||
.. code-block:: twig
|
||||
|
||||
@@ -27,6 +26,8 @@ Functions
|
||||
{{ object.(method)(arguments) }}
|
||||
{{ array[item] }}
|
||||
|
||||
Note that it won't be removed in 4.0 to allow a smoother upgrade path.
|
||||
|
||||
Extensions
|
||||
----------
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
The ``attribute`` filter is deprecated as of Twig 3.15. Use the ``.``
|
||||
operator that now accepts any expression when wrapped with parenthesis.
|
||||
Note that this filter will still be available in Twig 4.0 to allow a
|
||||
smoother upgrade path.
|
||||
|
||||
The ``attribute`` function can be used to access a "dynamic" attribute of a
|
||||
variable:
|
||||
|
||||
@@ -1966,11 +1966,14 @@ final class CoreExtension extends AbstractExtension
|
||||
$fakeFunction = new TwigFunction('attribute', fn ($variable, $attribute, $arguments = null) => null);
|
||||
$args = (new CallableArgumentsExtractor($fakeNode, $fakeFunction))->extractArguments($args);
|
||||
|
||||
/*
|
||||
Deprecation to uncomment sometimes during the lifetime of the 4.x branch
|
||||
$src = $parser->getStream()->getSourceContext();
|
||||
$dep = new DeprecatedCallableInfo('twig/twig', '3.15', 'The "attribute" function is deprecated, use the "." notation instead.');
|
||||
$dep->setName('attribute');
|
||||
$dep->setType('function');
|
||||
$dep->triggerDeprecation($src->getPath() ?: $src->getName(), $line);
|
||||
*/
|
||||
|
||||
return new GetAttrExpression($args[0], $args[1], $args[2] ?? null, Template::ANY_CALL, $line);
|
||||
}
|
||||
|
||||
@@ -1,16 +1,5 @@
|
||||
--TEST--
|
||||
"attribute" function
|
||||
--DEPRECATION--
|
||||
Since twig/twig 3.15: Twig Function "attribute" is deprecated; use "The "attribute" function is deprecated, use the "." notation instead." instead in index.twig at line 2.
|
||||
Since twig/twig 3.15: Twig Function "attribute" is deprecated; use "The "attribute" function is deprecated, use the "." notation instead." instead in index.twig at line 3.
|
||||
Since twig/twig 3.15: Twig Function "attribute" is deprecated; use "The "attribute" function is deprecated, use the "." notation instead." instead in index.twig at line 4.
|
||||
Since twig/twig 3.15: Twig Function "attribute" is deprecated; use "The "attribute" function is deprecated, use the "." notation instead." instead in index.twig at line 5.
|
||||
Since twig/twig 3.15: Twig Function "attribute" is deprecated; use "The "attribute" function is deprecated, use the "." notation instead." instead in index.twig at line 6.
|
||||
Since twig/twig 3.15: Twig Function "attribute" is deprecated; use "The "attribute" function is deprecated, use the "." notation instead." instead in index.twig at line 7.
|
||||
Since twig/twig 3.15: Twig Function "attribute" is deprecated; use "The "attribute" function is deprecated, use the "." notation instead." instead in index.twig at line 8.
|
||||
Since twig/twig 3.15: Twig Function "attribute" is deprecated; use "The "attribute" function is deprecated, use the "." notation instead." instead in index.twig at line 9.
|
||||
Since twig/twig 3.15: Twig Function "attribute" is deprecated; use "The "attribute" function is deprecated, use the "." notation instead." instead in index.twig at line 10.
|
||||
Since twig/twig 3.15: Twig Function "attribute" is deprecated; use "The "attribute" function is deprecated, use the "." notation instead." instead in index.twig at line 11.
|
||||
--TEMPLATE--
|
||||
{{ attribute(obj, method) }}
|
||||
{{ attribute(variable=obj, attribute=method) }}
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
--TEST--
|
||||
"defined" support for attribute
|
||||
--DEPRECATION--
|
||||
Since twig/twig 3.15: Twig Function "attribute" is deprecated; use "The "attribute" function is deprecated, use the "." notation instead." instead in index.twig at line 2.
|
||||
Since twig/twig 3.15: Twig Function "attribute" is deprecated; use "The "attribute" function is deprecated, use the "." notation instead." instead in index.twig at line 3.
|
||||
Since twig/twig 3.15: Twig Function "attribute" is deprecated; use "The "attribute" function is deprecated, use the "." notation instead." instead in index.twig at line 4.
|
||||
Since twig/twig 3.15: Twig Function "attribute" is deprecated; use "The "attribute" function is deprecated, use the "." notation instead." instead in index.twig at line 5.
|
||||
--TEMPLATE--
|
||||
{{ attribute(nested, "definedVar") is defined ? 'ok' : 'ko' }}
|
||||
{{ attribute(nested, "undefinedVar") is not defined ? 'ok' : 'ko' }}
|
||||
|
||||
Reference in New Issue
Block a user