composer update
This commit is contained in:
parent
f6abc3dce2
commit
71dfaca858
1753 changed files with 45274 additions and 14619 deletions
8
vendor/twig/twig/.php_cs.dist
vendored
8
vendor/twig/twig/.php_cs.dist
vendored
|
@ -1,16 +1,16 @@
|
|||
<?php
|
||||
|
||||
return PhpCsFixer\Config::create()
|
||||
->setRules(array(
|
||||
->setRules([
|
||||
'@Symfony' => true,
|
||||
'@Symfony:risky' => true,
|
||||
'array_syntax' => array('syntax' => 'long'),
|
||||
'array_syntax' => ['syntax' => 'short'],
|
||||
'php_unit_fqcn_annotation' => false,
|
||||
'no_unreachable_default_argument_value' => false,
|
||||
'braces' => array('allow_single_line_closure' => true),
|
||||
'braces' => ['allow_single_line_closure' => true],
|
||||
'heredoc_to_nowdoc' => false,
|
||||
'dir_constant' => false,
|
||||
))
|
||||
])
|
||||
->setRiskyAllowed(true)
|
||||
->setFinder(PhpCsFixer\Finder::create()->in(__DIR__))
|
||||
;
|
||||
|
|
14
vendor/twig/twig/.travis.yml
vendored
14
vendor/twig/twig/.travis.yml
vendored
|
@ -14,6 +14,7 @@ php:
|
|||
- 7.0
|
||||
- 7.1
|
||||
- 7.2
|
||||
- 7.3
|
||||
- nightly
|
||||
|
||||
env:
|
||||
|
@ -30,22 +31,11 @@ before_script:
|
|||
- if [ "$TWIG_EXT" == "yes" ]; then sh -c "cd ext/twig && phpize && ./configure --enable-twig && make && make install"; fi
|
||||
- if [ "$TWIG_EXT" == "yes" ]; then echo "extension=twig.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`; fi
|
||||
|
||||
script: |
|
||||
if [[ $TRAVIS_PHP_VERSION = 7.* || $TRAVIS_PHP_VERSION = nightly ]]; then
|
||||
SYMFONY_PHPUNIT_VERSION=6.1 ./vendor/bin/simple-phpunit
|
||||
else
|
||||
./vendor/bin/simple-phpunit
|
||||
fi
|
||||
script: ./vendor/bin/simple-phpunit
|
||||
|
||||
matrix:
|
||||
fast_finish: true
|
||||
include:
|
||||
- php: 5.3
|
||||
dist: precise
|
||||
env: TWIG_EXT=yes
|
||||
- php: 5.3
|
||||
dist: precise
|
||||
env: TWIG_EXT=no
|
||||
- php: 5.4
|
||||
env: TWIG_EXT=yes
|
||||
- php: 5.5
|
||||
|
|
24
vendor/twig/twig/CHANGELOG
vendored
24
vendor/twig/twig/CHANGELOG
vendored
|
@ -1,3 +1,27 @@
|
|||
* 1.37.1 (2019-01-14)
|
||||
|
||||
* fixed regression (key exists check for non ArrayObject objects)
|
||||
* fixed logic in TemplateWrapper
|
||||
|
||||
* 1.37.0 (2019-01-14)
|
||||
|
||||
* fixed ArrayObject access with a null value
|
||||
* fixed embedded templates starting with a BOM
|
||||
* fixed using a Twig_TemplateWrapper instance as an argument to extends
|
||||
* switched generated code to use the PHP short array notation
|
||||
* dropped PHP 5.3 support
|
||||
* fixed float representation in compiled templates
|
||||
* added a second argument to the join filter (last separator configuration)
|
||||
|
||||
* 1.36.0 (2018-12-16)
|
||||
|
||||
* made sure twig_include returns a string
|
||||
* fixed multi-byte UFT-8 in escape('html_attr')
|
||||
* added the "deprecated" tag
|
||||
* added support for dynamically named tests
|
||||
* fixed GlobalsInterface extended class
|
||||
* fixed filesystem loader throwing an exception instead of returning false
|
||||
|
||||
* 1.35.4 (2018-07-13)
|
||||
|
||||
* ensured that syntax errors are triggered with the right line
|
||||
|
|
2
vendor/twig/twig/LICENSE
vendored
2
vendor/twig/twig/LICENSE
vendored
|
@ -1,4 +1,4 @@
|
|||
Copyright (c) 2009-2018 by the Twig Team.
|
||||
Copyright (c) 2009-2019 by the Twig Team.
|
||||
|
||||
Some rights reserved.
|
||||
|
||||
|
|
6
vendor/twig/twig/composer.json
vendored
6
vendor/twig/twig/composer.json
vendored
|
@ -27,11 +27,11 @@
|
|||
"forum": "https://groups.google.com/forum/#!forum/twig-users"
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3",
|
||||
"php": ">=5.4.0",
|
||||
"symfony/polyfill-ctype": "^1.8"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/phpunit-bridge": "^3.3",
|
||||
"symfony/phpunit-bridge": "^3.4.19|^4.1.8",
|
||||
"symfony/debug": "^2.7",
|
||||
"psr/container": "^1.0"
|
||||
},
|
||||
|
@ -45,7 +45,7 @@
|
|||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.35-dev"
|
||||
"dev-master": "1.37-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
91
vendor/twig/twig/doc/advanced.rst
vendored
91
vendor/twig/twig/doc/advanced.rst
vendored
|
@ -137,13 +137,13 @@ Creating a filter is as simple as associating a name with a PHP callable::
|
|||
$filter = new Twig_SimpleFilter('rot13', 'str_rot13');
|
||||
|
||||
// or a class static method
|
||||
$filter = new Twig_SimpleFilter('rot13', array('SomeClass', 'rot13Filter'));
|
||||
$filter = new Twig_SimpleFilter('rot13', ['SomeClass', 'rot13Filter']);
|
||||
$filter = new Twig_SimpleFilter('rot13', 'SomeClass::rot13Filter');
|
||||
|
||||
// or a class method
|
||||
$filter = new Twig_SimpleFilter('rot13', array($this, 'rot13Filter'));
|
||||
$filter = new Twig_SimpleFilter('rot13', [$this, 'rot13Filter']);
|
||||
// the one below needs a runtime implementation (see below for more information)
|
||||
$filter = new Twig_SimpleFilter('rot13', array('SomeClass', 'rot13Filter'));
|
||||
$filter = new Twig_SimpleFilter('rot13', ['SomeClass', 'rot13Filter']);
|
||||
|
||||
The first argument passed to the ``Twig_SimpleFilter`` constructor is the name
|
||||
of the filter you will use in templates and the second one is the PHP callable
|
||||
|
@ -195,7 +195,7 @@ environment as the first argument to the filter call::
|
|||
$charset = $env->getCharset();
|
||||
|
||||
return str_rot13($string);
|
||||
}, array('needs_environment' => true));
|
||||
}, ['needs_environment' => true]);
|
||||
|
||||
Context-aware Filters
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
@ -207,11 +207,11 @@ the first argument to the filter call (or the second one if
|
|||
|
||||
$filter = new Twig_SimpleFilter('rot13', function ($context, $string) {
|
||||
// ...
|
||||
}, array('needs_context' => true));
|
||||
}, ['needs_context' => true]);
|
||||
|
||||
$filter = new Twig_SimpleFilter('rot13', function (Twig_Environment $env, $context, $string) {
|
||||
// ...
|
||||
}, array('needs_context' => true, 'needs_environment' => true));
|
||||
}, ['needs_context' => true, 'needs_environment' => true]);
|
||||
|
||||
Automatic Escaping
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
@ -221,14 +221,14 @@ before printing. If your filter acts as an escaper (or explicitly outputs HTML
|
|||
or JavaScript code), you will want the raw output to be printed. In such a
|
||||
case, set the ``is_safe`` option::
|
||||
|
||||
$filter = new Twig_SimpleFilter('nl2br', 'nl2br', array('is_safe' => array('html')));
|
||||
$filter = new Twig_SimpleFilter('nl2br', 'nl2br', ['is_safe' => ['html']]);
|
||||
|
||||
Some filters may need to work on input that is already escaped or safe, for
|
||||
example when adding (safe) HTML tags to originally unsafe output. In such a
|
||||
case, set the ``pre_escape`` option to escape the input data before it is run
|
||||
through your filter::
|
||||
|
||||
$filter = new Twig_SimpleFilter('somefilter', 'somefilter', array('pre_escape' => 'html', 'is_safe' => array('html')));
|
||||
$filter = new Twig_SimpleFilter('somefilter', 'somefilter', ['pre_escape' => 'html', 'is_safe' => ['html']]);
|
||||
|
||||
Variadic Filters
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
@ -240,9 +240,9 @@ When a filter should accept an arbitrary number of arguments, set the
|
|||
``is_variadic`` option to ``true``; Twig will pass the extra arguments as the
|
||||
last argument to the filter call as an array::
|
||||
|
||||
$filter = new Twig_SimpleFilter('thumbnail', function ($file, array $options = array()) {
|
||||
$filter = new Twig_SimpleFilter('thumbnail', function ($file, array $options = []) {
|
||||
// ...
|
||||
}, array('is_variadic' => true));
|
||||
}, ['is_variadic' => true]);
|
||||
|
||||
Be warned that named arguments passed to a variadic filter cannot be checked
|
||||
for validity as they will automatically end up in the option array.
|
||||
|
@ -285,7 +285,7 @@ deprecated one when that makes sense::
|
|||
|
||||
$filter = new Twig_SimpleFilter('obsolete', function () {
|
||||
// ...
|
||||
}, array('deprecated' => true, 'alternative' => 'new_one'));
|
||||
}, ['deprecated' => true, 'alternative' => 'new_one']);
|
||||
|
||||
When a filter is deprecated, Twig emits a deprecation notice when compiling a
|
||||
template using it. See :ref:`deprecation-notices` for more information.
|
||||
|
@ -343,7 +343,7 @@ This is used by many of the tests built into Twig::
|
|||
$test = new Twig_SimpleTest(
|
||||
'odd',
|
||||
null,
|
||||
array('node_class' => 'Twig_Node_Expression_Test_Odd'));
|
||||
['node_class' => 'Twig_Node_Expression_Test_Odd']);
|
||||
$twig->addTest($test);
|
||||
|
||||
class Twig_Node_Expression_Test_Odd extends Twig_Node_Expression_Test
|
||||
|
@ -371,9 +371,12 @@ The ``node`` sub-node will contain an expression of ``my_value``. Node-based
|
|||
tests also have access to the ``arguments`` node. This node will contain the
|
||||
various other arguments that have been provided to your test.
|
||||
|
||||
.. versionadded:: 1.36
|
||||
Dynamic tests support was added in Twig 1.36.
|
||||
|
||||
If you want to pass a variable number of positional or named arguments to the
|
||||
test, set the ``is_variadic`` option to ``true``. Tests also support dynamic
|
||||
name feature as filters and functions.
|
||||
test, set the ``is_variadic`` option to ``true``. Tests support dynamic
|
||||
names (see dynamic filters and functions for the syntax).
|
||||
|
||||
Tags
|
||||
----
|
||||
|
@ -483,7 +486,7 @@ The ``Project_Set_Node`` class itself is rather simple::
|
|||
{
|
||||
public function __construct($name, Twig_Node_Expression $value, $line, $tag = null)
|
||||
{
|
||||
parent::__construct(array('value' => $value), array('name' => $name), $line, $tag);
|
||||
parent::__construct(['value' => $value], ['name' => $name], $line, $tag);
|
||||
}
|
||||
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
|
@ -658,9 +661,9 @@ method::
|
|||
{
|
||||
public function getGlobals()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
'text' => new Text(),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
// ...
|
||||
|
@ -676,9 +679,9 @@ method::
|
|||
{
|
||||
public function getFunctions()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
new Twig_SimpleFunction('lipsum', 'generate_lipsum'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
// ...
|
||||
|
@ -695,9 +698,9 @@ environment::
|
|||
{
|
||||
public function getFilters()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
new Twig_SimpleFilter('rot13', 'str_rot13'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
// ...
|
||||
|
@ -714,7 +717,7 @@ to the Twig environment::
|
|||
{
|
||||
public function getTokenParsers()
|
||||
{
|
||||
return array(new Project_Set_TokenParser());
|
||||
return [new Project_Set_TokenParser()];
|
||||
}
|
||||
|
||||
// ...
|
||||
|
@ -734,15 +737,15 @@ The ``getOperators()`` methods lets you add new operators. Here is how to add
|
|||
{
|
||||
public function getOperators()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
'!' => array('precedence' => 50, 'class' => 'Twig_Node_Expression_Unary_Not'),
|
||||
),
|
||||
array(
|
||||
'||' => array('precedence' => 10, 'class' => 'Twig_Node_Expression_Binary_Or', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
||||
'&&' => array('precedence' => 15, 'class' => 'Twig_Node_Expression_Binary_And', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
||||
),
|
||||
);
|
||||
return [
|
||||
[
|
||||
'!' => ['precedence' => 50, 'class' => 'Twig_Node_Expression_Unary_Not'],
|
||||
],
|
||||
[
|
||||
'||' => ['precedence' => 10, 'class' => 'Twig_Node_Expression_Binary_Or', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT],
|
||||
'&&' => ['precedence' => 15, 'class' => 'Twig_Node_Expression_Binary_And', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
// ...
|
||||
|
@ -757,9 +760,9 @@ The ``getTests()`` method lets you add new test functions::
|
|||
{
|
||||
public function getTests()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
new Twig_SimpleTest('even', 'twig_test_even'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
// ...
|
||||
|
@ -793,9 +796,9 @@ The simplest way to use methods is to define them on the extension itself::
|
|||
|
||||
public function getFunctions()
|
||||
{
|
||||
return array(
|
||||
new Twig_SimpleFunction('rot13', array($this, 'rot13')),
|
||||
);
|
||||
return [
|
||||
new Twig_SimpleFunction('rot13', [$this, 'rot13']),
|
||||
];
|
||||
}
|
||||
|
||||
public function rot13($value)
|
||||
|
@ -857,11 +860,11 @@ It is now possible to move the runtime logic to a new
|
|||
{
|
||||
public function getFunctions()
|
||||
{
|
||||
return array(
|
||||
new Twig_SimpleFunction('rot13', array('Project_Twig_RuntimeExtension', 'rot13')),
|
||||
return [
|
||||
new Twig_SimpleFunction('rot13', ['Project_Twig_RuntimeExtension', 'rot13']),
|
||||
// or
|
||||
new Twig_SimpleFunction('rot13', 'Project_Twig_RuntimeExtension::rot13'),
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -876,9 +879,9 @@ possible** (order matters)::
|
|||
{
|
||||
public function getFilters()
|
||||
{
|
||||
return array(
|
||||
new Twig_SimpleFilter('date', array($this, 'dateFilter')),
|
||||
);
|
||||
return [
|
||||
new Twig_SimpleFilter('date', [$this, 'dateFilter']),
|
||||
];
|
||||
}
|
||||
|
||||
public function dateFilter($timestamp, $format = 'F j, Y H:i')
|
||||
|
@ -935,10 +938,10 @@ The ``IntegrationTest.php`` file should look like this::
|
|||
{
|
||||
public function getExtensions()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
new Project_Twig_Extension1(),
|
||||
new Project_Twig_Extension2(),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
public function getFixturesDir()
|
||||
|
|
54
vendor/twig/twig/doc/advanced_legacy.rst
vendored
54
vendor/twig/twig/doc/advanced_legacy.rst
vendored
|
@ -227,7 +227,7 @@ The ``Twig_Filter`` classes take options as their last argument. For instance,
|
|||
if you want access to the current environment instance in your filter, set the
|
||||
``needs_environment`` option to ``true``::
|
||||
|
||||
$filter = new Twig_Filter_Function('str_rot13', array('needs_environment' => true));
|
||||
$filter = new Twig_Filter_Function('str_rot13', ['needs_environment' => true]);
|
||||
|
||||
Twig will then pass the current environment as the first argument to the
|
||||
filter call::
|
||||
|
@ -248,14 +248,14 @@ before printing. If your filter acts as an escaper (or explicitly outputs HTML
|
|||
or JavaScript code), you will want the raw output to be printed. In such a
|
||||
case, set the ``is_safe`` option::
|
||||
|
||||
$filter = new Twig_Filter_Function('nl2br', array('is_safe' => array('html')));
|
||||
$filter = new Twig_Filter_Function('nl2br', ['is_safe' => ['html']]);
|
||||
|
||||
Some filters may need to work on input that is already escaped or safe, for
|
||||
example when adding (safe) HTML tags to originally unsafe output. In such a
|
||||
case, set the ``pre_escape`` option to escape the input data before it is run
|
||||
through your filter::
|
||||
|
||||
$filter = new Twig_Filter_Function('somefilter', array('pre_escape' => 'html', 'is_safe' => array('html')));
|
||||
$filter = new Twig_Filter_Function('somefilter', ['pre_escape' => 'html', 'is_safe' => ['html']]);
|
||||
|
||||
Dynamic Filters
|
||||
~~~~~~~~~~~~~~~
|
||||
|
@ -465,7 +465,7 @@ The ``Project_Set_Node`` class itself is rather simple::
|
|||
{
|
||||
public function __construct($name, Twig_Node_Expression $value, $lineno, $tag = null)
|
||||
{
|
||||
parent::__construct(array('value' => $value), array('name' => $name), $lineno, $tag);
|
||||
parent::__construct(['value' => $value], ['name' => $name], $lineno, $tag);
|
||||
}
|
||||
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
|
@ -648,9 +648,9 @@ method::
|
|||
{
|
||||
public function getGlobals()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
'text' => new Text(),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
// ...
|
||||
|
@ -666,9 +666,9 @@ method::
|
|||
{
|
||||
public function getFunctions()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
'lipsum' => new Twig_Function_Function('generate_lipsum'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
// ...
|
||||
|
@ -685,9 +685,9 @@ environment::
|
|||
{
|
||||
public function getFilters()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
'rot13' => new Twig_Filter_Function('str_rot13'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
// ...
|
||||
|
@ -709,9 +709,9 @@ when defining a filter to use a method::
|
|||
{
|
||||
public function getFilters()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
'rot13' => new Twig_Filter_Method($this, 'rot13Filter'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
public function rot13Filter($string)
|
||||
|
@ -741,10 +741,10 @@ want to override::
|
|||
{
|
||||
public function getFilters()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
'date' => new Twig_Filter_Method($this, 'dateFilter'),
|
||||
// ...
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
public function dateFilter($timestamp, $format = 'F j, Y H:i')
|
||||
|
@ -776,7 +776,7 @@ to the Twig environment::
|
|||
{
|
||||
public function getTokenParsers()
|
||||
{
|
||||
return array(new Project_Set_TokenParser());
|
||||
return [new Project_Set_TokenParser()];
|
||||
}
|
||||
|
||||
// ...
|
||||
|
@ -796,15 +796,15 @@ The ``getOperators()`` methods allows to add new operators. Here is how to add
|
|||
{
|
||||
public function getOperators()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
'!' => array('precedence' => 50, 'class' => 'Twig_Node_Expression_Unary_Not'),
|
||||
return [
|
||||
[
|
||||
'!' => ['precedence' => 50, 'class' => 'Twig_Node_Expression_Unary_Not'],
|
||||
),
|
||||
array(
|
||||
'||' => array('precedence' => 10, 'class' => 'Twig_Node_Expression_Binary_Or', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
||||
'&&' => array('precedence' => 15, 'class' => 'Twig_Node_Expression_Binary_And', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
||||
),
|
||||
);
|
||||
[
|
||||
'||' => ['precedence' => 10, 'class' => 'Twig_Node_Expression_Binary_Or', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT],
|
||||
'&&' => ['precedence' => 15, 'class' => 'Twig_Node_Expression_Binary_And', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
// ...
|
||||
|
@ -819,9 +819,9 @@ The ``getTests()`` methods allows to add new test functions::
|
|||
{
|
||||
public function getTests()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
'even' => new Twig_Test_Function('twig_test_even'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
// ...
|
||||
|
@ -857,10 +857,10 @@ The ``IntegrationTest.php`` file should look like this::
|
|||
{
|
||||
public function getExtensions()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
new Project_Twig_Extension1(),
|
||||
new Project_Twig_Extension2(),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
public function getFixturesDir()
|
||||
|
|
50
vendor/twig/twig/doc/api.rst
vendored
50
vendor/twig/twig/doc/api.rst
vendored
|
@ -25,9 +25,9 @@ looks roughly like this::
|
|||
Twig_Autoloader::register();
|
||||
|
||||
$loader = new Twig_Loader_Filesystem('/path/to/templates');
|
||||
$twig = new Twig_Environment($loader, array(
|
||||
$twig = new Twig_Environment($loader, [
|
||||
'cache' => '/path/to/compilation_cache',
|
||||
));
|
||||
]);
|
||||
|
||||
This will create a template environment with the default settings and a loader
|
||||
that looks up the templates in the ``/path/to/templates/`` folder. Different
|
||||
|
@ -58,7 +58,7 @@ returns a ``Twig_TemplateWrapper`` instance::
|
|||
|
||||
To render the template with some variables, call the ``render()`` method::
|
||||
|
||||
echo $template->render(array('the' => 'variables', 'go' => 'here'));
|
||||
echo $template->render(['the' => 'variables', 'go' => 'here']);
|
||||
|
||||
.. note::
|
||||
|
||||
|
@ -66,7 +66,7 @@ To render the template with some variables, call the ``render()`` method::
|
|||
|
||||
You can also load and render the template in one fell swoop::
|
||||
|
||||
echo $twig->render('index.html', array('the' => 'variables', 'go' => 'here'));
|
||||
echo $twig->render('index.html', ['the' => 'variables', 'go' => 'here']);
|
||||
|
||||
.. versionadded:: 1.28
|
||||
The possibility to render blocks from the API was added in Twig 1.28.
|
||||
|
@ -74,7 +74,7 @@ You can also load and render the template in one fell swoop::
|
|||
If a template defines blocks, they can be rendered individually via the
|
||||
``renderBlock()`` call::
|
||||
|
||||
echo $template->renderBlock('block_name', array('the' => 'variables', 'go' => 'here'));
|
||||
echo $template->renderBlock('block_name', ['the' => 'variables', 'go' => 'here']);
|
||||
|
||||
.. _environment_options:
|
||||
|
||||
|
@ -84,7 +84,7 @@ Environment Options
|
|||
When creating a new ``Twig_Environment`` instance, you can pass an array of
|
||||
options as the constructor second argument::
|
||||
|
||||
$twig = new Twig_Environment($loader, array('debug' => true));
|
||||
$twig = new Twig_Environment($loader, ['debug' => true]);
|
||||
|
||||
The following options are available:
|
||||
|
||||
|
@ -183,7 +183,7 @@ load them::
|
|||
|
||||
It can also look for templates in an array of directories::
|
||||
|
||||
$loader = new Twig_Loader_Filesystem(array($templateDir1, $templateDir2));
|
||||
$loader = new Twig_Loader_Filesystem([$templateDir1, $templateDir2]);
|
||||
|
||||
With such a configuration, Twig will first look for templates in
|
||||
``$templateDir1`` and if they do not exist, it will fallback to look for them
|
||||
|
@ -207,7 +207,7 @@ methods act on the "main" namespace)::
|
|||
Namespaced templates can be accessed via the special
|
||||
``@namespace_name/template_path`` notation::
|
||||
|
||||
$twig->render('@admin/index.html', array());
|
||||
$twig->render('@admin/index.html', []);
|
||||
|
||||
``Twig_Loader_Filesystem`` support absolute and relative paths. Using relative
|
||||
paths is preferred as it makes the cache keys independent of the project root
|
||||
|
@ -227,12 +227,12 @@ the directory might be different from the one used on production servers)::
|
|||
``Twig_Loader_Array`` loads a template from a PHP array. It's passed an array
|
||||
of strings bound to template names::
|
||||
|
||||
$loader = new Twig_Loader_Array(array(
|
||||
$loader = new Twig_Loader_Array([
|
||||
'index.html' => 'Hello {{ name }}!',
|
||||
));
|
||||
]);
|
||||
$twig = new Twig_Environment($loader);
|
||||
|
||||
echo $twig->render('index.html', array('name' => 'Fabien'));
|
||||
echo $twig->render('index.html', ['name' => 'Fabien']);
|
||||
|
||||
This loader is very useful for unit testing. It can also be used for small
|
||||
projects where storing all templates in a single PHP file might make sense.
|
||||
|
@ -250,15 +250,15 @@ projects where storing all templates in a single PHP file might make sense.
|
|||
|
||||
``Twig_Loader_Chain`` delegates the loading of templates to other loaders::
|
||||
|
||||
$loader1 = new Twig_Loader_Array(array(
|
||||
$loader1 = new Twig_Loader_Array([
|
||||
'base.html' => '{% block content %}{% endblock %}',
|
||||
));
|
||||
$loader2 = new Twig_Loader_Array(array(
|
||||
]);
|
||||
$loader2 = new Twig_Loader_Array([
|
||||
'index.html' => '{% extends "base.html" %}{% block content %}Hello {{ name }}{% endblock %}',
|
||||
'base.html' => 'Will never be loaded',
|
||||
));
|
||||
]);
|
||||
|
||||
$loader = new Twig_Loader_Chain(array($loader1, $loader2));
|
||||
$loader = new Twig_Loader_Chain([$loader1, $loader2]);
|
||||
|
||||
$twig = new Twig_Environment($loader);
|
||||
|
||||
|
@ -476,15 +476,15 @@ by a policy instance. By default, Twig comes with one policy class:
|
|||
``Twig_Sandbox_SecurityPolicy``. This class allows you to white-list some
|
||||
tags, filters, properties, and methods::
|
||||
|
||||
$tags = array('if');
|
||||
$filters = array('upper');
|
||||
$methods = array(
|
||||
'Article' => array('getTitle', 'getBody'),
|
||||
);
|
||||
$properties = array(
|
||||
'Article' => array('title', 'body'),
|
||||
);
|
||||
$functions = array('range');
|
||||
$tags = ['if'];
|
||||
$filters = ['upper'];
|
||||
$methods = [
|
||||
'Article' => ['getTitle', 'getBody'],
|
||||
];
|
||||
$properties = [
|
||||
'Article' => ['title', 'body'],
|
||||
];
|
||||
$functions = ['range'];
|
||||
$policy = new Twig_Sandbox_SecurityPolicy($tags, $filters, $methods, $properties, $functions);
|
||||
|
||||
With the previous configuration, the security policy will only allow usage of
|
||||
|
|
12
vendor/twig/twig/doc/filters/join.rst
vendored
12
vendor/twig/twig/doc/filters/join.rst
vendored
|
@ -1,6 +1,9 @@
|
|||
``join``
|
||||
========
|
||||
|
||||
.. versionadded:: 1.36.1
|
||||
The ``and`` argument was added in Twig 1.36.1.
|
||||
|
||||
The ``join`` filter returns a string which is the concatenation of the items
|
||||
of a sequence:
|
||||
|
||||
|
@ -16,8 +19,17 @@ define it with the optional first parameter:
|
|||
|
||||
{{ [1, 2, 3]|join('|') }}
|
||||
{# outputs 1|2|3 #}
|
||||
|
||||
A second parameter can also be provided that will be the separator used between
|
||||
the last two items of the sequence:
|
||||
|
||||
.. code-block:: jinja
|
||||
|
||||
{{ [1, 2, 3]|join(', ', ' and ') }}
|
||||
{# outputs 1, 2 and 3 #}
|
||||
|
||||
Arguments
|
||||
---------
|
||||
|
||||
* ``glue``: The separator
|
||||
* ``and``: The separator for the last pair of input items
|
||||
|
|
6
vendor/twig/twig/doc/filters/json_encode.rst
vendored
6
vendor/twig/twig/doc/filters/json_encode.rst
vendored
|
@ -14,8 +14,10 @@ The ``json_encode`` filter returns the JSON representation of a value:
|
|||
Arguments
|
||||
---------
|
||||
|
||||
* ``options``: A bitmask of `json_encode options`_ (``{{
|
||||
data|json_encode(constant('JSON_PRETTY_PRINT')) }}``)
|
||||
* ``options``: A bitmask of `json_encode options`_: ``{{
|
||||
data|json_encode(constant('JSON_PRETTY_PRINT')) }}``.
|
||||
Combine constants using :ref:`bitwise operators<template_logic>`:
|
||||
``{{ data|json_encode(constant('JSON_PRETTY_PRINT') b-or constant('JSON_HEX_QUOT') }}``
|
||||
|
||||
.. _`json_encode`: https://secure.php.net/json_encode
|
||||
.. _`json_encode options`: https://secure.php.net/manual/en/json.constants.php
|
||||
|
|
4
vendor/twig/twig/doc/functions/dump.rst
vendored
4
vendor/twig/twig/doc/functions/dump.rst
vendored
|
@ -18,10 +18,10 @@ introspecting its variables:
|
|||
``Twig_Extension_Debug`` extension explicitly when creating your Twig
|
||||
environment::
|
||||
|
||||
$twig = new Twig_Environment($loader, array(
|
||||
$twig = new Twig_Environment($loader, [
|
||||
'debug' => true,
|
||||
// ...
|
||||
));
|
||||
]);
|
||||
$twig->addExtension(new Twig_Extension_Debug());
|
||||
|
||||
Even when enabled, the ``dump`` function won't display anything if the
|
||||
|
|
2
vendor/twig/twig/doc/functions/include.rst
vendored
2
vendor/twig/twig/doc/functions/include.rst
vendored
|
@ -48,7 +48,7 @@ And if the expression evaluates to a ``Twig_Template`` or a
|
|||
// as of Twig 1.28
|
||||
$template = $twig->load('some_template.twig');
|
||||
|
||||
$twig->display('template.twig', array('template' => $template));
|
||||
$twig->display('template.twig', ['template' => $template]);
|
||||
|
||||
When you set the ``ignore_missing`` flag, Twig will return an empty string if
|
||||
the template does not exist:
|
||||
|
|
1
vendor/twig/twig/doc/installation.rst
vendored
1
vendor/twig/twig/doc/installation.rst
vendored
|
@ -55,6 +55,7 @@ Installing the C extension
|
|||
improvements. Note that the extension is not a replacement for the PHP
|
||||
code; it only implements a small part of the PHP code to improve the
|
||||
performance at runtime; you must still install the regular PHP code.
|
||||
The C extension is only compatible and useful for **PHP5**.
|
||||
|
||||
Twig comes with a C extension that enhances the performance of the Twig
|
||||
runtime engine; install it like any other PHP extensions:
|
||||
|
|
2
vendor/twig/twig/doc/internals.rst
vendored
2
vendor/twig/twig/doc/internals.rst
vendored
|
@ -124,7 +124,7 @@ using)::
|
|||
/* Hello {{ name }} */
|
||||
class __TwigTemplate_1121b6f109fe93ebe8c6e22e3712bceb extends Twig_Template
|
||||
{
|
||||
protected function doDisplay(array $context, array $blocks = array())
|
||||
protected function doDisplay(array $context, array $blocks = [])
|
||||
{
|
||||
// line 1
|
||||
echo "Hello ";
|
||||
|
|
12
vendor/twig/twig/doc/intro.rst
vendored
12
vendor/twig/twig/doc/intro.rst
vendored
|
@ -55,12 +55,12 @@ This section gives you a brief introduction to the PHP API for Twig.
|
|||
|
||||
require_once '/path/to/vendor/autoload.php';
|
||||
|
||||
$loader = new Twig_Loader_Array(array(
|
||||
$loader = new Twig_Loader_Array([
|
||||
'index' => 'Hello {{ name }}!',
|
||||
));
|
||||
]);
|
||||
$twig = new Twig_Environment($loader);
|
||||
|
||||
echo $twig->render('index', array('name' => 'Fabien'));
|
||||
echo $twig->render('index', ['name' => 'Fabien']);
|
||||
|
||||
Twig uses a loader (``Twig_Loader_Array``) to locate templates, and an
|
||||
environment (``Twig_Environment``) to store the configuration.
|
||||
|
@ -72,11 +72,11 @@ As templates are generally stored on the filesystem, Twig also comes with a
|
|||
filesystem loader::
|
||||
|
||||
$loader = new Twig_Loader_Filesystem('/path/to/templates');
|
||||
$twig = new Twig_Environment($loader, array(
|
||||
$twig = new Twig_Environment($loader, [
|
||||
'cache' => '/path/to/compilation_cache',
|
||||
));
|
||||
]);
|
||||
|
||||
echo $twig->render('index.html', array('name' => 'Fabien'));
|
||||
echo $twig->render('index.html', ['name' => 'Fabien']);
|
||||
|
||||
.. tip::
|
||||
|
||||
|
|
84
vendor/twig/twig/doc/recipes.rst
vendored
84
vendor/twig/twig/doc/recipes.rst
vendored
|
@ -38,7 +38,7 @@ However, this code won't find all deprecations (like using deprecated some Twig
|
|||
classes). To catch all notices, register a custom error handler like the one
|
||||
below::
|
||||
|
||||
$deprecations = array();
|
||||
$deprecations = [];
|
||||
set_error_handler(function ($type, $msg) use (&$deprecations) {
|
||||
if (E_USER_DEPRECATED === $type) {
|
||||
$deprecations[] = $msg;
|
||||
|
@ -163,37 +163,37 @@ To change the block delimiters, you need to create your own lexer object::
|
|||
|
||||
$twig = new Twig_Environment();
|
||||
|
||||
$lexer = new Twig_Lexer($twig, array(
|
||||
'tag_comment' => array('{#', '#}'),
|
||||
'tag_block' => array('{%', '%}'),
|
||||
'tag_variable' => array('{{', '}}'),
|
||||
'interpolation' => array('#{', '}'),
|
||||
));
|
||||
$lexer = new Twig_Lexer($twig, [
|
||||
'tag_comment' => ['{#', '#}'],
|
||||
'tag_block' => ['{%', '%}'],
|
||||
'tag_variable' => ['{{', '}}'],
|
||||
'interpolation' => ['#{', '}'],
|
||||
]);
|
||||
$twig->setLexer($lexer);
|
||||
|
||||
Here are some configuration example that simulates some other template engines
|
||||
syntax::
|
||||
|
||||
// Ruby erb syntax
|
||||
$lexer = new Twig_Lexer($twig, array(
|
||||
'tag_comment' => array('<%#', '%>'),
|
||||
'tag_block' => array('<%', '%>'),
|
||||
'tag_variable' => array('<%=', '%>'),
|
||||
));
|
||||
$lexer = new Twig_Lexer($twig, [
|
||||
'tag_comment' => ['<%#', '%>'],
|
||||
'tag_block' => ['<%', '%>'],
|
||||
'tag_variable' => ['<%=', '%>'],
|
||||
]);
|
||||
|
||||
// SGML Comment Syntax
|
||||
$lexer = new Twig_Lexer($twig, array(
|
||||
'tag_comment' => array('<!--#', '-->'),
|
||||
'tag_block' => array('<!--', '-->'),
|
||||
'tag_variable' => array('${', '}'),
|
||||
));
|
||||
$lexer = new Twig_Lexer($twig, [
|
||||
'tag_comment' => ['<!--#', '-->'],
|
||||
'tag_block' => ['<!--', '-->'],
|
||||
'tag_variable' => ['${', '}'],
|
||||
]);
|
||||
|
||||
// Smarty like
|
||||
$lexer = new Twig_Lexer($twig, array(
|
||||
'tag_comment' => array('{*', '*}'),
|
||||
'tag_block' => array('{', '}'),
|
||||
'tag_variable' => array('{$', '}'),
|
||||
));
|
||||
$lexer = new Twig_Lexer($twig, [
|
||||
'tag_comment' => ['{*', '*}'],
|
||||
'tag_block' => ['{', '}'],
|
||||
'tag_variable' => ['{$', '}'],
|
||||
]);
|
||||
|
||||
Using dynamic Object Properties
|
||||
-------------------------------
|
||||
|
@ -233,12 +233,12 @@ Sometimes, when using nested loops, you need to access the parent context. The
|
|||
parent context is always accessible via the ``loop.parent`` variable. For
|
||||
instance, if you have the following template data::
|
||||
|
||||
$data = array(
|
||||
'topics' => array(
|
||||
'topic1' => array('Message 1 of topic 1', 'Message 2 of topic 1'),
|
||||
'topic2' => array('Message 1 of topic 2', 'Message 2 of topic 2'),
|
||||
),
|
||||
);
|
||||
$data = [
|
||||
'topics' => [
|
||||
'topic1' => ['Message 1 of topic 1', 'Message 2 of topic 1'],
|
||||
'topic2' => ['Message 1 of topic 2', 'Message 2 of topic 2'],
|
||||
],
|
||||
];
|
||||
|
||||
And the following template to display all messages in all topics:
|
||||
|
||||
|
@ -345,10 +345,10 @@ cache won't update the cache.
|
|||
|
||||
To get around this, force Twig to invalidate the bytecode cache::
|
||||
|
||||
$twig = new Twig_Environment($loader, array(
|
||||
$twig = new Twig_Environment($loader, [
|
||||
'cache' => new Twig_Cache_Filesystem('/some/cache/path', Twig_Cache_Filesystem::FORCE_BYTECODE_INVALIDATION),
|
||||
// ...
|
||||
));
|
||||
]);
|
||||
|
||||
.. note::
|
||||
|
||||
|
@ -378,13 +378,13 @@ around, you probably want to reset it when visiting a new template.
|
|||
|
||||
This can be easily achieved with the following code::
|
||||
|
||||
protected $someTemplateState = array();
|
||||
protected $someTemplateState = [];
|
||||
|
||||
public function enterNode(Twig_NodeInterface $node, Twig_Environment $env)
|
||||
{
|
||||
if ($node instanceof Twig_Node_Module) {
|
||||
// reset the state as we are entering a new template
|
||||
$this->someTemplateState = array();
|
||||
$this->someTemplateState = [];
|
||||
}
|
||||
|
||||
// ...
|
||||
|
@ -468,7 +468,7 @@ Now, let's define a loader able to use this database::
|
|||
protected function getValue($column, $name)
|
||||
{
|
||||
$sth = $this->dbh->prepare('SELECT '.$column.' FROM templates WHERE name = :name');
|
||||
$sth->execute(array(':name' => (string) $name));
|
||||
$sth->execute([':name' => (string) $name]);
|
||||
|
||||
return $sth->fetchColumn();
|
||||
}
|
||||
|
@ -479,7 +479,7 @@ Finally, here is an example on how you can use it::
|
|||
$loader = new DatabaseTwigLoader($dbh);
|
||||
$twig = new Twig_Environment($loader);
|
||||
|
||||
echo $twig->render('index.twig', array('name' => 'Fabien'));
|
||||
echo $twig->render('index.twig', ['name' => 'Fabien']);
|
||||
|
||||
Using different Template Sources
|
||||
--------------------------------
|
||||
|
@ -496,14 +496,14 @@ filesystem, or any other loader for that matter: the template name should be a
|
|||
logical name, and not the path from the filesystem::
|
||||
|
||||
$loader1 = new DatabaseTwigLoader($dbh);
|
||||
$loader2 = new Twig_Loader_Array(array(
|
||||
$loader2 = new Twig_Loader_Array([
|
||||
'base.twig' => '{% block content %}{% endblock %}',
|
||||
));
|
||||
$loader = new Twig_Loader_Chain(array($loader1, $loader2));
|
||||
]);
|
||||
$loader = new Twig_Loader_Chain([$loader1, $loader2]);
|
||||
|
||||
$twig = new Twig_Environment($loader);
|
||||
|
||||
echo $twig->render('index.twig', array('name' => 'Fabien'));
|
||||
echo $twig->render('index.twig', ['name' => 'Fabien']);
|
||||
|
||||
Now that the ``base.twig`` templates is defined in an array loader, you can
|
||||
remove it from the database, and everything else will still work as before.
|
||||
|
@ -523,7 +523,7 @@ From PHP, it's also possible to load a template stored in a string via
|
|||
``Twig_Environment::createTemplate()`` (available as of Twig 1.18)::
|
||||
|
||||
$template = $twig->createTemplate('hello {{ name }}');
|
||||
echo $template->render(array('name' => 'Fabien'));
|
||||
echo $template->render(['name' => 'Fabien']);
|
||||
|
||||
.. note::
|
||||
|
||||
|
@ -561,8 +561,8 @@ include in your templates:
|
|||
|
||||
.. code-block:: php
|
||||
|
||||
$env->setLexer(new Twig_Lexer($env, array(
|
||||
'tag_variable' => array('{[', ']}'),
|
||||
)));
|
||||
$env->setLexer(new Twig_Lexer($env, [
|
||||
'tag_variable' => ['{[', ']}'],
|
||||
]));
|
||||
|
||||
.. _callback: https://secure.php.net/manual/en/function.is-callable.php
|
||||
|
|
30
vendor/twig/twig/doc/tags/deprecated.rst
vendored
Normal file
30
vendor/twig/twig/doc/tags/deprecated.rst
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
``deprecated``
|
||||
==============
|
||||
|
||||
.. versionadded:: 1.36 and 2.6
|
||||
The ``deprecated`` tag was added in Twig 1.36 and 2.6.
|
||||
|
||||
Twig generates a deprecation notice (via a call to the ``trigger_error()``
|
||||
PHP function) where the ``deprecated`` tag is used in a template:
|
||||
|
||||
.. code-block:: jinja
|
||||
|
||||
{# base.twig #}
|
||||
{% deprecated 'The "base.twig" template is deprecated, use "layout.twig" instead.' %}
|
||||
{% extends 'layout.twig' %}
|
||||
|
||||
Also you can deprecate a block in the following way:
|
||||
|
||||
.. code-block:: jinja
|
||||
|
||||
{% block hey %}
|
||||
{% deprecated 'The "hey" block is deprecated, use "greet" instead.' %}
|
||||
{{ block('greet') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block greet %}
|
||||
Hey you!
|
||||
{% endblock %}
|
||||
|
||||
Note that by default, the deprecation notices are silenced and never displayed nor logged.
|
||||
See :ref:`deprecation-notices` to learn how to handle them.
|
2
vendor/twig/twig/doc/tags/extends.rst
vendored
2
vendor/twig/twig/doc/tags/extends.rst
vendored
|
@ -164,7 +164,7 @@ instance, Twig will use it as the parent template::
|
|||
// as of Twig 1.28
|
||||
$layout = $twig->load('some_layout_template.twig');
|
||||
|
||||
$twig->display('template.twig', array('layout' => $layout));
|
||||
$twig->display('template.twig', ['layout' => $layout]);
|
||||
|
||||
.. versionadded:: 1.2
|
||||
The possibility to pass an array of templates has been added in Twig 1.2.
|
||||
|
|
10
vendor/twig/twig/doc/tags/if.rst
vendored
10
vendor/twig/twig/doc/tags/if.rst
vendored
|
@ -50,12 +50,12 @@ use more complex ``expressions`` there too:
|
|||
|
||||
.. code-block:: jinja
|
||||
|
||||
{% if kenny.sick %}
|
||||
Kenny is sick.
|
||||
{% elseif kenny.dead %}
|
||||
You killed Kenny! You bastard!!!
|
||||
{% if product.stock > 10 %}
|
||||
Available
|
||||
{% elseif product.stock > 0 %}
|
||||
Only {{ product.stock }} left!
|
||||
{% else %}
|
||||
Kenny looks okay --- so far
|
||||
Sold-out!
|
||||
{% endif %}
|
||||
|
||||
.. note::
|
||||
|
|
2
vendor/twig/twig/doc/tags/include.rst
vendored
2
vendor/twig/twig/doc/tags/include.rst
vendored
|
@ -61,7 +61,7 @@ And if the expression evaluates to a ``Twig_Template`` or a
|
|||
// as of Twig 1.28
|
||||
$template = $twig->load('some_template.twig');
|
||||
|
||||
$twig->display('template.twig', array('template' => $template));
|
||||
$twig->display('template.twig', ['template' => $template]);
|
||||
|
||||
.. versionadded:: 1.2
|
||||
The ``ignore missing`` feature has been added in Twig 1.2.
|
||||
|
|
1
vendor/twig/twig/doc/tags/index.rst
vendored
1
vendor/twig/twig/doc/tags/index.rst
vendored
|
@ -23,3 +23,4 @@ Tags
|
|||
use
|
||||
verbatim
|
||||
with
|
||||
deprecated
|
||||
|
|
15
vendor/twig/twig/doc/templates.rst
vendored
15
vendor/twig/twig/doc/templates.rst
vendored
|
@ -555,11 +555,12 @@ even if you're not working with PHP you should feel comfortable with it.
|
|||
|
||||
.. note::
|
||||
|
||||
The operator precedence is as follows, with the lowest-precedence
|
||||
operators listed first: ``b-and``, ``b-xor``, ``b-or``, ``or``, ``and``,
|
||||
``==``, ``!=``, ``<``, ``>``, ``>=``, ``<=``, ``in``, ``matches``,
|
||||
``starts with``, ``ends with``, ``..``, ``+``, ``-``, ``~``, ``*``, ``/``,
|
||||
``//``, ``%``, ``is``, ``**``, ``|``, ``[]``, and ``.``:
|
||||
The operator precedence is as follows, with the lowest-precedence operators
|
||||
listed first: ``?:`` (ternary operator), ``b-and``, ``b-xor``, ``b-or``,
|
||||
``or``, ``and``, ``==``, ``!=``, ``<``, ``>``, ``>=``, ``<=``, ``in``,
|
||||
``matches``, ``starts with``, ``ends with``, ``..``, ``+``, ``-``, ``~``,
|
||||
``*``, ``/``, ``//``, ``%``, ``is`` (tests), ``**``, ``??``, ``|``
|
||||
(filters), ``[]``, and ``.``.
|
||||
|
||||
.. code-block:: jinja
|
||||
|
||||
|
@ -659,6 +660,8 @@ but exists for completeness' sake. The following operators are supported:
|
|||
* ``**``: Raises the left operand to the power of the right operand. ``{{ 2 **
|
||||
3 }}`` would return ``8``.
|
||||
|
||||
.. _template_logic:
|
||||
|
||||
Logic
|
||||
~~~~~
|
||||
|
||||
|
@ -674,7 +677,7 @@ You can combine multiple expressions with the following operators:
|
|||
|
||||
.. note::
|
||||
|
||||
Twig also support bitwise operators (``b-and``, ``b-xor``, and ``b-or``).
|
||||
Twig also supports bitwise operators (``b-and``, ``b-xor``, and ``b-or``).
|
||||
|
||||
.. note::
|
||||
|
||||
|
|
2
vendor/twig/twig/ext/twig/php_twig.h
vendored
2
vendor/twig/twig/ext/twig/php_twig.h
vendored
|
@ -15,7 +15,7 @@
|
|||
#ifndef PHP_TWIG_H
|
||||
#define PHP_TWIG_H
|
||||
|
||||
#define PHP_TWIG_VERSION "1.35.4-DEV"
|
||||
#define PHP_TWIG_VERSION "1.37.1"
|
||||
|
||||
#include "php.h"
|
||||
|
||||
|
|
4
vendor/twig/twig/ext/twig/twig.c
vendored
4
vendor/twig/twig/ext/twig/twig.c
vendored
|
@ -959,7 +959,7 @@ PHP_FUNCTION(twig_template_get_attributes)
|
|||
if (!isset(self::$cache[$class]['methods'])) {
|
||||
if ($object instanceof self) {
|
||||
$ref = new ReflectionClass($class);
|
||||
$methods = array();
|
||||
$methods = [];
|
||||
|
||||
foreach ($ref->getMethods(ReflectionMethod::IS_PUBLIC) as $refMethod) {
|
||||
$methodName = strtolower($refMethod->name);
|
||||
|
@ -1081,7 +1081,7 @@ PHP_FUNCTION(twig_template_get_attributes)
|
|||
// Some objects throw exceptions when they have __call, and the method we try
|
||||
// to call is not supported. If ignoreStrictCheck is true, we should return null.
|
||||
try {
|
||||
$ret = call_user_func_array(array($object, $method), $arguments);
|
||||
$ret = call_user_func_array([$object, $method], $arguments);
|
||||
} catch (BadMethodCallException $e) {
|
||||
if ($call && ($ignoreStrictCheck || !$this->env->isStrictVariables())) {
|
||||
return null;
|
||||
|
|
8
vendor/twig/twig/lib/Twig/Autoloader.php
vendored
8
vendor/twig/twig/lib/Twig/Autoloader.php
vendored
|
@ -29,11 +29,7 @@ class Twig_Autoloader
|
|||
{
|
||||
@trigger_error('Using Twig_Autoloader is deprecated since version 1.21. Use Composer instead.', E_USER_DEPRECATED);
|
||||
|
||||
if (PHP_VERSION_ID < 50300) {
|
||||
spl_autoload_register(array(__CLASS__, 'autoload'));
|
||||
} else {
|
||||
spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend);
|
||||
}
|
||||
spl_autoload_register([__CLASS__, 'autoload'], true, $prepend);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -47,7 +43,7 @@ class Twig_Autoloader
|
|||
return;
|
||||
}
|
||||
|
||||
if (is_file($file = dirname(__FILE__).'/../'.str_replace(array('_', "\0"), array('/', ''), $class).'.php')) {
|
||||
if (is_file($file = dirname(__FILE__).'/../'.str_replace(['_', "\0"], ['/', ''], $class).'.php')) {
|
||||
require $file;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,9 +50,7 @@ class Twig_Cache_Filesystem implements Twig_CacheInterface
|
|||
$dir = dirname($key);
|
||||
if (!is_dir($dir)) {
|
||||
if (false === @mkdir($dir, 0777, true)) {
|
||||
if (PHP_VERSION_ID >= 50300) {
|
||||
clearstatcache(true, $dir);
|
||||
}
|
||||
clearstatcache(true, $dir);
|
||||
if (!is_dir($dir)) {
|
||||
throw new RuntimeException(sprintf('Unable to create the cache directory (%s).', $dir));
|
||||
}
|
||||
|
|
10
vendor/twig/twig/lib/Twig/Compiler.php
vendored
10
vendor/twig/twig/lib/Twig/Compiler.php
vendored
|
@ -21,7 +21,7 @@ class Twig_Compiler implements Twig_CompilerInterface
|
|||
protected $source;
|
||||
protected $indentation;
|
||||
protected $env;
|
||||
protected $debugInfo = array();
|
||||
protected $debugInfo = [];
|
||||
protected $sourceOffset;
|
||||
protected $sourceLine;
|
||||
protected $filename;
|
||||
|
@ -74,7 +74,7 @@ class Twig_Compiler implements Twig_CompilerInterface
|
|||
{
|
||||
$this->lastLine = null;
|
||||
$this->source = '';
|
||||
$this->debugInfo = array();
|
||||
$this->debugInfo = [];
|
||||
$this->sourceOffset = 0;
|
||||
// source code starts at 1 (as we then increment it when we encounter new lines)
|
||||
$this->sourceLine = 1;
|
||||
|
@ -175,7 +175,7 @@ class Twig_Compiler implements Twig_CompilerInterface
|
|||
setlocale(LC_NUMERIC, 'C');
|
||||
}
|
||||
|
||||
$this->raw($value);
|
||||
$this->raw(var_export($value, true));
|
||||
|
||||
if (false !== $locale) {
|
||||
setlocale(LC_NUMERIC, $locale);
|
||||
|
@ -185,7 +185,7 @@ class Twig_Compiler implements Twig_CompilerInterface
|
|||
} elseif (is_bool($value)) {
|
||||
$this->raw($value ? 'true' : 'false');
|
||||
} elseif (is_array($value)) {
|
||||
$this->raw('array(');
|
||||
$this->raw('[');
|
||||
$first = true;
|
||||
foreach ($value as $key => $v) {
|
||||
if (!$first) {
|
||||
|
@ -196,7 +196,7 @@ class Twig_Compiler implements Twig_CompilerInterface
|
|||
$this->raw(' => ');
|
||||
$this->repr($v);
|
||||
}
|
||||
$this->raw(')');
|
||||
$this->raw(']');
|
||||
} else {
|
||||
$this->string($value);
|
||||
}
|
||||
|
|
77
vendor/twig/twig/lib/Twig/Environment.php
vendored
77
vendor/twig/twig/lib/Twig/Environment.php
vendored
|
@ -16,11 +16,11 @@
|
|||
*/
|
||||
class Twig_Environment
|
||||
{
|
||||
const VERSION = '1.35.4';
|
||||
const VERSION_ID = 13504;
|
||||
const VERSION = '1.37.1';
|
||||
const VERSION_ID = 13701;
|
||||
const MAJOR_VERSION = 1;
|
||||
const MINOR_VERSION = 35;
|
||||
const RELEASE_VERSION = 4;
|
||||
const MINOR_VERSION = 37;
|
||||
const RELEASE_VERSION = 1;
|
||||
const EXTRA_VERSION = '';
|
||||
|
||||
protected $charset;
|
||||
|
@ -46,19 +46,19 @@ class Twig_Environment
|
|||
protected $unaryOperators;
|
||||
protected $binaryOperators;
|
||||
protected $templateClassPrefix = '__TwigTemplate_';
|
||||
protected $functionCallbacks = array();
|
||||
protected $filterCallbacks = array();
|
||||
protected $functionCallbacks = [];
|
||||
protected $filterCallbacks = [];
|
||||
protected $staging;
|
||||
|
||||
private $originalCache;
|
||||
private $bcWriteCacheFile = false;
|
||||
private $bcGetCacheFilename = false;
|
||||
private $lastModifiedExtension = 0;
|
||||
private $extensionsByClass = array();
|
||||
private $runtimeLoaders = array();
|
||||
private $runtimes = array();
|
||||
private $extensionsByClass = [];
|
||||
private $runtimeLoaders = [];
|
||||
private $runtimes = [];
|
||||
private $optionsHash;
|
||||
private $loading = array();
|
||||
private $loading = [];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
@ -98,7 +98,7 @@ class Twig_Environment
|
|||
* @param Twig_LoaderInterface $loader
|
||||
* @param array $options An array of options
|
||||
*/
|
||||
public function __construct(Twig_LoaderInterface $loader = null, $options = array())
|
||||
public function __construct(Twig_LoaderInterface $loader = null, $options = [])
|
||||
{
|
||||
if (null !== $loader) {
|
||||
$this->setLoader($loader);
|
||||
|
@ -106,7 +106,7 @@ class Twig_Environment
|
|||
@trigger_error('Not passing a Twig_LoaderInterface as the first constructor argument of Twig_Environment is deprecated since version 1.21.', E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
$options = array_merge(array(
|
||||
$options = array_merge([
|
||||
'debug' => false,
|
||||
'charset' => 'UTF-8',
|
||||
'base_template_class' => 'Twig_Template',
|
||||
|
@ -115,7 +115,7 @@ class Twig_Environment
|
|||
'cache' => false,
|
||||
'auto_reload' => null,
|
||||
'optimizations' => -1,
|
||||
), $options);
|
||||
], $options);
|
||||
|
||||
$this->debug = (bool) $options['debug'];
|
||||
$this->charset = strtoupper($options['charset']);
|
||||
|
@ -358,7 +358,7 @@ class Twig_Environment
|
|||
* @throws Twig_Error_Syntax When an error occurred during compilation
|
||||
* @throws Twig_Error_Runtime When an error occurred during rendering
|
||||
*/
|
||||
public function render($name, array $context = array())
|
||||
public function render($name, array $context = [])
|
||||
{
|
||||
return $this->loadTemplate($name)->render($context);
|
||||
}
|
||||
|
@ -373,7 +373,7 @@ class Twig_Environment
|
|||
* @throws Twig_Error_Syntax When an error occurred during compilation
|
||||
* @throws Twig_Error_Runtime When an error occurred during rendering
|
||||
*/
|
||||
public function display($name, array $context = array())
|
||||
public function display($name, array $context = [])
|
||||
{
|
||||
$this->loadTemplate($name)->display($context);
|
||||
}
|
||||
|
@ -478,7 +478,7 @@ class Twig_Environment
|
|||
}
|
||||
|
||||
if (isset($this->loading[$cls])) {
|
||||
throw new Twig_Error_Runtime(sprintf('Circular reference detected for Twig template "%s", path: %s.', $name, implode(' -> ', array_merge($this->loading, array($name)))));
|
||||
throw new Twig_Error_Runtime(sprintf('Circular reference detected for Twig template "%s", path: %s.', $name, implode(' -> ', array_merge($this->loading, [$name]))));
|
||||
}
|
||||
|
||||
$this->loading[$cls] = $name;
|
||||
|
@ -511,10 +511,10 @@ class Twig_Environment
|
|||
{
|
||||
$name = sprintf('__string_template__%s', hash('sha256', $template, false));
|
||||
|
||||
$loader = new Twig_Loader_Chain(array(
|
||||
new Twig_Loader_Array(array($name => $template)),
|
||||
$loader = new Twig_Loader_Chain([
|
||||
new Twig_Loader_Array([$name => $template]),
|
||||
$current = $this->getLoader(),
|
||||
));
|
||||
]);
|
||||
|
||||
$this->setLoader($loader);
|
||||
try {
|
||||
|
@ -575,7 +575,7 @@ class Twig_Environment
|
|||
public function resolveTemplate($names)
|
||||
{
|
||||
if (!is_array($names)) {
|
||||
$names = array($names);
|
||||
$names = [$names];
|
||||
}
|
||||
|
||||
foreach ($names as $name) {
|
||||
|
@ -609,7 +609,7 @@ class Twig_Environment
|
|||
{
|
||||
@trigger_error(sprintf('The %s method is deprecated since version 1.18.3 and will be removed in Twig 2.0.', __METHOD__), E_USER_DEPRECATED);
|
||||
|
||||
$this->loadedTemplates = array();
|
||||
$this->loadedTemplates = [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1049,7 +1049,7 @@ class Twig_Environment
|
|||
*/
|
||||
public function getTags()
|
||||
{
|
||||
$tags = array();
|
||||
$tags = [];
|
||||
foreach ($this->getTokenParsers()->getParsers() as $parser) {
|
||||
if ($parser instanceof Twig_TokenParserInterface) {
|
||||
$tags[$parser->getTag()] = $parser;
|
||||
|
@ -1240,6 +1240,19 @@ class Twig_Environment
|
|||
return $this->tests[$name];
|
||||
}
|
||||
|
||||
foreach ($this->tests as $pattern => $test) {
|
||||
$pattern = str_replace('\\*', '(.*?)', preg_quote($pattern, '#'), $count);
|
||||
|
||||
if ($count) {
|
||||
if (preg_match('#^'.$pattern.'$#', $name, $matches)) {
|
||||
array_shift($matches);
|
||||
$test->setArguments($matches);
|
||||
|
||||
return $test;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1456,7 +1469,7 @@ class Twig_Environment
|
|||
*/
|
||||
protected function initGlobals()
|
||||
{
|
||||
$globals = array();
|
||||
$globals = [];
|
||||
foreach ($this->extensions as $name => $extension) {
|
||||
if (!$extension instanceof Twig_Extension_GlobalsInterface) {
|
||||
$m = new ReflectionMethod($extension, 'getGlobals');
|
||||
|
@ -1488,13 +1501,13 @@ class Twig_Environment
|
|||
return;
|
||||
}
|
||||
|
||||
$this->parsers = new Twig_TokenParserBroker(array(), array(), false);
|
||||
$this->filters = array();
|
||||
$this->functions = array();
|
||||
$this->tests = array();
|
||||
$this->visitors = array();
|
||||
$this->unaryOperators = array();
|
||||
$this->binaryOperators = array();
|
||||
$this->parsers = new Twig_TokenParserBroker([], [], false);
|
||||
$this->filters = [];
|
||||
$this->functions = [];
|
||||
$this->tests = [];
|
||||
$this->visitors = [];
|
||||
$this->unaryOperators = [];
|
||||
$this->binaryOperators = [];
|
||||
|
||||
foreach ($this->extensions as $extension) {
|
||||
$this->initExtension($extension);
|
||||
|
@ -1587,7 +1600,7 @@ class Twig_Environment
|
|||
{
|
||||
$hashParts = array_merge(
|
||||
array_keys($this->extensions),
|
||||
array(
|
||||
[
|
||||
(int) function_exists('twig_template_get_attributes'),
|
||||
PHP_MAJOR_VERSION,
|
||||
PHP_MINOR_VERSION,
|
||||
|
@ -1595,7 +1608,7 @@ class Twig_Environment
|
|||
(int) $this->debug,
|
||||
$this->baseTemplateClass,
|
||||
(int) $this->strictVariables,
|
||||
)
|
||||
]
|
||||
);
|
||||
$this->optionsHash = implode(':', $hashParts);
|
||||
}
|
||||
|
|
40
vendor/twig/twig/lib/Twig/Error.php
vendored
40
vendor/twig/twig/lib/Twig/Error.php
vendored
|
@ -37,7 +37,6 @@ class Twig_Error extends Exception
|
|||
// to be renamed to name in 2.0
|
||||
protected $filename;
|
||||
protected $rawMessage;
|
||||
protected $previous;
|
||||
|
||||
private $sourcePath;
|
||||
private $sourceCode;
|
||||
|
@ -71,12 +70,7 @@ class Twig_Error extends Exception
|
|||
$this->sourceCode = $source->getCode();
|
||||
$this->sourcePath = $source->getPath();
|
||||
}
|
||||
if (PHP_VERSION_ID < 50300) {
|
||||
$this->previous = $previous;
|
||||
parent::__construct('');
|
||||
} else {
|
||||
parent::__construct('', 0, $previous);
|
||||
}
|
||||
parent::__construct('', 0, $previous);
|
||||
|
||||
$this->lineno = $lineno;
|
||||
$this->filename = $name;
|
||||
|
@ -215,25 +209,6 @@ class Twig_Error extends Exception
|
|||
$this->updateRepr();
|
||||
}
|
||||
|
||||
/**
|
||||
* For PHP < 5.3.0, provides access to the getPrevious() method.
|
||||
*
|
||||
* @param string $method The method name
|
||||
* @param array $arguments The parameters to be passed to the method
|
||||
*
|
||||
* @return Exception The previous exception or null
|
||||
*
|
||||
* @throws BadMethodCallException
|
||||
*/
|
||||
public function __call($method, $arguments)
|
||||
{
|
||||
if ('getprevious' == strtolower($method)) {
|
||||
return $this->previous;
|
||||
}
|
||||
|
||||
throw new BadMethodCallException(sprintf('Method "Twig_Error::%s()" does not exist.', $method));
|
||||
}
|
||||
|
||||
public function appendMessage($rawMessage)
|
||||
{
|
||||
$this->rawMessage .= $rawMessage;
|
||||
|
@ -296,12 +271,7 @@ class Twig_Error extends Exception
|
|||
$template = null;
|
||||
$templateClass = null;
|
||||
|
||||
if (PHP_VERSION_ID >= 50306) {
|
||||
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS | DEBUG_BACKTRACE_PROVIDE_OBJECT);
|
||||
} else {
|
||||
$backtrace = debug_backtrace();
|
||||
}
|
||||
|
||||
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS | DEBUG_BACKTRACE_PROVIDE_OBJECT);
|
||||
foreach ($backtrace as $trace) {
|
||||
if (isset($trace['object']) && $trace['object'] instanceof Twig_Template && 'Twig_Template' !== get_class($trace['object'])) {
|
||||
$currentClass = get_class($trace['object']);
|
||||
|
@ -332,14 +302,14 @@ class Twig_Error extends Exception
|
|||
$r = new ReflectionObject($template);
|
||||
$file = $r->getFileName();
|
||||
|
||||
$exceptions = array($e = $this);
|
||||
while (($e instanceof self || method_exists($e, 'getPrevious')) && $e = $e->getPrevious()) {
|
||||
$exceptions = [$e = $this];
|
||||
while ($e instanceof self && $e = $e->getPrevious()) {
|
||||
$exceptions[] = $e;
|
||||
}
|
||||
|
||||
while ($e = array_pop($exceptions)) {
|
||||
$traces = $e->getTrace();
|
||||
array_unshift($traces, array('file' => $e->getFile(), 'line' => $e->getLine()));
|
||||
array_unshift($traces, ['file' => $e->getFile(), 'line' => $e->getLine()]);
|
||||
|
||||
while ($trace = array_shift($traces)) {
|
||||
if (!isset($trace['file']) || !isset($trace['line']) || $file != $trace['file']) {
|
||||
|
|
8
vendor/twig/twig/lib/Twig/Error/Loader.php
vendored
8
vendor/twig/twig/lib/Twig/Error/Loader.php
vendored
|
@ -26,12 +26,8 @@ class Twig_Error_Loader extends Twig_Error
|
|||
{
|
||||
public function __construct($message, $lineno = -1, $source = null, Exception $previous = null)
|
||||
{
|
||||
if (PHP_VERSION_ID < 50300) {
|
||||
$this->previous = $previous;
|
||||
Exception::__construct('');
|
||||
} else {
|
||||
Exception::__construct('', 0, $previous);
|
||||
}
|
||||
Exception::__construct('', 0, $previous);
|
||||
|
||||
$this->appendMessage($message);
|
||||
$this->setTemplateLine(false);
|
||||
}
|
||||
|
|
2
vendor/twig/twig/lib/Twig/Error/Syntax.php
vendored
2
vendor/twig/twig/lib/Twig/Error/Syntax.php
vendored
|
@ -39,7 +39,7 @@ class Twig_Error_Syntax extends Twig_Error
|
|||
*/
|
||||
public static function computeAlternatives($name, $items)
|
||||
{
|
||||
$alternatives = array();
|
||||
$alternatives = [];
|
||||
foreach ($items as $item) {
|
||||
$lev = levenshtein($name, $item);
|
||||
if ($lev <= strlen($name) / 3 || false !== strpos($item, $name)) {
|
||||
|
|
26
vendor/twig/twig/lib/Twig/ExpressionParser.php
vendored
26
vendor/twig/twig/lib/Twig/ExpressionParser.php
vendored
|
@ -188,7 +188,7 @@ class Twig_ExpressionParser
|
|||
$ref = new ReflectionClass($class);
|
||||
$negClass = 'Twig_Node_Expression_Unary_Neg';
|
||||
$posClass = 'Twig_Node_Expression_Unary_Pos';
|
||||
if (!(in_array($ref->getName(), array($negClass, $posClass)) || $ref->isSubclassOf($negClass) || $ref->isSubclassOf($posClass))) {
|
||||
if (!(in_array($ref->getName(), [$negClass, $posClass]) || $ref->isSubclassOf($negClass) || $ref->isSubclassOf($posClass))) {
|
||||
throw new Twig_Error_Syntax(sprintf('Unexpected unary operator "%s".', $token->getValue()), $token->getLine(), $this->parser->getStream()->getSourceContext());
|
||||
}
|
||||
|
||||
|
@ -219,7 +219,7 @@ class Twig_ExpressionParser
|
|||
{
|
||||
$stream = $this->parser->getStream();
|
||||
|
||||
$nodes = array();
|
||||
$nodes = [];
|
||||
// a string cannot be followed by another string in a single expression
|
||||
$nextCanBeString = true;
|
||||
while (true) {
|
||||
|
@ -248,7 +248,7 @@ class Twig_ExpressionParser
|
|||
$stream = $this->parser->getStream();
|
||||
$stream->expect(Twig_Token::PUNCTUATION_TYPE, '[', 'An array element was expected');
|
||||
|
||||
$node = new Twig_Node_Expression_Array(array(), $stream->getCurrent()->getLine());
|
||||
$node = new Twig_Node_Expression_Array([], $stream->getCurrent()->getLine());
|
||||
$first = true;
|
||||
while (!$stream->test(Twig_Token::PUNCTUATION_TYPE, ']')) {
|
||||
if (!$first) {
|
||||
|
@ -273,7 +273,7 @@ class Twig_ExpressionParser
|
|||
$stream = $this->parser->getStream();
|
||||
$stream->expect(Twig_Token::PUNCTUATION_TYPE, '{', 'A hash element was expected');
|
||||
|
||||
$node = new Twig_Node_Expression_Array(array(), $stream->getCurrent()->getLine());
|
||||
$node = new Twig_Node_Expression_Array([], $stream->getCurrent()->getLine());
|
||||
$first = true;
|
||||
while (!$stream->test(Twig_Token::PUNCTUATION_TYPE, '}')) {
|
||||
if (!$first) {
|
||||
|
@ -362,7 +362,7 @@ class Twig_ExpressionParser
|
|||
return new Twig_Node_Expression_GetAttr($args->getNode(0), $args->getNode(1), count($args) > 2 ? $args->getNode(2) : null, Twig_Template::ANY_CALL, $line);
|
||||
default:
|
||||
if (null !== $alias = $this->parser->getImportedSymbol('function', $name)) {
|
||||
$arguments = new Twig_Node_Expression_Array(array(), $line);
|
||||
$arguments = new Twig_Node_Expression_Array([], $line);
|
||||
foreach ($this->parseArguments() as $n) {
|
||||
$arguments->addElement($n);
|
||||
}
|
||||
|
@ -385,7 +385,7 @@ class Twig_ExpressionParser
|
|||
$stream = $this->parser->getStream();
|
||||
$token = $stream->next();
|
||||
$lineno = $token->getLine();
|
||||
$arguments = new Twig_Node_Expression_Array(array(), $lineno);
|
||||
$arguments = new Twig_Node_Expression_Array([], $lineno);
|
||||
$type = Twig_Template::ANY_CALL;
|
||||
if ('.' == $token->getValue()) {
|
||||
$token = $stream->next();
|
||||
|
@ -448,7 +448,7 @@ class Twig_ExpressionParser
|
|||
}
|
||||
|
||||
$class = $this->getFilterNodeClass('slice', $token->getLine());
|
||||
$arguments = new Twig_Node(array($arg, $length));
|
||||
$arguments = new Twig_Node([$arg, $length]);
|
||||
$filter = new $class($node, new Twig_Node_Expression_Constant('slice', $token->getLine()), $arguments, $token->getLine());
|
||||
|
||||
$stream->expect(Twig_Token::PUNCTUATION_TYPE, ']');
|
||||
|
@ -507,7 +507,7 @@ class Twig_ExpressionParser
|
|||
*/
|
||||
public function parseArguments($namedArguments = false, $definition = false)
|
||||
{
|
||||
$args = array();
|
||||
$args = [];
|
||||
$stream = $this->parser->getStream();
|
||||
|
||||
$stream->expect(Twig_Token::PUNCTUATION_TYPE, '(', 'A list of arguments must begin with an opening parenthesis');
|
||||
|
@ -563,11 +563,11 @@ class Twig_ExpressionParser
|
|||
public function parseAssignmentExpression()
|
||||
{
|
||||
$stream = $this->parser->getStream();
|
||||
$targets = array();
|
||||
$targets = [];
|
||||
while (true) {
|
||||
$token = $stream->expect(Twig_Token::NAME_TYPE, null, 'Only variables can be assigned to');
|
||||
$value = $token->getValue();
|
||||
if (in_array(strtolower($value), array('true', 'false', 'none', 'null'))) {
|
||||
if (in_array(strtolower($value), ['true', 'false', 'none', 'null'])) {
|
||||
throw new Twig_Error_Syntax(sprintf('You cannot assign a value to "%s".', $value), $token->getLine(), $stream->getSourceContext());
|
||||
}
|
||||
$targets[] = new Twig_Node_Expression_AssignName($value, $token->getLine());
|
||||
|
@ -582,7 +582,7 @@ class Twig_ExpressionParser
|
|||
|
||||
public function parseMultitargetExpression()
|
||||
{
|
||||
$targets = array();
|
||||
$targets = [];
|
||||
while (true) {
|
||||
$targets[] = $this->parseExpression();
|
||||
if (!$this->parser->getStream()->nextIf(Twig_Token::PUNCTUATION_TYPE, ',')) {
|
||||
|
@ -618,7 +618,7 @@ class Twig_ExpressionParser
|
|||
$name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
|
||||
|
||||
if ($test = $this->env->getTest($name)) {
|
||||
return array($name, $test);
|
||||
return [$name, $test];
|
||||
}
|
||||
|
||||
if ($stream->test(Twig_Token::NAME_TYPE)) {
|
||||
|
@ -628,7 +628,7 @@ class Twig_ExpressionParser
|
|||
if ($test = $this->env->getTest($name)) {
|
||||
$stream->next();
|
||||
|
||||
return array($name, $test);
|
||||
return [$name, $test];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
14
vendor/twig/twig/lib/Twig/Extension.php
vendored
14
vendor/twig/twig/lib/Twig/Extension.php
vendored
|
@ -20,32 +20,32 @@ abstract class Twig_Extension implements Twig_ExtensionInterface
|
|||
|
||||
public function getTokenParsers()
|
||||
{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getNodeVisitors()
|
||||
{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getFilters()
|
||||
{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getTests()
|
||||
{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getFunctions()
|
||||
{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getOperators()
|
||||
{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -53,7 +53,7 @@ abstract class Twig_Extension implements Twig_ExtensionInterface
|
|||
*/
|
||||
public function getGlobals()
|
||||
{
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
379
vendor/twig/twig/lib/Twig/Extension/Core.php
vendored
379
vendor/twig/twig/lib/Twig/Extension/Core.php
vendored
|
@ -18,10 +18,10 @@ if (!defined('ENT_SUBSTITUTE')) {
|
|||
*/
|
||||
class Twig_Extension_Core extends Twig_Extension
|
||||
{
|
||||
protected $dateFormats = array('F j, Y H:i', '%d days');
|
||||
protected $numberFormat = array(0, '.', ',');
|
||||
protected $dateFormats = ['F j, Y H:i', '%d days'];
|
||||
protected $numberFormat = [0, '.', ','];
|
||||
protected $timezone = null;
|
||||
protected $escapers = array();
|
||||
protected $escapers = [];
|
||||
|
||||
/**
|
||||
* Defines a new escaper to be used via the escape filter.
|
||||
|
@ -104,7 +104,7 @@ class Twig_Extension_Core extends Twig_Extension
|
|||
*/
|
||||
public function setNumberFormat($decimal, $decimalPoint, $thousandSep)
|
||||
{
|
||||
$this->numberFormat = array($decimal, $decimalPoint, $thousandSep);
|
||||
$this->numberFormat = [$decimal, $decimalPoint, $thousandSep];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -119,7 +119,7 @@ class Twig_Extension_Core extends Twig_Extension
|
|||
|
||||
public function getTokenParsers()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
new Twig_TokenParser_For(),
|
||||
new Twig_TokenParser_If(),
|
||||
new Twig_TokenParser_Extends(),
|
||||
|
@ -136,18 +136,19 @@ class Twig_Extension_Core extends Twig_Extension
|
|||
new Twig_TokenParser_Do(),
|
||||
new Twig_TokenParser_Embed(),
|
||||
new Twig_TokenParser_With(),
|
||||
);
|
||||
new Twig_TokenParser_Deprecated(),
|
||||
];
|
||||
}
|
||||
|
||||
public function getFilters()
|
||||
{
|
||||
$filters = array(
|
||||
$filters = [
|
||||
// formatting filters
|
||||
new Twig_SimpleFilter('date', 'twig_date_format_filter', array('needs_environment' => true)),
|
||||
new Twig_SimpleFilter('date_modify', 'twig_date_modify_filter', array('needs_environment' => true)),
|
||||
new Twig_SimpleFilter('date', 'twig_date_format_filter', ['needs_environment' => true]),
|
||||
new Twig_SimpleFilter('date_modify', 'twig_date_modify_filter', ['needs_environment' => true]),
|
||||
new Twig_SimpleFilter('format', 'sprintf'),
|
||||
new Twig_SimpleFilter('replace', 'twig_replace_filter'),
|
||||
new Twig_SimpleFilter('number_format', 'twig_number_format_filter', array('needs_environment' => true)),
|
||||
new Twig_SimpleFilter('number_format', 'twig_number_format_filter', ['needs_environment' => true]),
|
||||
new Twig_SimpleFilter('abs', 'abs'),
|
||||
new Twig_SimpleFilter('round', 'twig_round'),
|
||||
|
||||
|
@ -157,40 +158,40 @@ class Twig_Extension_Core extends Twig_Extension
|
|||
new Twig_SimpleFilter('convert_encoding', 'twig_convert_encoding'),
|
||||
|
||||
// string filters
|
||||
new Twig_SimpleFilter('title', 'twig_title_string_filter', array('needs_environment' => true)),
|
||||
new Twig_SimpleFilter('capitalize', 'twig_capitalize_string_filter', array('needs_environment' => true)),
|
||||
new Twig_SimpleFilter('title', 'twig_title_string_filter', ['needs_environment' => true]),
|
||||
new Twig_SimpleFilter('capitalize', 'twig_capitalize_string_filter', ['needs_environment' => true]),
|
||||
new Twig_SimpleFilter('upper', 'strtoupper'),
|
||||
new Twig_SimpleFilter('lower', 'strtolower'),
|
||||
new Twig_SimpleFilter('striptags', 'strip_tags'),
|
||||
new Twig_SimpleFilter('trim', 'twig_trim_filter'),
|
||||
new Twig_SimpleFilter('nl2br', 'nl2br', array('pre_escape' => 'html', 'is_safe' => array('html'))),
|
||||
new Twig_SimpleFilter('nl2br', 'nl2br', ['pre_escape' => 'html', 'is_safe' => ['html']]),
|
||||
|
||||
// array helpers
|
||||
new Twig_SimpleFilter('join', 'twig_join_filter'),
|
||||
new Twig_SimpleFilter('split', 'twig_split_filter', array('needs_environment' => true)),
|
||||
new Twig_SimpleFilter('split', 'twig_split_filter', ['needs_environment' => true]),
|
||||
new Twig_SimpleFilter('sort', 'twig_sort_filter'),
|
||||
new Twig_SimpleFilter('merge', 'twig_array_merge'),
|
||||
new Twig_SimpleFilter('batch', 'twig_array_batch'),
|
||||
|
||||
// string/array filters
|
||||
new Twig_SimpleFilter('reverse', 'twig_reverse_filter', array('needs_environment' => true)),
|
||||
new Twig_SimpleFilter('length', 'twig_length_filter', array('needs_environment' => true)),
|
||||
new Twig_SimpleFilter('slice', 'twig_slice', array('needs_environment' => true)),
|
||||
new Twig_SimpleFilter('first', 'twig_first', array('needs_environment' => true)),
|
||||
new Twig_SimpleFilter('last', 'twig_last', array('needs_environment' => true)),
|
||||
new Twig_SimpleFilter('reverse', 'twig_reverse_filter', ['needs_environment' => true]),
|
||||
new Twig_SimpleFilter('length', 'twig_length_filter', ['needs_environment' => true]),
|
||||
new Twig_SimpleFilter('slice', 'twig_slice', ['needs_environment' => true]),
|
||||
new Twig_SimpleFilter('first', 'twig_first', ['needs_environment' => true]),
|
||||
new Twig_SimpleFilter('last', 'twig_last', ['needs_environment' => true]),
|
||||
|
||||
// iteration and runtime
|
||||
new Twig_SimpleFilter('default', '_twig_default_filter', array('node_class' => 'Twig_Node_Expression_Filter_Default')),
|
||||
new Twig_SimpleFilter('default', '_twig_default_filter', ['node_class' => 'Twig_Node_Expression_Filter_Default']),
|
||||
new Twig_SimpleFilter('keys', 'twig_get_array_keys_filter'),
|
||||
|
||||
// escaping
|
||||
new Twig_SimpleFilter('escape', 'twig_escape_filter', array('needs_environment' => true, 'is_safe_callback' => 'twig_escape_filter_is_safe')),
|
||||
new Twig_SimpleFilter('e', 'twig_escape_filter', array('needs_environment' => true, 'is_safe_callback' => 'twig_escape_filter_is_safe')),
|
||||
);
|
||||
new Twig_SimpleFilter('escape', 'twig_escape_filter', ['needs_environment' => true, 'is_safe_callback' => 'twig_escape_filter_is_safe']),
|
||||
new Twig_SimpleFilter('e', 'twig_escape_filter', ['needs_environment' => true, 'is_safe_callback' => 'twig_escape_filter_is_safe']),
|
||||
];
|
||||
|
||||
if (function_exists('mb_get_info')) {
|
||||
$filters[] = new Twig_SimpleFilter('upper', 'twig_upper_filter', array('needs_environment' => true));
|
||||
$filters[] = new Twig_SimpleFilter('lower', 'twig_lower_filter', array('needs_environment' => true));
|
||||
$filters[] = new Twig_SimpleFilter('upper', 'twig_upper_filter', ['needs_environment' => true]);
|
||||
$filters[] = new Twig_SimpleFilter('lower', 'twig_lower_filter', ['needs_environment' => true]);
|
||||
}
|
||||
|
||||
return $filters;
|
||||
|
@ -198,76 +199,76 @@ class Twig_Extension_Core extends Twig_Extension
|
|||
|
||||
public function getFunctions()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
new Twig_SimpleFunction('max', 'max'),
|
||||
new Twig_SimpleFunction('min', 'min'),
|
||||
new Twig_SimpleFunction('range', 'range'),
|
||||
new Twig_SimpleFunction('constant', 'twig_constant'),
|
||||
new Twig_SimpleFunction('cycle', 'twig_cycle'),
|
||||
new Twig_SimpleFunction('random', 'twig_random', array('needs_environment' => true)),
|
||||
new Twig_SimpleFunction('date', 'twig_date_converter', array('needs_environment' => true)),
|
||||
new Twig_SimpleFunction('include', 'twig_include', array('needs_environment' => true, 'needs_context' => true, 'is_safe' => array('all'))),
|
||||
new Twig_SimpleFunction('source', 'twig_source', array('needs_environment' => true, 'is_safe' => array('all'))),
|
||||
);
|
||||
new Twig_SimpleFunction('random', 'twig_random', ['needs_environment' => true]),
|
||||
new Twig_SimpleFunction('date', 'twig_date_converter', ['needs_environment' => true]),
|
||||
new Twig_SimpleFunction('include', 'twig_include', ['needs_environment' => true, 'needs_context' => true, 'is_safe' => ['all']]),
|
||||
new Twig_SimpleFunction('source', 'twig_source', ['needs_environment' => true, 'is_safe' => ['all']]),
|
||||
];
|
||||
}
|
||||
|
||||
public function getTests()
|
||||
{
|
||||
return array(
|
||||
new Twig_SimpleTest('even', null, array('node_class' => 'Twig_Node_Expression_Test_Even')),
|
||||
new Twig_SimpleTest('odd', null, array('node_class' => 'Twig_Node_Expression_Test_Odd')),
|
||||
new Twig_SimpleTest('defined', null, array('node_class' => 'Twig_Node_Expression_Test_Defined')),
|
||||
new Twig_SimpleTest('sameas', null, array('node_class' => 'Twig_Node_Expression_Test_Sameas', 'deprecated' => '1.21', 'alternative' => 'same as')),
|
||||
new Twig_SimpleTest('same as', null, array('node_class' => 'Twig_Node_Expression_Test_Sameas')),
|
||||
new Twig_SimpleTest('none', null, array('node_class' => 'Twig_Node_Expression_Test_Null')),
|
||||
new Twig_SimpleTest('null', null, array('node_class' => 'Twig_Node_Expression_Test_Null')),
|
||||
new Twig_SimpleTest('divisibleby', null, array('node_class' => 'Twig_Node_Expression_Test_Divisibleby', 'deprecated' => '1.21', 'alternative' => 'divisible by')),
|
||||
new Twig_SimpleTest('divisible by', null, array('node_class' => 'Twig_Node_Expression_Test_Divisibleby')),
|
||||
new Twig_SimpleTest('constant', null, array('node_class' => 'Twig_Node_Expression_Test_Constant')),
|
||||
return [
|
||||
new Twig_SimpleTest('even', null, ['node_class' => 'Twig_Node_Expression_Test_Even']),
|
||||
new Twig_SimpleTest('odd', null, ['node_class' => 'Twig_Node_Expression_Test_Odd']),
|
||||
new Twig_SimpleTest('defined', null, ['node_class' => 'Twig_Node_Expression_Test_Defined']),
|
||||
new Twig_SimpleTest('sameas', null, ['node_class' => 'Twig_Node_Expression_Test_Sameas', 'deprecated' => '1.21', 'alternative' => 'same as']),
|
||||
new Twig_SimpleTest('same as', null, ['node_class' => 'Twig_Node_Expression_Test_Sameas']),
|
||||
new Twig_SimpleTest('none', null, ['node_class' => 'Twig_Node_Expression_Test_Null']),
|
||||
new Twig_SimpleTest('null', null, ['node_class' => 'Twig_Node_Expression_Test_Null']),
|
||||
new Twig_SimpleTest('divisibleby', null, ['node_class' => 'Twig_Node_Expression_Test_Divisibleby', 'deprecated' => '1.21', 'alternative' => 'divisible by']),
|
||||
new Twig_SimpleTest('divisible by', null, ['node_class' => 'Twig_Node_Expression_Test_Divisibleby']),
|
||||
new Twig_SimpleTest('constant', null, ['node_class' => 'Twig_Node_Expression_Test_Constant']),
|
||||
new Twig_SimpleTest('empty', 'twig_test_empty'),
|
||||
new Twig_SimpleTest('iterable', 'twig_test_iterable'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
public function getOperators()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
'not' => array('precedence' => 50, 'class' => 'Twig_Node_Expression_Unary_Not'),
|
||||
'-' => array('precedence' => 500, 'class' => 'Twig_Node_Expression_Unary_Neg'),
|
||||
'+' => array('precedence' => 500, 'class' => 'Twig_Node_Expression_Unary_Pos'),
|
||||
),
|
||||
array(
|
||||
'or' => array('precedence' => 10, 'class' => 'Twig_Node_Expression_Binary_Or', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
||||
'and' => array('precedence' => 15, 'class' => 'Twig_Node_Expression_Binary_And', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
||||
'b-or' => array('precedence' => 16, 'class' => 'Twig_Node_Expression_Binary_BitwiseOr', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
||||
'b-xor' => array('precedence' => 17, 'class' => 'Twig_Node_Expression_Binary_BitwiseXor', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
||||
'b-and' => array('precedence' => 18, 'class' => 'Twig_Node_Expression_Binary_BitwiseAnd', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
||||
'==' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Equal', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
||||
'!=' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_NotEqual', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
||||
'<' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Less', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
||||
'>' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Greater', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
||||
'>=' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_GreaterEqual', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
||||
'<=' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_LessEqual', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
||||
'not in' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_NotIn', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
||||
'in' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_In', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
||||
'matches' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Matches', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
||||
'starts with' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_StartsWith', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
||||
'ends with' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_EndsWith', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
||||
'..' => array('precedence' => 25, 'class' => 'Twig_Node_Expression_Binary_Range', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
||||
'+' => array('precedence' => 30, 'class' => 'Twig_Node_Expression_Binary_Add', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
||||
'-' => array('precedence' => 30, 'class' => 'Twig_Node_Expression_Binary_Sub', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
||||
'~' => array('precedence' => 40, 'class' => 'Twig_Node_Expression_Binary_Concat', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
||||
'*' => array('precedence' => 60, 'class' => 'Twig_Node_Expression_Binary_Mul', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
||||
'/' => array('precedence' => 60, 'class' => 'Twig_Node_Expression_Binary_Div', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
||||
'//' => array('precedence' => 60, 'class' => 'Twig_Node_Expression_Binary_FloorDiv', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
||||
'%' => array('precedence' => 60, 'class' => 'Twig_Node_Expression_Binary_Mod', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
||||
'is' => array('precedence' => 100, 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
||||
'is not' => array('precedence' => 100, 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
|
||||
'**' => array('precedence' => 200, 'class' => 'Twig_Node_Expression_Binary_Power', 'associativity' => Twig_ExpressionParser::OPERATOR_RIGHT),
|
||||
'??' => array('precedence' => 300, 'class' => 'Twig_Node_Expression_NullCoalesce', 'associativity' => Twig_ExpressionParser::OPERATOR_RIGHT),
|
||||
),
|
||||
);
|
||||
return [
|
||||
[
|
||||
'not' => ['precedence' => 50, 'class' => 'Twig_Node_Expression_Unary_Not'],
|
||||
'-' => ['precedence' => 500, 'class' => 'Twig_Node_Expression_Unary_Neg'],
|
||||
'+' => ['precedence' => 500, 'class' => 'Twig_Node_Expression_Unary_Pos'],
|
||||
],
|
||||
[
|
||||
'or' => ['precedence' => 10, 'class' => 'Twig_Node_Expression_Binary_Or', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT],
|
||||
'and' => ['precedence' => 15, 'class' => 'Twig_Node_Expression_Binary_And', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT],
|
||||
'b-or' => ['precedence' => 16, 'class' => 'Twig_Node_Expression_Binary_BitwiseOr', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT],
|
||||
'b-xor' => ['precedence' => 17, 'class' => 'Twig_Node_Expression_Binary_BitwiseXor', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT],
|
||||
'b-and' => ['precedence' => 18, 'class' => 'Twig_Node_Expression_Binary_BitwiseAnd', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT],
|
||||
'==' => ['precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Equal', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT],
|
||||
'!=' => ['precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_NotEqual', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT],
|
||||
'<' => ['precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Less', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT],
|
||||
'>' => ['precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Greater', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT],
|
||||
'>=' => ['precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_GreaterEqual', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT],
|
||||
'<=' => ['precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_LessEqual', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT],
|
||||
'not in' => ['precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_NotIn', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT],
|
||||
'in' => ['precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_In', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT],
|
||||
'matches' => ['precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Matches', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT],
|
||||
'starts with' => ['precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_StartsWith', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT],
|
||||
'ends with' => ['precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_EndsWith', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT],
|
||||
'..' => ['precedence' => 25, 'class' => 'Twig_Node_Expression_Binary_Range', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT],
|
||||
'+' => ['precedence' => 30, 'class' => 'Twig_Node_Expression_Binary_Add', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT],
|
||||
'-' => ['precedence' => 30, 'class' => 'Twig_Node_Expression_Binary_Sub', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT],
|
||||
'~' => ['precedence' => 40, 'class' => 'Twig_Node_Expression_Binary_Concat', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT],
|
||||
'*' => ['precedence' => 60, 'class' => 'Twig_Node_Expression_Binary_Mul', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT],
|
||||
'/' => ['precedence' => 60, 'class' => 'Twig_Node_Expression_Binary_Div', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT],
|
||||
'//' => ['precedence' => 60, 'class' => 'Twig_Node_Expression_Binary_FloorDiv', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT],
|
||||
'%' => ['precedence' => 60, 'class' => 'Twig_Node_Expression_Binary_Mod', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT],
|
||||
'is' => ['precedence' => 100, 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT],
|
||||
'is not' => ['precedence' => 100, 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT],
|
||||
'**' => ['precedence' => 200, 'class' => 'Twig_Node_Expression_Binary_Power', 'associativity' => Twig_ExpressionParser::OPERATOR_RIGHT],
|
||||
'??' => ['precedence' => 300, 'class' => 'Twig_Node_Expression_NullCoalesce', 'associativity' => Twig_ExpressionParser::OPERATOR_RIGHT],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function getName()
|
||||
|
@ -362,7 +363,7 @@ function twig_random(Twig_Environment $env, $values = null)
|
|||
* @param Twig_Environment $env
|
||||
* @param DateTime|DateTimeInterface|DateInterval|string $date A date
|
||||
* @param string|null $format The target format, null to use the default
|
||||
* @param DateTimeZone|string|null|false $timezone The target timezone, null to use the default, false to leave unchanged
|
||||
* @param DateTimeZone|string|false|null $timezone The target timezone, null to use the default, false to leave unchanged
|
||||
*
|
||||
* @return string The formatted date
|
||||
*/
|
||||
|
@ -415,7 +416,7 @@ function twig_date_modify_filter(Twig_Environment $env, $date, $modifier)
|
|||
*
|
||||
* @param Twig_Environment $env
|
||||
* @param DateTime|DateTimeInterface|string|null $date A date
|
||||
* @param DateTimeZone|string|null|false $timezone The target timezone, null to use the default, false to leave unchanged
|
||||
* @param DateTimeZone|string|false|null $timezone The target timezone, null to use the default, false to leave unchanged
|
||||
*
|
||||
* @return DateTime A DateTime instance
|
||||
*/
|
||||
|
@ -561,44 +562,23 @@ function twig_urlencode_filter($url)
|
|||
return rawurlencode($url);
|
||||
}
|
||||
|
||||
if (PHP_VERSION_ID < 50300) {
|
||||
/**
|
||||
* JSON encodes a variable.
|
||||
*
|
||||
* @param mixed $value the value to encode
|
||||
* @param int $options Not used on PHP 5.2.x
|
||||
*
|
||||
* @return mixed The JSON encoded value
|
||||
*/
|
||||
function twig_jsonencode_filter($value, $options = 0)
|
||||
{
|
||||
if ($value instanceof Twig_Markup) {
|
||||
$value = (string) $value;
|
||||
} elseif (is_array($value)) {
|
||||
array_walk_recursive($value, '_twig_markup2string');
|
||||
}
|
||||
|
||||
return json_encode($value);
|
||||
/**
|
||||
* JSON encodes a variable.
|
||||
*
|
||||
* @param mixed $value the value to encode
|
||||
* @param int $options Bitmask consisting of JSON_HEX_QUOT, JSON_HEX_TAG, JSON_HEX_AMP, JSON_HEX_APOS, JSON_NUMERIC_CHECK, JSON_PRETTY_PRINT, JSON_UNESCAPED_SLASHES, JSON_FORCE_OBJECT
|
||||
*
|
||||
* @return mixed The JSON encoded value
|
||||
*/
|
||||
function twig_jsonencode_filter($value, $options = 0)
|
||||
{
|
||||
if ($value instanceof Twig_Markup) {
|
||||
$value = (string) $value;
|
||||
} elseif (is_array($value)) {
|
||||
array_walk_recursive($value, '_twig_markup2string');
|
||||
}
|
||||
} else {
|
||||
/**
|
||||
* JSON encodes a variable.
|
||||
*
|
||||
* @param mixed $value the value to encode
|
||||
* @param int $options Bitmask consisting of JSON_HEX_QUOT, JSON_HEX_TAG, JSON_HEX_AMP, JSON_HEX_APOS, JSON_NUMERIC_CHECK, JSON_PRETTY_PRINT, JSON_UNESCAPED_SLASHES, JSON_FORCE_OBJECT
|
||||
*
|
||||
* @return mixed The JSON encoded value
|
||||
*/
|
||||
function twig_jsonencode_filter($value, $options = 0)
|
||||
{
|
||||
if ($value instanceof Twig_Markup) {
|
||||
$value = (string) $value;
|
||||
} elseif (is_array($value)) {
|
||||
array_walk_recursive($value, '_twig_markup2string');
|
||||
}
|
||||
|
||||
return json_encode($value, $options);
|
||||
}
|
||||
return json_encode($value, $options);
|
||||
}
|
||||
|
||||
function _twig_markup2string(&$value)
|
||||
|
@ -663,7 +643,7 @@ function twig_slice(Twig_Environment $env, $item, $start, $length = null, $prese
|
|||
try {
|
||||
return iterator_to_array(new LimitIterator($item, $start, null === $length ? -1 : $length), $preserveKeys);
|
||||
} catch (OutOfBoundsException $exception) {
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -716,9 +696,12 @@ function twig_last(Twig_Environment $env, $item)
|
|||
/**
|
||||
* Joins the values to a string.
|
||||
*
|
||||
* The separator between elements is an empty string per default, you can define it with the optional parameter.
|
||||
* The separators between elements are empty strings per default, you can define them with the optional parameters.
|
||||
*
|
||||
* <pre>
|
||||
* {{ [1, 2, 3]|join(', ', ' and ') }}
|
||||
* {# returns 1, 2 and 3 #}
|
||||
*
|
||||
* {{ [1, 2, 3]|join('|') }}
|
||||
* {# returns 1|2|3 #}
|
||||
*
|
||||
|
@ -726,18 +709,34 @@ function twig_last(Twig_Environment $env, $item)
|
|||
* {# returns 123 #}
|
||||
* </pre>
|
||||
*
|
||||
* @param array $value An array
|
||||
* @param string $glue The separator
|
||||
* @param array $value An array
|
||||
* @param string $glue The separator
|
||||
* @param string|null $and The separator for the last pair
|
||||
*
|
||||
* @return string The concatenated string
|
||||
*/
|
||||
function twig_join_filter($value, $glue = '')
|
||||
function twig_join_filter($value, $glue = '', $and = null)
|
||||
{
|
||||
if ($value instanceof Traversable) {
|
||||
$value = iterator_to_array($value, false);
|
||||
} else {
|
||||
$value = (array) $value;
|
||||
}
|
||||
|
||||
return implode($glue, (array) $value);
|
||||
if (0 === count($value)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (null === $and || $and === $glue) {
|
||||
return implode($glue, $value);
|
||||
}
|
||||
|
||||
$v = array_values($value);
|
||||
if (1 === count($v)) {
|
||||
return $v[0];
|
||||
}
|
||||
|
||||
return implode($glue, array_slice($value, 0, -1)).$and.$v[count($v) - 1];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -780,10 +779,10 @@ function twig_split_filter(Twig_Environment $env, $value, $delimiter, $limit = n
|
|||
|
||||
$length = mb_strlen($value, $charset);
|
||||
if ($length < $limit) {
|
||||
return array($value);
|
||||
return [$value];
|
||||
}
|
||||
|
||||
$r = array();
|
||||
$r = [];
|
||||
for ($i = 0; $i < $length; $i += $limit) {
|
||||
$r[] = mb_substr($value, $i, $limit, $charset);
|
||||
}
|
||||
|
@ -829,7 +828,7 @@ function twig_get_array_keys_filter($array)
|
|||
}
|
||||
|
||||
if ($array instanceof Iterator) {
|
||||
$keys = array();
|
||||
$keys = [];
|
||||
$array->rewind();
|
||||
while ($array->valid()) {
|
||||
$keys[] = $array->key();
|
||||
|
@ -839,7 +838,7 @@ function twig_get_array_keys_filter($array)
|
|||
return $keys;
|
||||
}
|
||||
|
||||
$keys = array();
|
||||
$keys = [];
|
||||
foreach ($array as $key => $item) {
|
||||
$keys[] = $key;
|
||||
}
|
||||
|
@ -848,7 +847,7 @@ function twig_get_array_keys_filter($array)
|
|||
}
|
||||
|
||||
if (!is_array($array)) {
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
return array_keys($array);
|
||||
|
@ -989,11 +988,15 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html',
|
|||
if (!is_string($string)) {
|
||||
if (is_object($string) && method_exists($string, '__toString')) {
|
||||
$string = (string) $string;
|
||||
} elseif (in_array($strategy, array('html', 'js', 'css', 'html_attr', 'url'))) {
|
||||
} elseif (in_array($strategy, ['html', 'js', 'css', 'html_attr', 'url'])) {
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
|
||||
if ('' === $string) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (null === $charset) {
|
||||
$charset = $env->getCharset();
|
||||
}
|
||||
|
@ -1005,7 +1008,7 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html',
|
|||
// Using a static variable to avoid initializing the array
|
||||
// each time the function is called. Moving the declaration on the
|
||||
// top of the function slow downs other escaping strategies.
|
||||
static $htmlspecialcharsCharsets = array(
|
||||
static $htmlspecialcharsCharsets = [
|
||||
'ISO-8859-1' => true, 'ISO8859-1' => true,
|
||||
'ISO-8859-15' => true, 'ISO8859-15' => true,
|
||||
'utf-8' => true, 'UTF-8' => true,
|
||||
|
@ -1020,7 +1023,7 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html',
|
|||
'SHIFT_JIS' => true, 'SJIS' => true, '932' => true,
|
||||
'EUC-JP' => true, 'EUCJP' => true,
|
||||
'ISO8859-5' => true, 'ISO-8859-5' => true, 'MACROMAN' => true,
|
||||
);
|
||||
];
|
||||
|
||||
if (isset($htmlspecialcharsCharsets[$charset])) {
|
||||
return htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, $charset);
|
||||
|
@ -1045,7 +1048,7 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html',
|
|||
$string = twig_convert_encoding($string, 'UTF-8', $charset);
|
||||
}
|
||||
|
||||
if (0 == strlen($string) ? false : 1 !== preg_match('/^./su', $string)) {
|
||||
if (!preg_match('//u', $string)) {
|
||||
throw new Twig_Error_Runtime('The string to escape is not a valid UTF-8 string.');
|
||||
}
|
||||
|
||||
|
@ -1062,7 +1065,7 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html',
|
|||
$string = twig_convert_encoding($string, 'UTF-8', $charset);
|
||||
}
|
||||
|
||||
if (0 == strlen($string) ? false : 1 !== preg_match('/^./su', $string)) {
|
||||
if (!preg_match('//u', $string)) {
|
||||
throw new Twig_Error_Runtime('The string to escape is not a valid UTF-8 string.');
|
||||
}
|
||||
|
||||
|
@ -1079,7 +1082,7 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html',
|
|||
$string = twig_convert_encoding($string, 'UTF-8', $charset);
|
||||
}
|
||||
|
||||
if (0 == strlen($string) ? false : 1 !== preg_match('/^./su', $string)) {
|
||||
if (!preg_match('//u', $string)) {
|
||||
throw new Twig_Error_Runtime('The string to escape is not a valid UTF-8 string.');
|
||||
}
|
||||
|
||||
|
@ -1092,10 +1095,6 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html',
|
|||
return $string;
|
||||
|
||||
case 'url':
|
||||
if (PHP_VERSION_ID < 50300) {
|
||||
return str_replace('%7E', '~', rawurlencode($string));
|
||||
}
|
||||
|
||||
return rawurlencode($string);
|
||||
|
||||
default:
|
||||
|
@ -1109,7 +1108,7 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html',
|
|||
return call_user_func($escapers[$strategy], $env, $string, $charset);
|
||||
}
|
||||
|
||||
$validStrategies = implode(', ', array_merge(array('html', 'js', 'url', 'css', 'html_attr'), array_keys($escapers)));
|
||||
$validStrategies = implode(', ', array_merge(['html', 'js', 'url', 'css', 'html_attr'], array_keys($escapers)));
|
||||
|
||||
throw new Twig_Error_Runtime(sprintf('Invalid escaping strategy "%s" (valid ones: %s).', $strategy, $validStrategies));
|
||||
}
|
||||
|
@ -1122,13 +1121,13 @@ function twig_escape_filter_is_safe(Twig_Node $filterArgs)
|
|||
{
|
||||
foreach ($filterArgs as $arg) {
|
||||
if ($arg instanceof Twig_Node_Expression_Constant) {
|
||||
return array($arg->getAttribute('value'));
|
||||
return [$arg->getAttribute('value')];
|
||||
}
|
||||
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
return array('html');
|
||||
return ['html'];
|
||||
}
|
||||
|
||||
if (function_exists('mb_convert_encoding')) {
|
||||
|
@ -1148,6 +1147,29 @@ if (function_exists('mb_convert_encoding')) {
|
|||
}
|
||||
}
|
||||
|
||||
if (function_exists('mb_ord')) {
|
||||
function twig_ord($string)
|
||||
{
|
||||
return mb_ord($string, 'UTF-8');
|
||||
}
|
||||
} else {
|
||||
function twig_ord($string)
|
||||
{
|
||||
$code = ($string = unpack('C*', substr($string, 0, 4))) ? $string[1] : 0;
|
||||
if (0xF0 <= $code) {
|
||||
return (($code - 0xF0) << 18) + (($string[2] - 0x80) << 12) + (($string[3] - 0x80) << 6) + $string[4] - 0x80;
|
||||
}
|
||||
if (0xE0 <= $code) {
|
||||
return (($code - 0xE0) << 12) + (($string[2] - 0x80) << 6) + $string[3] - 0x80;
|
||||
}
|
||||
if (0xC0 <= $code) {
|
||||
return (($code - 0xC0) << 6) + $string[2] - 0x80;
|
||||
}
|
||||
|
||||
return $code;
|
||||
}
|
||||
}
|
||||
|
||||
function _twig_escape_js_callback($matches)
|
||||
{
|
||||
$char = $matches[0];
|
||||
|
@ -1157,7 +1179,7 @@ function _twig_escape_js_callback($matches)
|
|||
* Escape sequences supported only by JavaScript, not JSON, are ommitted.
|
||||
* \" is also supported but omitted, because the resulting string is not HTML safe.
|
||||
*/
|
||||
static $shortMap = array(
|
||||
static $shortMap = [
|
||||
'\\' => '\\\\',
|
||||
'/' => '\\/',
|
||||
"\x08" => '\b',
|
||||
|
@ -1165,7 +1187,7 @@ function _twig_escape_js_callback($matches)
|
|||
"\x0A" => '\n',
|
||||
"\x0D" => '\r',
|
||||
"\x09" => '\t',
|
||||
);
|
||||
];
|
||||
|
||||
if (isset($shortMap[$char])) {
|
||||
return $shortMap[$char];
|
||||
|
@ -1186,20 +1208,7 @@ function _twig_escape_css_callback($matches)
|
|||
{
|
||||
$char = $matches[0];
|
||||
|
||||
// \xHH
|
||||
if (!isset($char[1])) {
|
||||
$hex = ltrim(strtoupper(bin2hex($char)), '0');
|
||||
if (0 === strlen($hex)) {
|
||||
$hex = '0';
|
||||
}
|
||||
|
||||
return '\\'.$hex.' ';
|
||||
}
|
||||
|
||||
// \uHHHH
|
||||
$char = twig_convert_encoding($char, 'UTF-16BE', 'UTF-8');
|
||||
|
||||
return '\\'.ltrim(strtoupper(bin2hex($char)), '0').' ';
|
||||
return sprintf('\\%X ', 1 === strlen($char) ? ord($char) : twig_ord($char));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1210,19 +1219,6 @@ function _twig_escape_css_callback($matches)
|
|||
*/
|
||||
function _twig_escape_html_attr_callback($matches)
|
||||
{
|
||||
/*
|
||||
* While HTML supports far more named entities, the lowest common denominator
|
||||
* has become HTML5's XML Serialisation which is restricted to the those named
|
||||
* entities that XML supports. Using HTML entities would result in this error:
|
||||
* XML Parsing Error: undefined entity
|
||||
*/
|
||||
static $entityMap = array(
|
||||
34 => 'quot', /* quotation mark */
|
||||
38 => 'amp', /* ampersand */
|
||||
60 => 'lt', /* less-than sign */
|
||||
62 => 'gt', /* greater-than sign */
|
||||
);
|
||||
|
||||
$chr = $matches[0];
|
||||
$ord = ord($chr);
|
||||
|
||||
|
@ -1239,22 +1235,31 @@ function _twig_escape_html_attr_callback($matches)
|
|||
* replace it with while grabbing the hex value of the character.
|
||||
*/
|
||||
if (1 == strlen($chr)) {
|
||||
$hex = strtoupper(substr('00'.bin2hex($chr), -2));
|
||||
} else {
|
||||
$chr = twig_convert_encoding($chr, 'UTF-16BE', 'UTF-8');
|
||||
$hex = strtoupper(substr('0000'.bin2hex($chr), -4));
|
||||
}
|
||||
/*
|
||||
* While HTML supports far more named entities, the lowest common denominator
|
||||
* has become HTML5's XML Serialisation which is restricted to the those named
|
||||
* entities that XML supports. Using HTML entities would result in this error:
|
||||
* XML Parsing Error: undefined entity
|
||||
*/
|
||||
static $entityMap = [
|
||||
34 => '"', /* quotation mark */
|
||||
38 => '&', /* ampersand */
|
||||
60 => '<', /* less-than sign */
|
||||
62 => '>', /* greater-than sign */
|
||||
];
|
||||
|
||||
$int = hexdec($hex);
|
||||
if (array_key_exists($int, $entityMap)) {
|
||||
return sprintf('&%s;', $entityMap[$int]);
|
||||
if (isset($entityMap[$ord])) {
|
||||
return $entityMap[$ord];
|
||||
}
|
||||
|
||||
return sprintf('&#x%02X;', $ord);
|
||||
}
|
||||
|
||||
/*
|
||||
* Per OWASP recommendations, we'll use hex entities for any other
|
||||
* characters where a named entity does not exist.
|
||||
*/
|
||||
return sprintf('&#x%s;', $hex);
|
||||
return sprintf('&#x%04X;', twig_ord($chr));
|
||||
}
|
||||
|
||||
// add multibyte extensions if possible
|
||||
|
@ -1439,7 +1444,7 @@ function twig_ensure_traversable($seq)
|
|||
return $seq;
|
||||
}
|
||||
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1466,7 +1471,7 @@ function twig_test_empty($value)
|
|||
return '' === (string) $value;
|
||||
}
|
||||
|
||||
return '' === $value || false === $value || null === $value || array() === $value;
|
||||
return '' === $value || false === $value || null === $value || [] === $value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1501,7 +1506,7 @@ function twig_test_iterable($value)
|
|||
*
|
||||
* @return string The rendered template
|
||||
*/
|
||||
function twig_include(Twig_Environment $env, $context, $template, $variables = array(), $withContext = true, $ignoreMissing = false, $sandboxed = false)
|
||||
function twig_include(Twig_Environment $env, $context, $template, $variables = [], $withContext = true, $ignoreMissing = false, $sandboxed = false)
|
||||
{
|
||||
$alreadySandboxed = false;
|
||||
$sandbox = null;
|
||||
|
@ -1516,7 +1521,7 @@ function twig_include(Twig_Environment $env, $context, $template, $variables = a
|
|||
}
|
||||
}
|
||||
|
||||
$result = null;
|
||||
$result = '';
|
||||
try {
|
||||
$result = $env->resolveTemplate($template)->render($variables);
|
||||
} catch (Twig_Error_Loader $e) {
|
||||
|
@ -1577,7 +1582,7 @@ function twig_source(Twig_Environment $env, $name, $ignoreMissing = false)
|
|||
* Provides the ability to get constants from instances as well as class/global constants.
|
||||
*
|
||||
* @param string $constant The name of the constant
|
||||
* @param null|object $object The object to get the constant from
|
||||
* @param object|null $object The object to get the constant from
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
@ -1594,7 +1599,7 @@ function twig_constant($constant, $object = null)
|
|||
* Checks if a constant exists.
|
||||
*
|
||||
* @param string $constant The name of the constant
|
||||
* @param null|object $object The object to get the constant from
|
||||
* @param object|null $object The object to get the constant from
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
|
|
|
@ -26,9 +26,9 @@ class Twig_Extension_Debug extends Twig_Extension
|
|||
|| 'cli' === PHP_SAPI
|
||||
;
|
||||
|
||||
return array(
|
||||
new Twig_SimpleFunction('dump', 'twig_var_dump', array('is_safe' => $isDumpOutputHtmlSafe ? array('html') : array(), 'needs_context' => true, 'needs_environment' => true)),
|
||||
);
|
||||
return [
|
||||
new Twig_SimpleFunction('dump', 'twig_var_dump', ['is_safe' => $isDumpOutputHtmlSafe ? ['html'] : [], 'needs_context' => true, 'needs_environment' => true]),
|
||||
];
|
||||
}
|
||||
|
||||
public function getName()
|
||||
|
@ -47,7 +47,7 @@ function twig_var_dump(Twig_Environment $env, $context)
|
|||
|
||||
$count = func_num_args();
|
||||
if (2 === $count) {
|
||||
$vars = array();
|
||||
$vars = [];
|
||||
foreach ($context as $key => $value) {
|
||||
if (!$value instanceof Twig_Template) {
|
||||
$vars[$key] = $value;
|
||||
|
|
12
vendor/twig/twig/lib/Twig/Extension/Escaper.php
vendored
12
vendor/twig/twig/lib/Twig/Extension/Escaper.php
vendored
|
@ -28,19 +28,19 @@ class Twig_Extension_Escaper extends Twig_Extension
|
|||
|
||||
public function getTokenParsers()
|
||||
{
|
||||
return array(new Twig_TokenParser_AutoEscape());
|
||||
return [new Twig_TokenParser_AutoEscape()];
|
||||
}
|
||||
|
||||
public function getNodeVisitors()
|
||||
{
|
||||
return array(new Twig_NodeVisitor_Escaper());
|
||||
return [new Twig_NodeVisitor_Escaper()];
|
||||
}
|
||||
|
||||
public function getFilters()
|
||||
{
|
||||
return array(
|
||||
new Twig_SimpleFilter('raw', 'twig_raw_filter', array('is_safe' => array('all'))),
|
||||
);
|
||||
return [
|
||||
new Twig_SimpleFilter('raw', 'twig_raw_filter', ['is_safe' => ['all']]),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -67,7 +67,7 @@ class Twig_Extension_Escaper extends Twig_Extension
|
|||
}
|
||||
|
||||
if ('name' === $defaultStrategy) {
|
||||
$defaultStrategy = array('Twig_FileExtensionEscapingStrategy', 'guess');
|
||||
$defaultStrategy = ['Twig_FileExtensionEscapingStrategy', 'guess'];
|
||||
}
|
||||
|
||||
$this->defaultStrategy = $defaultStrategy;
|
||||
|
|
|
@ -23,7 +23,7 @@ class Twig_Extension_Optimizer extends Twig_Extension
|
|||
|
||||
public function getNodeVisitors()
|
||||
{
|
||||
return array(new Twig_NodeVisitor_Optimizer($this->optimizers));
|
||||
return [new Twig_NodeVisitor_Optimizer($this->optimizers)];
|
||||
}
|
||||
|
||||
public function getName()
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
class Twig_Extension_Profiler extends Twig_Extension
|
||||
{
|
||||
private $actives = array();
|
||||
private $actives = [];
|
||||
|
||||
public function __construct(Twig_Profiler_Profile $profile)
|
||||
{
|
||||
|
@ -36,7 +36,7 @@ class Twig_Extension_Profiler extends Twig_Extension
|
|||
|
||||
public function getNodeVisitors()
|
||||
{
|
||||
return array(new Twig_Profiler_NodeVisitor_Profiler(get_class($this)));
|
||||
return [new Twig_Profiler_NodeVisitor_Profiler(get_class($this))];
|
||||
}
|
||||
|
||||
public function getName()
|
||||
|
|
|
@ -26,12 +26,12 @@ class Twig_Extension_Sandbox extends Twig_Extension
|
|||
|
||||
public function getTokenParsers()
|
||||
{
|
||||
return array(new Twig_TokenParser_Sandbox());
|
||||
return [new Twig_TokenParser_Sandbox()];
|
||||
}
|
||||
|
||||
public function getNodeVisitors()
|
||||
{
|
||||
return array(new Twig_NodeVisitor_Sandbox());
|
||||
return [new Twig_NodeVisitor_Sandbox()];
|
||||
}
|
||||
|
||||
public function enableSandbox()
|
||||
|
|
12
vendor/twig/twig/lib/Twig/Extension/Staging.php
vendored
12
vendor/twig/twig/lib/Twig/Extension/Staging.php
vendored
|
@ -20,12 +20,12 @@
|
|||
*/
|
||||
class Twig_Extension_Staging extends Twig_Extension
|
||||
{
|
||||
protected $functions = array();
|
||||
protected $filters = array();
|
||||
protected $visitors = array();
|
||||
protected $tokenParsers = array();
|
||||
protected $globals = array();
|
||||
protected $tests = array();
|
||||
protected $functions = [];
|
||||
protected $filters = [];
|
||||
protected $visitors = [];
|
||||
protected $tokenParsers = [];
|
||||
protected $globals = [];
|
||||
protected $tests = [];
|
||||
|
||||
public function addFunction($name, $function)
|
||||
{
|
||||
|
|
|
@ -16,9 +16,9 @@ class Twig_Extension_StringLoader extends Twig_Extension
|
|||
{
|
||||
public function getFunctions()
|
||||
{
|
||||
return array(
|
||||
new Twig_SimpleFunction('template_from_string', 'twig_template_from_string', array('needs_environment' => true)),
|
||||
);
|
||||
return [
|
||||
new Twig_SimpleFunction('template_from_string', 'twig_template_from_string', ['needs_environment' => true]),
|
||||
];
|
||||
}
|
||||
|
||||
public function getName()
|
||||
|
|
|
@ -21,7 +21,7 @@ class Twig_FactoryRuntimeLoader implements Twig_RuntimeLoaderInterface
|
|||
/**
|
||||
* @param array $map An array where keys are class names and values factory callables
|
||||
*/
|
||||
public function __construct($map = array())
|
||||
public function __construct($map = [])
|
||||
{
|
||||
$this->map = $map;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ class Twig_FileExtensionEscapingStrategy
|
|||
*/
|
||||
public static function guess($name)
|
||||
{
|
||||
if (in_array(substr($name, -1), array('/', '\\'))) {
|
||||
if (in_array(substr($name, -1), ['/', '\\'])) {
|
||||
return 'html'; // return html for directories
|
||||
}
|
||||
|
||||
|
|
8
vendor/twig/twig/lib/Twig/Filter.php
vendored
8
vendor/twig/twig/lib/Twig/Filter.php
vendored
|
@ -23,17 +23,17 @@
|
|||
abstract class Twig_Filter implements Twig_FilterInterface, Twig_FilterCallableInterface
|
||||
{
|
||||
protected $options;
|
||||
protected $arguments = array();
|
||||
protected $arguments = [];
|
||||
|
||||
public function __construct(array $options = array())
|
||||
public function __construct(array $options = [])
|
||||
{
|
||||
$this->options = array_merge(array(
|
||||
$this->options = array_merge([
|
||||
'needs_environment' => false,
|
||||
'needs_context' => false,
|
||||
'pre_escape' => null,
|
||||
'preserves_safety' => null,
|
||||
'callable' => null,
|
||||
), $options);
|
||||
], $options);
|
||||
}
|
||||
|
||||
public function setArguments($arguments)
|
||||
|
|
|
@ -24,7 +24,7 @@ class Twig_Filter_Function extends Twig_Filter
|
|||
{
|
||||
protected $function;
|
||||
|
||||
public function __construct($function, array $options = array())
|
||||
public function __construct($function, array $options = [])
|
||||
{
|
||||
$options['callable'] = $function;
|
||||
|
||||
|
|
4
vendor/twig/twig/lib/Twig/Filter/Method.php
vendored
4
vendor/twig/twig/lib/Twig/Filter/Method.php
vendored
|
@ -25,9 +25,9 @@ class Twig_Filter_Method extends Twig_Filter
|
|||
protected $extension;
|
||||
protected $method;
|
||||
|
||||
public function __construct(Twig_ExtensionInterface $extension, $method, array $options = array())
|
||||
public function __construct(Twig_ExtensionInterface $extension, $method, array $options = [])
|
||||
{
|
||||
$options['callable'] = array($extension, $method);
|
||||
$options['callable'] = [$extension, $method];
|
||||
|
||||
parent::__construct($options);
|
||||
|
||||
|
|
2
vendor/twig/twig/lib/Twig/Filter/Node.php
vendored
2
vendor/twig/twig/lib/Twig/Filter/Node.php
vendored
|
@ -24,7 +24,7 @@ class Twig_Filter_Node extends Twig_Filter
|
|||
{
|
||||
protected $class;
|
||||
|
||||
public function __construct($class, array $options = array())
|
||||
public function __construct($class, array $options = [])
|
||||
{
|
||||
parent::__construct($options);
|
||||
|
||||
|
|
10
vendor/twig/twig/lib/Twig/Function.php
vendored
10
vendor/twig/twig/lib/Twig/Function.php
vendored
|
@ -23,15 +23,15 @@
|
|||
abstract class Twig_Function implements Twig_FunctionInterface, Twig_FunctionCallableInterface
|
||||
{
|
||||
protected $options;
|
||||
protected $arguments = array();
|
||||
protected $arguments = [];
|
||||
|
||||
public function __construct(array $options = array())
|
||||
public function __construct(array $options = [])
|
||||
{
|
||||
$this->options = array_merge(array(
|
||||
$this->options = array_merge([
|
||||
'needs_environment' => false,
|
||||
'needs_context' => false,
|
||||
'callable' => null,
|
||||
), $options);
|
||||
], $options);
|
||||
}
|
||||
|
||||
public function setArguments($arguments)
|
||||
|
@ -64,7 +64,7 @@ abstract class Twig_Function implements Twig_FunctionInterface, Twig_FunctionCal
|
|||
return call_user_func($this->options['is_safe_callback'], $functionArgs);
|
||||
}
|
||||
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getCallable()
|
||||
|
|
|
@ -25,7 +25,7 @@ class Twig_Function_Function extends Twig_Function
|
|||
{
|
||||
protected $function;
|
||||
|
||||
public function __construct($function, array $options = array())
|
||||
public function __construct($function, array $options = [])
|
||||
{
|
||||
$options['callable'] = $function;
|
||||
|
||||
|
|
|
@ -26,9 +26,9 @@ class Twig_Function_Method extends Twig_Function
|
|||
protected $extension;
|
||||
protected $method;
|
||||
|
||||
public function __construct(Twig_ExtensionInterface $extension, $method, array $options = array())
|
||||
public function __construct(Twig_ExtensionInterface $extension, $method, array $options = [])
|
||||
{
|
||||
$options['callable'] = array($extension, $method);
|
||||
$options['callable'] = [$extension, $method];
|
||||
|
||||
parent::__construct($options);
|
||||
|
||||
|
|
2
vendor/twig/twig/lib/Twig/Function/Node.php
vendored
2
vendor/twig/twig/lib/Twig/Function/Node.php
vendored
|
@ -24,7 +24,7 @@ class Twig_Function_Node extends Twig_Function
|
|||
{
|
||||
protected $class;
|
||||
|
||||
public function __construct($class, array $options = array())
|
||||
public function __construct($class, array $options = [])
|
||||
{
|
||||
parent::__construct($options);
|
||||
|
||||
|
|
36
vendor/twig/twig/lib/Twig/Lexer.php
vendored
36
vendor/twig/twig/lib/Twig/Lexer.php
vendored
|
@ -49,19 +49,19 @@ class Twig_Lexer implements Twig_LexerInterface
|
|||
const REGEX_DQ_STRING_PART = '/[^#"\\\\]*(?:(?:\\\\.|#(?!\{))[^#"\\\\]*)*/As';
|
||||
const PUNCTUATION = '()[]{}?:.,|';
|
||||
|
||||
public function __construct(Twig_Environment $env, array $options = array())
|
||||
public function __construct(Twig_Environment $env, array $options = [])
|
||||
{
|
||||
$this->env = $env;
|
||||
|
||||
$this->options = array_merge(array(
|
||||
'tag_comment' => array('{#', '#}'),
|
||||
'tag_block' => array('{%', '%}'),
|
||||
'tag_variable' => array('{{', '}}'),
|
||||
$this->options = array_merge([
|
||||
'tag_comment' => ['{#', '#}'],
|
||||
'tag_block' => ['{%', '%}'],
|
||||
'tag_variable' => ['{{', '}}'],
|
||||
'whitespace_trim' => '-',
|
||||
'interpolation' => array('#{', '}'),
|
||||
), $options);
|
||||
'interpolation' => ['#{', '}'],
|
||||
], $options);
|
||||
|
||||
$this->regexes = array(
|
||||
$this->regexes = [
|
||||
'lex_var' => '/\s*'.preg_quote($this->options['whitespace_trim'].$this->options['tag_variable'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_variable'][1], '/').'/A',
|
||||
'lex_block' => '/\s*(?:'.preg_quote($this->options['whitespace_trim'].$this->options['tag_block'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_block'][1], '/').')\n?/A',
|
||||
'lex_raw_data' => '/('.preg_quote($this->options['tag_block'][0].$this->options['whitespace_trim'], '/').'|'.preg_quote($this->options['tag_block'][0], '/').')\s*(?:end%s)\s*(?:'.preg_quote($this->options['whitespace_trim'].$this->options['tag_block'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_block'][1], '/').')/s',
|
||||
|
@ -72,7 +72,7 @@ class Twig_Lexer implements Twig_LexerInterface
|
|||
'lex_tokens_start' => '/('.preg_quote($this->options['tag_variable'][0], '/').'|'.preg_quote($this->options['tag_block'][0], '/').'|'.preg_quote($this->options['tag_comment'][0], '/').')('.preg_quote($this->options['whitespace_trim'], '/').')?/s',
|
||||
'interpolation_start' => '/'.preg_quote($this->options['interpolation'][0], '/').'\s*/A',
|
||||
'interpolation_end' => '/\s*'.preg_quote($this->options['interpolation'][1], '/').'/A',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
public function tokenize($code, $name = null)
|
||||
|
@ -95,15 +95,15 @@ class Twig_Lexer implements Twig_LexerInterface
|
|||
$mbEncoding = null;
|
||||
}
|
||||
|
||||
$this->code = str_replace(array("\r\n", "\r"), "\n", $this->source->getCode());
|
||||
$this->code = str_replace(["\r\n", "\r"], "\n", $this->source->getCode());
|
||||
$this->filename = $this->source->getName();
|
||||
$this->cursor = 0;
|
||||
$this->lineno = 1;
|
||||
$this->end = strlen($this->code);
|
||||
$this->tokens = array();
|
||||
$this->tokens = [];
|
||||
$this->state = self::STATE_DATA;
|
||||
$this->states = array();
|
||||
$this->brackets = array();
|
||||
$this->states = [];
|
||||
$this->brackets = [];
|
||||
$this->position = -1;
|
||||
|
||||
// find all token starts in one go
|
||||
|
@ -262,7 +262,7 @@ class Twig_Lexer implements Twig_LexerInterface
|
|||
elseif (false !== strpos(self::PUNCTUATION, $this->code[$this->cursor])) {
|
||||
// opening bracket
|
||||
if (false !== strpos('([{', $this->code[$this->cursor])) {
|
||||
$this->brackets[] = array($this->code[$this->cursor], $this->lineno);
|
||||
$this->brackets[] = [$this->code[$this->cursor], $this->lineno];
|
||||
}
|
||||
// closing bracket
|
||||
elseif (false !== strpos(')]}', $this->code[$this->cursor])) {
|
||||
|
@ -286,7 +286,7 @@ class Twig_Lexer implements Twig_LexerInterface
|
|||
}
|
||||
// opening double quoted string
|
||||
elseif (preg_match(self::REGEX_DQ_STRING_DELIM, $this->code, $match, null, $this->cursor)) {
|
||||
$this->brackets[] = array('"', $this->lineno);
|
||||
$this->brackets[] = ['"', $this->lineno];
|
||||
$this->pushState(self::STATE_STRING);
|
||||
$this->moveCursor($match[0]);
|
||||
}
|
||||
|
@ -328,7 +328,7 @@ class Twig_Lexer implements Twig_LexerInterface
|
|||
protected function lexString()
|
||||
{
|
||||
if (preg_match($this->regexes['interpolation_start'], $this->code, $match, null, $this->cursor)) {
|
||||
$this->brackets[] = array($this->options['interpolation'][0], $this->lineno);
|
||||
$this->brackets[] = [$this->options['interpolation'][0], $this->lineno];
|
||||
$this->pushToken(Twig_Token::INTERPOLATION_START_TYPE);
|
||||
$this->moveCursor($match[0]);
|
||||
$this->pushState(self::STATE_INTERPOLATION);
|
||||
|
@ -381,7 +381,7 @@ class Twig_Lexer implements Twig_LexerInterface
|
|||
protected function getOperatorRegex()
|
||||
{
|
||||
$operators = array_merge(
|
||||
array('='),
|
||||
['='],
|
||||
array_keys($this->env->getUnaryOperators()),
|
||||
array_keys($this->env->getBinaryOperators())
|
||||
);
|
||||
|
@ -389,7 +389,7 @@ class Twig_Lexer implements Twig_LexerInterface
|
|||
$operators = array_combine($operators, array_map('strlen', $operators));
|
||||
arsort($operators);
|
||||
|
||||
$regex = array();
|
||||
$regex = [];
|
||||
foreach ($operators as $operator => $length) {
|
||||
// an operator that ends with a character must be followed by
|
||||
// a whitespace or a parenthesis
|
||||
|
|
4
vendor/twig/twig/lib/Twig/Loader/Array.php
vendored
4
vendor/twig/twig/lib/Twig/Loader/Array.php
vendored
|
@ -25,12 +25,12 @@
|
|||
*/
|
||||
class Twig_Loader_Array implements Twig_LoaderInterface, Twig_ExistsLoaderInterface, Twig_SourceContextLoaderInterface
|
||||
{
|
||||
protected $templates = array();
|
||||
protected $templates = [];
|
||||
|
||||
/**
|
||||
* @param array $templates An array of templates (keys are the names, and values are the source code)
|
||||
*/
|
||||
public function __construct(array $templates = array())
|
||||
public function __construct(array $templates = [])
|
||||
{
|
||||
$this->templates = $templates;
|
||||
}
|
||||
|
|
16
vendor/twig/twig/lib/Twig/Loader/Chain.php
vendored
16
vendor/twig/twig/lib/Twig/Loader/Chain.php
vendored
|
@ -18,13 +18,13 @@
|
|||
*/
|
||||
class Twig_Loader_Chain implements Twig_LoaderInterface, Twig_ExistsLoaderInterface, Twig_SourceContextLoaderInterface
|
||||
{
|
||||
private $hasSourceCache = array();
|
||||
protected $loaders = array();
|
||||
private $hasSourceCache = [];
|
||||
protected $loaders = [];
|
||||
|
||||
/**
|
||||
* @param Twig_LoaderInterface[] $loaders
|
||||
*/
|
||||
public function __construct(array $loaders = array())
|
||||
public function __construct(array $loaders = [])
|
||||
{
|
||||
foreach ($loaders as $loader) {
|
||||
$this->addLoader($loader);
|
||||
|
@ -34,14 +34,14 @@ class Twig_Loader_Chain implements Twig_LoaderInterface, Twig_ExistsLoaderInterf
|
|||
public function addLoader(Twig_LoaderInterface $loader)
|
||||
{
|
||||
$this->loaders[] = $loader;
|
||||
$this->hasSourceCache = array();
|
||||
$this->hasSourceCache = [];
|
||||
}
|
||||
|
||||
public function getSource($name)
|
||||
{
|
||||
@trigger_error(sprintf('Calling "getSource" on "%s" is deprecated since 1.27. Use getSourceContext() instead.', get_class($this)), E_USER_DEPRECATED);
|
||||
|
||||
$exceptions = array();
|
||||
$exceptions = [];
|
||||
foreach ($this->loaders as $loader) {
|
||||
if ($loader instanceof Twig_ExistsLoaderInterface && !$loader->exists($name)) {
|
||||
continue;
|
||||
|
@ -59,7 +59,7 @@ class Twig_Loader_Chain implements Twig_LoaderInterface, Twig_ExistsLoaderInterf
|
|||
|
||||
public function getSourceContext($name)
|
||||
{
|
||||
$exceptions = array();
|
||||
$exceptions = [];
|
||||
foreach ($this->loaders as $loader) {
|
||||
if ($loader instanceof Twig_ExistsLoaderInterface && !$loader->exists($name)) {
|
||||
continue;
|
||||
|
@ -113,7 +113,7 @@ class Twig_Loader_Chain implements Twig_LoaderInterface, Twig_ExistsLoaderInterf
|
|||
|
||||
public function getCacheKey($name)
|
||||
{
|
||||
$exceptions = array();
|
||||
$exceptions = [];
|
||||
foreach ($this->loaders as $loader) {
|
||||
if ($loader instanceof Twig_ExistsLoaderInterface && !$loader->exists($name)) {
|
||||
continue;
|
||||
|
@ -131,7 +131,7 @@ class Twig_Loader_Chain implements Twig_LoaderInterface, Twig_ExistsLoaderInterf
|
|||
|
||||
public function isFresh($name, $time)
|
||||
{
|
||||
$exceptions = array();
|
||||
$exceptions = [];
|
||||
foreach ($this->loaders as $loader) {
|
||||
if ($loader instanceof Twig_ExistsLoaderInterface && !$loader->exists($name)) {
|
||||
continue;
|
||||
|
|
34
vendor/twig/twig/lib/Twig/Loader/Filesystem.php
vendored
34
vendor/twig/twig/lib/Twig/Loader/Filesystem.php
vendored
|
@ -19,9 +19,9 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
|
|||
/** Identifier of the main namespace. */
|
||||
const MAIN_NAMESPACE = '__main__';
|
||||
|
||||
protected $paths = array();
|
||||
protected $cache = array();
|
||||
protected $errorCache = array();
|
||||
protected $paths = [];
|
||||
protected $cache = [];
|
||||
protected $errorCache = [];
|
||||
|
||||
private $rootPath;
|
||||
|
||||
|
@ -29,7 +29,7 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
|
|||
* @param string|array $paths A path or an array of paths where to look for templates
|
||||
* @param string|null $rootPath The root path common to all relative paths (null for getcwd())
|
||||
*/
|
||||
public function __construct($paths = array(), $rootPath = null)
|
||||
public function __construct($paths = [], $rootPath = null)
|
||||
{
|
||||
$this->rootPath = (null === $rootPath ? getcwd() : $rootPath).DIRECTORY_SEPARATOR;
|
||||
if (false !== $realPath = realpath($rootPath)) {
|
||||
|
@ -50,7 +50,7 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
|
|||
*/
|
||||
public function getPaths($namespace = self::MAIN_NAMESPACE)
|
||||
{
|
||||
return isset($this->paths[$namespace]) ? $this->paths[$namespace] : array();
|
||||
return isset($this->paths[$namespace]) ? $this->paths[$namespace] : [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -74,10 +74,10 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
|
|||
public function setPaths($paths, $namespace = self::MAIN_NAMESPACE)
|
||||
{
|
||||
if (!is_array($paths)) {
|
||||
$paths = array($paths);
|
||||
$paths = [$paths];
|
||||
}
|
||||
|
||||
$this->paths[$namespace] = array();
|
||||
$this->paths[$namespace] = [];
|
||||
foreach ($paths as $path) {
|
||||
$this->addPath($path, $namespace);
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
|
|||
public function addPath($path, $namespace = self::MAIN_NAMESPACE)
|
||||
{
|
||||
// invalidate the cache
|
||||
$this->cache = $this->errorCache = array();
|
||||
$this->cache = $this->errorCache = [];
|
||||
|
||||
$checkPath = $this->isAbsolutePath($path) ? $path : $this->rootPath.$path;
|
||||
if (!is_dir($checkPath)) {
|
||||
|
@ -115,7 +115,7 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
|
|||
public function prependPath($path, $namespace = self::MAIN_NAMESPACE)
|
||||
{
|
||||
// invalidate the cache
|
||||
$this->cache = $this->errorCache = array();
|
||||
$this->cache = $this->errorCache = [];
|
||||
|
||||
$checkPath = $this->isAbsolutePath($path) ? $path : $this->rootPath.$path;
|
||||
if (!is_dir($checkPath)) {
|
||||
|
@ -195,9 +195,17 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
|
|||
throw new Twig_Error_Loader($this->errorCache[$name]);
|
||||
}
|
||||
|
||||
$this->validateName($name);
|
||||
try {
|
||||
$this->validateName($name);
|
||||
|
||||
list($namespace, $shortname) = $this->parseName($name);
|
||||
list($namespace, $shortname) = $this->parseName($name);
|
||||
} catch (Twig_Error_Loader $e) {
|
||||
if (!$throw) {
|
||||
return false;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if (!isset($this->paths[$namespace])) {
|
||||
$this->errorCache[$name] = sprintf('There are no registered paths for namespace "%s".', $namespace);
|
||||
|
@ -242,10 +250,10 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
|
|||
$namespace = substr($name, 1, $pos - 1);
|
||||
$shortname = substr($name, $pos + 1);
|
||||
|
||||
return array($namespace, $shortname);
|
||||
return [$namespace, $shortname];
|
||||
}
|
||||
|
||||
return array($default, $name);
|
||||
return [$default, $name];
|
||||
}
|
||||
|
||||
protected function normalizeName($name)
|
||||
|
|
8
vendor/twig/twig/lib/Twig/Node.php
vendored
8
vendor/twig/twig/lib/Twig/Node.php
vendored
|
@ -35,7 +35,7 @@ class Twig_Node implements Twig_NodeInterface
|
|||
* @param int $lineno The line number
|
||||
* @param string $tag The tag name associated with the Node
|
||||
*/
|
||||
public function __construct(array $nodes = array(), array $attributes = array(), $lineno = 0, $tag = null)
|
||||
public function __construct(array $nodes = [], array $attributes = [], $lineno = 0, $tag = null)
|
||||
{
|
||||
foreach ($nodes as $name => $node) {
|
||||
if (!$node instanceof Twig_NodeInterface) {
|
||||
|
@ -50,17 +50,17 @@ class Twig_Node implements Twig_NodeInterface
|
|||
|
||||
public function __toString()
|
||||
{
|
||||
$attributes = array();
|
||||
$attributes = [];
|
||||
foreach ($this->attributes as $name => $value) {
|
||||
$attributes[] = sprintf('%s: %s', $name, str_replace("\n", '', var_export($value, true)));
|
||||
}
|
||||
|
||||
$repr = array(get_class($this).'('.implode(', ', $attributes));
|
||||
$repr = [get_class($this).'('.implode(', ', $attributes)];
|
||||
|
||||
if (count($this->nodes)) {
|
||||
foreach ($this->nodes as $name => $node) {
|
||||
$len = strlen($name) + 4;
|
||||
$noderepr = array();
|
||||
$noderepr = [];
|
||||
foreach (explode("\n", (string) $node) as $line) {
|
||||
$noderepr[] = str_repeat(' ', $len).$line;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ class Twig_Node_AutoEscape extends Twig_Node
|
|||
{
|
||||
public function __construct($value, Twig_NodeInterface $body, $lineno, $tag = 'autoescape')
|
||||
{
|
||||
parent::__construct(array('body' => $body), array('value' => $value), $lineno, $tag);
|
||||
parent::__construct(['body' => $body], ['value' => $value], $lineno, $tag);
|
||||
}
|
||||
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
|
|
4
vendor/twig/twig/lib/Twig/Node/Block.php
vendored
4
vendor/twig/twig/lib/Twig/Node/Block.php
vendored
|
@ -19,14 +19,14 @@ class Twig_Node_Block extends Twig_Node
|
|||
{
|
||||
public function __construct($name, Twig_NodeInterface $body, $lineno, $tag = null)
|
||||
{
|
||||
parent::__construct(array('body' => $body), array('name' => $name), $lineno, $tag);
|
||||
parent::__construct(['body' => $body], ['name' => $name], $lineno, $tag);
|
||||
}
|
||||
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
{
|
||||
$compiler
|
||||
->addDebugInfo($this)
|
||||
->write(sprintf("public function block_%s(\$context, array \$blocks = array())\n", $this->getAttribute('name')), "{\n")
|
||||
->write(sprintf("public function block_%s(\$context, array \$blocks = [])\n", $this->getAttribute('name')), "{\n")
|
||||
->indent()
|
||||
;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ class Twig_Node_BlockReference extends Twig_Node implements Twig_NodeOutputInter
|
|||
{
|
||||
public function __construct($name, $lineno, $tag = null)
|
||||
{
|
||||
parent::__construct(array(), array('name' => $name), $lineno, $tag);
|
||||
parent::__construct([], ['name' => $name], $lineno, $tag);
|
||||
}
|
||||
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
|
|
10
vendor/twig/twig/lib/Twig/Node/CheckSecurity.php
vendored
10
vendor/twig/twig/lib/Twig/Node/CheckSecurity.php
vendored
|
@ -29,8 +29,8 @@ class Twig_Node_CheckSecurity extends Twig_Node
|
|||
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
{
|
||||
$tags = $filters = $functions = array();
|
||||
foreach (array('tags', 'filters', 'functions') as $type) {
|
||||
$tags = $filters = $functions = [];
|
||||
foreach (['tags', 'filters', 'functions'] as $type) {
|
||||
foreach ($this->{'used'.ucfirst($type)} as $name => $node) {
|
||||
if ($node instanceof Twig_Node) {
|
||||
${$type}[$name] = $node->getTemplateLine();
|
||||
|
@ -48,9 +48,9 @@ class Twig_Node_CheckSecurity extends Twig_Node
|
|||
->indent()
|
||||
->write("\$this->env->getExtension('Twig_Extension_Sandbox')->checkSecurity(\n")
|
||||
->indent()
|
||||
->write(!$tags ? "array(),\n" : "array('".implode("', '", array_keys($tags))."'),\n")
|
||||
->write(!$filters ? "array(),\n" : "array('".implode("', '", array_keys($filters))."'),\n")
|
||||
->write(!$functions ? "array()\n" : "array('".implode("', '", array_keys($functions))."')\n")
|
||||
->write(!$tags ? "[],\n" : "['".implode("', '", array_keys($tags))."'],\n")
|
||||
->write(!$filters ? "[],\n" : "['".implode("', '", array_keys($filters))."'],\n")
|
||||
->write(!$functions ? "[]\n" : "['".implode("', '", array_keys($functions))."']\n")
|
||||
->outdent()
|
||||
->write(");\n")
|
||||
->outdent()
|
||||
|
|
49
vendor/twig/twig/lib/Twig/Node/Deprecated.php
vendored
Normal file
49
vendor/twig/twig/lib/Twig/Node/Deprecated.php
vendored
Normal file
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Twig.
|
||||
*
|
||||
* (c) Fabien Potencier
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Represents a deprecated node.
|
||||
*
|
||||
* @author Yonel Ceruto <yonelceruto@gmail.com>
|
||||
*/
|
||||
class Twig_Node_Deprecated extends Twig_Node
|
||||
{
|
||||
public function __construct(Twig_Node_Expression $expr, $lineno, $tag = null)
|
||||
{
|
||||
parent::__construct(['expr' => $expr], [], $lineno, $tag);
|
||||
}
|
||||
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
{
|
||||
$compiler->addDebugInfo($this);
|
||||
|
||||
$expr = $this->getNode('expr');
|
||||
|
||||
if ($expr instanceof Twig_Node_Expression_Constant) {
|
||||
$compiler->write('@trigger_error(')
|
||||
->subcompile($expr);
|
||||
} else {
|
||||
$varName = $compiler->getVarName();
|
||||
$compiler->write(sprintf('$%s = ', $varName))
|
||||
->subcompile($expr)
|
||||
->raw(";\n")
|
||||
->write(sprintf('@trigger_error($%s', $varName));
|
||||
}
|
||||
|
||||
$compiler
|
||||
->raw('.')
|
||||
->string(sprintf(' ("%s" at line %d).', $this->getTemplateName(), $this->getTemplateLine()))
|
||||
->raw(", E_USER_DEPRECATED);\n")
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
class_alias('Twig_Node_Deprecated', 'Twig\Node\DeprecatedNode', false);
|
2
vendor/twig/twig/lib/Twig/Node/Do.php
vendored
2
vendor/twig/twig/lib/Twig/Node/Do.php
vendored
|
@ -18,7 +18,7 @@ class Twig_Node_Do extends Twig_Node
|
|||
{
|
||||
public function __construct(Twig_Node_Expression $expr, $lineno, $tag = null)
|
||||
{
|
||||
parent::__construct(array('expr' => $expr), array(), $lineno, $tag);
|
||||
parent::__construct(['expr' => $expr], [], $lineno, $tag);
|
||||
}
|
||||
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
|
|
|
@ -14,7 +14,7 @@ class Twig_Node_Expression_Array extends Twig_Node_Expression
|
|||
|
||||
public function __construct(array $elements, $lineno)
|
||||
{
|
||||
parent::__construct($elements, array(), $lineno);
|
||||
parent::__construct($elements, [], $lineno);
|
||||
|
||||
$this->index = -1;
|
||||
foreach ($this->getKeyValuePairs() as $pair) {
|
||||
|
@ -26,13 +26,13 @@ class Twig_Node_Expression_Array extends Twig_Node_Expression
|
|||
|
||||
public function getKeyValuePairs()
|
||||
{
|
||||
$pairs = array();
|
||||
$pairs = [];
|
||||
|
||||
foreach (array_chunk($this->nodes, 2) as $pair) {
|
||||
$pairs[] = array(
|
||||
$pairs[] = [
|
||||
'key' => $pair[0],
|
||||
'value' => $pair[1],
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
return $pairs;
|
||||
|
@ -62,7 +62,7 @@ class Twig_Node_Expression_Array extends Twig_Node_Expression
|
|||
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
{
|
||||
$compiler->raw('array(');
|
||||
$compiler->raw('[');
|
||||
$first = true;
|
||||
foreach ($this->getKeyValuePairs() as $pair) {
|
||||
if (!$first) {
|
||||
|
@ -76,7 +76,7 @@ class Twig_Node_Expression_Array extends Twig_Node_Expression
|
|||
->subcompile($pair['value'])
|
||||
;
|
||||
}
|
||||
$compiler->raw(')');
|
||||
$compiler->raw(']');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ abstract class Twig_Node_Expression_Binary extends Twig_Node_Expression
|
|||
{
|
||||
public function __construct(Twig_NodeInterface $left, Twig_NodeInterface $right, $lineno)
|
||||
{
|
||||
parent::__construct(array('left' => $left, 'right' => $right), array(), $lineno);
|
||||
parent::__construct(['left' => $left, 'right' => $right], [], $lineno);
|
||||
}
|
||||
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
|
|
|
@ -28,12 +28,12 @@ class Twig_Node_Expression_BlockReference extends Twig_Node_Expression
|
|||
$template = null;
|
||||
}
|
||||
|
||||
$nodes = array('name' => $name);
|
||||
$nodes = ['name' => $name];
|
||||
if (null !== $template) {
|
||||
$nodes['template'] = $template;
|
||||
}
|
||||
|
||||
parent::__construct($nodes, array('is_defined_test' => false, 'output' => false), $lineno, $tag);
|
||||
parent::__construct($nodes, ['is_defined_test' => false, 'output' => false], $lineno, $tag);
|
||||
}
|
||||
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
|
|
|
@ -15,6 +15,7 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
|
|||
protected function compileCallable(Twig_Compiler $compiler)
|
||||
{
|
||||
$closingParenthesis = false;
|
||||
$isArray = false;
|
||||
if ($this->hasAttribute('callable') && $callable = $this->getAttribute('callable')) {
|
||||
if (is_string($callable) && false === strpos($callable, '::')) {
|
||||
$compiler->raw($callable);
|
||||
|
@ -30,24 +31,25 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
|
|||
$compiler->raw(sprintf('$this->env->getExtension(\'%s\')->%s', get_class($callable[0]), $callable[1]));
|
||||
} else {
|
||||
$type = ucfirst($this->getAttribute('type'));
|
||||
$compiler->raw(sprintf('call_user_func_array($this->env->get%s(\'%s\')->getCallable(), array', $type, $this->getAttribute('name')));
|
||||
$compiler->raw(sprintf('call_user_func_array($this->env->get%s(\'%s\')->getCallable(), ', $type, $this->getAttribute('name')));
|
||||
$closingParenthesis = true;
|
||||
$isArray = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$compiler->raw($this->getAttribute('thing')->compile());
|
||||
}
|
||||
|
||||
$this->compileArguments($compiler);
|
||||
$this->compileArguments($compiler, $isArray);
|
||||
|
||||
if ($closingParenthesis) {
|
||||
$compiler->raw(')');
|
||||
}
|
||||
}
|
||||
|
||||
protected function compileArguments(Twig_Compiler $compiler)
|
||||
protected function compileArguments(Twig_Compiler $compiler, $isArray = false)
|
||||
{
|
||||
$compiler->raw('(');
|
||||
$compiler->raw($isArray ? '[' : '(');
|
||||
|
||||
$first = true;
|
||||
|
||||
|
@ -96,7 +98,7 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
|
|||
}
|
||||
}
|
||||
|
||||
$compiler->raw(')');
|
||||
$compiler->raw($isArray ? ']' : ')');
|
||||
}
|
||||
|
||||
protected function getArguments($callable, $arguments)
|
||||
|
@ -104,7 +106,7 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
|
|||
$callType = $this->getAttribute('type');
|
||||
$callName = $this->getAttribute('name');
|
||||
|
||||
$parameters = array();
|
||||
$parameters = [];
|
||||
$named = false;
|
||||
foreach ($arguments as $name => $node) {
|
||||
if (!is_int($name)) {
|
||||
|
@ -133,10 +135,10 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
|
|||
}
|
||||
|
||||
$callableParameters = $this->getCallableParameters($callable, $isVariadic);
|
||||
$arguments = array();
|
||||
$names = array();
|
||||
$missingArguments = array();
|
||||
$optionalArguments = array();
|
||||
$arguments = [];
|
||||
$names = [];
|
||||
$missingArguments = [];
|
||||
$optionalArguments = [];
|
||||
$pos = 0;
|
||||
foreach ($callableParameters as $callableParameter) {
|
||||
$names[] = $name = $this->normalizeName($callableParameter->name);
|
||||
|
@ -156,12 +158,12 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
|
|||
$arguments = array_merge($arguments, $optionalArguments);
|
||||
$arguments[] = $parameters[$name];
|
||||
unset($parameters[$name]);
|
||||
$optionalArguments = array();
|
||||
$optionalArguments = [];
|
||||
} elseif (array_key_exists($pos, $parameters)) {
|
||||
$arguments = array_merge($arguments, $optionalArguments);
|
||||
$arguments[] = $parameters[$pos];
|
||||
unset($parameters[$pos]);
|
||||
$optionalArguments = array();
|
||||
$optionalArguments = [];
|
||||
++$pos;
|
||||
} elseif ($callableParameter->isDefaultValueAvailable()) {
|
||||
$optionalArguments[] = new Twig_Node_Expression_Constant($callableParameter->getDefaultValue(), -1);
|
||||
|
@ -177,7 +179,7 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
|
|||
}
|
||||
|
||||
if ($isVariadic) {
|
||||
$arbitraryArguments = new Twig_Node_Expression_Array(array(), -1);
|
||||
$arbitraryArguments = new Twig_Node_Expression_Array([], -1);
|
||||
foreach ($parameters as $key => $value) {
|
||||
if (is_int($key)) {
|
||||
$arbitraryArguments->addElement($value);
|
||||
|
@ -213,14 +215,14 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
|
|||
|
||||
protected function normalizeName($name)
|
||||
{
|
||||
return strtolower(preg_replace(array('/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'), array('\\1_\\2', '\\1_\\2'), $name));
|
||||
return strtolower(preg_replace(['/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'], ['\\1_\\2', '\\1_\\2'], $name));
|
||||
}
|
||||
|
||||
private function getCallableParameters($callable, $isVariadic)
|
||||
{
|
||||
list($r) = $this->reflectCallable($callable);
|
||||
if (null === $r) {
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
$parameters = $r->getParameters();
|
||||
|
@ -240,7 +242,7 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
|
|||
}
|
||||
if ($isVariadic) {
|
||||
$argument = end($parameters);
|
||||
if ($argument && $argument->isArray() && $argument->isDefaultValueAvailable() && array() === $argument->getDefaultValue()) {
|
||||
if ($argument && $argument->isArray() && $argument->isDefaultValueAvailable() && [] === $argument->getDefaultValue()) {
|
||||
array_pop($parameters);
|
||||
} else {
|
||||
$callableName = $r->name;
|
||||
|
@ -248,7 +250,7 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
|
|||
$callableName = $r->getDeclaringClass()->name.'::'.$callableName;
|
||||
}
|
||||
|
||||
throw new LogicException(sprintf('The last parameter of "%s" for %s "%s" must be an array with default value, eg. "array $arg = array()".', $callableName, $this->getAttribute('type'), $this->getAttribute('name')));
|
||||
throw new LogicException(sprintf('The last parameter of "%s" for %s "%s" must be an array with default value, eg. "array $arg = []".', $callableName, $this->getAttribute('type'), $this->getAttribute('name')));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -264,27 +266,27 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
|
|||
if (is_array($callable)) {
|
||||
if (!method_exists($callable[0], $callable[1])) {
|
||||
// __call()
|
||||
return array(null, array());
|
||||
return [null, []];
|
||||
}
|
||||
$r = new ReflectionMethod($callable[0], $callable[1]);
|
||||
} elseif (is_object($callable) && !$callable instanceof Closure) {
|
||||
$r = new ReflectionObject($callable);
|
||||
$r = $r->getMethod('__invoke');
|
||||
$callable = array($callable, '__invoke');
|
||||
$callable = [$callable, '__invoke'];
|
||||
} elseif (is_string($callable) && false !== $pos = strpos($callable, '::')) {
|
||||
$class = substr($callable, 0, $pos);
|
||||
$method = substr($callable, $pos + 2);
|
||||
if (!method_exists($class, $method)) {
|
||||
// __staticCall()
|
||||
return array(null, array());
|
||||
return [null, []];
|
||||
}
|
||||
$r = new ReflectionMethod($callable);
|
||||
$callable = array($class, $method);
|
||||
$callable = [$class, $method];
|
||||
} else {
|
||||
$r = new ReflectionFunction($callable);
|
||||
}
|
||||
|
||||
return $this->reflector = array($r, $callable);
|
||||
return $this->reflector = [$r, $callable];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ class Twig_Node_Expression_Conditional extends Twig_Node_Expression
|
|||
{
|
||||
public function __construct(Twig_Node_Expression $expr1, Twig_Node_Expression $expr2, Twig_Node_Expression $expr3, $lineno)
|
||||
{
|
||||
parent::__construct(array('expr1' => $expr1, 'expr2' => $expr2, 'expr3' => $expr3), array(), $lineno);
|
||||
parent::__construct(['expr1' => $expr1, 'expr2' => $expr2, 'expr3' => $expr3], [], $lineno);
|
||||
}
|
||||
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
|
|
|
@ -13,7 +13,7 @@ class Twig_Node_Expression_Constant extends Twig_Node_Expression
|
|||
{
|
||||
public function __construct($value, $lineno)
|
||||
{
|
||||
parent::__construct(array(), array('value' => $value), $lineno);
|
||||
parent::__construct([], ['value' => $value], $lineno);
|
||||
}
|
||||
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
|
|
|
@ -22,7 +22,7 @@ class Twig_Node_Expression_ExtensionReference extends Twig_Node_Expression
|
|||
{
|
||||
public function __construct($name, $lineno, $tag = null)
|
||||
{
|
||||
parent::__construct(array(), array('name' => $name), $lineno, $tag);
|
||||
parent::__construct([], ['name' => $name], $lineno, $tag);
|
||||
}
|
||||
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
|
|
|
@ -13,7 +13,7 @@ class Twig_Node_Expression_Filter extends Twig_Node_Expression_Call
|
|||
{
|
||||
public function __construct(Twig_NodeInterface $node, Twig_Node_Expression_Constant $filterName, Twig_NodeInterface $arguments, $lineno, $tag = null)
|
||||
{
|
||||
parent::__construct(array('node' => $node, 'filter' => $filterName, 'arguments' => $arguments), array(), $lineno, $tag);
|
||||
parent::__construct(['node' => $node, 'filter' => $filterName, 'arguments' => $arguments], [], $lineno, $tag);
|
||||
}
|
||||
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
|
|
|
@ -12,7 +12,7 @@ class Twig_Node_Expression_Function extends Twig_Node_Expression_Call
|
|||
{
|
||||
public function __construct($name, Twig_NodeInterface $arguments, $lineno)
|
||||
{
|
||||
parent::__construct(array('arguments' => $arguments), array('name' => $name, 'is_defined_test' => false), $lineno);
|
||||
parent::__construct(['arguments' => $arguments], ['name' => $name, 'is_defined_test' => false], $lineno);
|
||||
}
|
||||
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
|
|
|
@ -13,12 +13,12 @@ class Twig_Node_Expression_GetAttr extends Twig_Node_Expression
|
|||
{
|
||||
public function __construct(Twig_Node_Expression $node, Twig_Node_Expression $attribute, Twig_Node_Expression $arguments = null, $type, $lineno)
|
||||
{
|
||||
$nodes = array('node' => $node, 'attribute' => $attribute);
|
||||
$nodes = ['node' => $node, 'attribute' => $attribute];
|
||||
if (null !== $arguments) {
|
||||
$nodes['arguments'] = $arguments;
|
||||
}
|
||||
|
||||
parent::__construct($nodes, array('type' => $type, 'is_defined_test' => false, 'ignore_strict_check' => false, 'disable_c_ext' => false), $lineno);
|
||||
parent::__construct($nodes, ['type' => $type, 'is_defined_test' => false, 'ignore_strict_check' => false, 'disable_c_ext' => false], $lineno);
|
||||
}
|
||||
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
|
@ -51,7 +51,7 @@ class Twig_Node_Expression_GetAttr extends Twig_Node_Expression
|
|||
if ($this->hasNode('arguments')) {
|
||||
$compiler->raw(', ')->subcompile($this->getNode('arguments'));
|
||||
} else {
|
||||
$compiler->raw(', array()');
|
||||
$compiler->raw(', []');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ class Twig_Node_Expression_MethodCall extends Twig_Node_Expression
|
|||
{
|
||||
public function __construct(Twig_Node_Expression $node, $method, Twig_Node_Expression_Array $arguments, $lineno)
|
||||
{
|
||||
parent::__construct(array('node' => $node, 'arguments' => $arguments), array('method' => $method, 'safe' => false), $lineno);
|
||||
parent::__construct(['node' => $node, 'arguments' => $arguments], ['method' => $method, 'safe' => false], $lineno);
|
||||
|
||||
if ($node instanceof Twig_Node_Expression_Name) {
|
||||
$node->setAttribute('always_defined', true);
|
||||
|
|
|
@ -11,15 +11,15 @@
|
|||
*/
|
||||
class Twig_Node_Expression_Name extends Twig_Node_Expression
|
||||
{
|
||||
protected $specialVars = array(
|
||||
protected $specialVars = [
|
||||
'_self' => '$this',
|
||||
'_context' => '$context',
|
||||
'_charset' => '$this->env->getCharset()',
|
||||
);
|
||||
];
|
||||
|
||||
public function __construct($name, $lineno)
|
||||
{
|
||||
parent::__construct(array(), array('name' => $name, 'is_defined_test' => false, 'ignore_strict_check' => false, 'always_defined' => false), $lineno);
|
||||
parent::__construct([], ['name' => $name, 'is_defined_test' => false, 'ignore_strict_check' => false, 'always_defined' => false], $lineno);
|
||||
}
|
||||
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
|
|
|
@ -19,7 +19,7 @@ class Twig_Node_Expression_Parent extends Twig_Node_Expression
|
|||
{
|
||||
public function __construct($name, $lineno, $tag = null)
|
||||
{
|
||||
parent::__construct(array(), array('output' => false, 'name' => $name), $lineno, $tag);
|
||||
parent::__construct([], ['output' => false, 'name' => $name], $lineno, $tag);
|
||||
}
|
||||
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
|
|
|
@ -12,7 +12,7 @@ class Twig_Node_Expression_TempName extends Twig_Node_Expression
|
|||
{
|
||||
public function __construct($name, $lineno)
|
||||
{
|
||||
parent::__construct(array(), array('name' => $name), $lineno);
|
||||
parent::__construct([], ['name' => $name], $lineno);
|
||||
}
|
||||
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
|
|
|
@ -12,12 +12,12 @@ class Twig_Node_Expression_Test extends Twig_Node_Expression_Call
|
|||
{
|
||||
public function __construct(Twig_NodeInterface $node, $name, Twig_NodeInterface $arguments = null, $lineno)
|
||||
{
|
||||
$nodes = array('node' => $node);
|
||||
$nodes = ['node' => $node];
|
||||
if (null !== $arguments) {
|
||||
$nodes['arguments'] = $arguments;
|
||||
}
|
||||
|
||||
parent::__construct($nodes, array('name' => $name), $lineno);
|
||||
parent::__construct($nodes, ['name' => $name], $lineno);
|
||||
}
|
||||
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
|
@ -28,6 +28,9 @@ class Twig_Node_Expression_Test extends Twig_Node_Expression_Call
|
|||
$this->setAttribute('name', $name);
|
||||
$this->setAttribute('type', 'test');
|
||||
$this->setAttribute('thing', $test);
|
||||
if ($test instanceof Twig_SimpleTest) {
|
||||
$this->setAttribute('arguments', $test->getArguments());
|
||||
}
|
||||
if ($test instanceof Twig_TestCallableInterface || $test instanceof Twig_SimpleTest) {
|
||||
$this->setAttribute('callable', $test->getCallable());
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ abstract class Twig_Node_Expression_Unary extends Twig_Node_Expression
|
|||
{
|
||||
public function __construct(Twig_NodeInterface $node, $lineno)
|
||||
{
|
||||
parent::__construct(array('node' => $node), array(), $lineno);
|
||||
parent::__construct(['node' => $node], [], $lineno);
|
||||
}
|
||||
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
|
|
2
vendor/twig/twig/lib/Twig/Node/Flush.php
vendored
2
vendor/twig/twig/lib/Twig/Node/Flush.php
vendored
|
@ -18,7 +18,7 @@ class Twig_Node_Flush extends Twig_Node
|
|||
{
|
||||
public function __construct($lineno, $tag)
|
||||
{
|
||||
parent::__construct(array(), array(), $lineno, $tag);
|
||||
parent::__construct([], [], $lineno, $tag);
|
||||
}
|
||||
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
|
|
12
vendor/twig/twig/lib/Twig/Node/For.php
vendored
12
vendor/twig/twig/lib/Twig/Node/For.php
vendored
|
@ -21,18 +21,18 @@ class Twig_Node_For extends Twig_Node
|
|||
|
||||
public function __construct(Twig_Node_Expression_AssignName $keyTarget, Twig_Node_Expression_AssignName $valueTarget, Twig_Node_Expression $seq, Twig_Node_Expression $ifexpr = null, Twig_NodeInterface $body, Twig_NodeInterface $else = null, $lineno, $tag = null)
|
||||
{
|
||||
$body = new Twig_Node(array($body, $this->loop = new Twig_Node_ForLoop($lineno, $tag)));
|
||||
$body = new Twig_Node([$body, $this->loop = new Twig_Node_ForLoop($lineno, $tag)]);
|
||||
|
||||
if (null !== $ifexpr) {
|
||||
$body = new Twig_Node_If(new Twig_Node(array($ifexpr, $body)), null, $lineno, $tag);
|
||||
$body = new Twig_Node_If(new Twig_Node([$ifexpr, $body]), null, $lineno, $tag);
|
||||
}
|
||||
|
||||
$nodes = array('key_target' => $keyTarget, 'value_target' => $valueTarget, 'seq' => $seq, 'body' => $body);
|
||||
$nodes = ['key_target' => $keyTarget, 'value_target' => $valueTarget, 'seq' => $seq, 'body' => $body];
|
||||
if (null !== $else) {
|
||||
$nodes['else'] = $else;
|
||||
}
|
||||
|
||||
parent::__construct($nodes, array('with_loop' => true, 'ifexpr' => null !== $ifexpr), $lineno, $tag);
|
||||
parent::__construct($nodes, ['with_loop' => true, 'ifexpr' => null !== $ifexpr], $lineno, $tag);
|
||||
}
|
||||
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
|
@ -51,12 +51,12 @@ class Twig_Node_For extends Twig_Node
|
|||
|
||||
if ($this->getAttribute('with_loop')) {
|
||||
$compiler
|
||||
->write("\$context['loop'] = array(\n")
|
||||
->write("\$context['loop'] = [\n")
|
||||
->write(" 'parent' => \$context['_parent'],\n")
|
||||
->write(" 'index0' => 0,\n")
|
||||
->write(" 'index' => 1,\n")
|
||||
->write(" 'first' => true,\n")
|
||||
->write(");\n")
|
||||
->write("];\n")
|
||||
;
|
||||
|
||||
if (!$this->getAttribute('ifexpr')) {
|
||||
|
|
2
vendor/twig/twig/lib/Twig/Node/ForLoop.php
vendored
2
vendor/twig/twig/lib/Twig/Node/ForLoop.php
vendored
|
@ -18,7 +18,7 @@ class Twig_Node_ForLoop extends Twig_Node
|
|||
{
|
||||
public function __construct($lineno, $tag = null)
|
||||
{
|
||||
parent::__construct(array(), array('with_loop' => false, 'ifexpr' => false, 'else' => false), $lineno, $tag);
|
||||
parent::__construct([], ['with_loop' => false, 'ifexpr' => false, 'else' => false], $lineno, $tag);
|
||||
}
|
||||
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
|
|
4
vendor/twig/twig/lib/Twig/Node/If.php
vendored
4
vendor/twig/twig/lib/Twig/Node/If.php
vendored
|
@ -19,12 +19,12 @@ class Twig_Node_If extends Twig_Node
|
|||
{
|
||||
public function __construct(Twig_NodeInterface $tests, Twig_NodeInterface $else = null, $lineno, $tag = null)
|
||||
{
|
||||
$nodes = array('tests' => $tests);
|
||||
$nodes = ['tests' => $tests];
|
||||
if (null !== $else) {
|
||||
$nodes['else'] = $else;
|
||||
}
|
||||
|
||||
parent::__construct($nodes, array(), $lineno, $tag);
|
||||
parent::__construct($nodes, [], $lineno, $tag);
|
||||
}
|
||||
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
|
|
2
vendor/twig/twig/lib/Twig/Node/Import.php
vendored
2
vendor/twig/twig/lib/Twig/Node/Import.php
vendored
|
@ -18,7 +18,7 @@ class Twig_Node_Import extends Twig_Node
|
|||
{
|
||||
public function __construct(Twig_Node_Expression $expr, Twig_Node_Expression $var, $lineno, $tag = null)
|
||||
{
|
||||
parent::__construct(array('expr' => $expr, 'var' => $var), array(), $lineno, $tag);
|
||||
parent::__construct(['expr' => $expr, 'var' => $var], [], $lineno, $tag);
|
||||
}
|
||||
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
|
|
6
vendor/twig/twig/lib/Twig/Node/Include.php
vendored
6
vendor/twig/twig/lib/Twig/Node/Include.php
vendored
|
@ -19,12 +19,12 @@ class Twig_Node_Include extends Twig_Node implements Twig_NodeOutputInterface
|
|||
{
|
||||
public function __construct(Twig_Node_Expression $expr, Twig_Node_Expression $variables = null, $only = false, $ignoreMissing = false, $lineno, $tag = null)
|
||||
{
|
||||
$nodes = array('expr' => $expr);
|
||||
$nodes = ['expr' => $expr];
|
||||
if (null !== $variables) {
|
||||
$nodes['variables'] = $variables;
|
||||
}
|
||||
|
||||
parent::__construct($nodes, array('only' => (bool) $only, 'ignore_missing' => (bool) $ignoreMissing), $lineno, $tag);
|
||||
parent::__construct($nodes, ['only' => (bool) $only, 'ignore_missing' => (bool) $ignoreMissing], $lineno, $tag);
|
||||
}
|
||||
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
|
@ -74,7 +74,7 @@ class Twig_Node_Include extends Twig_Node implements Twig_NodeOutputInterface
|
|||
protected function addTemplateArguments(Twig_Compiler $compiler)
|
||||
{
|
||||
if (!$this->hasNode('variables')) {
|
||||
$compiler->raw(false === $this->getAttribute('only') ? '$context' : 'array()');
|
||||
$compiler->raw(false === $this->getAttribute('only') ? '$context' : '[]');
|
||||
} elseif (false === $this->getAttribute('only')) {
|
||||
$compiler
|
||||
->raw('array_merge($context, ')
|
||||
|
|
10
vendor/twig/twig/lib/Twig/Node/Macro.php
vendored
10
vendor/twig/twig/lib/Twig/Node/Macro.php
vendored
|
@ -26,7 +26,7 @@ class Twig_Node_Macro extends Twig_Node
|
|||
}
|
||||
}
|
||||
|
||||
parent::__construct(array('body' => $body, 'arguments' => $arguments), array('name' => $name), $lineno, $tag);
|
||||
parent::__construct(['body' => $body, 'arguments' => $arguments], ['name' => $name], $lineno, $tag);
|
||||
}
|
||||
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
|
@ -64,7 +64,7 @@ class Twig_Node_Macro extends Twig_Node
|
|||
;
|
||||
|
||||
$compiler
|
||||
->write("\$context = \$this->env->mergeGlobals(array(\n")
|
||||
->write("\$context = \$this->env->mergeGlobals([\n")
|
||||
->indent()
|
||||
;
|
||||
|
||||
|
@ -91,14 +91,14 @@ class Twig_Node_Macro extends Twig_Node
|
|||
->repr($count)
|
||||
->raw(' ? array_slice(func_get_args(), ')
|
||||
->repr($count)
|
||||
->raw(") : array(),\n")
|
||||
->raw(") : [],\n")
|
||||
;
|
||||
}
|
||||
|
||||
$compiler
|
||||
->outdent()
|
||||
->write("));\n\n")
|
||||
->write("\$blocks = array();\n\n")
|
||||
->write("]);\n\n")
|
||||
->write("\$blocks = [];\n\n")
|
||||
->write("ob_start();\n")
|
||||
->write("try {\n")
|
||||
->indent()
|
||||
|
|
29
vendor/twig/twig/lib/Twig/Node/Module.php
vendored
29
vendor/twig/twig/lib/Twig/Node/Module.php
vendored
|
@ -32,7 +32,7 @@ class Twig_Node_Module extends Twig_Node
|
|||
$this->source = $name;
|
||||
}
|
||||
|
||||
$nodes = array(
|
||||
$nodes = [
|
||||
'body' => $body,
|
||||
'blocks' => $blocks,
|
||||
'macros' => $macros,
|
||||
|
@ -42,20 +42,20 @@ class Twig_Node_Module extends Twig_Node
|
|||
'constructor_start' => new Twig_Node(),
|
||||
'constructor_end' => new Twig_Node(),
|
||||
'class_end' => new Twig_Node(),
|
||||
);
|
||||
];
|
||||
if (null !== $parent) {
|
||||
$nodes['parent'] = $parent;
|
||||
}
|
||||
|
||||
// embedded templates are set as attributes so that they are only visited once by the visitors
|
||||
parent::__construct($nodes, array(
|
||||
parent::__construct($nodes, [
|
||||
// source to be remove in 2.0
|
||||
'source' => $this->source->getCode(),
|
||||
// filename to be remove in 2.0 (use getTemplateName() instead)
|
||||
'filename' => $this->source->getName(),
|
||||
'index' => null,
|
||||
'embedded_templates' => $embeddedTemplates,
|
||||
), 1);
|
||||
], 1);
|
||||
|
||||
// populate the template name of all node children
|
||||
$this->setTemplateName($this->source->getName());
|
||||
|
@ -257,11 +257,11 @@ class Twig_Node_Module extends Twig_Node
|
|||
->write("\$this->blocks = array_merge(\n")
|
||||
->indent()
|
||||
->write("\$this->traits,\n")
|
||||
->write("array(\n")
|
||||
->write("[\n")
|
||||
;
|
||||
} else {
|
||||
$compiler
|
||||
->write("\$this->blocks = array(\n")
|
||||
->write("\$this->blocks = [\n")
|
||||
;
|
||||
}
|
||||
|
||||
|
@ -272,20 +272,25 @@ class Twig_Node_Module extends Twig_Node
|
|||
|
||||
foreach ($this->getNode('blocks') as $name => $node) {
|
||||
$compiler
|
||||
->write(sprintf("'%s' => array(\$this, 'block_%s'),\n", $name, $name))
|
||||
->write(sprintf("'%s' => [\$this, 'block_%s'],\n", $name, $name))
|
||||
;
|
||||
}
|
||||
|
||||
if ($countTraits) {
|
||||
$compiler
|
||||
->outdent()
|
||||
->write(")\n")
|
||||
->write("]\n")
|
||||
->outdent()
|
||||
->write(");\n")
|
||||
;
|
||||
} else {
|
||||
$compiler
|
||||
->outdent()
|
||||
->write("];\n")
|
||||
;
|
||||
}
|
||||
|
||||
$compiler
|
||||
->outdent()
|
||||
->write(");\n")
|
||||
->outdent()
|
||||
->subcompile($this->getNode('constructor_end'))
|
||||
->write("}\n\n")
|
||||
|
@ -295,7 +300,7 @@ class Twig_Node_Module extends Twig_Node
|
|||
protected function compileDisplay(Twig_Compiler $compiler)
|
||||
{
|
||||
$compiler
|
||||
->write("protected function doDisplay(array \$context, array \$blocks = array())\n", "{\n")
|
||||
->write("protected function doDisplay(array \$context, array \$blocks = [])\n", "{\n")
|
||||
->indent()
|
||||
->subcompile($this->getNode('display_start'))
|
||||
->subcompile($this->getNode('body'))
|
||||
|
@ -364,7 +369,7 @@ class Twig_Node_Module extends Twig_Node
|
|||
}
|
||||
|
||||
if (!count($nodes)) {
|
||||
$nodes = new Twig_Node(array($nodes));
|
||||
$nodes = new Twig_Node([$nodes]);
|
||||
}
|
||||
|
||||
foreach ($nodes as $node) {
|
||||
|
|
2
vendor/twig/twig/lib/Twig/Node/Print.php
vendored
2
vendor/twig/twig/lib/Twig/Node/Print.php
vendored
|
@ -19,7 +19,7 @@ class Twig_Node_Print extends Twig_Node implements Twig_NodeOutputInterface
|
|||
{
|
||||
public function __construct(Twig_Node_Expression $expr, $lineno, $tag = null)
|
||||
{
|
||||
parent::__construct(array('expr' => $expr), array(), $lineno, $tag);
|
||||
parent::__construct(['expr' => $expr], [], $lineno, $tag);
|
||||
}
|
||||
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
|
|
2
vendor/twig/twig/lib/Twig/Node/Sandbox.php
vendored
2
vendor/twig/twig/lib/Twig/Node/Sandbox.php
vendored
|
@ -18,7 +18,7 @@ class Twig_Node_Sandbox extends Twig_Node
|
|||
{
|
||||
public function __construct(Twig_NodeInterface $body, $lineno, $tag = null)
|
||||
{
|
||||
parent::__construct(array('body' => $body), array(), $lineno, $tag);
|
||||
parent::__construct(['body' => $body], [], $lineno, $tag);
|
||||
}
|
||||
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
|
|
6
vendor/twig/twig/lib/Twig/Node/Set.php
vendored
6
vendor/twig/twig/lib/Twig/Node/Set.php
vendored
|
@ -18,7 +18,7 @@ class Twig_Node_Set extends Twig_Node implements Twig_NodeCaptureInterface
|
|||
{
|
||||
public function __construct($capture, Twig_NodeInterface $names, Twig_NodeInterface $values, $lineno, $tag = null)
|
||||
{
|
||||
parent::__construct(array('names' => $names, 'values' => $values), array('capture' => $capture, 'safe' => false), $lineno, $tag);
|
||||
parent::__construct(['names' => $names, 'values' => $values], ['capture' => $capture, 'safe' => false], $lineno, $tag);
|
||||
|
||||
/*
|
||||
* Optimizes the node when capture is used for a large block of text.
|
||||
|
@ -69,7 +69,7 @@ class Twig_Node_Set extends Twig_Node implements Twig_NodeCaptureInterface
|
|||
$compiler->raw(' = ');
|
||||
|
||||
if (count($this->getNode('names')) > 1) {
|
||||
$compiler->write('array(');
|
||||
$compiler->write('[');
|
||||
foreach ($this->getNode('values') as $idx => $value) {
|
||||
if ($idx) {
|
||||
$compiler->raw(', ');
|
||||
|
@ -77,7 +77,7 @@ class Twig_Node_Set extends Twig_Node implements Twig_NodeCaptureInterface
|
|||
|
||||
$compiler->subcompile($value);
|
||||
}
|
||||
$compiler->raw(')');
|
||||
$compiler->raw(']');
|
||||
} else {
|
||||
if ($this->getAttribute('safe')) {
|
||||
$compiler
|
||||
|
|
2
vendor/twig/twig/lib/Twig/Node/SetTemp.php
vendored
2
vendor/twig/twig/lib/Twig/Node/SetTemp.php
vendored
|
@ -16,7 +16,7 @@ class Twig_Node_SetTemp extends Twig_Node
|
|||
{
|
||||
public function __construct($name, $lineno)
|
||||
{
|
||||
parent::__construct(array(), array('name' => $name), $lineno);
|
||||
parent::__construct([], ['name' => $name], $lineno);
|
||||
}
|
||||
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
|
|
2
vendor/twig/twig/lib/Twig/Node/Spaceless.php
vendored
2
vendor/twig/twig/lib/Twig/Node/Spaceless.php
vendored
|
@ -20,7 +20,7 @@ class Twig_Node_Spaceless extends Twig_Node
|
|||
{
|
||||
public function __construct(Twig_NodeInterface $body, $lineno, $tag = 'spaceless')
|
||||
{
|
||||
parent::__construct(array('body' => $body), array(), $lineno, $tag);
|
||||
parent::__construct(['body' => $body], [], $lineno, $tag);
|
||||
}
|
||||
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
|
|
2
vendor/twig/twig/lib/Twig/Node/Text.php
vendored
2
vendor/twig/twig/lib/Twig/Node/Text.php
vendored
|
@ -19,7 +19,7 @@ class Twig_Node_Text extends Twig_Node implements Twig_NodeOutputInterface
|
|||
{
|
||||
public function __construct($data, $lineno)
|
||||
{
|
||||
parent::__construct(array(), array('data' => $data), $lineno);
|
||||
parent::__construct([], ['data' => $data], $lineno);
|
||||
}
|
||||
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
|
|
6
vendor/twig/twig/lib/Twig/Node/With.php
vendored
6
vendor/twig/twig/lib/Twig/Node/With.php
vendored
|
@ -18,12 +18,12 @@ class Twig_Node_With extends Twig_Node
|
|||
{
|
||||
public function __construct(Twig_Node $body, Twig_Node $variables = null, $only = false, $lineno, $tag = null)
|
||||
{
|
||||
$nodes = array('body' => $body);
|
||||
$nodes = ['body' => $body];
|
||||
if (null !== $variables) {
|
||||
$nodes['variables'] = $variables;
|
||||
}
|
||||
|
||||
parent::__construct($nodes, array('only' => (bool) $only), $lineno, $tag);
|
||||
parent::__construct($nodes, ['only' => (bool) $only], $lineno, $tag);
|
||||
}
|
||||
|
||||
public function compile(Twig_Compiler $compiler)
|
||||
|
@ -44,7 +44,7 @@ class Twig_Node_With extends Twig_Node
|
|||
;
|
||||
|
||||
if ($this->getAttribute('only')) {
|
||||
$compiler->write("\$context = array('_parent' => \$context);\n");
|
||||
$compiler->write("\$context = ['_parent' => \$context];\n");
|
||||
} else {
|
||||
$compiler->write("\$context['_parent'] = \$context;\n");
|
||||
}
|
||||
|
|
6
vendor/twig/twig/lib/Twig/NodeTraverser.php
vendored
6
vendor/twig/twig/lib/Twig/NodeTraverser.php
vendored
|
@ -21,13 +21,13 @@
|
|||
class Twig_NodeTraverser
|
||||
{
|
||||
protected $env;
|
||||
protected $visitors = array();
|
||||
protected $visitors = [];
|
||||
|
||||
/**
|
||||
* @param Twig_Environment $env
|
||||
* @param Twig_NodeVisitorInterface[] $visitors
|
||||
*/
|
||||
public function __construct(Twig_Environment $env, array $visitors = array())
|
||||
public function __construct(Twig_Environment $env, array $visitors = [])
|
||||
{
|
||||
$this->env = $env;
|
||||
foreach ($visitors as $visitor) {
|
||||
|
@ -38,7 +38,7 @@ class Twig_NodeTraverser
|
|||
public function addVisitor(Twig_NodeVisitorInterface $visitor)
|
||||
{
|
||||
if (!isset($this->visitors[$visitor->getPriority()])) {
|
||||
$this->visitors[$visitor->getPriority()] = array();
|
||||
$this->visitors[$visitor->getPriority()] = [];
|
||||
}
|
||||
|
||||
$this->visitors[$visitor->getPriority()][] = $visitor;
|
||||
|
|
|
@ -18,12 +18,12 @@
|
|||
*/
|
||||
class Twig_NodeVisitor_Escaper extends Twig_BaseNodeVisitor
|
||||
{
|
||||
protected $statusStack = array();
|
||||
protected $blocks = array();
|
||||
protected $statusStack = [];
|
||||
protected $blocks = [];
|
||||
protected $safeAnalysis;
|
||||
protected $traverser;
|
||||
protected $defaultStrategy = false;
|
||||
protected $safeVars = array();
|
||||
protected $safeVars = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
@ -36,8 +36,8 @@ class Twig_NodeVisitor_Escaper extends Twig_BaseNodeVisitor
|
|||
if ($env->hasExtension('Twig_Extension_Escaper') && $defaultStrategy = $env->getExtension('Twig_Extension_Escaper')->getDefaultStrategy($node->getTemplateName())) {
|
||||
$this->defaultStrategy = $defaultStrategy;
|
||||
}
|
||||
$this->safeVars = array();
|
||||
$this->blocks = array();
|
||||
$this->safeVars = [];
|
||||
$this->blocks = [];
|
||||
} elseif ($node instanceof Twig_Node_AutoEscape) {
|
||||
$this->statusStack[] = $node->getAttribute('value');
|
||||
} elseif ($node instanceof Twig_Node_Block) {
|
||||
|
@ -53,8 +53,8 @@ class Twig_NodeVisitor_Escaper extends Twig_BaseNodeVisitor
|
|||
{
|
||||
if ($node instanceof Twig_Node_Module) {
|
||||
$this->defaultStrategy = false;
|
||||
$this->safeVars = array();
|
||||
$this->blocks = array();
|
||||
$this->safeVars = [];
|
||||
$this->blocks = [];
|
||||
} elseif ($node instanceof Twig_Node_Expression_Filter) {
|
||||
return $this->preEscapeFilterNode($node, $env);
|
||||
} elseif ($node instanceof Twig_Node_Print) {
|
||||
|
@ -115,7 +115,7 @@ class Twig_NodeVisitor_Escaper extends Twig_BaseNodeVisitor
|
|||
|
||||
if (null === $safe) {
|
||||
if (null === $this->traverser) {
|
||||
$this->traverser = new Twig_NodeTraverser($env, array($this->safeAnalysis));
|
||||
$this->traverser = new Twig_NodeTraverser($env, [$this->safeAnalysis]);
|
||||
}
|
||||
|
||||
$this->safeAnalysis->setSafeVars($this->safeVars);
|
||||
|
@ -140,7 +140,7 @@ class Twig_NodeVisitor_Escaper extends Twig_BaseNodeVisitor
|
|||
{
|
||||
$line = $node->getTemplateLine();
|
||||
$name = new Twig_Node_Expression_Constant('escape', $line);
|
||||
$args = new Twig_Node(array(new Twig_Node_Expression_Constant((string) $type, $line), new Twig_Node_Expression_Constant(null, $line), new Twig_Node_Expression_Constant(true, $line)));
|
||||
$args = new Twig_Node([new Twig_Node_Expression_Constant((string) $type, $line), new Twig_Node_Expression_Constant(null, $line), new Twig_Node_Expression_Constant(true, $line)]);
|
||||
|
||||
return new Twig_Node_Expression_Filter($node, $name, $args, $line);
|
||||
}
|
||||
|
|
|
@ -29,10 +29,10 @@ class Twig_NodeVisitor_Optimizer extends Twig_BaseNodeVisitor
|
|||
const OPTIMIZE_RAW_FILTER = 4;
|
||||
const OPTIMIZE_VAR_ACCESS = 8;
|
||||
|
||||
protected $loops = array();
|
||||
protected $loopsTargets = array();
|
||||
protected $loops = [];
|
||||
protected $loopsTargets = [];
|
||||
protected $optimizers;
|
||||
protected $prependedNodes = array();
|
||||
protected $prependedNodes = [];
|
||||
protected $inABody = false;
|
||||
|
||||
/**
|
||||
|
@ -57,7 +57,7 @@ class Twig_NodeVisitor_Optimizer extends Twig_BaseNodeVisitor
|
|||
if ($this->inABody) {
|
||||
if (!$node instanceof Twig_Node_Expression) {
|
||||
if ('Twig_Node' !== get_class($node)) {
|
||||
array_unshift($this->prependedNodes, array());
|
||||
array_unshift($this->prependedNodes, []);
|
||||
}
|
||||
} else {
|
||||
$node = $this->optimizeVariables($node, $env);
|
||||
|
@ -89,7 +89,7 @@ class Twig_NodeVisitor_Optimizer extends Twig_BaseNodeVisitor
|
|||
$this->inABody = false;
|
||||
} elseif ($this->inABody) {
|
||||
if (!$expression && 'Twig_Node' !== get_class($node) && $prependedNodes = array_shift($this->prependedNodes)) {
|
||||
$nodes = array();
|
||||
$nodes = [];
|
||||
foreach (array_unique($prependedNodes) as $name) {
|
||||
$nodes[] = new Twig_Node_SetTemp($name, $node->getTemplateLine());
|
||||
}
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
*/
|
||||
class Twig_NodeVisitor_SafeAnalysis extends Twig_BaseNodeVisitor
|
||||
{
|
||||
protected $data = array();
|
||||
protected $safeVars = array();
|
||||
protected $data = [];
|
||||
protected $safeVars = [];
|
||||
|
||||
public function setSafeVars($safeVars)
|
||||
{
|
||||
|
@ -54,10 +54,10 @@ class Twig_NodeVisitor_SafeAnalysis extends Twig_BaseNodeVisitor
|
|||
}
|
||||
}
|
||||
}
|
||||
$this->data[$hash][] = array(
|
||||
$this->data[$hash][] = [
|
||||
'key' => $node,
|
||||
'value' => $safe,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
protected function doEnterNode(Twig_Node $node, Twig_Environment $env)
|
||||
|
@ -69,13 +69,13 @@ class Twig_NodeVisitor_SafeAnalysis extends Twig_BaseNodeVisitor
|
|||
{
|
||||
if ($node instanceof Twig_Node_Expression_Constant) {
|
||||
// constants are marked safe for all
|
||||
$this->setSafe($node, array('all'));
|
||||
$this->setSafe($node, ['all']);
|
||||
} elseif ($node instanceof Twig_Node_Expression_BlockReference) {
|
||||
// blocks are safe by definition
|
||||
$this->setSafe($node, array('all'));
|
||||
$this->setSafe($node, ['all']);
|
||||
} elseif ($node instanceof Twig_Node_Expression_Parent) {
|
||||
// parent block is safe by definition
|
||||
$this->setSafe($node, array('all'));
|
||||
$this->setSafe($node, ['all']);
|
||||
} elseif ($node instanceof Twig_Node_Expression_Conditional) {
|
||||
// intersect safeness of both operands
|
||||
$safe = $this->intersectSafe($this->getSafe($node->getNode('expr2')), $this->getSafe($node->getNode('expr3')));
|
||||
|
@ -91,7 +91,7 @@ class Twig_NodeVisitor_SafeAnalysis extends Twig_BaseNodeVisitor
|
|||
}
|
||||
$this->setSafe($node, $safe);
|
||||
} else {
|
||||
$this->setSafe($node, array());
|
||||
$this->setSafe($node, []);
|
||||
}
|
||||
} elseif ($node instanceof Twig_Node_Expression_Function) {
|
||||
// function expression is safe when the function is safe
|
||||
|
@ -101,24 +101,24 @@ class Twig_NodeVisitor_SafeAnalysis extends Twig_BaseNodeVisitor
|
|||
if (false !== $function) {
|
||||
$this->setSafe($node, $function->getSafe($args));
|
||||
} else {
|
||||
$this->setSafe($node, array());
|
||||
$this->setSafe($node, []);
|
||||
}
|
||||
} elseif ($node instanceof Twig_Node_Expression_MethodCall) {
|
||||
if ($node->getAttribute('safe')) {
|
||||
$this->setSafe($node, array('all'));
|
||||
$this->setSafe($node, ['all']);
|
||||
} else {
|
||||
$this->setSafe($node, array());
|
||||
$this->setSafe($node, []);
|
||||
}
|
||||
} elseif ($node instanceof Twig_Node_Expression_GetAttr && $node->getNode('node') instanceof Twig_Node_Expression_Name) {
|
||||
$name = $node->getNode('node')->getAttribute('name');
|
||||
// attributes on template instances are safe
|
||||
if ('_self' == $name || in_array($name, $this->safeVars)) {
|
||||
$this->setSafe($node, array('all'));
|
||||
$this->setSafe($node, ['all']);
|
||||
} else {
|
||||
$this->setSafe($node, array());
|
||||
$this->setSafe($node, []);
|
||||
}
|
||||
} else {
|
||||
$this->setSafe($node, array());
|
||||
$this->setSafe($node, []);
|
||||
}
|
||||
|
||||
return $node;
|
||||
|
@ -127,7 +127,7 @@ class Twig_NodeVisitor_SafeAnalysis extends Twig_BaseNodeVisitor
|
|||
protected function intersectSafe(array $a = null, array $b = null)
|
||||
{
|
||||
if (null === $a || null === $b) {
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
if (in_array('all', $a)) {
|
||||
|
|
|
@ -27,9 +27,9 @@ class Twig_NodeVisitor_Sandbox extends Twig_BaseNodeVisitor
|
|||
{
|
||||
if ($node instanceof Twig_Node_Module) {
|
||||
$this->inAModule = true;
|
||||
$this->tags = array();
|
||||
$this->filters = array();
|
||||
$this->functions = array();
|
||||
$this->tags = [];
|
||||
$this->filters = [];
|
||||
$this->functions = [];
|
||||
|
||||
return $node;
|
||||
} elseif ($this->inAModule) {
|
||||
|
@ -67,7 +67,7 @@ class Twig_NodeVisitor_Sandbox extends Twig_BaseNodeVisitor
|
|||
if ($node instanceof Twig_Node_Module) {
|
||||
$this->inAModule = false;
|
||||
|
||||
$node->setNode('display_start', new Twig_Node(array(new Twig_Node_CheckSecurity($this->filters, $this->tags, $this->functions), $node->getNode('display_start'))));
|
||||
$node->setNode('display_start', new Twig_Node([new Twig_Node_CheckSecurity($this->filters, $this->tags, $this->functions), $node->getNode('display_start')]));
|
||||
}
|
||||
|
||||
return $node;
|
||||
|
|
40
vendor/twig/twig/lib/Twig/Parser.php
vendored
40
vendor/twig/twig/lib/Twig/Parser.php
vendored
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
class Twig_Parser implements Twig_ParserInterface
|
||||
{
|
||||
protected $stack = array();
|
||||
protected $stack = [];
|
||||
protected $stream;
|
||||
protected $parent;
|
||||
protected $handlers;
|
||||
|
@ -30,7 +30,7 @@ class Twig_Parser implements Twig_ParserInterface
|
|||
protected $reservedMacroNames;
|
||||
protected $importedSymbols;
|
||||
protected $traits;
|
||||
protected $embeddedTemplates = array();
|
||||
protected $embeddedTemplates = [];
|
||||
private $varNameSalt = 0;
|
||||
|
||||
public function __construct(Twig_Environment $env)
|
||||
|
@ -68,7 +68,7 @@ class Twig_Parser implements Twig_ParserInterface
|
|||
// push all variables into the stack to keep the current state of the parser
|
||||
// using get_object_vars() instead of foreach would lead to https://bugs.php.net/71336
|
||||
// This hack can be removed when min version if PHP 7.0
|
||||
$vars = array();
|
||||
$vars = [];
|
||||
foreach ($this as $k => $v) {
|
||||
$vars[$k] = $v;
|
||||
}
|
||||
|
@ -93,12 +93,12 @@ class Twig_Parser implements Twig_ParserInterface
|
|||
|
||||
$this->stream = $stream;
|
||||
$this->parent = null;
|
||||
$this->blocks = array();
|
||||
$this->macros = array();
|
||||
$this->traits = array();
|
||||
$this->blockStack = array();
|
||||
$this->importedSymbols = array(array());
|
||||
$this->embeddedTemplates = array();
|
||||
$this->blocks = [];
|
||||
$this->macros = [];
|
||||
$this->traits = [];
|
||||
$this->blockStack = [];
|
||||
$this->importedSymbols = [[]];
|
||||
$this->embeddedTemplates = [];
|
||||
$this->varNameSalt = 0;
|
||||
|
||||
try {
|
||||
|
@ -119,7 +119,7 @@ class Twig_Parser implements Twig_ParserInterface
|
|||
throw $e;
|
||||
}
|
||||
|
||||
$node = new Twig_Node_Module(new Twig_Node_Body(array($body)), $this->parent, new Twig_Node($this->blocks), new Twig_Node($this->macros), new Twig_Node($this->traits), $this->embeddedTemplates, $stream->getSourceContext());
|
||||
$node = new Twig_Node_Module(new Twig_Node_Body([$body]), $this->parent, new Twig_Node($this->blocks), new Twig_Node($this->macros), new Twig_Node($this->traits), $this->embeddedTemplates, $stream->getSourceContext());
|
||||
|
||||
$traverser = new Twig_NodeTraverser($this->env, $this->visitors);
|
||||
|
||||
|
@ -136,7 +136,7 @@ class Twig_Parser implements Twig_ParserInterface
|
|||
public function subparse($test, $dropNeedle = false)
|
||||
{
|
||||
$lineno = $this->getCurrentToken()->getLine();
|
||||
$rv = array();
|
||||
$rv = [];
|
||||
while (!$this->stream->isEOF()) {
|
||||
switch ($this->getCurrentToken()->getType()) {
|
||||
case Twig_Token::TEXT_TYPE:
|
||||
|
@ -168,7 +168,7 @@ class Twig_Parser implements Twig_ParserInterface
|
|||
return $rv[0];
|
||||
}
|
||||
|
||||
return new Twig_Node($rv, array(), $lineno);
|
||||
return new Twig_Node($rv, [], $lineno);
|
||||
}
|
||||
|
||||
$subparser = $this->handlers->getTokenParser($token->getValue());
|
||||
|
@ -204,7 +204,7 @@ class Twig_Parser implements Twig_ParserInterface
|
|||
return $rv[0];
|
||||
}
|
||||
|
||||
return new Twig_Node($rv, array(), $lineno);
|
||||
return new Twig_Node($rv, [], $lineno);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -259,7 +259,7 @@ class Twig_Parser implements Twig_ParserInterface
|
|||
|
||||
public function setBlock($name, Twig_Node_Block $value)
|
||||
{
|
||||
$this->blocks[$name] = new Twig_Node_Body(array($value), array(), $value->getTemplateLine());
|
||||
$this->blocks[$name] = new Twig_Node_Body([$value], [], $value->getTemplateLine());
|
||||
}
|
||||
|
||||
public function hasMacro($name)
|
||||
|
@ -279,7 +279,7 @@ class Twig_Parser implements Twig_ParserInterface
|
|||
public function isReservedMacroName($name)
|
||||
{
|
||||
if (null === $this->reservedMacroNames) {
|
||||
$this->reservedMacroNames = array();
|
||||
$this->reservedMacroNames = [];
|
||||
$r = new ReflectionClass($this->env->getBaseTemplateClass());
|
||||
foreach ($r->getMethods() as $method) {
|
||||
$methodName = strtolower($method->getName());
|
||||
|
@ -312,7 +312,7 @@ class Twig_Parser implements Twig_ParserInterface
|
|||
|
||||
public function addImportedSymbol($type, $alias, $name = null, Twig_Node_Expression $node = null)
|
||||
{
|
||||
$this->importedSymbols[0][$type][$alias] = array('name' => $name, 'node' => $node);
|
||||
$this->importedSymbols[0][$type][$alias] = ['name' => $name, 'node' => $node];
|
||||
}
|
||||
|
||||
public function getImportedSymbol($type, $alias)
|
||||
|
@ -331,7 +331,7 @@ class Twig_Parser implements Twig_ParserInterface
|
|||
|
||||
public function pushLocalScope()
|
||||
{
|
||||
array_unshift($this->importedSymbols, array());
|
||||
array_unshift($this->importedSymbols, []);
|
||||
}
|
||||
|
||||
public function popLocalScope()
|
||||
|
@ -382,7 +382,11 @@ class Twig_Parser implements Twig_ParserInterface
|
|||
(!$node instanceof Twig_Node_Text && !$node instanceof Twig_Node_BlockReference && $node instanceof Twig_NodeOutputInterface)
|
||||
) {
|
||||
if (false !== strpos((string) $node, chr(0xEF).chr(0xBB).chr(0xBF))) {
|
||||
throw new Twig_Error_Syntax('A template that extends another one cannot start with a byte order mark (BOM); it must be removed.', $node->getTemplateLine(), $this->stream->getSourceContext());
|
||||
$t = substr($node->getAttribute('data'), 3);
|
||||
if ('' === $t || ctype_space($t)) {
|
||||
// bypass empty nodes starting with a BOM
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
throw new Twig_Error_Syntax('A template that extends another one cannot include content outside Twig blocks. Did you forget to put the content inside a {% block %} tag?', $node->getTemplateLine(), $this->stream->getSourceContext());
|
||||
|
|
|
@ -18,7 +18,7 @@ class Twig_Profiler_Dumper_Blackfire
|
|||
{
|
||||
public function dump(Twig_Profiler_Profile $profile)
|
||||
{
|
||||
$data = array();
|
||||
$data = [];
|
||||
$this->dumpProfile('main()', $profile, $data);
|
||||
$this->dumpChildren('main()', $profile, $data);
|
||||
|
||||
|
@ -54,17 +54,17 @@ EOF;
|
|||
private function dumpProfile($edge, Twig_Profiler_Profile $profile, &$data)
|
||||
{
|
||||
if (isset($data[$edge])) {
|
||||
$data[$edge]['ct'] += 1;
|
||||
++$data[$edge]['ct'];
|
||||
$data[$edge]['wt'] += floor($profile->getDuration() * 1000000);
|
||||
$data[$edge]['mu'] += $profile->getMemoryUsage();
|
||||
$data[$edge]['pmu'] += $profile->getPeakMemoryUsage();
|
||||
} else {
|
||||
$data[$edge] = array(
|
||||
$data[$edge] = [
|
||||
'ct' => 1,
|
||||
'wt' => floor($profile->getDuration() * 1000000),
|
||||
'mu' => $profile->getMemoryUsage(),
|
||||
'pmu' => $profile->getPeakMemoryUsage(),
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Reference in a new issue