diff --git a/README.md b/README.md
index 7bb2b42..bff0827 100644
--- a/README.md
+++ b/README.md
@@ -124,6 +124,9 @@ All routes are a mapping class with extends the primary Controller class. In a s
| DB_DATABASE | string | Database name |
| SQL_CACHE | boolean | Use the SQL Select cache system |
| ROUTES | array | Specify manually routes |
+ | DEFAULT_ROUTE | string | Define the default route to assume with initial page. Default is *common/home*. |
+ | CUSTOM_DB_CONFIG | string | Custom SQL to load application configs in database. |
+ | NOT_FOUND | string | Custom route to not found page. Default is error/not_found. |
## Outputs and renders
@@ -519,6 +522,38 @@ In a sample case, we have this controller:
*http://example.com/index.php?route=contact/contato/place&foo=bar*
***Note:*** *It's necessary specify the config `config_seo_url` for correctly function of this URLs. If you use the SQL url_alias table, you need specify the `USE_DB_CONFIG` to true in config file.*
+
+ ### Passing URI Segments to your Functions
+
+ Use the *'%'* character and its variations (see below) to create a route with wildcard. All contents in the URL will matches with wildcard is passed to your controller function as argument.
+
+ | Wildcard | Description |
+ | ----- | -----|
+ | %d | Matches any decimal digit equivalent to [0-9].|
+ | %w | Matches any letter, digit or underscore. Equivalent to [a-zA-Z0-9_]. Spaces or others character is not allowed. |
+ | %a | Matches any character in the valid ASCII range. Latin characters like *'ç'* or *'ã'* is not accepted. |
+ | % | Accept any character.|
+
+ ##### Sample:
+ ```php
+ define("ROUTES", array(
+ "produto/%d/%/promo" => "feriado/natal/presentes"
+ )
+ ```
+
+ ```php
+
bla
- foo
+ foo
```
diff --git a/system/engine/loader.php b/system/engine/loader.php
index 2afe93e..e961798 100644
--- a/system/engine/loader.php
+++ b/system/engine/loader.php
@@ -38,17 +38,21 @@ final class Loader {
exit();
}
}
-
- public function control($model) {
- $file = DIR_APPLICATION . 'controller/' . $model . '.php';
- $class = 'Controller' . preg_replace('/[^a-zA-Z0-9]/', '', $model);
+
+ public function control($model) { //temp alias, consider change to loader controller function
+ $this->controller($model);
+ }
+
+ public function controller($control) {
+ $file = DIR_APPLICATION . 'controller/' . $control . '.php';
+ $class = 'Controller' . preg_replace('/[^a-zA-Z0-9]/', '', $control);
if (file_exists($file)) {
include_once($file);
- $this->registry->set('controller_' . str_replace('/', '_', $model), new $class($this->registry));
+ $this->registry->set('controller_' . str_replace('/', '_', $control), new $class($this->registry));
} else {
- trigger_error('Error: Could not load model ' . $model . '!');
+ trigger_error('Error: Could not load model ' . $control . '!');
exit();
}
}
diff --git a/system/system.php b/system/system.php
index 9559fe4..395db1d 100644
--- a/system/system.php
+++ b/system/system.php
@@ -225,7 +225,7 @@ $registry->set('mail', $mail);
$document = new Document();
$registry->set('document', $document);
-// Personalized registrations
+// Custom registrations
include(DIR_SYSTEM."registrations.php");
// Front Controller
@@ -238,12 +238,14 @@ $controller->addPreAction(new ActionSystem('url/seo_url'));
if (isset($request->get['route'])) {
$action = new Action($request->get['route']);
} else {
- $request->get['route'] = "common/home";
- $action = new Action('common/home');
+ $default = (defined('DEFAULT_ROUTE')) ? DEFAULT_ROUTE : 'common/home';
+ $request->get['route'] = $default;
+ $action = new Action($default);
}
// Dispatch
-$controller->dispatch($action, new Action('error/not_found'));
+$not_found = (defined('NOT_FOUND')) ? NOT_FOUND : 'error/not_found';
+$controller->dispatch($action, new Action($not_found));
// Output
$response->output();
diff --git a/system/templateEngines/Twig/Twig1x/Autoloader.php b/system/templateEngines/Twig/Twig1x/Autoloader.php
index 212af54..6a2bf4a 100644
--- a/system/templateEngines/Twig/Twig1x/Autoloader.php
+++ b/system/templateEngines/Twig/Twig1x/Autoloader.php
@@ -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;
}
}
diff --git a/system/templateEngines/Twig/Twig1x/Cache/Filesystem.php b/system/templateEngines/Twig/Twig1x/Cache/Filesystem.php
index 6597628..5b0acc0 100644
--- a/system/templateEngines/Twig/Twig1x/Cache/Filesystem.php
+++ b/system/templateEngines/Twig/Twig1x/Cache/Filesystem.php
@@ -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));
}
diff --git a/system/templateEngines/Twig/Twig1x/Compiler.php b/system/templateEngines/Twig/Twig1x/Compiler.php
index 803eb89..a5a6030 100644
--- a/system/templateEngines/Twig/Twig1x/Compiler.php
+++ b/system/templateEngines/Twig/Twig1x/Compiler.php
@@ -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);
}
diff --git a/system/templateEngines/Twig/Twig1x/Environment.php b/system/templateEngines/Twig/Twig1x/Environment.php
index 9b610f7..2a051b9 100644
--- a/system/templateEngines/Twig/Twig1x/Environment.php
+++ b/system/templateEngines/Twig/Twig1x/Environment.php
@@ -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);
}
diff --git a/system/templateEngines/Twig/Twig1x/Error.php b/system/templateEngines/Twig/Twig1x/Error.php
index 787e0d0..569c2fe 100644
--- a/system/templateEngines/Twig/Twig1x/Error.php
+++ b/system/templateEngines/Twig/Twig1x/Error.php
@@ -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']) {
diff --git a/system/templateEngines/Twig/Twig1x/Error/Loader.php b/system/templateEngines/Twig/Twig1x/Error/Loader.php
index df566dd..2ef0480 100644
--- a/system/templateEngines/Twig/Twig1x/Error/Loader.php
+++ b/system/templateEngines/Twig/Twig1x/Error/Loader.php
@@ -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);
}
diff --git a/system/templateEngines/Twig/Twig1x/Error/Syntax.php b/system/templateEngines/Twig/Twig1x/Error/Syntax.php
index 9d09f21..c889dc6 100644
--- a/system/templateEngines/Twig/Twig1x/Error/Syntax.php
+++ b/system/templateEngines/Twig/Twig1x/Error/Syntax.php
@@ -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)) {
diff --git a/system/templateEngines/Twig/Twig1x/ExpressionParser.php b/system/templateEngines/Twig/Twig1x/ExpressionParser.php
index fe4a9b4..eaaafb1 100644
--- a/system/templateEngines/Twig/Twig1x/ExpressionParser.php
+++ b/system/templateEngines/Twig/Twig1x/ExpressionParser.php
@@ -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];
}
}
diff --git a/system/templateEngines/Twig/Twig1x/Extension.php b/system/templateEngines/Twig/Twig1x/Extension.php
index 3808449..de93ca6 100644
--- a/system/templateEngines/Twig/Twig1x/Extension.php
+++ b/system/templateEngines/Twig/Twig1x/Extension.php
@@ -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 [];
}
/**
diff --git a/system/templateEngines/Twig/Twig1x/Extension/Core.php b/system/templateEngines/Twig/Twig1x/Extension/Core.php
index 6fa78e1..9babcfc 100644
--- a/system/templateEngines/Twig/Twig1x/Extension/Core.php
+++ b/system/templateEngines/Twig/Twig1x/Extension/Core.php
@@ -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.
*
*
+ * {{ [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 #}
*
*
- * @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;
+ }
+
+ 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) $value);
+ 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 */
+ ];
+
+ if (isset($entityMap[$ord])) {
+ return $entityMap[$ord];
+ }
- $int = hexdec($hex);
- if (array_key_exists($int, $entityMap)) {
- return sprintf('&%s;', $entityMap[$int]);
+ return sprintf('%02X;', $ord);
}
/*
* Per OWASP recommendations, we'll use hex entities for any other
* characters where a named entity does not exist.
*/
- return sprintf('%s;', $hex);
+ return sprintf('%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
*/
diff --git a/system/templateEngines/Twig/Twig1x/Extension/Debug.php b/system/templateEngines/Twig/Twig1x/Extension/Debug.php
index d0cd196..87f47d6 100644
--- a/system/templateEngines/Twig/Twig1x/Extension/Debug.php
+++ b/system/templateEngines/Twig/Twig1x/Extension/Debug.php
@@ -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;
diff --git a/system/templateEngines/Twig/Twig1x/Extension/Escaper.php b/system/templateEngines/Twig/Twig1x/Extension/Escaper.php
index 46c2d84..74f0e99 100644
--- a/system/templateEngines/Twig/Twig1x/Extension/Escaper.php
+++ b/system/templateEngines/Twig/Twig1x/Extension/Escaper.php
@@ -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;
diff --git a/system/templateEngines/Twig/Twig1x/Extension/ExacTITranslate.php b/system/templateEngines/Twig/Twig1x/Extension/ExacTITranslate.php
deleted file mode 100644
index 67b5d72..0000000
--- a/system/templateEngines/Twig/Twig1x/Extension/ExacTITranslate.php
+++ /dev/null
@@ -1,178 +0,0 @@
-getLine();
-
- $stream = $this->parser->getStream();
-
- // recovers all inline parameters close to your tag name
- $params = array_merge(array (), $this->getInlineParams($token));
-
- $continue = true;
- while ($continue)
- {
- // create subtree until the decidetransFork() callback returns true
- $body = $this->parser->subparse(array ($this, 'decidetransFork'));
-
- // I like to put a switch here, in case you need to add middle tags, such
- // as: {% trans %}, {% nexttrans %}, {% endtrans %}.
- $tag = $stream->next()->getValue();
-
- switch ($tag)
- {
- case tagClose:
- $continue = false;
- break;
- default:
- throw new \Twig_Error_Syntax(sprintf('Unexpected end of template. Twig was looking for the following tags '.tagClose.' to close the '.tagIni.' block started at line %d)', $lineno), -1);
- }
-
- // you want $body at the beginning of your arguments
- array_unshift($params, $body);
-
- // if your endtrans can also contains params, you can uncomment this line:
- // $params = array_merge($params, $this->getInlineParams($token));
- // and comment this one:
- $stream->expect(\Twig_Token::BLOCK_END_TYPE);
- }
-
- return new transNode(new \Twig_Node($params), $lineno, $this->getTag());
- }
-
- /**
- * Recovers all tag parameters until we find a BLOCK_END_TYPE ( %} )
- *
- * @param \Twig_Token $token
- * @return array
- */
- protected function getInlineParams(\Twig_Token $token)
- {
- $stream = $this->parser->getStream();
- $params = array ();
- while (!$stream->test(\Twig_Token::BLOCK_END_TYPE))
- {
- $params[] = $this->parser->getExpressionParser()->parseExpression();
- }
- $stream->expect(\Twig_Token::BLOCK_END_TYPE);
- return $params;
- }
-
- /**
- * Callback called at each tag name when subparsing, must return
- * true when the expected end tag is reached.
- *
- * @param \Twig_Token $token
- * @return bool
- */
- public function decidetransFork(\Twig_Token $token)
- {
- return $token->test(array (tagClose));
- }
-
- /**
- * Your tag name: if the parsed tag match the one you put here, your parse()
- * method will be called.
- *
- * @return string
- */
- public function getTag()
- {
- return tagIni;
- }
-
-}
-
-
-class transNode extends \Twig_Node
-{
-
- public function __construct($params, $lineno = 0, $tag = null)
- {
- parent::__construct(array ('params' => $params), array (), $lineno, $tag);
- }
-
- public function compile(\Twig_Compiler $compiler)
- {
- $count = count($this->getNode('params'));
-
- $compiler
- ->addDebugInfo($this);
-
- for ($i = 0; ($i < $count); $i++)
- {
- // argument is not an expression (such as, a \Twig_Node_Textbody)
- // we should trick with output buffering to get a valid argument to pass
- // to the functionToCall() function.
- if (!($this->getNode('params')->getNode($i) instanceof \Twig_Node_Expression))
- {
- $compiler
- ->write('ob_start();')
- ->raw(PHP_EOL);
-
- $compiler
- ->subcompile($this->getNode('params')->getNode($i));
-
- $compiler
- ->write('$_trans[] = ob_get_clean();')
- ->raw(PHP_EOL);
- }
- else
- {
- $compiler
- ->write('$_trans[] = ')
- ->subcompile($this->getNode('params')->getNode($i))
- ->raw(';')
- ->raw(PHP_EOL);
- }
- }
-
- $compiler
- ->write('call_user_func_array(')
- ->string('traduzir')
- ->raw(', $_trans);')
- ->raw(PHP_EOL);
-
- $compiler
- ->write('unset($_trans);')
- ->raw(PHP_EOL);
- }
-
-}
-
-
-
-class transExtension extends \Twig_Extension
-{
-
- public function getTokenParsers()
- {
- return array (
- new transTokenParser(),
- );
- }
-
- public function getName()
- {
- return tagIni;
- }
-
-}
-
-
-function traduzir() {
- $params = func_get_args();
-
- $trans = new Translate();
- $body = array_shift($params);
- echo ($trans->translation($body));
- /* $body = array_shift($params);
- echo "body = {$body}", PHP_EOL;
- echo "params = ", implode(', ', $params), PHP_EOL;*/
-}
\ No newline at end of file
diff --git a/system/templateEngines/Twig/Twig1x/Extension/Optimizer.php b/system/templateEngines/Twig/Twig1x/Extension/Optimizer.php
index 6c62e3e..70a64be 100644
--- a/system/templateEngines/Twig/Twig1x/Extension/Optimizer.php
+++ b/system/templateEngines/Twig/Twig1x/Extension/Optimizer.php
@@ -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()
diff --git a/system/templateEngines/Twig/Twig1x/Extension/Profiler.php b/system/templateEngines/Twig/Twig1x/Extension/Profiler.php
index fcfc002..d7faef8 100644
--- a/system/templateEngines/Twig/Twig1x/Extension/Profiler.php
+++ b/system/templateEngines/Twig/Twig1x/Extension/Profiler.php
@@ -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()
diff --git a/system/templateEngines/Twig/Twig1x/Extension/Sandbox.php b/system/templateEngines/Twig/Twig1x/Extension/Sandbox.php
index 5cb80a7..cacde63 100644
--- a/system/templateEngines/Twig/Twig1x/Extension/Sandbox.php
+++ b/system/templateEngines/Twig/Twig1x/Extension/Sandbox.php
@@ -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()
diff --git a/system/templateEngines/Twig/Twig1x/Extension/Staging.php b/system/templateEngines/Twig/Twig1x/Extension/Staging.php
index d3a0f9c..897b379 100644
--- a/system/templateEngines/Twig/Twig1x/Extension/Staging.php
+++ b/system/templateEngines/Twig/Twig1x/Extension/Staging.php
@@ -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)
{
diff --git a/system/templateEngines/Twig/Twig1x/Extension/StringLoader.php b/system/templateEngines/Twig/Twig1x/Extension/StringLoader.php
index 2ce3c99..58b731c 100644
--- a/system/templateEngines/Twig/Twig1x/Extension/StringLoader.php
+++ b/system/templateEngines/Twig/Twig1x/Extension/StringLoader.php
@@ -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()
diff --git a/system/templateEngines/Twig/Twig1x/FactoryRuntimeLoader.php b/system/templateEngines/Twig/Twig1x/FactoryRuntimeLoader.php
index 2cdaded..2a86712 100644
--- a/system/templateEngines/Twig/Twig1x/FactoryRuntimeLoader.php
+++ b/system/templateEngines/Twig/Twig1x/FactoryRuntimeLoader.php
@@ -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;
}
diff --git a/system/templateEngines/Twig/Twig1x/FileExtensionEscapingStrategy.php b/system/templateEngines/Twig/Twig1x/FileExtensionEscapingStrategy.php
index 8f8cd2e..6b13c72 100644
--- a/system/templateEngines/Twig/Twig1x/FileExtensionEscapingStrategy.php
+++ b/system/templateEngines/Twig/Twig1x/FileExtensionEscapingStrategy.php
@@ -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
}
diff --git a/system/templateEngines/Twig/Twig1x/Filter.php b/system/templateEngines/Twig/Twig1x/Filter.php
index 893d75d..9191c54 100644
--- a/system/templateEngines/Twig/Twig1x/Filter.php
+++ b/system/templateEngines/Twig/Twig1x/Filter.php
@@ -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)
diff --git a/system/templateEngines/Twig/Twig1x/Filter/Function.php b/system/templateEngines/Twig/Twig1x/Filter/Function.php
index 71b1655..0423102 100644
--- a/system/templateEngines/Twig/Twig1x/Filter/Function.php
+++ b/system/templateEngines/Twig/Twig1x/Filter/Function.php
@@ -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;
diff --git a/system/templateEngines/Twig/Twig1x/Filter/Method.php b/system/templateEngines/Twig/Twig1x/Filter/Method.php
index 1b75676..2dc39b6 100644
--- a/system/templateEngines/Twig/Twig1x/Filter/Method.php
+++ b/system/templateEngines/Twig/Twig1x/Filter/Method.php
@@ -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);
diff --git a/system/templateEngines/Twig/Twig1x/Filter/Node.php b/system/templateEngines/Twig/Twig1x/Filter/Node.php
index 3e6b12e..0d96081 100644
--- a/system/templateEngines/Twig/Twig1x/Filter/Node.php
+++ b/system/templateEngines/Twig/Twig1x/Filter/Node.php
@@ -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);
diff --git a/system/templateEngines/Twig/Twig1x/Function.php b/system/templateEngines/Twig/Twig1x/Function.php
index 9dc16e9..a829eee 100644
--- a/system/templateEngines/Twig/Twig1x/Function.php
+++ b/system/templateEngines/Twig/Twig1x/Function.php
@@ -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()
diff --git a/system/templateEngines/Twig/Twig1x/Function/Function.php b/system/templateEngines/Twig/Twig1x/Function/Function.php
index 97c0eb7..86f853b 100644
--- a/system/templateEngines/Twig/Twig1x/Function/Function.php
+++ b/system/templateEngines/Twig/Twig1x/Function/Function.php
@@ -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;
diff --git a/system/templateEngines/Twig/Twig1x/Function/Method.php b/system/templateEngines/Twig/Twig1x/Function/Method.php
index 4299e11..4806a43 100644
--- a/system/templateEngines/Twig/Twig1x/Function/Method.php
+++ b/system/templateEngines/Twig/Twig1x/Function/Method.php
@@ -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);
diff --git a/system/templateEngines/Twig/Twig1x/Function/Node.php b/system/templateEngines/Twig/Twig1x/Function/Node.php
index 0adc5d9..68688c7 100644
--- a/system/templateEngines/Twig/Twig1x/Function/Node.php
+++ b/system/templateEngines/Twig/Twig1x/Function/Node.php
@@ -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);
diff --git a/system/templateEngines/Twig/Twig1x/Lexer.php b/system/templateEngines/Twig/Twig1x/Lexer.php
index 41211eb..eea2d0f 100644
--- a/system/templateEngines/Twig/Twig1x/Lexer.php
+++ b/system/templateEngines/Twig/Twig1x/Lexer.php
@@ -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
diff --git a/system/templateEngines/Twig/Twig1x/Loader/Array.php b/system/templateEngines/Twig/Twig1x/Loader/Array.php
index 0aac769..7c51317 100644
--- a/system/templateEngines/Twig/Twig1x/Loader/Array.php
+++ b/system/templateEngines/Twig/Twig1x/Loader/Array.php
@@ -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;
}
diff --git a/system/templateEngines/Twig/Twig1x/Loader/Chain.php b/system/templateEngines/Twig/Twig1x/Loader/Chain.php
index 59a3379..8ccf8c9 100644
--- a/system/templateEngines/Twig/Twig1x/Loader/Chain.php
+++ b/system/templateEngines/Twig/Twig1x/Loader/Chain.php
@@ -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;
diff --git a/system/templateEngines/Twig/Twig1x/Loader/Filesystem.php b/system/templateEngines/Twig/Twig1x/Loader/Filesystem.php
index 4e8be0d..1263dc4 100644
--- a/system/templateEngines/Twig/Twig1x/Loader/Filesystem.php
+++ b/system/templateEngines/Twig/Twig1x/Loader/Filesystem.php
@@ -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);
+ } catch (Twig_Error_Loader $e) {
+ if (!$throw) {
+ return false;
+ }
- list($namespace, $shortname) = $this->parseName($name);
+ 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)
diff --git a/system/templateEngines/Twig/Twig1x/Node.php b/system/templateEngines/Twig/Twig1x/Node.php
index 89ada14..bdc9ec2 100644
--- a/system/templateEngines/Twig/Twig1x/Node.php
+++ b/system/templateEngines/Twig/Twig1x/Node.php
@@ -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;
}
diff --git a/system/templateEngines/Twig/Twig1x/Node/AutoEscape.php b/system/templateEngines/Twig/Twig1x/Node/AutoEscape.php
index 17e4e38..62e0961 100644
--- a/system/templateEngines/Twig/Twig1x/Node/AutoEscape.php
+++ b/system/templateEngines/Twig/Twig1x/Node/AutoEscape.php
@@ -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)
diff --git a/system/templateEngines/Twig/Twig1x/Node/Block.php b/system/templateEngines/Twig/Twig1x/Node/Block.php
index 91752ad..2d0300b 100644
--- a/system/templateEngines/Twig/Twig1x/Node/Block.php
+++ b/system/templateEngines/Twig/Twig1x/Node/Block.php
@@ -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()
;
diff --git a/system/templateEngines/Twig/Twig1x/Node/BlockReference.php b/system/templateEngines/Twig/Twig1x/Node/BlockReference.php
index 92a9f39..0b0f7b3 100644
--- a/system/templateEngines/Twig/Twig1x/Node/BlockReference.php
+++ b/system/templateEngines/Twig/Twig1x/Node/BlockReference.php
@@ -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)
diff --git a/system/templateEngines/Twig/Twig1x/Node/CheckSecurity.php b/system/templateEngines/Twig/Twig1x/Node/CheckSecurity.php
index 7258acb..aecdb83 100644
--- a/system/templateEngines/Twig/Twig1x/Node/CheckSecurity.php
+++ b/system/templateEngines/Twig/Twig1x/Node/CheckSecurity.php
@@ -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()
diff --git a/system/templateEngines/Twig/Twig1x/Node/Deprecated.php b/system/templateEngines/Twig/Twig1x/Node/Deprecated.php
new file mode 100644
index 0000000..fc4c392
--- /dev/null
+++ b/system/templateEngines/Twig/Twig1x/Node/Deprecated.php
@@ -0,0 +1,49 @@
+
+ */
+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);
diff --git a/system/templateEngines/Twig/Twig1x/Node/Do.php b/system/templateEngines/Twig/Twig1x/Node/Do.php
index cdd7e77..1335045 100644
--- a/system/templateEngines/Twig/Twig1x/Node/Do.php
+++ b/system/templateEngines/Twig/Twig1x/Node/Do.php
@@ -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)
diff --git a/system/templateEngines/Twig/Twig1x/Node/Expression/Array.php b/system/templateEngines/Twig/Twig1x/Node/Expression/Array.php
index 0e77bb0..61e0d96 100644
--- a/system/templateEngines/Twig/Twig1x/Node/Expression/Array.php
+++ b/system/templateEngines/Twig/Twig1x/Node/Expression/Array.php
@@ -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(']');
}
}
diff --git a/system/templateEngines/Twig/Twig1x/Node/Expression/Binary.php b/system/templateEngines/Twig/Twig1x/Node/Expression/Binary.php
index 2b545d9..e9155dd 100644
--- a/system/templateEngines/Twig/Twig1x/Node/Expression/Binary.php
+++ b/system/templateEngines/Twig/Twig1x/Node/Expression/Binary.php
@@ -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)
diff --git a/system/templateEngines/Twig/Twig1x/Node/Expression/BlockReference.php b/system/templateEngines/Twig/Twig1x/Node/Expression/BlockReference.php
index 37a3983..4beb13a 100644
--- a/system/templateEngines/Twig/Twig1x/Node/Expression/BlockReference.php
+++ b/system/templateEngines/Twig/Twig1x/Node/Expression/BlockReference.php
@@ -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)
diff --git a/system/templateEngines/Twig/Twig1x/Node/Expression/Call.php b/system/templateEngines/Twig/Twig1x/Node/Expression/Call.php
index ec20348..d1d3025 100644
--- a/system/templateEngines/Twig/Twig1x/Node/Expression/Call.php
+++ b/system/templateEngines/Twig/Twig1x/Node/Expression/Call.php
@@ -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];
}
}
diff --git a/system/templateEngines/Twig/Twig1x/Node/Expression/Conditional.php b/system/templateEngines/Twig/Twig1x/Node/Expression/Conditional.php
index c339d77..996772a 100644
--- a/system/templateEngines/Twig/Twig1x/Node/Expression/Conditional.php
+++ b/system/templateEngines/Twig/Twig1x/Node/Expression/Conditional.php
@@ -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)
diff --git a/system/templateEngines/Twig/Twig1x/Node/Expression/Constant.php b/system/templateEngines/Twig/Twig1x/Node/Expression/Constant.php
index bf4d031..7304e8c 100644
--- a/system/templateEngines/Twig/Twig1x/Node/Expression/Constant.php
+++ b/system/templateEngines/Twig/Twig1x/Node/Expression/Constant.php
@@ -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)
diff --git a/system/templateEngines/Twig/Twig1x/Node/Expression/ExtensionReference.php b/system/templateEngines/Twig/Twig1x/Node/Expression/ExtensionReference.php
index 114b5cd..7bcc078 100644
--- a/system/templateEngines/Twig/Twig1x/Node/Expression/ExtensionReference.php
+++ b/system/templateEngines/Twig/Twig1x/Node/Expression/ExtensionReference.php
@@ -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)
diff --git a/system/templateEngines/Twig/Twig1x/Node/Expression/Filter.php b/system/templateEngines/Twig/Twig1x/Node/Expression/Filter.php
index 12da1d6..7b5952f 100644
--- a/system/templateEngines/Twig/Twig1x/Node/Expression/Filter.php
+++ b/system/templateEngines/Twig/Twig1x/Node/Expression/Filter.php
@@ -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)
diff --git a/system/templateEngines/Twig/Twig1x/Node/Expression/Function.php b/system/templateEngines/Twig/Twig1x/Node/Expression/Function.php
index cdee7c9..c19633f 100644
--- a/system/templateEngines/Twig/Twig1x/Node/Expression/Function.php
+++ b/system/templateEngines/Twig/Twig1x/Node/Expression/Function.php
@@ -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)
diff --git a/system/templateEngines/Twig/Twig1x/Node/Expression/GetAttr.php b/system/templateEngines/Twig/Twig1x/Node/Expression/GetAttr.php
index b7823ac..8976915 100644
--- a/system/templateEngines/Twig/Twig1x/Node/Expression/GetAttr.php
+++ b/system/templateEngines/Twig/Twig1x/Node/Expression/GetAttr.php
@@ -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(', []');
}
}
diff --git a/system/templateEngines/Twig/Twig1x/Node/Expression/MethodCall.php b/system/templateEngines/Twig/Twig1x/Node/Expression/MethodCall.php
index 709016e..b8a8345 100644
--- a/system/templateEngines/Twig/Twig1x/Node/Expression/MethodCall.php
+++ b/system/templateEngines/Twig/Twig1x/Node/Expression/MethodCall.php
@@ -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);
diff --git a/system/templateEngines/Twig/Twig1x/Node/Expression/Name.php b/system/templateEngines/Twig/Twig1x/Node/Expression/Name.php
index 7d3d622..2d1d3d1 100644
--- a/system/templateEngines/Twig/Twig1x/Node/Expression/Name.php
+++ b/system/templateEngines/Twig/Twig1x/Node/Expression/Name.php
@@ -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)
diff --git a/system/templateEngines/Twig/Twig1x/Node/Expression/Parent.php b/system/templateEngines/Twig/Twig1x/Node/Expression/Parent.php
index 78692db..8623685 100644
--- a/system/templateEngines/Twig/Twig1x/Node/Expression/Parent.php
+++ b/system/templateEngines/Twig/Twig1x/Node/Expression/Parent.php
@@ -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)
diff --git a/system/templateEngines/Twig/Twig1x/Node/Expression/TempName.php b/system/templateEngines/Twig/Twig1x/Node/Expression/TempName.php
index 0a86e00..4be1cc2 100644
--- a/system/templateEngines/Twig/Twig1x/Node/Expression/TempName.php
+++ b/system/templateEngines/Twig/Twig1x/Node/Expression/TempName.php
@@ -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)
diff --git a/system/templateEngines/Twig/Twig1x/Node/Expression/Test.php b/system/templateEngines/Twig/Twig1x/Node/Expression/Test.php
index ad102ba..a543ec5 100644
--- a/system/templateEngines/Twig/Twig1x/Node/Expression/Test.php
+++ b/system/templateEngines/Twig/Twig1x/Node/Expression/Test.php
@@ -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());
}
diff --git a/system/templateEngines/Twig/Twig1x/Node/Expression/Unary.php b/system/templateEngines/Twig/Twig1x/Node/Expression/Unary.php
index 5804485..abf191a 100644
--- a/system/templateEngines/Twig/Twig1x/Node/Expression/Unary.php
+++ b/system/templateEngines/Twig/Twig1x/Node/Expression/Unary.php
@@ -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)
diff --git a/system/templateEngines/Twig/Twig1x/Node/Flush.php b/system/templateEngines/Twig/Twig1x/Node/Flush.php
index fcc461a..5d3ffd5 100644
--- a/system/templateEngines/Twig/Twig1x/Node/Flush.php
+++ b/system/templateEngines/Twig/Twig1x/Node/Flush.php
@@ -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)
diff --git a/system/templateEngines/Twig/Twig1x/Node/For.php b/system/templateEngines/Twig/Twig1x/Node/For.php
index 914b70c..7651945 100644
--- a/system/templateEngines/Twig/Twig1x/Node/For.php
+++ b/system/templateEngines/Twig/Twig1x/Node/For.php
@@ -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')) {
diff --git a/system/templateEngines/Twig/Twig1x/Node/ForLoop.php b/system/templateEngines/Twig/Twig1x/Node/ForLoop.php
index 06477cf..31f282d 100644
--- a/system/templateEngines/Twig/Twig1x/Node/ForLoop.php
+++ b/system/templateEngines/Twig/Twig1x/Node/ForLoop.php
@@ -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)
diff --git a/system/templateEngines/Twig/Twig1x/Node/If.php b/system/templateEngines/Twig/Twig1x/Node/If.php
index d82edec..b096cd4 100644
--- a/system/templateEngines/Twig/Twig1x/Node/If.php
+++ b/system/templateEngines/Twig/Twig1x/Node/If.php
@@ -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)
diff --git a/system/templateEngines/Twig/Twig1x/Node/Import.php b/system/templateEngines/Twig/Twig1x/Node/Import.php
index c77e320..44b2131 100644
--- a/system/templateEngines/Twig/Twig1x/Node/Import.php
+++ b/system/templateEngines/Twig/Twig1x/Node/Import.php
@@ -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)
diff --git a/system/templateEngines/Twig/Twig1x/Node/Include.php b/system/templateEngines/Twig/Twig1x/Node/Include.php
index 2a5114c..4b26381 100644
--- a/system/templateEngines/Twig/Twig1x/Node/Include.php
+++ b/system/templateEngines/Twig/Twig1x/Node/Include.php
@@ -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, ')
diff --git a/system/templateEngines/Twig/Twig1x/Node/Macro.php b/system/templateEngines/Twig/Twig1x/Node/Macro.php
index 3cf5497..0c4f928 100644
--- a/system/templateEngines/Twig/Twig1x/Node/Macro.php
+++ b/system/templateEngines/Twig/Twig1x/Node/Macro.php
@@ -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()
diff --git a/system/templateEngines/Twig/Twig1x/Node/Module.php b/system/templateEngines/Twig/Twig1x/Node/Module.php
index 5cd8d05..c33bbe1 100644
--- a/system/templateEngines/Twig/Twig1x/Node/Module.php
+++ b/system/templateEngines/Twig/Twig1x/Node/Module.php
@@ -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) {
diff --git a/system/templateEngines/Twig/Twig1x/Node/Print.php b/system/templateEngines/Twig/Twig1x/Node/Print.php
index 374db89..215d712 100644
--- a/system/templateEngines/Twig/Twig1x/Node/Print.php
+++ b/system/templateEngines/Twig/Twig1x/Node/Print.php
@@ -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)
diff --git a/system/templateEngines/Twig/Twig1x/Node/Sandbox.php b/system/templateEngines/Twig/Twig1x/Node/Sandbox.php
index 44b30ab..e06f332 100644
--- a/system/templateEngines/Twig/Twig1x/Node/Sandbox.php
+++ b/system/templateEngines/Twig/Twig1x/Node/Sandbox.php
@@ -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)
diff --git a/system/templateEngines/Twig/Twig1x/Node/Set.php b/system/templateEngines/Twig/Twig1x/Node/Set.php
index 6c6743e..155cc48 100644
--- a/system/templateEngines/Twig/Twig1x/Node/Set.php
+++ b/system/templateEngines/Twig/Twig1x/Node/Set.php
@@ -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
diff --git a/system/templateEngines/Twig/Twig1x/Node/SetTemp.php b/system/templateEngines/Twig/Twig1x/Node/SetTemp.php
index 996fdcd..c04ff45 100644
--- a/system/templateEngines/Twig/Twig1x/Node/SetTemp.php
+++ b/system/templateEngines/Twig/Twig1x/Node/SetTemp.php
@@ -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)
diff --git a/system/templateEngines/Twig/Twig1x/Node/Spaceless.php b/system/templateEngines/Twig/Twig1x/Node/Spaceless.php
index 76f90cd..43e907a 100644
--- a/system/templateEngines/Twig/Twig1x/Node/Spaceless.php
+++ b/system/templateEngines/Twig/Twig1x/Node/Spaceless.php
@@ -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)
diff --git a/system/templateEngines/Twig/Twig1x/Node/Text.php b/system/templateEngines/Twig/Twig1x/Node/Text.php
index f4577fe..ab24d71 100644
--- a/system/templateEngines/Twig/Twig1x/Node/Text.php
+++ b/system/templateEngines/Twig/Twig1x/Node/Text.php
@@ -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)
diff --git a/system/templateEngines/Twig/Twig1x/Node/With.php b/system/templateEngines/Twig/Twig1x/Node/With.php
index 2ab0ea5..422cc81 100644
--- a/system/templateEngines/Twig/Twig1x/Node/With.php
+++ b/system/templateEngines/Twig/Twig1x/Node/With.php
@@ -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");
}
diff --git a/system/templateEngines/Twig/Twig1x/NodeTraverser.php b/system/templateEngines/Twig/Twig1x/NodeTraverser.php
index f00a0bf..7f80e76 100644
--- a/system/templateEngines/Twig/Twig1x/NodeTraverser.php
+++ b/system/templateEngines/Twig/Twig1x/NodeTraverser.php
@@ -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;
diff --git a/system/templateEngines/Twig/Twig1x/NodeVisitor/Escaper.php b/system/templateEngines/Twig/Twig1x/NodeVisitor/Escaper.php
index 1a1ae66..5eb32ea 100644
--- a/system/templateEngines/Twig/Twig1x/NodeVisitor/Escaper.php
+++ b/system/templateEngines/Twig/Twig1x/NodeVisitor/Escaper.php
@@ -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);
}
diff --git a/system/templateEngines/Twig/Twig1x/NodeVisitor/Optimizer.php b/system/templateEngines/Twig/Twig1x/NodeVisitor/Optimizer.php
index c55e40f..f97ea56 100644
--- a/system/templateEngines/Twig/Twig1x/NodeVisitor/Optimizer.php
+++ b/system/templateEngines/Twig/Twig1x/NodeVisitor/Optimizer.php
@@ -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());
}
diff --git a/system/templateEngines/Twig/Twig1x/NodeVisitor/SafeAnalysis.php b/system/templateEngines/Twig/Twig1x/NodeVisitor/SafeAnalysis.php
index ca31c8f..eff855b 100644
--- a/system/templateEngines/Twig/Twig1x/NodeVisitor/SafeAnalysis.php
+++ b/system/templateEngines/Twig/Twig1x/NodeVisitor/SafeAnalysis.php
@@ -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)) {
diff --git a/system/templateEngines/Twig/Twig1x/NodeVisitor/Sandbox.php b/system/templateEngines/Twig/Twig1x/NodeVisitor/Sandbox.php
index 71aa4f0..894cc1a 100644
--- a/system/templateEngines/Twig/Twig1x/NodeVisitor/Sandbox.php
+++ b/system/templateEngines/Twig/Twig1x/NodeVisitor/Sandbox.php
@@ -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;
diff --git a/system/templateEngines/Twig/Twig1x/Parser.php b/system/templateEngines/Twig/Twig1x/Parser.php
index 6de879a..ff44401 100644
--- a/system/templateEngines/Twig/Twig1x/Parser.php
+++ b/system/templateEngines/Twig/Twig1x/Parser.php
@@ -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());
diff --git a/system/templateEngines/Twig/Twig1x/Profiler/Dumper/Blackfire.php b/system/templateEngines/Twig/Twig1x/Profiler/Dumper/Blackfire.php
index 7a33baf..4ebb0d0 100644
--- a/system/templateEngines/Twig/Twig1x/Profiler/Dumper/Blackfire.php
+++ b/system/templateEngines/Twig/Twig1x/Profiler/Dumper/Blackfire.php
@@ -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(),
- );
+ ];
}
}
}
diff --git a/system/templateEngines/Twig/Twig1x/Profiler/Dumper/Html.php b/system/templateEngines/Twig/Twig1x/Profiler/Dumper/Html.php
index b57a255..974b521 100644
--- a/system/templateEngines/Twig/Twig1x/Profiler/Dumper/Html.php
+++ b/system/templateEngines/Twig/Twig1x/Profiler/Dumper/Html.php
@@ -16,12 +16,12 @@
*/
class Twig_Profiler_Dumper_Html extends Twig_Profiler_Dumper_Base
{
- private static $colors = array(
+ private static $colors = [
'block' => '#dfd',
'macro' => '#ddf',
'template' => '#ffd',
'big' => '#d44',
- );
+ ];
public function dump(Twig_Profiler_Profile $profile)
{
diff --git a/system/templateEngines/Twig/Twig1x/Profiler/Node/EnterProfile.php b/system/templateEngines/Twig/Twig1x/Profiler/Node/EnterProfile.php
index 69c8f79..b29ec9b 100644
--- a/system/templateEngines/Twig/Twig1x/Profiler/Node/EnterProfile.php
+++ b/system/templateEngines/Twig/Twig1x/Profiler/Node/EnterProfile.php
@@ -18,7 +18,7 @@ class Twig_Profiler_Node_EnterProfile extends Twig_Node
{
public function __construct($extensionName, $type, $name, $varName)
{
- parent::__construct(array(), array('extension_name' => $extensionName, 'name' => $name, 'type' => $type, 'var_name' => $varName));
+ parent::__construct([], ['extension_name' => $extensionName, 'name' => $name, 'type' => $type, 'var_name' => $varName]);
}
public function compile(Twig_Compiler $compiler)
diff --git a/system/templateEngines/Twig/Twig1x/Profiler/Node/LeaveProfile.php b/system/templateEngines/Twig/Twig1x/Profiler/Node/LeaveProfile.php
index d1d6a7c..bcb912d 100644
--- a/system/templateEngines/Twig/Twig1x/Profiler/Node/LeaveProfile.php
+++ b/system/templateEngines/Twig/Twig1x/Profiler/Node/LeaveProfile.php
@@ -18,7 +18,7 @@ class Twig_Profiler_Node_LeaveProfile extends Twig_Node
{
public function __construct($varName)
{
- parent::__construct(array(), array('var_name' => $varName));
+ parent::__construct([], ['var_name' => $varName]);
}
public function compile(Twig_Compiler $compiler)
diff --git a/system/templateEngines/Twig/Twig1x/Profiler/NodeVisitor/Profiler.php b/system/templateEngines/Twig/Twig1x/Profiler/NodeVisitor/Profiler.php
index 5db41fe..6cf5bb0 100644
--- a/system/templateEngines/Twig/Twig1x/Profiler/NodeVisitor/Profiler.php
+++ b/system/templateEngines/Twig/Twig1x/Profiler/NodeVisitor/Profiler.php
@@ -32,22 +32,22 @@ class Twig_Profiler_NodeVisitor_Profiler extends Twig_BaseNodeVisitor
{
if ($node instanceof Twig_Node_Module) {
$varName = $this->getVarName();
- $node->setNode('display_start', new Twig_Node(array(new Twig_Profiler_Node_EnterProfile($this->extensionName, Twig_Profiler_Profile::TEMPLATE, $node->getTemplateName(), $varName), $node->getNode('display_start'))));
- $node->setNode('display_end', new Twig_Node(array(new Twig_Profiler_Node_LeaveProfile($varName), $node->getNode('display_end'))));
+ $node->setNode('display_start', new Twig_Node([new Twig_Profiler_Node_EnterProfile($this->extensionName, Twig_Profiler_Profile::TEMPLATE, $node->getTemplateName(), $varName), $node->getNode('display_start')]));
+ $node->setNode('display_end', new Twig_Node([new Twig_Profiler_Node_LeaveProfile($varName), $node->getNode('display_end')]));
} elseif ($node instanceof Twig_Node_Block) {
$varName = $this->getVarName();
- $node->setNode('body', new Twig_Node_Body(array(
+ $node->setNode('body', new Twig_Node_Body([
new Twig_Profiler_Node_EnterProfile($this->extensionName, Twig_Profiler_Profile::BLOCK, $node->getAttribute('name'), $varName),
$node->getNode('body'),
new Twig_Profiler_Node_LeaveProfile($varName),
- )));
+ ]));
} elseif ($node instanceof Twig_Node_Macro) {
$varName = $this->getVarName();
- $node->setNode('body', new Twig_Node_Body(array(
+ $node->setNode('body', new Twig_Node_Body([
new Twig_Profiler_Node_EnterProfile($this->extensionName, Twig_Profiler_Profile::MACRO, $node->getAttribute('name'), $varName),
$node->getNode('body'),
new Twig_Profiler_Node_LeaveProfile($varName),
- )));
+ ]));
}
return $node;
diff --git a/system/templateEngines/Twig/Twig1x/Profiler/Profile.php b/system/templateEngines/Twig/Twig1x/Profiler/Profile.php
index 3fdc1a8..8ba1c4c 100644
--- a/system/templateEngines/Twig/Twig1x/Profiler/Profile.php
+++ b/system/templateEngines/Twig/Twig1x/Profiler/Profile.php
@@ -24,9 +24,9 @@ class Twig_Profiler_Profile implements IteratorAggregate, Serializable
private $template;
private $name;
private $type;
- private $starts = array();
- private $ends = array();
- private $profiles = array();
+ private $starts = [];
+ private $ends = [];
+ private $profiles = [];
public function __construct($template = 'main', $type = self::ROOT, $name = 'main')
{
@@ -76,7 +76,7 @@ class Twig_Profiler_Profile implements IteratorAggregate, Serializable
return $this->profiles;
}
- public function addProfile(Twig_Profiler_Profile $profile)
+ public function addProfile(self $profile)
{
$this->profiles[] = $profile;
}
@@ -126,11 +126,11 @@ class Twig_Profiler_Profile implements IteratorAggregate, Serializable
*/
public function enter()
{
- $this->starts = array(
+ $this->starts = [
'wt' => microtime(true),
'mu' => memory_get_usage(),
'pmu' => memory_get_peak_usage(),
- );
+ ];
}
/**
@@ -138,16 +138,16 @@ class Twig_Profiler_Profile implements IteratorAggregate, Serializable
*/
public function leave()
{
- $this->ends = array(
+ $this->ends = [
'wt' => microtime(true),
'mu' => memory_get_usage(),
'pmu' => memory_get_peak_usage(),
- );
+ ];
}
public function reset()
{
- $this->starts = $this->ends = $this->profiles = array();
+ $this->starts = $this->ends = $this->profiles = [];
$this->enter();
}
@@ -158,7 +158,7 @@ class Twig_Profiler_Profile implements IteratorAggregate, Serializable
public function serialize()
{
- return serialize(array($this->template, $this->name, $this->type, $this->starts, $this->ends, $this->profiles));
+ return serialize([$this->template, $this->name, $this->type, $this->starts, $this->ends, $this->profiles]);
}
public function unserialize($data)
diff --git a/system/templateEngines/Twig/Twig1x/Sandbox/SecurityPolicy.php b/system/templateEngines/Twig/Twig1x/Sandbox/SecurityPolicy.php
index dca0b82..cf59117 100644
--- a/system/templateEngines/Twig/Twig1x/Sandbox/SecurityPolicy.php
+++ b/system/templateEngines/Twig/Twig1x/Sandbox/SecurityPolicy.php
@@ -24,7 +24,7 @@ class Twig_Sandbox_SecurityPolicy implements Twig_Sandbox_SecurityPolicyInterfac
protected $allowedProperties;
protected $allowedFunctions;
- public function __construct(array $allowedTags = array(), array $allowedFilters = array(), array $allowedMethods = array(), array $allowedProperties = array(), array $allowedFunctions = array())
+ public function __construct(array $allowedTags = [], array $allowedFilters = [], array $allowedMethods = [], array $allowedProperties = [], array $allowedFunctions = [])
{
$this->allowedTags = $allowedTags;
$this->allowedFilters = $allowedFilters;
@@ -45,9 +45,9 @@ class Twig_Sandbox_SecurityPolicy implements Twig_Sandbox_SecurityPolicyInterfac
public function setAllowedMethods(array $methods)
{
- $this->allowedMethods = array();
+ $this->allowedMethods = [];
foreach ($methods as $class => $m) {
- $this->allowedMethods[$class] = array_map('strtolower', is_array($m) ? $m : array($m));
+ $this->allowedMethods[$class] = array_map('strtolower', is_array($m) ? $m : [$m]);
}
}
@@ -109,7 +109,7 @@ class Twig_Sandbox_SecurityPolicy implements Twig_Sandbox_SecurityPolicyInterfac
$allowed = false;
foreach ($this->allowedProperties as $class => $properties) {
if ($obj instanceof $class) {
- $allowed = in_array($property, is_array($properties) ? $properties : array($properties));
+ $allowed = in_array($property, is_array($properties) ? $properties : [$properties]);
break;
}
diff --git a/system/templateEngines/Twig/Twig1x/SimpleFilter.php b/system/templateEngines/Twig/Twig1x/SimpleFilter.php
index ee4c0ae..5c4cfc5 100644
--- a/system/templateEngines/Twig/Twig1x/SimpleFilter.php
+++ b/system/templateEngines/Twig/Twig1x/SimpleFilter.php
@@ -21,13 +21,13 @@ class Twig_SimpleFilter
protected $name;
protected $callable;
protected $options;
- protected $arguments = array();
+ protected $arguments = [];
- public function __construct($name, $callable, array $options = array())
+ public function __construct($name, $callable, array $options = [])
{
$this->name = $name;
$this->callable = $callable;
- $this->options = array_merge(array(
+ $this->options = array_merge([
'needs_environment' => false,
'needs_context' => false,
'is_variadic' => false,
@@ -38,7 +38,7 @@ class Twig_SimpleFilter
'node_class' => 'Twig_Node_Expression_Filter',
'deprecated' => false,
'alternative' => null,
- ), $options);
+ ], $options);
}
public function getName()
diff --git a/system/templateEngines/Twig/Twig1x/SimpleFunction.php b/system/templateEngines/Twig/Twig1x/SimpleFunction.php
index a6aa7ca..fbe06b9 100644
--- a/system/templateEngines/Twig/Twig1x/SimpleFunction.php
+++ b/system/templateEngines/Twig/Twig1x/SimpleFunction.php
@@ -21,13 +21,13 @@ class Twig_SimpleFunction
protected $name;
protected $callable;
protected $options;
- protected $arguments = array();
+ protected $arguments = [];
- public function __construct($name, $callable, array $options = array())
+ public function __construct($name, $callable, array $options = [])
{
$this->name = $name;
$this->callable = $callable;
- $this->options = array_merge(array(
+ $this->options = array_merge([
'needs_environment' => false,
'needs_context' => false,
'is_variadic' => false,
@@ -36,7 +36,7 @@ class Twig_SimpleFunction
'node_class' => 'Twig_Node_Expression_Function',
'deprecated' => false,
'alternative' => null,
- ), $options);
+ ], $options);
}
public function getName()
@@ -84,7 +84,7 @@ class Twig_SimpleFunction
return call_user_func($this->options['is_safe_callback'], $functionArgs);
}
- return array();
+ return [];
}
public function isVariadic()
diff --git a/system/templateEngines/Twig/Twig1x/SimpleTest.php b/system/templateEngines/Twig/Twig1x/SimpleTest.php
index fee5778..393fad1 100644
--- a/system/templateEngines/Twig/Twig1x/SimpleTest.php
+++ b/system/templateEngines/Twig/Twig1x/SimpleTest.php
@@ -22,16 +22,18 @@ class Twig_SimpleTest
protected $callable;
protected $options;
- public function __construct($name, $callable, array $options = array())
+ private $arguments = [];
+
+ public function __construct($name, $callable, array $options = [])
{
$this->name = $name;
$this->callable = $callable;
- $this->options = array_merge(array(
+ $this->options = array_merge([
'is_variadic' => false,
'node_class' => 'Twig_Node_Expression_Test',
'deprecated' => false,
'alternative' => null,
- ), $options);
+ ], $options);
}
public function getName()
@@ -68,6 +70,16 @@ class Twig_SimpleTest
{
return $this->options['alternative'];
}
+
+ public function setArguments($arguments)
+ {
+ $this->arguments = $arguments;
+ }
+
+ public function getArguments()
+ {
+ return $this->arguments;
+ }
}
class_alias('Twig_SimpleTest', 'Twig\TwigTest', false);
diff --git a/system/templateEngines/Twig/Twig1x/Template.php b/system/templateEngines/Twig/Twig1x/Template.php
index 3709232..78a5738 100644
--- a/system/templateEngines/Twig/Twig1x/Template.php
+++ b/system/templateEngines/Twig/Twig1x/Template.php
@@ -26,13 +26,13 @@ abstract class Twig_Template implements Twig_TemplateInterface
/**
* @internal
*/
- protected static $cache = array();
+ protected static $cache = [];
protected $parent;
- protected $parents = array();
+ protected $parents = [];
protected $env;
- protected $blocks = array();
- protected $traits = array();
+ protected $blocks = [];
+ protected $traits = [];
public function __construct(Twig_Environment $env)
{
@@ -63,7 +63,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
*/
public function getDebugInfo()
{
- return array();
+ return [];
}
/**
@@ -108,7 +108,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
*
* @param array $context
*
- * @return Twig_TemplateInterface|false The parent template or false if there is no parent
+ * @return Twig_TemplateInterface|Twig_TemplateWrapper|false The parent template or false if there is no parent
*
* @internal
*/
@@ -125,8 +125,8 @@ abstract class Twig_Template implements Twig_TemplateInterface
return false;
}
- if ($parent instanceof self) {
- return $this->parents[$parent->getTemplateName()] = $parent;
+ if ($parent instanceof self || $parent instanceof Twig_TemplateWrapper) {
+ return $this->parents[$parent->getSourceContext()->getName()] = $parent;
}
if (!isset($this->parents[$parent])) {
@@ -164,7 +164,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
*
* @internal
*/
- public function displayParentBlock($name, array $context, array $blocks = array())
+ public function displayParentBlock($name, array $context, array $blocks = [])
{
$name = (string) $name;
@@ -190,7 +190,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
*
* @internal
*/
- public function displayBlock($name, array $context, array $blocks = array(), $useBlocks = true)
+ public function displayBlock($name, array $context, array $blocks = [], $useBlocks = true)
{
$name = (string) $name;
@@ -250,7 +250,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
*
* @internal
*/
- public function renderParentBlock($name, array $context, array $blocks = array())
+ public function renderParentBlock($name, array $context, array $blocks = [])
{
ob_start();
$this->displayParentBlock($name, $context, $blocks);
@@ -273,7 +273,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
*
* @internal
*/
- public function renderBlock($name, array $context, array $blocks = array(), $useBlocks = true)
+ public function renderBlock($name, array $context, array $blocks = [], $useBlocks = true)
{
ob_start();
$this->displayBlock($name, $context, $blocks, $useBlocks);
@@ -295,7 +295,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
*
* @internal
*/
- public function hasBlock($name, array $context = null, array $blocks = array())
+ public function hasBlock($name, array $context = null, array $blocks = [])
{
if (null === $context) {
@trigger_error('The '.__METHOD__.' method is internal and should never be called; calling it directly is deprecated since version 1.28 and won\'t be possible anymore in 2.0.', E_USER_DEPRECATED);
@@ -331,7 +331,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
*
* @internal
*/
- public function getBlockNames(array $context = null, array $blocks = array())
+ public function getBlockNames(array $context = null, array $blocks = [])
{
if (null === $context) {
@trigger_error('The '.__METHOD__.' method is internal and should never be called; calling it directly is deprecated since version 1.28 and won\'t be possible anymore in 2.0.', E_USER_DEPRECATED);
@@ -355,11 +355,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
return $this->env->resolveTemplate($template);
}
- if ($template instanceof self) {
- return $template;
- }
-
- if ($template instanceof Twig_TemplateWrapper) {
+ if ($template instanceof self || $template instanceof Twig_TemplateWrapper) {
return $template;
}
@@ -398,7 +394,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
return $this->blocks;
}
- public function display(array $context, array $blocks = array())
+ public function display(array $context, array $blocks = [])
{
$this->displayWithErrorHandling($this->env->mergeGlobals($context), array_merge($this->blocks, $blocks));
}
@@ -426,7 +422,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
return ob_get_clean();
}
- protected function displayWithErrorHandling(array $context, array $blocks = array())
+ protected function displayWithErrorHandling(array $context, array $blocks = [])
{
try {
$this->doDisplay($context, $blocks);
@@ -454,7 +450,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
* @param array $context An array of parameters to pass to the template
* @param array $blocks An array of blocks to pass to the template
*/
- abstract protected function doDisplay(array $context, array $blocks = array());
+ abstract protected function doDisplay(array $context, array $blocks = []);
/**
* Returns a variable from the context.
@@ -506,13 +502,13 @@ abstract class Twig_Template implements Twig_TemplateInterface
*
* @internal
*/
- protected function getAttribute($object, $item, array $arguments = array(), $type = self::ANY_CALL, $isDefinedTest = false, $ignoreStrictCheck = false)
+ protected function getAttribute($object, $item, array $arguments = [], $type = self::ANY_CALL, $isDefinedTest = false, $ignoreStrictCheck = false)
{
// array
if (self::METHOD_CALL !== $type) {
$arrayItem = is_bool($item) || is_float($item) ? (int) $item : $item;
- if ((is_array($object) && (isset($object[$arrayItem]) || array_key_exists($arrayItem, $object)))
+ if (((is_array($object) || $object instanceof ArrayObject) && (isset($object[$arrayItem]) || array_key_exists($arrayItem, $object)))
|| ($object instanceof ArrayAccess && isset($object[$arrayItem]))
) {
if ($isDefinedTest) {
@@ -599,7 +595,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
// get_class_methods returns all methods accessible in the scope, but we only want public ones to be accessible in templates
if ($object instanceof self) {
$ref = new ReflectionClass($class);
- $methods = array();
+ $methods = [];
foreach ($ref->getMethods(ReflectionMethod::IS_PUBLIC) as $refMethod) {
// Accessing the environment from templates is forbidden to prevent untrusted changes to the environment
@@ -613,7 +609,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
// sort values to have consistent behavior, so that "get" methods win precedence over "is" methods
sort($methods);
- $cache = array();
+ $cache = [];
foreach ($methods as $method) {
$cache[$method] = $method;
@@ -676,7 +672,7 @@ abstract class Twig_Template implements Twig_TemplateInterface
if (!$arguments) {
$ret = $object->$method();
} else {
- $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())) {
diff --git a/system/templateEngines/Twig/Twig1x/TemplateInterface.php b/system/templateEngines/Twig/Twig1x/TemplateInterface.php
index 457ef7d..4ab9c57 100644
--- a/system/templateEngines/Twig/Twig1x/TemplateInterface.php
+++ b/system/templateEngines/Twig/Twig1x/TemplateInterface.php
@@ -37,7 +37,7 @@ interface Twig_TemplateInterface
* @param array $context An array of parameters to pass to the template
* @param array $blocks An array of blocks to pass to the template
*/
- public function display(array $context, array $blocks = array());
+ public function display(array $context, array $blocks = []);
/**
* Returns the bound environment for this template.
diff --git a/system/templateEngines/Twig/Twig1x/TemplateWrapper.php b/system/templateEngines/Twig/Twig1x/TemplateWrapper.php
index 497f6e9..430e91c 100644
--- a/system/templateEngines/Twig/Twig1x/TemplateWrapper.php
+++ b/system/templateEngines/Twig/Twig1x/TemplateWrapper.php
@@ -38,9 +38,11 @@ final class Twig_TemplateWrapper
*
* @return string The rendered template
*/
- public function render($context = array())
+ public function render($context = [])
{
- return $this->template->render($context);
+ // using func_get_args() allows to not expose the blocks argument
+ // as it should only be used by internal code
+ return $this->template->render($context, func_num_args() > 1 ? func_get_arg(1) : []);
}
/**
@@ -48,9 +50,11 @@ final class Twig_TemplateWrapper
*
* @param array $context An array of parameters to pass to the template
*/
- public function display($context = array())
+ public function display($context = [])
{
- $this->template->display($context);
+ // using func_get_args() allows to not expose the blocks argument
+ // as it should only be used by internal code
+ $this->template->display($context, func_num_args() >= 1 ? func_get_arg(1) : []);
}
/**
@@ -61,7 +65,7 @@ final class Twig_TemplateWrapper
*
* @return bool
*/
- public function hasBlock($name, $context = array())
+ public function hasBlock($name, $context = [])
{
return $this->template->hasBlock($name, $context);
}
@@ -73,7 +77,7 @@ final class Twig_TemplateWrapper
*
* @return string[] An array of defined template block names
*/
- public function getBlockNames($context = array())
+ public function getBlockNames($context = [])
{
return $this->template->getBlockNames($context);
}
@@ -86,7 +90,7 @@ final class Twig_TemplateWrapper
*
* @return string The rendered block
*/
- public function renderBlock($name, $context = array())
+ public function renderBlock($name, $context = [])
{
$context = $this->env->mergeGlobals($context);
$level = ob_get_level();
@@ -116,7 +120,7 @@ final class Twig_TemplateWrapper
* @param string $name The block name to render
* @param array $context An array of parameters to pass to the template
*/
- public function displayBlock($name, $context = array())
+ public function displayBlock($name, $context = [])
{
$this->template->displayBlock($name, $this->env->mergeGlobals($context));
}
diff --git a/system/templateEngines/Twig/Twig1x/Test.php b/system/templateEngines/Twig/Twig1x/Test.php
index b450ec6..5396644 100644
--- a/system/templateEngines/Twig/Twig1x/Test.php
+++ b/system/templateEngines/Twig/Twig1x/Test.php
@@ -21,13 +21,13 @@
abstract class Twig_Test implements Twig_TestInterface, Twig_TestCallableInterface
{
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([
'callable' => null,
- ), $options);
+ ], $options);
}
public function getCallable()
diff --git a/system/templateEngines/Twig/Twig1x/Test/Function.php b/system/templateEngines/Twig/Twig1x/Test/Function.php
index 9e83c3f..f34fb05 100644
--- a/system/templateEngines/Twig/Twig1x/Test/Function.php
+++ b/system/templateEngines/Twig/Twig1x/Test/Function.php
@@ -22,7 +22,7 @@ class Twig_Test_Function extends Twig_Test
{
protected $function;
- public function __construct($function, array $options = array())
+ public function __construct($function, array $options = [])
{
$options['callable'] = $function;
diff --git a/system/templateEngines/Twig/Twig1x/Test/IntegrationTestCase.php b/system/templateEngines/Twig/Twig1x/Test/IntegrationTestCase.php
index 382a3f2..31db139 100644
--- a/system/templateEngines/Twig/Twig1x/Test/IntegrationTestCase.php
+++ b/system/templateEngines/Twig/Twig1x/Test/IntegrationTestCase.php
@@ -29,7 +29,7 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
*/
protected function getRuntimeLoaders()
{
- return array();
+ return [];
}
/**
@@ -37,7 +37,7 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
*/
protected function getExtensions()
{
- return array();
+ return [];
}
/**
@@ -45,7 +45,7 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
*/
protected function getTwigFilters()
{
- return array();
+ return [];
}
/**
@@ -53,7 +53,7 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
*/
protected function getTwigFunctions()
{
- return array();
+ return [];
}
/**
@@ -61,7 +61,7 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
*/
protected function getTwigTests()
{
- return array();
+ return [];
}
/**
@@ -84,7 +84,7 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
public function getTests($name, $legacyTests = false)
{
$fixturesDir = realpath($this->getFixturesDir());
- $tests = array();
+ $tests = [];
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($fixturesDir), RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
if (!preg_match('/\.test$/', $file)) {
@@ -102,7 +102,7 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
$condition = $match[2];
$templates = self::parseTemplates($match[3]);
$exception = $match[5];
- $outputs = array(array(null, $match[4], null, ''));
+ $outputs = [[null, $match[4], null, '']];
} elseif (preg_match('/--TEST--\s*(.*?)\s*(?:--CONDITION--\s*(.*))?\s*((?:--TEMPLATE(?:\(.*?\))?--(?:.*?))+)--DATA--.*?--EXPECT--.*/s', $test, $match)) {
$message = $match[1];
$condition = $match[2];
@@ -113,12 +113,12 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
throw new InvalidArgumentException(sprintf('Test "%s" is not valid.', str_replace($fixturesDir.'/', '', $file)));
}
- $tests[] = array(str_replace($fixturesDir.'/', '', $file), $message, $condition, $templates, $exception, $outputs);
+ $tests[] = [str_replace($fixturesDir.'/', '', $file), $message, $condition, $templates, $exception, $outputs];
}
if ($legacyTests && empty($tests)) {
// add a dummy test to avoid a PHPUnit message
- return array(array('not', '-', '', array(), '', array()));
+ return [['not', '-', '', [], '', []]];
}
return $tests;
@@ -145,10 +145,10 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
$loader = new Twig_Loader_Array($templates);
foreach ($outputs as $i => $match) {
- $config = array_merge(array(
+ $config = array_merge([
'cache' => false,
'strict_variables' => true,
- ), $match[2] ? eval($match[2].';') : array());
+ ], $match[2] ? eval($match[2].';') : []);
$twig = new Twig_Environment($loader, $config);
$twig->addGlobal('global', 'global');
foreach ($this->getRuntimeLoaders() as $runtimeLoader) {
@@ -171,13 +171,9 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
$twig->addFunction($function);
}
- // avoid using the same PHP class name for different cases
- // only for PHP 5.2+
- if (PHP_VERSION_ID >= 50300) {
- $p = new ReflectionProperty($twig, 'templateClassPrefix');
- $p->setAccessible(true);
- $p->setValue($twig, '__TwigTemplate_'.hash('sha256', uniqid(mt_rand(), true), false).'_');
- }
+ $p = new ReflectionProperty($twig, 'templateClassPrefix');
+ $p->setAccessible(true);
+ $p->setValue($twig, '__TwigTemplate_'.hash('sha256', uniqid(mt_rand(), true), false).'_');
try {
$template = $twig->loadTemplate('index.twig');
@@ -236,7 +232,7 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
protected static function parseTemplates($test)
{
- $templates = array();
+ $templates = [];
preg_match_all('/--TEMPLATE(?:\((.*?)\))?--(.*?)(?=\-\-TEMPLATE|$)/s', $test, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
$templates[($match[1] ? $match[1] : 'index.twig')] = $match[2];
diff --git a/system/templateEngines/Twig/Twig1x/Test/Method.php b/system/templateEngines/Twig/Twig1x/Test/Method.php
index feccd5d..6949bb2 100644
--- a/system/templateEngines/Twig/Twig1x/Test/Method.php
+++ b/system/templateEngines/Twig/Twig1x/Test/Method.php
@@ -23,9 +23,9 @@ class Twig_Test_Method extends Twig_Test
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);
diff --git a/system/templateEngines/Twig/Twig1x/Test/Node.php b/system/templateEngines/Twig/Twig1x/Test/Node.php
index 6098a52..6b5de15 100644
--- a/system/templateEngines/Twig/Twig1x/Test/Node.php
+++ b/system/templateEngines/Twig/Twig1x/Test/Node.php
@@ -22,7 +22,7 @@ class Twig_Test_Node extends Twig_Test
{
protected $class;
- public function __construct($class, array $options = array())
+ public function __construct($class, array $options = [])
{
parent::__construct($options);
diff --git a/system/templateEngines/Twig/Twig1x/Test/NodeTestCase.php b/system/templateEngines/Twig/Twig1x/Test/NodeTestCase.php
index 4794267..a20fbba 100644
--- a/system/templateEngines/Twig/Twig1x/Test/NodeTestCase.php
+++ b/system/templateEngines/Twig/Twig1x/Test/NodeTestCase.php
@@ -42,7 +42,7 @@ abstract class Twig_Test_NodeTestCase extends TestCase
protected function getEnvironment()
{
- return new Twig_Environment(new Twig_Loader_Array(array()));
+ return new Twig_Environment(new Twig_Loader_Array([]));
}
protected function getVariableGetter($name, $line = false)
diff --git a/system/templateEngines/Twig/Twig1x/TokenParser/AutoEscape.php b/system/templateEngines/Twig/Twig1x/TokenParser/AutoEscape.php
index a20dedd..0a3ba09 100644
--- a/system/templateEngines/Twig/Twig1x/TokenParser/AutoEscape.php
+++ b/system/templateEngines/Twig/Twig1x/TokenParser/AutoEscape.php
@@ -63,7 +63,7 @@ class Twig_TokenParser_AutoEscape extends Twig_TokenParser
}
$stream->expect(Twig_Token::BLOCK_END_TYPE);
- $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
+ $body = $this->parser->subparse([$this, 'decideBlockEnd'], true);
$stream->expect(Twig_Token::BLOCK_END_TYPE);
return new Twig_Node_AutoEscape($value, $body, $lineno, $this->getTag());
diff --git a/system/templateEngines/Twig/Twig1x/TokenParser/Block.php b/system/templateEngines/Twig/Twig1x/TokenParser/Block.php
index f30f86b..2f83315 100644
--- a/system/templateEngines/Twig/Twig1x/TokenParser/Block.php
+++ b/system/templateEngines/Twig/Twig1x/TokenParser/Block.php
@@ -32,12 +32,12 @@ class Twig_TokenParser_Block extends Twig_TokenParser
if ($this->parser->hasBlock($name)) {
throw new Twig_Error_Syntax(sprintf("The block '%s' has already been defined line %d.", $name, $this->parser->getBlock($name)->getTemplateLine()), $stream->getCurrent()->getLine(), $stream->getSourceContext());
}
- $this->parser->setBlock($name, $block = new Twig_Node_Block($name, new Twig_Node(array()), $lineno));
+ $this->parser->setBlock($name, $block = new Twig_Node_Block($name, new Twig_Node([]), $lineno));
$this->parser->pushLocalScope();
$this->parser->pushBlockStack($name);
if ($stream->nextIf(Twig_Token::BLOCK_END_TYPE)) {
- $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
+ $body = $this->parser->subparse([$this, 'decideBlockEnd'], true);
if ($token = $stream->nextIf(Twig_Token::NAME_TYPE)) {
$value = $token->getValue();
@@ -46,9 +46,9 @@ class Twig_TokenParser_Block extends Twig_TokenParser
}
}
} else {
- $body = new Twig_Node(array(
+ $body = new Twig_Node([
new Twig_Node_Print($this->parser->getExpressionParser()->parseExpression(), $lineno),
- ));
+ ]);
}
$stream->expect(Twig_Token::BLOCK_END_TYPE);
diff --git a/system/templateEngines/Twig/Twig1x/TokenParser/Deprecated.php b/system/templateEngines/Twig/Twig1x/TokenParser/Deprecated.php
new file mode 100644
index 0000000..be5d549
--- /dev/null
+++ b/system/templateEngines/Twig/Twig1x/TokenParser/Deprecated.php
@@ -0,0 +1,42 @@
+
+ * {% deprecated 'The "base.twig" template is deprecated, use "layout.twig" instead.' %}
+ *
+ * {% extends 'layout.html.twig' %}
+ *
+ *
+ * @author Yonel Ceruto
+ *
+ * @final
+ */
+class Twig_TokenParser_Deprecated extends Twig_TokenParser
+{
+ public function parse(Twig_Token $token)
+ {
+ $expr = $this->parser->getExpressionParser()->parseExpression();
+
+ $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
+
+ return new Twig_Node_Deprecated($expr, $token->getLine(), $this->getTag());
+ }
+
+ public function getTag()
+ {
+ return 'deprecated';
+ }
+}
+
+class_alias('Twig_TokenParser_Deprecated', 'Twig\TokenParser\DeprecatedTokenParser', false);
diff --git a/system/templateEngines/Twig/Twig1x/TokenParser/Embed.php b/system/templateEngines/Twig/Twig1x/TokenParser/Embed.php
index 44644cc..62ad917 100644
--- a/system/templateEngines/Twig/Twig1x/TokenParser/Embed.php
+++ b/system/templateEngines/Twig/Twig1x/TokenParser/Embed.php
@@ -32,14 +32,14 @@ class Twig_TokenParser_Embed extends Twig_TokenParser_Include
}
// inject a fake parent to make the parent() function work
- $stream->injectTokens(array(
+ $stream->injectTokens([
new Twig_Token(Twig_Token::BLOCK_START_TYPE, '', $token->getLine()),
new Twig_Token(Twig_Token::NAME_TYPE, 'extends', $token->getLine()),
$parentToken,
new Twig_Token(Twig_Token::BLOCK_END_TYPE, '', $token->getLine()),
- ));
+ ]);
- $module = $this->parser->parse($stream, array($this, 'decideBlockEnd'), true);
+ $module = $this->parser->parse($stream, [$this, 'decideBlockEnd'], true);
// override the parent with the correct one
if ($fakeParentToken === $parentToken) {
diff --git a/system/templateEngines/Twig/Twig1x/TokenParser/Filter.php b/system/templateEngines/Twig/Twig1x/TokenParser/Filter.php
index 7601782..e956d04 100644
--- a/system/templateEngines/Twig/Twig1x/TokenParser/Filter.php
+++ b/system/templateEngines/Twig/Twig1x/TokenParser/Filter.php
@@ -30,7 +30,7 @@ class Twig_TokenParser_Filter extends Twig_TokenParser
$filter = $this->parser->getExpressionParser()->parseFilterExpressionRaw($ref, $this->getTag());
$this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
- $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
+ $body = $this->parser->subparse([$this, 'decideBlockEnd'], true);
$this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
$block = new Twig_Node_Block($name, $body, $token->getLine());
diff --git a/system/templateEngines/Twig/Twig1x/TokenParser/For.php b/system/templateEngines/Twig/Twig1x/TokenParser/For.php
index 8e737c5..fecf58b 100644
--- a/system/templateEngines/Twig/Twig1x/TokenParser/For.php
+++ b/system/templateEngines/Twig/Twig1x/TokenParser/For.php
@@ -39,10 +39,10 @@ class Twig_TokenParser_For extends Twig_TokenParser
}
$stream->expect(Twig_Token::BLOCK_END_TYPE);
- $body = $this->parser->subparse(array($this, 'decideForFork'));
+ $body = $this->parser->subparse([$this, 'decideForFork']);
if ('else' == $stream->next()->getValue()) {
$stream->expect(Twig_Token::BLOCK_END_TYPE);
- $else = $this->parser->subparse(array($this, 'decideForEnd'), true);
+ $else = $this->parser->subparse([$this, 'decideForEnd'], true);
} else {
$else = null;
}
@@ -69,7 +69,7 @@ class Twig_TokenParser_For extends Twig_TokenParser
public function decideForFork(Twig_Token $token)
{
- return $token->test(array('else', 'endfor'));
+ return $token->test(['else', 'endfor']);
}
public function decideForEnd(Twig_Token $token)
@@ -99,7 +99,7 @@ class Twig_TokenParser_For extends Twig_TokenParser
{
if ($node instanceof Twig_Node_Expression_GetAttr && $node->getNode('node') instanceof Twig_Node_Expression_Name && 'loop' == $node->getNode('node')->getAttribute('name')) {
$attribute = $node->getNode('attribute');
- if ($attribute instanceof Twig_Node_Expression_Constant && in_array($attribute->getAttribute('value'), array('length', 'revindex0', 'revindex', 'last'))) {
+ if ($attribute instanceof Twig_Node_Expression_Constant && in_array($attribute->getAttribute('value'), ['length', 'revindex0', 'revindex', 'last'])) {
throw new Twig_Error_Syntax(sprintf('The "loop.%s" variable is not defined when looping with a condition.', $attribute->getAttribute('value')), $node->getTemplateLine(), $stream->getSourceContext());
}
}
diff --git a/system/templateEngines/Twig/Twig1x/TokenParser/From.php b/system/templateEngines/Twig/Twig1x/TokenParser/From.php
index f3053da..234301b 100644
--- a/system/templateEngines/Twig/Twig1x/TokenParser/From.php
+++ b/system/templateEngines/Twig/Twig1x/TokenParser/From.php
@@ -26,7 +26,7 @@ class Twig_TokenParser_From extends Twig_TokenParser
$stream = $this->parser->getStream();
$stream->expect('import');
- $targets = array();
+ $targets = [];
do {
$name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
diff --git a/system/templateEngines/Twig/Twig1x/TokenParser/If.php b/system/templateEngines/Twig/Twig1x/TokenParser/If.php
index f081df3..ba48e27 100644
--- a/system/templateEngines/Twig/Twig1x/TokenParser/If.php
+++ b/system/templateEngines/Twig/Twig1x/TokenParser/If.php
@@ -33,8 +33,8 @@ class Twig_TokenParser_If extends Twig_TokenParser
$expr = $this->parser->getExpressionParser()->parseExpression();
$stream = $this->parser->getStream();
$stream->expect(Twig_Token::BLOCK_END_TYPE);
- $body = $this->parser->subparse(array($this, 'decideIfFork'));
- $tests = array($expr, $body);
+ $body = $this->parser->subparse([$this, 'decideIfFork']);
+ $tests = [$expr, $body];
$else = null;
$end = false;
@@ -42,13 +42,13 @@ class Twig_TokenParser_If extends Twig_TokenParser
switch ($stream->next()->getValue()) {
case 'else':
$stream->expect(Twig_Token::BLOCK_END_TYPE);
- $else = $this->parser->subparse(array($this, 'decideIfEnd'));
+ $else = $this->parser->subparse([$this, 'decideIfEnd']);
break;
case 'elseif':
$expr = $this->parser->getExpressionParser()->parseExpression();
$stream->expect(Twig_Token::BLOCK_END_TYPE);
- $body = $this->parser->subparse(array($this, 'decideIfFork'));
+ $body = $this->parser->subparse([$this, 'decideIfFork']);
$tests[] = $expr;
$tests[] = $body;
break;
@@ -69,12 +69,12 @@ class Twig_TokenParser_If extends Twig_TokenParser
public function decideIfFork(Twig_Token $token)
{
- return $token->test(array('elseif', 'else', 'endif'));
+ return $token->test(['elseif', 'else', 'endif']);
}
public function decideIfEnd(Twig_Token $token)
{
- return $token->test(array('endif'));
+ return $token->test(['endif']);
}
public function getTag()
diff --git a/system/templateEngines/Twig/Twig1x/TokenParser/Include.php b/system/templateEngines/Twig/Twig1x/TokenParser/Include.php
index 309f11d..483f107 100644
--- a/system/templateEngines/Twig/Twig1x/TokenParser/Include.php
+++ b/system/templateEngines/Twig/Twig1x/TokenParser/Include.php
@@ -53,7 +53,7 @@ class Twig_TokenParser_Include extends Twig_TokenParser
$stream->expect(Twig_Token::BLOCK_END_TYPE);
- return array($variables, $only, $ignoreMissing);
+ return [$variables, $only, $ignoreMissing];
}
public function getTag()
diff --git a/system/templateEngines/Twig/Twig1x/TokenParser/Macro.php b/system/templateEngines/Twig/Twig1x/TokenParser/Macro.php
index 4287934..fa55a7c 100644
--- a/system/templateEngines/Twig/Twig1x/TokenParser/Macro.php
+++ b/system/templateEngines/Twig/Twig1x/TokenParser/Macro.php
@@ -32,7 +32,7 @@ class Twig_TokenParser_Macro extends Twig_TokenParser
$stream->expect(Twig_Token::BLOCK_END_TYPE);
$this->parser->pushLocalScope();
- $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
+ $body = $this->parser->subparse([$this, 'decideBlockEnd'], true);
if ($token = $stream->nextIf(Twig_Token::NAME_TYPE)) {
$value = $token->getValue();
@@ -43,7 +43,7 @@ class Twig_TokenParser_Macro extends Twig_TokenParser
$this->parser->popLocalScope();
$stream->expect(Twig_Token::BLOCK_END_TYPE);
- $this->parser->setMacro($name, new Twig_Node_Macro($name, new Twig_Node_Body(array($body)), $arguments, $lineno, $this->getTag()));
+ $this->parser->setMacro($name, new Twig_Node_Macro($name, new Twig_Node_Body([$body]), $arguments, $lineno, $this->getTag()));
}
public function decideBlockEnd(Twig_Token $token)
diff --git a/system/templateEngines/Twig/Twig1x/TokenParser/Sandbox.php b/system/templateEngines/Twig/Twig1x/TokenParser/Sandbox.php
index 7fc70d9..5161458 100644
--- a/system/templateEngines/Twig/Twig1x/TokenParser/Sandbox.php
+++ b/system/templateEngines/Twig/Twig1x/TokenParser/Sandbox.php
@@ -28,7 +28,7 @@ class Twig_TokenParser_Sandbox extends Twig_TokenParser
{
$stream = $this->parser->getStream();
$stream->expect(Twig_Token::BLOCK_END_TYPE);
- $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
+ $body = $this->parser->subparse([$this, 'decideBlockEnd'], true);
$stream->expect(Twig_Token::BLOCK_END_TYPE);
// in a sandbox tag, only include tags are allowed
diff --git a/system/templateEngines/Twig/Twig1x/TokenParser/Set.php b/system/templateEngines/Twig/Twig1x/TokenParser/Set.php
index 48c6b3a..a692947 100644
--- a/system/templateEngines/Twig/Twig1x/TokenParser/Set.php
+++ b/system/templateEngines/Twig/Twig1x/TokenParser/Set.php
@@ -54,7 +54,7 @@ class Twig_TokenParser_Set extends Twig_TokenParser
$stream->expect(Twig_Token::BLOCK_END_TYPE);
- $values = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
+ $values = $this->parser->subparse([$this, 'decideBlockEnd'], true);
$stream->expect(Twig_Token::BLOCK_END_TYPE);
}
diff --git a/system/templateEngines/Twig/Twig1x/TokenParser/Spaceless.php b/system/templateEngines/Twig/Twig1x/TokenParser/Spaceless.php
index cecf27c..934717c 100644
--- a/system/templateEngines/Twig/Twig1x/TokenParser/Spaceless.php
+++ b/system/templateEngines/Twig/Twig1x/TokenParser/Spaceless.php
@@ -31,7 +31,7 @@ class Twig_TokenParser_Spaceless extends Twig_TokenParser
$lineno = $token->getLine();
$this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
- $body = $this->parser->subparse(array($this, 'decideSpacelessEnd'), true);
+ $body = $this->parser->subparse([$this, 'decideSpacelessEnd'], true);
$this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
return new Twig_Node_Spaceless($body, $lineno, $this->getTag());
diff --git a/system/templateEngines/Twig/Twig1x/TokenParser/Use.php b/system/templateEngines/Twig/Twig1x/TokenParser/Use.php
index 1ab24e2..fc4471f 100644
--- a/system/templateEngines/Twig/Twig1x/TokenParser/Use.php
+++ b/system/templateEngines/Twig/Twig1x/TokenParser/Use.php
@@ -36,7 +36,7 @@ class Twig_TokenParser_Use extends Twig_TokenParser
throw new Twig_Error_Syntax('The template references in a "use" statement must be a string.', $stream->getCurrent()->getLine(), $stream->getSourceContext());
}
- $targets = array();
+ $targets = [];
if ($stream->nextIf('with')) {
do {
$name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
@@ -56,7 +56,7 @@ class Twig_TokenParser_Use extends Twig_TokenParser
$stream->expect(Twig_Token::BLOCK_END_TYPE);
- $this->parser->addTrait(new Twig_Node(array('template' => $template, 'targets' => new Twig_Node($targets))));
+ $this->parser->addTrait(new Twig_Node(['template' => $template, 'targets' => new Twig_Node($targets)]));
return new Twig_Node();
}
diff --git a/system/templateEngines/Twig/Twig1x/TokenParser/With.php b/system/templateEngines/Twig/Twig1x/TokenParser/With.php
index 7a69259..34a0812 100644
--- a/system/templateEngines/Twig/Twig1x/TokenParser/With.php
+++ b/system/templateEngines/Twig/Twig1x/TokenParser/With.php
@@ -31,7 +31,7 @@ class Twig_TokenParser_With extends Twig_TokenParser
$stream->expect(Twig_Token::BLOCK_END_TYPE);
- $body = $this->parser->subparse(array($this, 'decideWithEnd'), true);
+ $body = $this->parser->subparse([$this, 'decideWithEnd'], true);
$stream->expect(Twig_Token::BLOCK_END_TYPE);
diff --git a/system/templateEngines/Twig/Twig1x/TokenParserBroker.php b/system/templateEngines/Twig/Twig1x/TokenParserBroker.php
index 0d7d6e5..c90a3c6 100644
--- a/system/templateEngines/Twig/Twig1x/TokenParserBroker.php
+++ b/system/templateEngines/Twig/Twig1x/TokenParserBroker.php
@@ -20,15 +20,15 @@
class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface
{
protected $parser;
- protected $parsers = array();
- protected $brokers = array();
+ protected $parsers = [];
+ protected $brokers = [];
/**
* @param array|Traversable $parsers A Traversable of Twig_TokenParserInterface instances
* @param array|Traversable $brokers A Traversable of Twig_TokenParserBrokerInterface instances
* @param bool $triggerDeprecationError
*/
- public function __construct($parsers = array(), $brokers = array(), $triggerDeprecationError = true)
+ public function __construct($parsers = [], $brokers = [], $triggerDeprecationError = true)
{
if ($triggerDeprecationError) {
@trigger_error('The '.__CLASS__.' class is deprecated since version 1.12 and will be removed in 2.0.', E_USER_DEPRECATED);
@@ -80,7 +80,7 @@ class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface
*
* @param string $tag A tag name
*
- * @return null|Twig_TokenParserInterface A Twig_TokenParserInterface or null if no suitable TokenParser was found
+ * @return Twig_TokenParserInterface|null A Twig_TokenParserInterface or null if no suitable TokenParser was found
*/
public function getTokenParser($tag)
{
diff --git a/system/templateEngines/Twig/Twig1x/TokenParserBrokerInterface.php b/system/templateEngines/Twig/Twig1x/TokenParserBrokerInterface.php
index 6c93f5e..c239c2e 100644
--- a/system/templateEngines/Twig/Twig1x/TokenParserBrokerInterface.php
+++ b/system/templateEngines/Twig/Twig1x/TokenParserBrokerInterface.php
@@ -38,7 +38,7 @@ interface Twig_TokenParserBrokerInterface
/**
* Gets the Twig_ParserInterface.
*
- * @return null|Twig_ParserInterface A Twig_ParserInterface instance or null
+ * @return Twig_ParserInterface|null A Twig_ParserInterface instance or null
*/
public function getParser();
}
diff --git a/system/templateEngines/Twig/Twig1x/Util/DeprecationCollector.php b/system/templateEngines/Twig/Twig1x/Util/DeprecationCollector.php
index c7bf53b..b6cccf2 100644
--- a/system/templateEngines/Twig/Twig1x/Util/DeprecationCollector.php
+++ b/system/templateEngines/Twig/Twig1x/Util/DeprecationCollector.php
@@ -52,9 +52,9 @@ class Twig_Util_DeprecationCollector
*/
public function collect(Traversable $iterator)
{
- $this->deprecations = array();
+ $this->deprecations = [];
- set_error_handler(array($this, 'errorHandler'));
+ set_error_handler([$this, 'errorHandler']);
foreach ($iterator as $name => $contents) {
try {
@@ -67,7 +67,7 @@ class Twig_Util_DeprecationCollector
restore_error_handler();
$deprecations = $this->deprecations;
- $this->deprecations = array();
+ $this->deprecations = [];
return $deprecations;
}
diff --git a/system/templateEngines/Twig/Twig2x/Compiler.php b/system/templateEngines/Twig/Twig2x/Compiler.php
index 9e8a8d5..62aa314 100644
--- a/system/templateEngines/Twig/Twig2x/Compiler.php
+++ b/system/templateEngines/Twig/Twig2x/Compiler.php
@@ -21,7 +21,7 @@ class Twig_Compiler
private $source;
private $indentation;
private $env;
- private $debugInfo = array();
+ private $debugInfo = [];
private $sourceOffset;
private $sourceLine;
private $varNameSalt = 0;
@@ -63,7 +63,7 @@ class Twig_Compiler
{
$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;
@@ -142,7 +142,7 @@ class Twig_Compiler
setlocale(LC_NUMERIC, 'C');
}
- $this->raw($value);
+ $this->raw(var_export($value, true));
if (false !== $locale) {
setlocale(LC_NUMERIC, $locale);
diff --git a/system/templateEngines/Twig/Twig2x/Environment.php b/system/templateEngines/Twig/Twig2x/Environment.php
index 2a69489..f63153c 100644
--- a/system/templateEngines/Twig/Twig2x/Environment.php
+++ b/system/templateEngines/Twig/Twig2x/Environment.php
@@ -16,11 +16,11 @@
*/
class Twig_Environment
{
- const VERSION = '2.5.0';
- const VERSION_ID = 20500;
+ const VERSION = '2.6.2';
+ const VERSION_ID = 20602;
const MAJOR_VERSION = 2;
- const MINOR_VERSION = 5;
- const RELEASE_VERSION = 0;
+ const MINOR_VERSION = 6;
+ const RELEASE_VERSION = 2;
const EXTRA_VERSION = '';
private $charset;
@@ -32,17 +32,17 @@ class Twig_Environment
private $parser;
private $compiler;
private $baseTemplateClass;
- private $globals = array();
+ private $globals = [];
private $resolvedGlobals;
private $loadedTemplates;
private $strictVariables;
private $templateClassPrefix = '__TwigTemplate_';
private $originalCache;
private $extensionSet;
- private $runtimeLoaders = array();
- private $runtimes = array();
+ private $runtimeLoaders = [];
+ private $runtimes = [];
private $optionsHash;
- private $loading = array();
+ private $loading = [];
/**
* Constructor.
@@ -81,11 +81,11 @@ class Twig_Environment
* @param Twig_LoaderInterface $loader
* @param array $options An array of options
*/
- public function __construct(Twig_LoaderInterface $loader, $options = array())
+ public function __construct(Twig_LoaderInterface $loader, $options = [])
{
$this->setLoader($loader);
- $options = array_merge(array(
+ $options = array_merge([
'debug' => false,
'charset' => 'UTF-8',
'base_template_class' => 'Twig_Template',
@@ -94,7 +94,7 @@ class Twig_Environment
'cache' => false,
'auto_reload' => null,
'optimizations' => -1,
- ), $options);
+ ], $options);
$this->debug = (bool) $options['debug'];
$this->setCharset($options['charset']);
@@ -284,7 +284,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);
}
@@ -299,7 +299,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);
}
@@ -388,7 +388,7 @@ class Twig_Environment
$this->extensionSet->initRuntime($this);
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;
@@ -418,10 +418,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 {
@@ -466,7 +466,7 @@ class Twig_Environment
public function resolveTemplate($names)
{
if (!is_array($names)) {
- $names = array($names);
+ $names = [$names];
}
foreach ($names as $name) {
@@ -720,7 +720,7 @@ class Twig_Environment
*/
public function getTags()
{
- $tags = array();
+ $tags = [];
foreach ($this->getTokenParsers() as $parser) {
$tags[$parser->getTag()] = $parser;
}
@@ -955,7 +955,7 @@ class Twig_Environment
private function updateOptionsHash()
{
- $this->optionsHash = implode(':', array(
+ $this->optionsHash = implode(':', [
$this->extensionSet->getSignature(),
PHP_MAJOR_VERSION,
PHP_MINOR_VERSION,
@@ -963,7 +963,7 @@ class Twig_Environment
(int) $this->debug,
$this->baseTemplateClass,
(int) $this->strictVariables,
- ));
+ ]);
}
}
diff --git a/system/templateEngines/Twig/Twig2x/Error.php b/system/templateEngines/Twig/Twig2x/Error.php
index 77b0813..1f36852 100644
--- a/system/templateEngines/Twig/Twig2x/Error.php
+++ b/system/templateEngines/Twig/Twig2x/Error.php
@@ -63,7 +63,7 @@ class Twig_Error extends Exception
if (null === $source) {
$name = null;
} elseif (!$source instanceof Twig_Source) {
- // for compat with the Twig C ext., passing the template name as string is accepted
+ @trigger_error(sprintf('Passing a string as a source to %s is deprecated since version 2.6.1; pass a Twig_Source instance instead.', __CLASS__), E_USER_DEPRECATED);
$name = $source;
} else {
$name = $source->getName();
@@ -234,14 +234,14 @@ class Twig_Error extends Exception
$r = new ReflectionObject($template);
$file = $r->getFileName();
- $exceptions = array($e = $this);
+ $exceptions = [$e = $this];
while ($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']) {
diff --git a/system/templateEngines/Twig/Twig2x/Error/Syntax.php b/system/templateEngines/Twig/Twig2x/Error/Syntax.php
index aadd45e..3f76920 100644
--- a/system/templateEngines/Twig/Twig2x/Error/Syntax.php
+++ b/system/templateEngines/Twig/Twig2x/Error/Syntax.php
@@ -25,7 +25,7 @@ class Twig_Error_Syntax extends Twig_Error
*/
public function addSuggestions($name, array $items)
{
- $alternatives = array();
+ $alternatives = [];
foreach ($items as $item) {
$lev = levenshtein($name, $item);
if ($lev <= strlen($name) / 3 || false !== strpos($item, $name)) {
diff --git a/system/templateEngines/Twig/Twig2x/ExpressionParser.php b/system/templateEngines/Twig/Twig2x/ExpressionParser.php
index 117a4d2..4f4ad56 100644
--- a/system/templateEngines/Twig/Twig2x/ExpressionParser.php
+++ b/system/templateEngines/Twig/Twig2x/ExpressionParser.php
@@ -178,7 +178,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());
}
@@ -209,7 +209,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) {
@@ -238,7 +238,7 @@ class Twig_ExpressionParser
$stream = $this->parser->getStream();
$stream->expect(/* Twig_Token::PUNCTUATION_TYPE */ 9, '[', '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 */ 9, ']')) {
if (!$first) {
@@ -263,7 +263,7 @@ class Twig_ExpressionParser
$stream = $this->parser->getStream();
$stream->expect(/* Twig_Token::PUNCTUATION_TYPE */ 9, '{', '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 */ 9, '}')) {
if (!$first) {
@@ -352,7 +352,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);
}
@@ -375,7 +375,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();
@@ -434,7 +434,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 */ 9, ']');
@@ -493,7 +493,7 @@ class Twig_ExpressionParser
*/
public function parseArguments($namedArguments = false, $definition = false)
{
- $args = array();
+ $args = [];
$stream = $this->parser->getStream();
$stream->expect(/* Twig_Token::PUNCTUATION_TYPE */ 9, '(', 'A list of arguments must begin with an opening parenthesis');
@@ -549,11 +549,11 @@ class Twig_ExpressionParser
public function parseAssignmentExpression()
{
$stream = $this->parser->getStream();
- $targets = array();
+ $targets = [];
while (true) {
$token = $stream->expect(/* Twig_Token::NAME_TYPE */ 5, 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());
@@ -568,7 +568,7 @@ class Twig_ExpressionParser
public function parseMultitargetExpression()
{
- $targets = array();
+ $targets = [];
while (true) {
$targets[] = $this->parseExpression();
if (!$this->parser->getStream()->nextIf(/* Twig_Token::PUNCTUATION_TYPE */ 9, ',')) {
@@ -604,7 +604,7 @@ class Twig_ExpressionParser
$name = $stream->expect(/* Twig_Token::NAME_TYPE */ 5)->getValue();
if ($test = $this->env->getTest($name)) {
- return array($name, $test);
+ return [$name, $test];
}
if ($stream->test(/* Twig_Token::NAME_TYPE */ 5)) {
@@ -614,7 +614,7 @@ class Twig_ExpressionParser
if ($test = $this->env->getTest($name)) {
$stream->next();
- return array($name, $test);
+ return [$name, $test];
}
}
diff --git a/system/templateEngines/Twig/Twig2x/Extension.php b/system/templateEngines/Twig/Twig2x/Extension.php
index e8916b4..5d1b505 100644
--- a/system/templateEngines/Twig/Twig2x/Extension.php
+++ b/system/templateEngines/Twig/Twig2x/Extension.php
@@ -13,32 +13,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 [];
}
}
diff --git a/system/templateEngines/Twig/Twig2x/Extension/Core.php b/system/templateEngines/Twig/Twig2x/Extension/Core.php
index a45b29a..073a80b 100644
--- a/system/templateEngines/Twig/Twig2x/Extension/Core.php
+++ b/system/templateEngines/Twig/Twig2x/Extension/Core.php
@@ -11,10 +11,10 @@
final class Twig_Extension_Core extends Twig_Extension
{
- private $dateFormats = array('F j, Y H:i', '%d days');
- private $numberFormat = array(0, '.', ',');
+ private $dateFormats = ['F j, Y H:i', '%d days'];
+ private $numberFormat = [0, '.', ','];
private $timezone = null;
- private $escapers = array();
+ private $escapers = [];
/**
* Defines a new escaper to be used via the escape filter.
@@ -97,7 +97,7 @@ final class Twig_Extension_Core extends Twig_Extension
*/
public function setNumberFormat($decimal, $decimalPoint, $thousandSep)
{
- $this->numberFormat = array($decimal, $decimalPoint, $thousandSep);
+ $this->numberFormat = [$decimal, $decimalPoint, $thousandSep];
}
/**
@@ -112,7 +112,7 @@ final 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(),
@@ -129,18 +129,19 @@ final 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()
{
- return array(
+ return [
// formatting filters
- new Twig_Filter('date', 'twig_date_format_filter', array('needs_environment' => true)),
- new Twig_Filter('date_modify', 'twig_date_modify_filter', array('needs_environment' => true)),
+ new Twig_Filter('date', 'twig_date_format_filter', ['needs_environment' => true]),
+ new Twig_Filter('date_modify', 'twig_date_modify_filter', ['needs_environment' => true]),
new Twig_Filter('format', 'sprintf'),
new Twig_Filter('replace', 'twig_replace_filter'),
- new Twig_Filter('number_format', 'twig_number_format_filter', array('needs_environment' => true)),
+ new Twig_Filter('number_format', 'twig_number_format_filter', ['needs_environment' => true]),
new Twig_Filter('abs', 'abs'),
new Twig_Filter('round', 'twig_round'),
@@ -150,108 +151,108 @@ final class Twig_Extension_Core extends Twig_Extension
new Twig_Filter('convert_encoding', 'twig_convert_encoding'),
// string filters
- new Twig_Filter('title', 'twig_title_string_filter', array('needs_environment' => true)),
- new Twig_Filter('capitalize', 'twig_capitalize_string_filter', array('needs_environment' => true)),
- new Twig_Filter('upper', 'twig_upper_filter', array('needs_environment' => true)),
- new Twig_Filter('lower', 'twig_lower_filter', array('needs_environment' => true)),
+ new Twig_Filter('title', 'twig_title_string_filter', ['needs_environment' => true]),
+ new Twig_Filter('capitalize', 'twig_capitalize_string_filter', ['needs_environment' => true]),
+ new Twig_Filter('upper', 'twig_upper_filter', ['needs_environment' => true]),
+ new Twig_Filter('lower', 'twig_lower_filter', ['needs_environment' => true]),
new Twig_Filter('striptags', 'strip_tags'),
new Twig_Filter('trim', 'twig_trim_filter'),
- new Twig_Filter('nl2br', 'nl2br', array('pre_escape' => 'html', 'is_safe' => array('html'))),
+ new Twig_Filter('nl2br', 'nl2br', ['pre_escape' => 'html', 'is_safe' => ['html']]),
// array helpers
new Twig_Filter('join', 'twig_join_filter'),
- new Twig_Filter('split', 'twig_split_filter', array('needs_environment' => true)),
+ new Twig_Filter('split', 'twig_split_filter', ['needs_environment' => true]),
new Twig_Filter('sort', 'twig_sort_filter'),
new Twig_Filter('merge', 'twig_array_merge'),
new Twig_Filter('batch', 'twig_array_batch'),
// string/array filters
- new Twig_Filter('reverse', 'twig_reverse_filter', array('needs_environment' => true)),
- new Twig_Filter('length', 'twig_length_filter', array('needs_environment' => true)),
- new Twig_Filter('slice', 'twig_slice', array('needs_environment' => true)),
- new Twig_Filter('first', 'twig_first', array('needs_environment' => true)),
- new Twig_Filter('last', 'twig_last', array('needs_environment' => true)),
+ new Twig_Filter('reverse', 'twig_reverse_filter', ['needs_environment' => true]),
+ new Twig_Filter('length', 'twig_length_filter', ['needs_environment' => true]),
+ new Twig_Filter('slice', 'twig_slice', ['needs_environment' => true]),
+ new Twig_Filter('first', 'twig_first', ['needs_environment' => true]),
+ new Twig_Filter('last', 'twig_last', ['needs_environment' => true]),
// iteration and runtime
- new Twig_Filter('default', '_twig_default_filter', array('node_class' => 'Twig_Node_Expression_Filter_Default')),
+ new Twig_Filter('default', '_twig_default_filter', ['node_class' => 'Twig_Node_Expression_Filter_Default']),
new Twig_Filter('keys', 'twig_get_array_keys_filter'),
// escaping
- new Twig_Filter('escape', 'twig_escape_filter', array('needs_environment' => true, 'is_safe_callback' => 'twig_escape_filter_is_safe')),
- new Twig_Filter('e', 'twig_escape_filter', array('needs_environment' => true, 'is_safe_callback' => 'twig_escape_filter_is_safe')),
- );
+ new Twig_Filter('escape', 'twig_escape_filter', ['needs_environment' => true, 'is_safe_callback' => 'twig_escape_filter_is_safe']),
+ new Twig_Filter('e', 'twig_escape_filter', ['needs_environment' => true, 'is_safe_callback' => 'twig_escape_filter_is_safe']),
+ ];
}
public function getFunctions()
{
- return array(
+ return [
new Twig_Function('max', 'max'),
new Twig_Function('min', 'min'),
new Twig_Function('range', 'range'),
new Twig_Function('constant', 'twig_constant'),
new Twig_Function('cycle', 'twig_cycle'),
- new Twig_Function('random', 'twig_random', array('needs_environment' => true)),
- new Twig_Function('date', 'twig_date_converter', array('needs_environment' => true)),
- new Twig_Function('include', 'twig_include', array('needs_environment' => true, 'needs_context' => true, 'is_safe' => array('all'))),
- new Twig_Function('source', 'twig_source', array('needs_environment' => true, 'is_safe' => array('all'))),
- );
+ new Twig_Function('random', 'twig_random', ['needs_environment' => true]),
+ new Twig_Function('date', 'twig_date_converter', ['needs_environment' => true]),
+ new Twig_Function('include', 'twig_include', ['needs_environment' => true, 'needs_context' => true, 'is_safe' => ['all']]),
+ new Twig_Function('source', 'twig_source', ['needs_environment' => true, 'is_safe' => ['all']]),
+ ];
}
public function getTests()
{
- return array(
- new Twig_Test('even', null, array('node_class' => 'Twig_Node_Expression_Test_Even')),
- new Twig_Test('odd', null, array('node_class' => 'Twig_Node_Expression_Test_Odd')),
- new Twig_Test('defined', null, array('node_class' => 'Twig_Node_Expression_Test_Defined')),
- new Twig_Test('same as', null, array('node_class' => 'Twig_Node_Expression_Test_Sameas')),
- new Twig_Test('none', null, array('node_class' => 'Twig_Node_Expression_Test_Null')),
- new Twig_Test('null', null, array('node_class' => 'Twig_Node_Expression_Test_Null')),
- new Twig_Test('divisible by', null, array('node_class' => 'Twig_Node_Expression_Test_Divisibleby')),
- new Twig_Test('constant', null, array('node_class' => 'Twig_Node_Expression_Test_Constant')),
+ return [
+ new Twig_Test('even', null, ['node_class' => 'Twig_Node_Expression_Test_Even']),
+ new Twig_Test('odd', null, ['node_class' => 'Twig_Node_Expression_Test_Odd']),
+ new Twig_Test('defined', null, ['node_class' => 'Twig_Node_Expression_Test_Defined']),
+ new Twig_Test('same as', null, ['node_class' => 'Twig_Node_Expression_Test_Sameas']),
+ new Twig_Test('none', null, ['node_class' => 'Twig_Node_Expression_Test_Null']),
+ new Twig_Test('null', null, ['node_class' => 'Twig_Node_Expression_Test_Null']),
+ new Twig_Test('divisible by', null, ['node_class' => 'Twig_Node_Expression_Test_Divisibleby']),
+ new Twig_Test('constant', null, ['node_class' => 'Twig_Node_Expression_Test_Constant']),
new Twig_Test('empty', 'twig_test_empty'),
new Twig_Test('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],
+ ],
+ ];
}
}
@@ -340,7 +341,7 @@ function twig_random(Twig_Environment $env, $values = null)
* @param Twig_Environment $env
* @param 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
*/
@@ -389,7 +390,7 @@ function twig_date_modify_filter(Twig_Environment $env, $date, $modifier)
*
* @param Twig_Environment $env
* @param DateTimeInterface|string|null $date A date or null to use the current time
- * @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
*/
@@ -581,7 +582,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 [];
}
}
@@ -630,9 +631,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.
*
*
+ * {{ [1, 2, 3]|join(', ', ' and ') }}
+ * {# returns 1, 2 and 3 #}
+ *
* {{ [1, 2, 3]|join('|') }}
* {# returns 1|2|3 #}
*
@@ -640,18 +644,34 @@ function twig_last(Twig_Environment $env, $item)
* {# returns 123 #}
*
*
- * @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;
+ }
+
+ if (0 === count($value)) {
+ return '';
+ }
+
+ if (null === $and || $and === $glue) {
+ return implode($glue, $value);
}
- return implode($glue, (array) $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];
}
/**
@@ -690,10 +710,10 @@ function twig_split_filter(Twig_Environment $env, $value, $delimiter, $limit = n
$length = mb_strlen($value, $env->getCharset());
if ($length < $limit) {
- return array($value);
+ return [$value];
}
- $r = array();
+ $r = [];
for ($i = 0; $i < $length; $i += $limit) {
$r[] = mb_substr($value, $i, $limit, $env->getCharset());
}
@@ -739,7 +759,7 @@ function twig_get_array_keys_filter($array)
}
if ($array instanceof Iterator) {
- $keys = array();
+ $keys = [];
$array->rewind();
while ($array->valid()) {
$keys[] = $array->key();
@@ -749,7 +769,7 @@ function twig_get_array_keys_filter($array)
return $keys;
}
- $keys = array();
+ $keys = [];
foreach ($array as $key => $item) {
$keys[] = $key;
}
@@ -758,7 +778,7 @@ function twig_get_array_keys_filter($array)
}
if (!is_array($array)) {
- return array();
+ return [];
}
return array_keys($array);
@@ -897,11 +917,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();
}
@@ -913,7 +937,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,
@@ -928,7 +952,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);
@@ -953,7 +977,7 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html',
$string = iconv($charset, 'UTF-8', $string);
}
- 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.');
}
@@ -965,7 +989,7 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html',
* 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',
@@ -973,7 +997,7 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html',
"\x0A" => '\n',
"\x0D" => '\r',
"\x09" => '\t',
- );
+ ];
if (isset($shortMap[$char])) {
return $shortMap[$char];
@@ -1001,27 +1025,14 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html',
$string = iconv($charset, 'UTF-8', $string);
}
- 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.');
}
$string = preg_replace_callback('#[^a-zA-Z0-9]#Su', function ($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) : mb_ord($char, 'UTF-8'));
}, $string);
if ('UTF-8' !== $charset) {
@@ -1035,7 +1046,7 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html',
$string = iconv($charset, 'UTF-8', $string);
}
- 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.');
}
@@ -1046,19 +1057,6 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html',
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (https://www.zend.com)
* @license https://framework.zend.com/license/new-bsd New BSD License
*/
- /*
- * 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);
@@ -1074,23 +1072,32 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html',
* Check if the current character to escape has a name entity we should
* 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));
- }
+ if (1 === strlen($chr)) {
+ /*
+ * 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 */
+ ];
+
+ if (isset($entityMap[$ord])) {
+ return $entityMap[$ord];
+ }
- $int = hexdec($hex);
- if (array_key_exists($int, $entityMap)) {
- return sprintf('&%s;', $entityMap[$int]);
+ return sprintf('%02X;', $ord);
}
/*
* Per OWASP recommendations, we'll use hex entities for any other
* characters where a named entity does not exist.
*/
- return sprintf('%s;', $hex);
+ return sprintf('%04X;', mb_ord($chr, 'UTF-8'));
}, $string);
if ('UTF-8' !== $charset) {
@@ -1113,7 +1120,7 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html',
return $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));
}
@@ -1126,13 +1133,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'];
}
function twig_convert_encoding($string, $to, $from)
@@ -1244,7 +1251,7 @@ function twig_ensure_traversable($seq)
return $seq;
}
- return array();
+ return [];
}
/**
@@ -1271,7 +1278,7 @@ function twig_test_empty($value)
return '' === (string) $value;
}
- return '' === $value || false === $value || null === $value || array() === $value;
+ return '' === $value || false === $value || null === $value || [] === $value;
}
/**
@@ -1306,7 +1313,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;
@@ -1321,7 +1328,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) {
@@ -1372,7 +1379,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
*/
@@ -1389,7 +1396,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
*/
@@ -1450,13 +1457,13 @@ function twig_array_batch($items, $size, $fill = null)
*
* @internal
*/
-function twig_get_attribute(Twig_Environment $env, Twig_Source $source, $object, $item, array $arguments = array(), $type = /* Twig_Template::ANY_CALL */ 'any', $isDefinedTest = false, $ignoreStrictCheck = false, $sandboxed = false)
+function twig_get_attribute(Twig_Environment $env, Twig_Source $source, $object, $item, array $arguments = [], $type = /* Twig_Template::ANY_CALL */ 'any', $isDefinedTest = false, $ignoreStrictCheck = false, $sandboxed = false)
{
// array
if (/* Twig_Template::METHOD_CALL */ 'method' !== $type) {
$arrayItem = is_bool($item) || is_float($item) ? (int) $item : $item;
- if ((is_array($object) && (isset($object[$arrayItem]) || array_key_exists($arrayItem, $object)))
+ if (((is_array($object) || $object instanceof ArrayObject) && (isset($object[$arrayItem]) || array_key_exists($arrayItem, $object)))
|| ($object instanceof ArrayAccess && isset($object[$arrayItem]))
) {
if ($isDefinedTest) {
@@ -1540,7 +1547,7 @@ function twig_get_attribute(Twig_Environment $env, Twig_Source $source, $object,
}
}
- static $cache = array();
+ static $cache = [];
$class = get_class($object);
@@ -1550,7 +1557,7 @@ function twig_get_attribute(Twig_Environment $env, Twig_Source $source, $object,
$methods = get_class_methods($object);
sort($methods);
$lcMethods = array_map('strtolower', $methods);
- $classCache = array();
+ $classCache = [];
foreach ($methods as $i => $method) {
$classCache[$method] = $method;
$classCache[$lcName = $lcMethods[$i]] = $method;
diff --git a/system/templateEngines/Twig/Twig2x/Extension/Debug.php b/system/templateEngines/Twig/Twig2x/Extension/Debug.php
index a4f7b3c..f7d3d7c 100644
--- a/system/templateEngines/Twig/Twig2x/Extension/Debug.php
+++ b/system/templateEngines/Twig/Twig2x/Extension/Debug.php
@@ -23,9 +23,9 @@ final class Twig_Extension_Debug extends Twig_Extension
|| 'cli' === PHP_SAPI
;
- return array(
- new Twig_Function('dump', 'twig_var_dump', array('is_safe' => $isDumpOutputHtmlSafe ? array('html') : array(), 'needs_context' => true, 'needs_environment' => true)),
- );
+ return [
+ new Twig_Function('dump', 'twig_var_dump', ['is_safe' => $isDumpOutputHtmlSafe ? ['html'] : [], 'needs_context' => true, 'needs_environment' => true]),
+ ];
}
}
@@ -38,7 +38,7 @@ function twig_var_dump(Twig_Environment $env, $context, ...$vars)
ob_start();
if (!$vars) {
- $vars = array();
+ $vars = [];
foreach ($context as $key => $value) {
if (!$value instanceof Twig_Template) {
$vars[$key] = $value;
diff --git a/system/templateEngines/Twig/Twig2x/Extension/Escaper.php b/system/templateEngines/Twig/Twig2x/Extension/Escaper.php
index c0fd667..d4808f6 100644
--- a/system/templateEngines/Twig/Twig2x/Extension/Escaper.php
+++ b/system/templateEngines/Twig/Twig2x/Extension/Escaper.php
@@ -25,19 +25,19 @@ final 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_Filter('raw', 'twig_raw_filter', array('is_safe' => array('all'))),
- );
+ return [
+ new Twig_Filter('raw', 'twig_raw_filter', ['is_safe' => ['all']]),
+ ];
}
/**
@@ -51,7 +51,7 @@ final class Twig_Extension_Escaper extends Twig_Extension
public function setDefaultStrategy($defaultStrategy)
{
if ('name' === $defaultStrategy) {
- $defaultStrategy = array('Twig_FileExtensionEscapingStrategy', 'guess');
+ $defaultStrategy = ['Twig_FileExtensionEscapingStrategy', 'guess'];
}
$this->defaultStrategy = $defaultStrategy;
diff --git a/system/templateEngines/Twig/Twig2x/Extension/Optimizer.php b/system/templateEngines/Twig/Twig2x/Extension/Optimizer.php
index 8b5bba5..140020f 100644
--- a/system/templateEngines/Twig/Twig2x/Extension/Optimizer.php
+++ b/system/templateEngines/Twig/Twig2x/Extension/Optimizer.php
@@ -20,7 +20,7 @@ final 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)];
}
}
diff --git a/system/templateEngines/Twig/Twig2x/Extension/Profiler.php b/system/templateEngines/Twig/Twig2x/Extension/Profiler.php
index ffad77c..065b221 100644
--- a/system/templateEngines/Twig/Twig2x/Extension/Profiler.php
+++ b/system/templateEngines/Twig/Twig2x/Extension/Profiler.php
@@ -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))];
}
}
diff --git a/system/templateEngines/Twig/Twig2x/Extension/Sandbox.php b/system/templateEngines/Twig/Twig2x/Extension/Sandbox.php
index 3ab71c3..77b23c5 100644
--- a/system/templateEngines/Twig/Twig2x/Extension/Sandbox.php
+++ b/system/templateEngines/Twig/Twig2x/Extension/Sandbox.php
@@ -23,12 +23,12 @@ final 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()
diff --git a/system/templateEngines/Twig/Twig2x/Extension/Staging.php b/system/templateEngines/Twig/Twig2x/Extension/Staging.php
index 926b2b7..36876b7 100644
--- a/system/templateEngines/Twig/Twig2x/Extension/Staging.php
+++ b/system/templateEngines/Twig/Twig2x/Extension/Staging.php
@@ -18,11 +18,11 @@
*/
final class Twig_Extension_Staging extends Twig_Extension
{
- private $functions = array();
- private $filters = array();
- private $visitors = array();
- private $tokenParsers = array();
- private $tests = array();
+ private $functions = [];
+ private $filters = [];
+ private $visitors = [];
+ private $tokenParsers = [];
+ private $tests = [];
public function addFunction(Twig_Function $function)
{
diff --git a/system/templateEngines/Twig/Twig2x/Extension/StringLoader.php b/system/templateEngines/Twig/Twig2x/Extension/StringLoader.php
index de3593d..606b24d 100644
--- a/system/templateEngines/Twig/Twig2x/Extension/StringLoader.php
+++ b/system/templateEngines/Twig/Twig2x/Extension/StringLoader.php
@@ -13,9 +13,9 @@ final class Twig_Extension_StringLoader extends Twig_Extension
{
public function getFunctions()
{
- return array(
- new Twig_Function('template_from_string', 'twig_template_from_string', array('needs_environment' => true)),
- );
+ return [
+ new Twig_Function('template_from_string', 'twig_template_from_string', ['needs_environment' => true]),
+ ];
}
}
diff --git a/system/templateEngines/Twig/Twig2x/ExtensionSet.php b/system/templateEngines/Twig/Twig2x/ExtensionSet.php
index 2ade646..c1bd03c 100644
--- a/system/templateEngines/Twig/Twig2x/ExtensionSet.php
+++ b/system/templateEngines/Twig/Twig2x/ExtensionSet.php
@@ -28,8 +28,8 @@ final class Twig_ExtensionSet
private $unaryOperators;
private $binaryOperators;
private $globals;
- private $functionCallbacks = array();
- private $filterCallbacks = array();
+ private $functionCallbacks = [];
+ private $filterCallbacks = [];
private $lastModified = 0;
public function __construct()
@@ -330,7 +330,7 @@ final class Twig_ExtensionSet
return $this->globals;
}
- $globals = array();
+ $globals = [];
foreach ($this->extensions as $extension) {
if (!$extension instanceof Twig_Extension_GlobalsInterface) {
continue;
@@ -386,6 +386,19 @@ final class Twig_ExtensionSet
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;
}
@@ -419,13 +432,13 @@ final class Twig_ExtensionSet
private function initExtensions()
{
- $this->parsers = array();
- $this->filters = array();
- $this->functions = array();
- $this->tests = array();
- $this->visitors = array();
- $this->unaryOperators = array();
- $this->binaryOperators = array();
+ $this->parsers = [];
+ $this->filters = [];
+ $this->functions = [];
+ $this->tests = [];
+ $this->visitors = [];
+ $this->unaryOperators = [];
+ $this->binaryOperators = [];
foreach ($this->extensions as $extension) {
$this->initExtension($extension);
diff --git a/system/templateEngines/Twig/Twig2x/FactoryRuntimeLoader.php b/system/templateEngines/Twig/Twig2x/FactoryRuntimeLoader.php
index 2cdaded..2a86712 100644
--- a/system/templateEngines/Twig/Twig2x/FactoryRuntimeLoader.php
+++ b/system/templateEngines/Twig/Twig2x/FactoryRuntimeLoader.php
@@ -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;
}
diff --git a/system/templateEngines/Twig/Twig2x/FileExtensionEscapingStrategy.php b/system/templateEngines/Twig/Twig2x/FileExtensionEscapingStrategy.php
index 8f8cd2e..6b13c72 100644
--- a/system/templateEngines/Twig/Twig2x/FileExtensionEscapingStrategy.php
+++ b/system/templateEngines/Twig/Twig2x/FileExtensionEscapingStrategy.php
@@ -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
}
diff --git a/system/templateEngines/Twig/Twig2x/Filter.php b/system/templateEngines/Twig/Twig2x/Filter.php
index d2182ef..9a86d06 100644
--- a/system/templateEngines/Twig/Twig2x/Filter.php
+++ b/system/templateEngines/Twig/Twig2x/Filter.php
@@ -23,7 +23,7 @@ class Twig_Filter
private $name;
private $callable;
private $options;
- private $arguments = array();
+ private $arguments = [];
/**
* Creates a template filter.
@@ -32,7 +32,7 @@ class Twig_Filter
* @param callable|null $callable A callable implementing the filter. If null, you need to overwrite the "node_class" option to customize compilation.
* @param array $options Options array
*/
- public function __construct(string $name, $callable = null, array $options = array())
+ public function __construct(string $name, $callable = null, array $options = [])
{
if (__CLASS__ !== get_class($this)) {
@trigger_error('Overriding '.__CLASS__.' is deprecated since version 2.4.0 and the class will be final in 3.0.', E_USER_DEPRECATED);
@@ -40,7 +40,7 @@ class Twig_Filter
$this->name = $name;
$this->callable = $callable;
- $this->options = array_merge(array(
+ $this->options = array_merge([
'needs_environment' => false,
'needs_context' => false,
'is_variadic' => false,
@@ -51,7 +51,7 @@ class Twig_Filter
'node_class' => 'Twig_Node_Expression_Filter',
'deprecated' => false,
'alternative' => null,
- ), $options);
+ ], $options);
}
public function getName()
diff --git a/system/templateEngines/Twig/Twig2x/Function.php b/system/templateEngines/Twig/Twig2x/Function.php
index 75a99f2..b0b6cc0 100644
--- a/system/templateEngines/Twig/Twig2x/Function.php
+++ b/system/templateEngines/Twig/Twig2x/Function.php
@@ -23,7 +23,7 @@ class Twig_Function
private $name;
private $callable;
private $options;
- private $arguments = array();
+ private $arguments = [];
/**
* Creates a template function.
@@ -32,7 +32,7 @@ class Twig_Function
* @param callable|null $callable A callable implementing the function. If null, you need to overwrite the "node_class" option to customize compilation.
* @param array $options Options array
*/
- public function __construct(string $name, $callable = null, array $options = array())
+ public function __construct(string $name, $callable = null, array $options = [])
{
if (__CLASS__ !== get_class($this)) {
@trigger_error('Overriding '.__CLASS__.' is deprecated since version 2.4.0 and the class will be final in 3.0.', E_USER_DEPRECATED);
@@ -40,7 +40,7 @@ class Twig_Function
$this->name = $name;
$this->callable = $callable;
- $this->options = array_merge(array(
+ $this->options = array_merge([
'needs_environment' => false,
'needs_context' => false,
'is_variadic' => false,
@@ -49,7 +49,7 @@ class Twig_Function
'node_class' => 'Twig_Node_Expression_Function',
'deprecated' => false,
'alternative' => null,
- ), $options);
+ ], $options);
}
public function getName()
@@ -102,7 +102,7 @@ class Twig_Function
return $this->options['is_safe_callback']($functionArgs);
}
- return array();
+ return [];
}
public function isVariadic()
diff --git a/system/templateEngines/Twig/Twig2x/Lexer.php b/system/templateEngines/Twig/Twig2x/Lexer.php
index fa06eae..75f45d1 100644
--- a/system/templateEngines/Twig/Twig2x/Lexer.php
+++ b/system/templateEngines/Twig/Twig2x/Lexer.php
@@ -46,19 +46,19 @@ class Twig_Lexer
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*(?:endverbatim)\s*(?:'.preg_quote($this->options['whitespace_trim'].$this->options['tag_block'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_block'][1], '/').')/s',
@@ -69,20 +69,20 @@ class Twig_Lexer
'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(Twig_Source $source)
{
$this->source = $source;
- $this->code = str_replace(array("\r\n", "\r"), "\n", $source->getCode());
+ $this->code = str_replace(["\r\n", "\r"], "\n", $source->getCode());
$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
@@ -237,7 +237,7 @@ class Twig_Lexer
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])) {
@@ -261,7 +261,7 @@ class Twig_Lexer
}
// 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]);
}
@@ -299,7 +299,7 @@ class Twig_Lexer
private 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 */ 10);
$this->moveCursor($match[0]);
$this->pushState(self::STATE_INTERPOLATION);
@@ -352,7 +352,7 @@ class Twig_Lexer
private function getOperatorRegex()
{
$operators = array_merge(
- array('='),
+ ['='],
array_keys($this->env->getUnaryOperators()),
array_keys($this->env->getBinaryOperators())
);
@@ -360,7 +360,7 @@ class Twig_Lexer
$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
diff --git a/system/templateEngines/Twig/Twig2x/Loader/Array.php b/system/templateEngines/Twig/Twig2x/Loader/Array.php
index ba23bfa..a7e8057 100644
--- a/system/templateEngines/Twig/Twig2x/Loader/Array.php
+++ b/system/templateEngines/Twig/Twig2x/Loader/Array.php
@@ -23,12 +23,12 @@
*/
final class Twig_Loader_Array implements Twig_LoaderInterface, Twig_ExistsLoaderInterface, Twig_SourceContextLoaderInterface
{
- private $templates = array();
+ private $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;
}
diff --git a/system/templateEngines/Twig/Twig2x/Loader/Chain.php b/system/templateEngines/Twig/Twig2x/Loader/Chain.php
index dba9b77..c4ff8b6 100644
--- a/system/templateEngines/Twig/Twig2x/Loader/Chain.php
+++ b/system/templateEngines/Twig/Twig2x/Loader/Chain.php
@@ -16,13 +16,13 @@
*/
final class Twig_Loader_Chain implements Twig_LoaderInterface, Twig_ExistsLoaderInterface, Twig_SourceContextLoaderInterface
{
- private $hasSourceCache = array();
- private $loaders = array();
+ private $hasSourceCache = [];
+ private $loaders = [];
/**
* @param Twig_LoaderInterface[] $loaders
*/
- public function __construct(array $loaders = array())
+ public function __construct(array $loaders = [])
{
foreach ($loaders as $loader) {
$this->addLoader($loader);
@@ -32,12 +32,12 @@ final class Twig_Loader_Chain implements Twig_LoaderInterface, Twig_ExistsLoader
public function addLoader(Twig_LoaderInterface $loader)
{
$this->loaders[] = $loader;
- $this->hasSourceCache = array();
+ $this->hasSourceCache = [];
}
public function getSourceContext($name)
{
- $exceptions = array();
+ $exceptions = [];
foreach ($this->loaders as $loader) {
if (!$loader->exists($name)) {
continue;
@@ -70,7 +70,7 @@ final class Twig_Loader_Chain implements Twig_LoaderInterface, Twig_ExistsLoader
public function getCacheKey($name)
{
- $exceptions = array();
+ $exceptions = [];
foreach ($this->loaders as $loader) {
if (!$loader->exists($name)) {
continue;
@@ -88,7 +88,7 @@ final class Twig_Loader_Chain implements Twig_LoaderInterface, Twig_ExistsLoader
public function isFresh($name, $time)
{
- $exceptions = array();
+ $exceptions = [];
foreach ($this->loaders as $loader) {
if (!$loader->exists($name)) {
continue;
diff --git a/system/templateEngines/Twig/Twig2x/Loader/Filesystem.php b/system/templateEngines/Twig/Twig2x/Loader/Filesystem.php
index 1cd448a..58d082c 100644
--- a/system/templateEngines/Twig/Twig2x/Loader/Filesystem.php
+++ b/system/templateEngines/Twig/Twig2x/Loader/Filesystem.php
@@ -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)) {
@@ -189,9 +189,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);
@@ -241,10 +249,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];
}
private function validateName($name)
diff --git a/system/templateEngines/Twig/Twig2x/Node.php b/system/templateEngines/Twig/Twig2x/Node.php
index 8b62c29..d0272cc 100644
--- a/system/templateEngines/Twig/Twig2x/Node.php
+++ b/system/templateEngines/Twig/Twig2x/Node.php
@@ -35,7 +35,7 @@ class Twig_Node implements Countable, IteratorAggregate
* @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 self) {
@@ -50,17 +50,17 @@ class Twig_Node implements Countable, IteratorAggregate
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;
}
diff --git a/system/templateEngines/Twig/Twig2x/Node/AutoEscape.php b/system/templateEngines/Twig/Twig2x/Node/AutoEscape.php
index 36a982b..a191cbf 100644
--- a/system/templateEngines/Twig/Twig2x/Node/AutoEscape.php
+++ b/system/templateEngines/Twig/Twig2x/Node/AutoEscape.php
@@ -24,7 +24,7 @@ class Twig_Node_AutoEscape extends Twig_Node
{
public function __construct($value, Twig_Node $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)
diff --git a/system/templateEngines/Twig/Twig2x/Node/Block.php b/system/templateEngines/Twig/Twig2x/Node/Block.php
index be87ef6..2e8ebdf 100644
--- a/system/templateEngines/Twig/Twig2x/Node/Block.php
+++ b/system/templateEngines/Twig/Twig2x/Node/Block.php
@@ -19,14 +19,14 @@ class Twig_Node_Block extends Twig_Node
{
public function __construct($name, Twig_Node $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()
;
diff --git a/system/templateEngines/Twig/Twig2x/Node/BlockReference.php b/system/templateEngines/Twig/Twig2x/Node/BlockReference.php
index 92a9f39..0b0f7b3 100644
--- a/system/templateEngines/Twig/Twig2x/Node/BlockReference.php
+++ b/system/templateEngines/Twig/Twig2x/Node/BlockReference.php
@@ -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)
diff --git a/system/templateEngines/Twig/Twig2x/Node/CheckSecurity.php b/system/templateEngines/Twig/Twig2x/Node/CheckSecurity.php
index d73185d..e3faf86 100644
--- a/system/templateEngines/Twig/Twig2x/Node/CheckSecurity.php
+++ b/system/templateEngines/Twig/Twig2x/Node/CheckSecurity.php
@@ -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->extensions['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()
diff --git a/system/templateEngines/Twig/Twig2x/Node/Deprecated.php b/system/templateEngines/Twig/Twig2x/Node/Deprecated.php
new file mode 100644
index 0000000..fc4c392
--- /dev/null
+++ b/system/templateEngines/Twig/Twig2x/Node/Deprecated.php
@@ -0,0 +1,49 @@
+
+ */
+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);
diff --git a/system/templateEngines/Twig/Twig2x/Node/Do.php b/system/templateEngines/Twig/Twig2x/Node/Do.php
index cdd7e77..1335045 100644
--- a/system/templateEngines/Twig/Twig2x/Node/Do.php
+++ b/system/templateEngines/Twig/Twig2x/Node/Do.php
@@ -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)
diff --git a/system/templateEngines/Twig/Twig2x/Node/Expression/Array.php b/system/templateEngines/Twig/Twig2x/Node/Expression/Array.php
index 5c71f5e..664a213 100644
--- a/system/templateEngines/Twig/Twig2x/Node/Expression/Array.php
+++ b/system/templateEngines/Twig/Twig2x/Node/Expression/Array.php
@@ -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(']');
}
}
diff --git a/system/templateEngines/Twig/Twig2x/Node/Expression/Binary.php b/system/templateEngines/Twig/Twig2x/Node/Expression/Binary.php
index 2401bc1..f5296fd 100644
--- a/system/templateEngines/Twig/Twig2x/Node/Expression/Binary.php
+++ b/system/templateEngines/Twig/Twig2x/Node/Expression/Binary.php
@@ -13,7 +13,7 @@ abstract class Twig_Node_Expression_Binary extends Twig_Node_Expression
{
public function __construct(Twig_Node $left, Twig_Node $right, $lineno)
{
- parent::__construct(array('left' => $left, 'right' => $right), array(), $lineno);
+ parent::__construct(['left' => $left, 'right' => $right], [], $lineno);
}
public function compile(Twig_Compiler $compiler)
diff --git a/system/templateEngines/Twig/Twig2x/Node/Expression/BlockReference.php b/system/templateEngines/Twig/Twig2x/Node/Expression/BlockReference.php
index 48c982c..daed1c5 100644
--- a/system/templateEngines/Twig/Twig2x/Node/Expression/BlockReference.php
+++ b/system/templateEngines/Twig/Twig2x/Node/Expression/BlockReference.php
@@ -19,12 +19,12 @@ class Twig_Node_Expression_BlockReference extends Twig_Node_Expression
{
public function __construct(Twig_Node $name, Twig_Node $template = null, $lineno, $tag = 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)
diff --git a/system/templateEngines/Twig/Twig2x/Node/Expression/Call.php b/system/templateEngines/Twig/Twig2x/Node/Expression/Call.php
index ac5ac0d..27b86e2 100644
--- a/system/templateEngines/Twig/Twig2x/Node/Expression/Call.php
+++ b/system/templateEngines/Twig/Twig2x/Node/Expression/Call.php
@@ -17,6 +17,7 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
$callable = $this->getAttribute('callable');
$closingParenthesis = false;
+ $isArray = false;
if (is_string($callable) && false === strpos($callable, '::')) {
$compiler->raw($callable);
} else {
@@ -40,20 +41,21 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
$compiler->raw(sprintf('->%s', $callable[1]));
} else {
$closingParenthesis = true;
- $compiler->raw(sprintf('call_user_func_array($this->env->get%s(\'%s\')->getCallable(), array', ucfirst($this->getAttribute('type')), $this->getAttribute('name')));
+ $isArray = true;
+ $compiler->raw(sprintf('call_user_func_array($this->env->get%s(\'%s\')->getCallable(), ', ucfirst($this->getAttribute('type')), $this->getAttribute('name')));
}
}
- $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;
@@ -100,7 +102,7 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
}
}
- $compiler->raw(')');
+ $compiler->raw($isArray ? ']' : ')');
}
protected function getArguments($callable = null, $arguments)
@@ -108,7 +110,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)) {
@@ -137,10 +139,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);
@@ -160,12 +162,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);
@@ -181,7 +183,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);
@@ -217,14 +219,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();
@@ -244,7 +246,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;
@@ -252,7 +254,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')));
}
}
@@ -268,27 +270,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];
}
}
diff --git a/system/templateEngines/Twig/Twig2x/Node/Expression/Conditional.php b/system/templateEngines/Twig/Twig2x/Node/Expression/Conditional.php
index c339d77..996772a 100644
--- a/system/templateEngines/Twig/Twig2x/Node/Expression/Conditional.php
+++ b/system/templateEngines/Twig/Twig2x/Node/Expression/Conditional.php
@@ -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)
diff --git a/system/templateEngines/Twig/Twig2x/Node/Expression/Constant.php b/system/templateEngines/Twig/Twig2x/Node/Expression/Constant.php
index bf4d031..7304e8c 100644
--- a/system/templateEngines/Twig/Twig2x/Node/Expression/Constant.php
+++ b/system/templateEngines/Twig/Twig2x/Node/Expression/Constant.php
@@ -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)
diff --git a/system/templateEngines/Twig/Twig2x/Node/Expression/Filter.php b/system/templateEngines/Twig/Twig2x/Node/Expression/Filter.php
index efa91c5..61b0470 100644
--- a/system/templateEngines/Twig/Twig2x/Node/Expression/Filter.php
+++ b/system/templateEngines/Twig/Twig2x/Node/Expression/Filter.php
@@ -13,7 +13,7 @@ class Twig_Node_Expression_Filter extends Twig_Node_Expression_Call
{
public function __construct(Twig_Node $node, Twig_Node_Expression_Constant $filterName, Twig_Node $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)
diff --git a/system/templateEngines/Twig/Twig2x/Node/Expression/Function.php b/system/templateEngines/Twig/Twig2x/Node/Expression/Function.php
index 6f4e872..37281d7 100644
--- a/system/templateEngines/Twig/Twig2x/Node/Expression/Function.php
+++ b/system/templateEngines/Twig/Twig2x/Node/Expression/Function.php
@@ -12,7 +12,7 @@ class Twig_Node_Expression_Function extends Twig_Node_Expression_Call
{
public function __construct($name, Twig_Node $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)
diff --git a/system/templateEngines/Twig/Twig2x/Node/Expression/GetAttr.php b/system/templateEngines/Twig/Twig2x/Node/Expression/GetAttr.php
index c4c6b63..3423af0 100644
--- a/system/templateEngines/Twig/Twig2x/Node/Expression/GetAttr.php
+++ b/system/templateEngines/Twig/Twig2x/Node/Expression/GetAttr.php
@@ -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, 'optimizable' => true), $lineno);
+ parent::__construct($nodes, ['type' => $type, 'is_defined_test' => false, 'ignore_strict_check' => false, 'optimizable' => true], $lineno);
}
public function compile(Twig_Compiler $compiler)
@@ -71,7 +71,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(', []');
}
}
diff --git a/system/templateEngines/Twig/Twig2x/Node/Expression/MethodCall.php b/system/templateEngines/Twig/Twig2x/Node/Expression/MethodCall.php
index 709016e..b8a8345 100644
--- a/system/templateEngines/Twig/Twig2x/Node/Expression/MethodCall.php
+++ b/system/templateEngines/Twig/Twig2x/Node/Expression/MethodCall.php
@@ -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);
diff --git a/system/templateEngines/Twig/Twig2x/Node/Expression/Name.php b/system/templateEngines/Twig/Twig2x/Node/Expression/Name.php
index 6459678..f265267 100644
--- a/system/templateEngines/Twig/Twig2x/Node/Expression/Name.php
+++ b/system/templateEngines/Twig/Twig2x/Node/Expression/Name.php
@@ -11,15 +11,15 @@
*/
class Twig_Node_Expression_Name extends Twig_Node_Expression
{
- private $specialVars = array(
+ private $specialVars = [
'_self' => '$this->getTemplateName()',
'_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)
diff --git a/system/templateEngines/Twig/Twig2x/Node/Expression/Parent.php b/system/templateEngines/Twig/Twig2x/Node/Expression/Parent.php
index 78692db..8623685 100644
--- a/system/templateEngines/Twig/Twig2x/Node/Expression/Parent.php
+++ b/system/templateEngines/Twig/Twig2x/Node/Expression/Parent.php
@@ -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)
diff --git a/system/templateEngines/Twig/Twig2x/Node/Expression/TempName.php b/system/templateEngines/Twig/Twig2x/Node/Expression/TempName.php
index 0a86e00..4be1cc2 100644
--- a/system/templateEngines/Twig/Twig2x/Node/Expression/TempName.php
+++ b/system/templateEngines/Twig/Twig2x/Node/Expression/TempName.php
@@ -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)
diff --git a/system/templateEngines/Twig/Twig2x/Node/Expression/Test.php b/system/templateEngines/Twig/Twig2x/Node/Expression/Test.php
index 7a1aed8..328823b 100644
--- a/system/templateEngines/Twig/Twig2x/Node/Expression/Test.php
+++ b/system/templateEngines/Twig/Twig2x/Node/Expression/Test.php
@@ -12,12 +12,12 @@ class Twig_Node_Expression_Test extends Twig_Node_Expression_Call
{
public function __construct(Twig_Node $node, $name, Twig_Node $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)
@@ -27,6 +27,7 @@ class Twig_Node_Expression_Test extends Twig_Node_Expression_Call
$this->setAttribute('name', $name);
$this->setAttribute('type', 'test');
+ $this->setAttribute('arguments', $test->getArguments());
$this->setAttribute('callable', $test->getCallable());
$this->setAttribute('is_variadic', $test->isVariadic());
diff --git a/system/templateEngines/Twig/Twig2x/Node/Expression/Unary.php b/system/templateEngines/Twig/Twig2x/Node/Expression/Unary.php
index 135d3cc..85ad1f6 100644
--- a/system/templateEngines/Twig/Twig2x/Node/Expression/Unary.php
+++ b/system/templateEngines/Twig/Twig2x/Node/Expression/Unary.php
@@ -13,7 +13,7 @@ abstract class Twig_Node_Expression_Unary extends Twig_Node_Expression
{
public function __construct(Twig_Node $node, $lineno)
{
- parent::__construct(array('node' => $node), array(), $lineno);
+ parent::__construct(['node' => $node], [], $lineno);
}
public function compile(Twig_Compiler $compiler)
diff --git a/system/templateEngines/Twig/Twig2x/Node/Flush.php b/system/templateEngines/Twig/Twig2x/Node/Flush.php
index fcc461a..5d3ffd5 100644
--- a/system/templateEngines/Twig/Twig2x/Node/Flush.php
+++ b/system/templateEngines/Twig/Twig2x/Node/Flush.php
@@ -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)
diff --git a/system/templateEngines/Twig/Twig2x/Node/For.php b/system/templateEngines/Twig/Twig2x/Node/For.php
index 4745c5a..0ed1bc5 100644
--- a/system/templateEngines/Twig/Twig2x/Node/For.php
+++ b/system/templateEngines/Twig/Twig2x/Node/For.php
@@ -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_Node $body, Twig_Node $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')) {
diff --git a/system/templateEngines/Twig/Twig2x/Node/ForLoop.php b/system/templateEngines/Twig/Twig2x/Node/ForLoop.php
index 06477cf..31f282d 100644
--- a/system/templateEngines/Twig/Twig2x/Node/ForLoop.php
+++ b/system/templateEngines/Twig/Twig2x/Node/ForLoop.php
@@ -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)
diff --git a/system/templateEngines/Twig/Twig2x/Node/If.php b/system/templateEngines/Twig/Twig2x/Node/If.php
index dcea344..2980a67 100644
--- a/system/templateEngines/Twig/Twig2x/Node/If.php
+++ b/system/templateEngines/Twig/Twig2x/Node/If.php
@@ -19,12 +19,12 @@ class Twig_Node_If extends Twig_Node
{
public function __construct(Twig_Node $tests, Twig_Node $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)
diff --git a/system/templateEngines/Twig/Twig2x/Node/Import.php b/system/templateEngines/Twig/Twig2x/Node/Import.php
index c77e320..44b2131 100644
--- a/system/templateEngines/Twig/Twig2x/Node/Import.php
+++ b/system/templateEngines/Twig/Twig2x/Node/Import.php
@@ -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)
diff --git a/system/templateEngines/Twig/Twig2x/Node/Include.php b/system/templateEngines/Twig/Twig2x/Node/Include.php
index 2a5114c..4b26381 100644
--- a/system/templateEngines/Twig/Twig2x/Node/Include.php
+++ b/system/templateEngines/Twig/Twig2x/Node/Include.php
@@ -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, ')
diff --git a/system/templateEngines/Twig/Twig2x/Node/Macro.php b/system/templateEngines/Twig/Twig2x/Node/Macro.php
index 9649be0..1f0d468 100644
--- a/system/templateEngines/Twig/Twig2x/Node/Macro.php
+++ b/system/templateEngines/Twig/Twig2x/Node/Macro.php
@@ -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)
@@ -61,7 +61,7 @@ class Twig_Node_Macro extends Twig_Node
;
$compiler
- ->write("\$context = \$this->env->mergeGlobals(array(\n")
+ ->write("\$context = \$this->env->mergeGlobals([\n")
->indent()
;
@@ -83,8 +83,8 @@ class Twig_Node_Macro extends Twig_Node
$compiler
->raw("\$__varargs__,\n")
->outdent()
- ->write("));\n\n")
- ->write("\$blocks = array();\n\n")
+ ->write("]);\n\n")
+ ->write("\$blocks = [];\n\n")
->write("ob_start();\n")
->write("try {\n")
->indent()
diff --git a/system/templateEngines/Twig/Twig2x/Node/Module.php b/system/templateEngines/Twig/Twig2x/Node/Module.php
index 4cb6c19..7b60746 100644
--- a/system/templateEngines/Twig/Twig2x/Node/Module.php
+++ b/system/templateEngines/Twig/Twig2x/Node/Module.php
@@ -33,7 +33,7 @@ class Twig_Node_Module extends Twig_Node
$this->source = $source;
- $nodes = array(
+ $nodes = [
'body' => $body,
'blocks' => $blocks,
'macros' => $macros,
@@ -43,16 +43,16 @@ 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, [
'index' => null,
'embedded_templates' => $embeddedTemplates,
- ), 1);
+ ], 1);
// populate the template name of all node children
$this->setTemplateName($this->source->getName());
@@ -259,11 +259,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")
;
}
@@ -274,20 +274,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")
@@ -297,7 +302,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'))
@@ -366,7 +371,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) {
diff --git a/system/templateEngines/Twig/Twig2x/Node/Print.php b/system/templateEngines/Twig/Twig2x/Node/Print.php
index 374db89..215d712 100644
--- a/system/templateEngines/Twig/Twig2x/Node/Print.php
+++ b/system/templateEngines/Twig/Twig2x/Node/Print.php
@@ -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)
diff --git a/system/templateEngines/Twig/Twig2x/Node/Sandbox.php b/system/templateEngines/Twig/Twig2x/Node/Sandbox.php
index 03a6b45..4976f74 100644
--- a/system/templateEngines/Twig/Twig2x/Node/Sandbox.php
+++ b/system/templateEngines/Twig/Twig2x/Node/Sandbox.php
@@ -18,7 +18,7 @@ class Twig_Node_Sandbox extends Twig_Node
{
public function __construct(Twig_Node $body, $lineno, $tag = null)
{
- parent::__construct(array('body' => $body), array(), $lineno, $tag);
+ parent::__construct(['body' => $body], [], $lineno, $tag);
}
public function compile(Twig_Compiler $compiler)
diff --git a/system/templateEngines/Twig/Twig2x/Node/Set.php b/system/templateEngines/Twig/Twig2x/Node/Set.php
index 02a8a2c..0db7309 100644
--- a/system/templateEngines/Twig/Twig2x/Node/Set.php
+++ b/system/templateEngines/Twig/Twig2x/Node/Set.php
@@ -18,7 +18,7 @@ class Twig_Node_Set extends Twig_Node implements Twig_NodeCaptureInterface
{
public function __construct($capture, Twig_Node $names, Twig_Node $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
diff --git a/system/templateEngines/Twig/Twig2x/Node/Spaceless.php b/system/templateEngines/Twig/Twig2x/Node/Spaceless.php
index bccdb26..06604f7 100644
--- a/system/templateEngines/Twig/Twig2x/Node/Spaceless.php
+++ b/system/templateEngines/Twig/Twig2x/Node/Spaceless.php
@@ -20,7 +20,7 @@ class Twig_Node_Spaceless extends Twig_Node implements Twig_NodeOutputInterface
{
public function __construct(Twig_Node $body, $lineno, $tag = 'spaceless')
{
- parent::__construct(array('body' => $body), array(), $lineno, $tag);
+ parent::__construct(['body' => $body], [], $lineno, $tag);
}
public function compile(Twig_Compiler $compiler)
diff --git a/system/templateEngines/Twig/Twig2x/Node/Text.php b/system/templateEngines/Twig/Twig2x/Node/Text.php
index f4577fe..ab24d71 100644
--- a/system/templateEngines/Twig/Twig2x/Node/Text.php
+++ b/system/templateEngines/Twig/Twig2x/Node/Text.php
@@ -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)
diff --git a/system/templateEngines/Twig/Twig2x/Node/With.php b/system/templateEngines/Twig/Twig2x/Node/With.php
index baf721d..c573c81 100644
--- a/system/templateEngines/Twig/Twig2x/Node/With.php
+++ b/system/templateEngines/Twig/Twig2x/Node/With.php
@@ -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)
@@ -46,7 +46,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");
}
diff --git a/system/templateEngines/Twig/Twig2x/NodeTraverser.php b/system/templateEngines/Twig/Twig2x/NodeTraverser.php
index dc6c4a0..bca741e 100644
--- a/system/templateEngines/Twig/Twig2x/NodeTraverser.php
+++ b/system/templateEngines/Twig/Twig2x/NodeTraverser.php
@@ -19,13 +19,13 @@
final class Twig_NodeTraverser
{
private $env;
- private $visitors = array();
+ private $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) {
@@ -36,7 +36,7 @@ final 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;
diff --git a/system/templateEngines/Twig/Twig2x/NodeVisitor/Escaper.php b/system/templateEngines/Twig/Twig2x/NodeVisitor/Escaper.php
index a6d28de..628a195 100644
--- a/system/templateEngines/Twig/Twig2x/NodeVisitor/Escaper.php
+++ b/system/templateEngines/Twig/Twig2x/NodeVisitor/Escaper.php
@@ -16,12 +16,12 @@
*/
final class Twig_NodeVisitor_Escaper extends Twig_BaseNodeVisitor
{
- private $statusStack = array();
- private $blocks = array();
+ private $statusStack = [];
+ private $blocks = [];
private $safeAnalysis;
private $traverser;
private $defaultStrategy = false;
- private $safeVars = array();
+ private $safeVars = [];
public function __construct()
{
@@ -34,8 +34,8 @@ final 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) {
@@ -51,8 +51,8 @@ final 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) {
@@ -113,7 +113,7 @@ final 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);
@@ -138,7 +138,7 @@ final 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);
}
diff --git a/system/templateEngines/Twig/Twig2x/NodeVisitor/Optimizer.php b/system/templateEngines/Twig/Twig2x/NodeVisitor/Optimizer.php
index b3433c0..1210571 100644
--- a/system/templateEngines/Twig/Twig2x/NodeVisitor/Optimizer.php
+++ b/system/templateEngines/Twig/Twig2x/NodeVisitor/Optimizer.php
@@ -28,8 +28,8 @@ final class Twig_NodeVisitor_Optimizer extends Twig_BaseNodeVisitor
// obsolete, does not do anything
const OPTIMIZE_VAR_ACCESS = 8;
- private $loops = array();
- private $loopsTargets = array();
+ private $loops = [];
+ private $loopsTargets = [];
private $optimizers;
/**
diff --git a/system/templateEngines/Twig/Twig2x/NodeVisitor/SafeAnalysis.php b/system/templateEngines/Twig/Twig2x/NodeVisitor/SafeAnalysis.php
index 48ae293..64f93b8 100644
--- a/system/templateEngines/Twig/Twig2x/NodeVisitor/SafeAnalysis.php
+++ b/system/templateEngines/Twig/Twig2x/NodeVisitor/SafeAnalysis.php
@@ -11,8 +11,8 @@
final class Twig_NodeVisitor_SafeAnalysis extends Twig_BaseNodeVisitor
{
- private $data = array();
- private $safeVars = array();
+ private $data = [];
+ private $safeVars = [];
public function setSafeVars($safeVars)
{
@@ -51,10 +51,10 @@ final 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)
@@ -66,13 +66,13 @@ final 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')));
@@ -88,7 +88,7 @@ final 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
@@ -98,23 +98,23 @@ final 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');
if (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;
@@ -123,7 +123,7 @@ final class Twig_NodeVisitor_SafeAnalysis extends Twig_BaseNodeVisitor
private function intersectSafe(array $a = null, array $b = null)
{
if (null === $a || null === $b) {
- return array();
+ return [];
}
if (in_array('all', $a)) {
diff --git a/system/templateEngines/Twig/Twig2x/NodeVisitor/Sandbox.php b/system/templateEngines/Twig/Twig2x/NodeVisitor/Sandbox.php
index 46ac722..4d41ff6 100644
--- a/system/templateEngines/Twig/Twig2x/NodeVisitor/Sandbox.php
+++ b/system/templateEngines/Twig/Twig2x/NodeVisitor/Sandbox.php
@@ -25,9 +25,9 @@ final 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) {
@@ -65,7 +65,7 @@ final 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;
diff --git a/system/templateEngines/Twig/Twig2x/Parser.php b/system/templateEngines/Twig/Twig2x/Parser.php
index 4f1fb7b..43c5ea0 100644
--- a/system/templateEngines/Twig/Twig2x/Parser.php
+++ b/system/templateEngines/Twig/Twig2x/Parser.php
@@ -17,7 +17,7 @@
*/
class Twig_Parser
{
- private $stack = array();
+ private $stack = [];
private $stream;
private $parent;
private $handlers;
@@ -29,7 +29,7 @@ class Twig_Parser
private $env;
private $importedSymbols;
private $traits;
- private $embeddedTemplates = array();
+ private $embeddedTemplates = [];
private $varNameSalt = 0;
public function __construct(Twig_Environment $env)
@@ -50,7 +50,7 @@ class Twig_Parser
// tag handlers
if (null === $this->handlers) {
- $this->handlers = array();
+ $this->handlers = [];
foreach ($this->env->getTokenParsers() as $handler) {
$handler->setParser($this);
@@ -69,12 +69,12 @@ class Twig_Parser
$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 {
@@ -95,7 +95,7 @@ class Twig_Parser
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);
@@ -112,7 +112,7 @@ class Twig_Parser
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 */ 0:
@@ -144,7 +144,7 @@ class Twig_Parser
return $rv[0];
}
- return new Twig_Node($rv, array(), $lineno);
+ return new Twig_Node($rv, [], $lineno);
}
if (!isset($this->handlers[$token->getValue()])) {
@@ -180,7 +180,7 @@ class Twig_Parser
return $rv[0];
}
- return new Twig_Node($rv, array(), $lineno);
+ return new Twig_Node($rv, [], $lineno);
}
public function getBlockStack()
@@ -215,7 +215,7 @@ class Twig_Parser
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)
@@ -252,7 +252,7 @@ class Twig_Parser
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)
@@ -271,7 +271,7 @@ class Twig_Parser
public function pushLocalScope()
{
- array_unshift($this->importedSymbols, array());
+ array_unshift($this->importedSymbols, []);
}
public function popLocalScope()
@@ -323,7 +323,11 @@ class Twig_Parser
(!$node instanceof Twig_Node_Text && !$node instanceof Twig_Node_BlockReference && ($node instanceof Twig_NodeOutputInterface && !$node instanceof Twig_Node_Spaceless))
) {
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());
@@ -346,6 +350,7 @@ class Twig_Parser
if ($nested && $node instanceof Twig_Node_BlockReference) {
//throw new Twig_Error_Syntax('A block definition cannot be nested under non-capturing nodes.', $node->getTemplateLine(), $this->stream->getSourceContext());
@trigger_error(sprintf('Nesting a block definition under a non-capturing node in "%s" at line %d is deprecated since version 2.5.0 and will become a syntax error in 3.0.', $this->stream->getSourceContext()->getName(), $node->getTemplateLine()), E_USER_DEPRECATED);
+
return;
}
@@ -356,7 +361,7 @@ class Twig_Parser
// here, $nested means "being at the root level of a child template"
// we need to discard the wrapping "Twig_Node" for the "body" node
- $nested = $nested || get_class($node) !== 'Twig_Node';
+ $nested = $nested || 'Twig_Node' !== get_class($node);
foreach ($node as $k => $n) {
if (null !== $n && null === $this->filterBodyNodes($n, $nested)) {
$node->removeNode($k);
diff --git a/system/templateEngines/Twig/Twig2x/Profiler/Dumper/Blackfire.php b/system/templateEngines/Twig/Twig2x/Profiler/Dumper/Blackfire.php
index cdcdea2..f6084b5 100644
--- a/system/templateEngines/Twig/Twig2x/Profiler/Dumper/Blackfire.php
+++ b/system/templateEngines/Twig/Twig2x/Profiler/Dumper/Blackfire.php
@@ -16,7 +16,7 @@ final 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);
@@ -52,17 +52,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(),
- );
+ ];
}
}
}
diff --git a/system/templateEngines/Twig/Twig2x/Profiler/Dumper/Html.php b/system/templateEngines/Twig/Twig2x/Profiler/Dumper/Html.php
index 7c2f791..25989e2 100644
--- a/system/templateEngines/Twig/Twig2x/Profiler/Dumper/Html.php
+++ b/system/templateEngines/Twig/Twig2x/Profiler/Dumper/Html.php
@@ -14,12 +14,12 @@
*/
final class Twig_Profiler_Dumper_Html extends Twig_Profiler_Dumper_Base
{
- private static $colors = array(
+ private static $colors = [
'block' => '#dfd',
'macro' => '#ddf',
'template' => '#ffd',
'big' => '#d44',
- );
+ ];
public function dump(Twig_Profiler_Profile $profile)
{
diff --git a/system/templateEngines/Twig/Twig2x/Profiler/Node/EnterProfile.php b/system/templateEngines/Twig/Twig2x/Profiler/Node/EnterProfile.php
index 5a21dde..8ce40fa 100644
--- a/system/templateEngines/Twig/Twig2x/Profiler/Node/EnterProfile.php
+++ b/system/templateEngines/Twig/Twig2x/Profiler/Node/EnterProfile.php
@@ -18,7 +18,7 @@ class Twig_Profiler_Node_EnterProfile extends Twig_Node
{
public function __construct($extensionName, $type, $name, $varName)
{
- parent::__construct(array(), array('extension_name' => $extensionName, 'name' => $name, 'type' => $type, 'var_name' => $varName));
+ parent::__construct([], ['extension_name' => $extensionName, 'name' => $name, 'type' => $type, 'var_name' => $varName]);
}
public function compile(Twig_Compiler $compiler)
diff --git a/system/templateEngines/Twig/Twig2x/Profiler/Node/LeaveProfile.php b/system/templateEngines/Twig/Twig2x/Profiler/Node/LeaveProfile.php
index d1d6a7c..bcb912d 100644
--- a/system/templateEngines/Twig/Twig2x/Profiler/Node/LeaveProfile.php
+++ b/system/templateEngines/Twig/Twig2x/Profiler/Node/LeaveProfile.php
@@ -18,7 +18,7 @@ class Twig_Profiler_Node_LeaveProfile extends Twig_Node
{
public function __construct($varName)
{
- parent::__construct(array(), array('var_name' => $varName));
+ parent::__construct([], ['var_name' => $varName]);
}
public function compile(Twig_Compiler $compiler)
diff --git a/system/templateEngines/Twig/Twig2x/Profiler/NodeVisitor/Profiler.php b/system/templateEngines/Twig/Twig2x/Profiler/NodeVisitor/Profiler.php
index 8b428e9..e17b368 100644
--- a/system/templateEngines/Twig/Twig2x/Profiler/NodeVisitor/Profiler.php
+++ b/system/templateEngines/Twig/Twig2x/Profiler/NodeVisitor/Profiler.php
@@ -30,22 +30,22 @@ final class Twig_Profiler_NodeVisitor_Profiler extends Twig_BaseNodeVisitor
{
if ($node instanceof Twig_Node_Module) {
$varName = $this->getVarName();
- $node->setNode('display_start', new Twig_Node(array(new Twig_Profiler_Node_EnterProfile($this->extensionName, Twig_Profiler_Profile::TEMPLATE, $node->getTemplateName(), $varName), $node->getNode('display_start'))));
- $node->setNode('display_end', new Twig_Node(array(new Twig_Profiler_Node_LeaveProfile($varName), $node->getNode('display_end'))));
+ $node->setNode('display_start', new Twig_Node([new Twig_Profiler_Node_EnterProfile($this->extensionName, Twig_Profiler_Profile::TEMPLATE, $node->getTemplateName(), $varName), $node->getNode('display_start')]));
+ $node->setNode('display_end', new Twig_Node([new Twig_Profiler_Node_LeaveProfile($varName), $node->getNode('display_end')]));
} elseif ($node instanceof Twig_Node_Block) {
$varName = $this->getVarName();
- $node->setNode('body', new Twig_Node_Body(array(
+ $node->setNode('body', new Twig_Node_Body([
new Twig_Profiler_Node_EnterProfile($this->extensionName, Twig_Profiler_Profile::BLOCK, $node->getAttribute('name'), $varName),
$node->getNode('body'),
new Twig_Profiler_Node_LeaveProfile($varName),
- )));
+ ]));
} elseif ($node instanceof Twig_Node_Macro) {
$varName = $this->getVarName();
- $node->setNode('body', new Twig_Node_Body(array(
+ $node->setNode('body', new Twig_Node_Body([
new Twig_Profiler_Node_EnterProfile($this->extensionName, Twig_Profiler_Profile::MACRO, $node->getAttribute('name'), $varName),
$node->getNode('body'),
new Twig_Profiler_Node_LeaveProfile($varName),
- )));
+ ]));
}
return $node;
diff --git a/system/templateEngines/Twig/Twig2x/Profiler/Profile.php b/system/templateEngines/Twig/Twig2x/Profiler/Profile.php
index 2177f60..1cc982c 100644
--- a/system/templateEngines/Twig/Twig2x/Profiler/Profile.php
+++ b/system/templateEngines/Twig/Twig2x/Profiler/Profile.php
@@ -24,9 +24,9 @@ class Twig_Profiler_Profile implements IteratorAggregate, Serializable
private $template;
private $name;
private $type;
- private $starts = array();
- private $ends = array();
- private $profiles = array();
+ private $starts = [];
+ private $ends = [];
+ private $profiles = [];
public function __construct($template = 'main', $type = self::ROOT, $name = 'main')
{
@@ -80,7 +80,7 @@ class Twig_Profiler_Profile implements IteratorAggregate, Serializable
return $this->profiles;
}
- public function addProfile(Twig_Profiler_Profile $profile)
+ public function addProfile(self $profile)
{
$this->profiles[] = $profile;
}
@@ -130,11 +130,11 @@ class Twig_Profiler_Profile implements IteratorAggregate, Serializable
*/
public function enter()
{
- $this->starts = array(
+ $this->starts = [
'wt' => microtime(true),
'mu' => memory_get_usage(),
'pmu' => memory_get_peak_usage(),
- );
+ ];
}
/**
@@ -142,16 +142,16 @@ class Twig_Profiler_Profile implements IteratorAggregate, Serializable
*/
public function leave()
{
- $this->ends = array(
+ $this->ends = [
'wt' => microtime(true),
'mu' => memory_get_usage(),
'pmu' => memory_get_peak_usage(),
- );
+ ];
}
public function reset()
{
- $this->starts = $this->ends = $this->profiles = array();
+ $this->starts = $this->ends = $this->profiles = [];
$this->enter();
}
@@ -162,7 +162,7 @@ class Twig_Profiler_Profile implements IteratorAggregate, Serializable
public function serialize()
{
- return serialize(array($this->template, $this->name, $this->type, $this->starts, $this->ends, $this->profiles));
+ return serialize([$this->template, $this->name, $this->type, $this->starts, $this->ends, $this->profiles]);
}
public function unserialize($data)
diff --git a/system/templateEngines/Twig/Twig2x/Sandbox/SecurityPolicy.php b/system/templateEngines/Twig/Twig2x/Sandbox/SecurityPolicy.php
index 175b2e4..9c0d352 100644
--- a/system/templateEngines/Twig/Twig2x/Sandbox/SecurityPolicy.php
+++ b/system/templateEngines/Twig/Twig2x/Sandbox/SecurityPolicy.php
@@ -22,7 +22,7 @@ final class Twig_Sandbox_SecurityPolicy implements Twig_Sandbox_SecurityPolicyIn
private $allowedProperties;
private $allowedFunctions;
- public function __construct(array $allowedTags = array(), array $allowedFilters = array(), array $allowedMethods = array(), array $allowedProperties = array(), array $allowedFunctions = array())
+ public function __construct(array $allowedTags = [], array $allowedFilters = [], array $allowedMethods = [], array $allowedProperties = [], array $allowedFunctions = [])
{
$this->allowedTags = $allowedTags;
$this->allowedFilters = $allowedFilters;
@@ -43,9 +43,9 @@ final class Twig_Sandbox_SecurityPolicy implements Twig_Sandbox_SecurityPolicyIn
public function setAllowedMethods(array $methods)
{
- $this->allowedMethods = array();
+ $this->allowedMethods = [];
foreach ($methods as $class => $m) {
- $this->allowedMethods[$class] = array_map('strtolower', is_array($m) ? $m : array($m));
+ $this->allowedMethods[$class] = array_map('strtolower', is_array($m) ? $m : [$m]);
}
}
@@ -107,7 +107,7 @@ final class Twig_Sandbox_SecurityPolicy implements Twig_Sandbox_SecurityPolicyIn
$allowed = false;
foreach ($this->allowedProperties as $class => $properties) {
if ($obj instanceof $class) {
- $allowed = in_array($property, is_array($properties) ? $properties : array($properties));
+ $allowed = in_array($property, is_array($properties) ? $properties : [$properties]);
break;
}
diff --git a/system/templateEngines/Twig/Twig2x/Template.php b/system/templateEngines/Twig/Twig2x/Template.php
index dc70d78..8a1d760 100644
--- a/system/templateEngines/Twig/Twig2x/Template.php
+++ b/system/templateEngines/Twig/Twig2x/Template.php
@@ -28,15 +28,15 @@ abstract class Twig_Template
const METHOD_CALL = 'method';
protected $parent;
- protected $parents = array();
+ protected $parents = [];
protected $env;
- protected $blocks = array();
- protected $traits = array();
+ protected $blocks = [];
+ protected $traits = [];
/**
* @internal
*/
- protected $extensions = array();
+ protected $extensions = [];
public function __construct(Twig_Environment $env)
{
@@ -86,7 +86,7 @@ abstract class Twig_Template
*
* @param array $context
*
- * @return Twig_Template|false The parent template or false if there is no parent
+ * @return Twig_Template|Twig_TemplateWrapper|false The parent template or false if there is no parent
*
* @internal
*/
@@ -103,8 +103,8 @@ abstract class Twig_Template
return false;
}
- if ($parent instanceof self) {
- return $this->parents[$parent->getTemplateName()] = $parent;
+ if ($parent instanceof self || $parent instanceof Twig_TemplateWrapper) {
+ return $this->parents[$parent->getSourceContext()->getName()] = $parent;
}
if (!isset($this->parents[$parent])) {
@@ -142,7 +142,7 @@ abstract class Twig_Template
*
* @internal
*/
- public function displayParentBlock($name, array $context, array $blocks = array())
+ public function displayParentBlock($name, array $context, array $blocks = [])
{
if (isset($this->traits[$name])) {
$this->traits[$name][0]->displayBlock($name, $context, $blocks, false);
@@ -166,7 +166,7 @@ abstract class Twig_Template
*
* @internal
*/
- public function displayBlock($name, array $context, array $blocks = array(), $useBlocks = true)
+ public function displayBlock($name, array $context, array $blocks = [], $useBlocks = true, self $templateContext = null)
{
if ($useBlocks && isset($blocks[$name])) {
$template = $blocks[$name][0];
@@ -204,11 +204,11 @@ abstract class Twig_Template
throw new Twig_Error_Runtime(sprintf('An exception has been thrown during the rendering of a template ("%s").', $e->getMessage()), -1, $template->getSourceContext(), $e);
}
} elseif (false !== $parent = $this->getParent($context)) {
- $parent->displayBlock($name, $context, array_merge($this->blocks, $blocks), false);
+ $parent->displayBlock($name, $context, array_merge($this->blocks, $blocks), false, $templateContext ?? $this);
} elseif (isset($blocks[$name])) {
- throw new Twig_Error_Runtime(sprintf('Block "%s" should not call parent() in "%s" as the block does not exist in the parent template "%s".', $name, $blocks[$name][0]->getTemplateName(), $this->getTemplateName()), -1, $blocks[$name][0]->getTemplateName());
+ throw new Twig_Error_Runtime(sprintf('Block "%s" should not call parent() in "%s" as the block does not exist in the parent template "%s".', $name, $blocks[$name][0]->getTemplateName(), $this->getTemplateName()), -1, $blocks[$name][0]->getSourceContext());
} else {
- throw new Twig_Error_Runtime(sprintf('Block "%s" on template "%s" does not exist.', $name, $this->getTemplateName()), -1, $this->getTemplateName());
+ throw new Twig_Error_Runtime(sprintf('Block "%s" on template "%s" does not exist.', $name, $this->getTemplateName()), -1, ($templateContext ?? $this)->getSourceContext());
}
}
@@ -226,7 +226,7 @@ abstract class Twig_Template
*
* @internal
*/
- public function renderParentBlock($name, array $context, array $blocks = array())
+ public function renderParentBlock($name, array $context, array $blocks = [])
{
ob_start();
$this->displayParentBlock($name, $context, $blocks);
@@ -249,7 +249,7 @@ abstract class Twig_Template
*
* @internal
*/
- public function renderBlock($name, array $context, array $blocks = array(), $useBlocks = true)
+ public function renderBlock($name, array $context, array $blocks = [], $useBlocks = true)
{
ob_start();
$this->displayBlock($name, $context, $blocks, $useBlocks);
@@ -271,7 +271,7 @@ abstract class Twig_Template
*
* @internal
*/
- public function hasBlock($name, array $context, array $blocks = array())
+ public function hasBlock($name, array $context, array $blocks = [])
{
if (isset($blocks[$name])) {
return $blocks[$name][0] instanceof self;
@@ -301,7 +301,7 @@ abstract class Twig_Template
*
* @internal
*/
- public function getBlockNames(array $context, array $blocks = array())
+ public function getBlockNames(array $context, array $blocks = [])
{
$names = array_merge(array_keys($blocks), array_keys($this->blocks));
@@ -319,11 +319,7 @@ abstract class Twig_Template
return $this->env->resolveTemplate($template);
}
- if ($template instanceof self) {
- return $template;
- }
-
- if ($template instanceof Twig_TemplateWrapper) {
+ if ($template instanceof self || $template instanceof Twig_TemplateWrapper) {
return $template;
}
@@ -362,7 +358,7 @@ abstract class Twig_Template
return $this->blocks;
}
- public function display(array $context, array $blocks = array())
+ public function display(array $context, array $blocks = [])
{
$this->displayWithErrorHandling($this->env->mergeGlobals($context), array_merge($this->blocks, $blocks));
}
@@ -384,7 +380,7 @@ abstract class Twig_Template
return ob_get_clean();
}
- protected function displayWithErrorHandling(array $context, array $blocks = array())
+ protected function displayWithErrorHandling(array $context, array $blocks = [])
{
try {
$this->doDisplay($context, $blocks);
@@ -412,7 +408,7 @@ abstract class Twig_Template
* @param array $context An array of parameters to pass to the template
* @param array $blocks An array of blocks to pass to the template
*/
- abstract protected function doDisplay(array $context, array $blocks = array());
+ abstract protected function doDisplay(array $context, array $blocks = []);
}
class_alias('Twig_Template', 'Twig\Template', false);
diff --git a/system/templateEngines/Twig/Twig2x/TemplateWrapper.php b/system/templateEngines/Twig/Twig2x/TemplateWrapper.php
index 4748184..b0ff5a7 100644
--- a/system/templateEngines/Twig/Twig2x/TemplateWrapper.php
+++ b/system/templateEngines/Twig/Twig2x/TemplateWrapper.php
@@ -38,9 +38,11 @@ final class Twig_TemplateWrapper
*
* @return string The rendered template
*/
- public function render($context = array())
+ public function render($context = [])
{
- return $this->template->render($context);
+ // using func_get_args() allows to not expose the blocks argument
+ // as it should only be used by internal code
+ return $this->template->render($context, func_get_args()[1] ?? []);
}
/**
@@ -48,9 +50,11 @@ final class Twig_TemplateWrapper
*
* @param array $context An array of parameters to pass to the template
*/
- public function display($context = array())
+ public function display($context = [])
{
- $this->template->display($context);
+ // using func_get_args() allows to not expose the blocks argument
+ // as it should only be used by internal code
+ $this->template->display($context, func_get_args()[1] ?? []);
}
/**
@@ -61,7 +65,7 @@ final class Twig_TemplateWrapper
*
* @return bool
*/
- public function hasBlock($name, $context = array())
+ public function hasBlock($name, $context = [])
{
return $this->template->hasBlock($name, $context);
}
@@ -73,7 +77,7 @@ final class Twig_TemplateWrapper
*
* @return string[] An array of defined template block names
*/
- public function getBlockNames($context = array())
+ public function getBlockNames($context = [])
{
return $this->template->getBlockNames($context);
}
@@ -86,7 +90,7 @@ final class Twig_TemplateWrapper
*
* @return string The rendered block
*/
- public function renderBlock($name, $context = array())
+ public function renderBlock($name, $context = [])
{
$context = $this->env->mergeGlobals($context);
$level = ob_get_level();
@@ -110,7 +114,7 @@ final class Twig_TemplateWrapper
* @param string $name The block name to render
* @param array $context An array of parameters to pass to the template
*/
- public function displayBlock($name, $context = array())
+ public function displayBlock($name, $context = [])
{
$this->template->displayBlock($name, $this->env->mergeGlobals($context));
}
diff --git a/system/templateEngines/Twig/Twig2x/Test.php b/system/templateEngines/Twig/Twig2x/Test.php
index fc6c59b..b604e78 100644
--- a/system/templateEngines/Twig/Twig2x/Test.php
+++ b/system/templateEngines/Twig/Twig2x/Test.php
@@ -23,6 +23,7 @@ class Twig_Test
private $name;
private $callable;
private $options;
+ private $arguments = [];
/**
* Creates a template test.
@@ -31,7 +32,7 @@ class Twig_Test
* @param callable|null $callable A callable implementing the test. If null, you need to overwrite the "node_class" option to customize compilation.
* @param array $options Options array
*/
- public function __construct(string $name, $callable = null, array $options = array())
+ public function __construct(string $name, $callable = null, array $options = [])
{
if (__CLASS__ !== get_class($this)) {
@trigger_error('Overriding '.__CLASS__.' is deprecated since version 2.4.0 and the class will be final in 3.0.', E_USER_DEPRECATED);
@@ -39,12 +40,12 @@ class Twig_Test
$this->name = $name;
$this->callable = $callable;
- $this->options = array_merge(array(
+ $this->options = array_merge([
'is_variadic' => false,
'node_class' => 'Twig_Node_Expression_Test',
'deprecated' => false,
'alternative' => null,
- ), $options);
+ ], $options);
}
public function getName()
@@ -67,6 +68,16 @@ class Twig_Test
return $this->options['node_class'];
}
+ public function setArguments($arguments)
+ {
+ $this->arguments = $arguments;
+ }
+
+ public function getArguments()
+ {
+ return $this->arguments;
+ }
+
public function isVariadic()
{
return $this->options['is_variadic'];
diff --git a/system/templateEngines/Twig/Twig2x/Test/IntegrationTestCase.php b/system/templateEngines/Twig/Twig2x/Test/IntegrationTestCase.php
index 2f03230..566ef3f 100644
--- a/system/templateEngines/Twig/Twig2x/Test/IntegrationTestCase.php
+++ b/system/templateEngines/Twig/Twig2x/Test/IntegrationTestCase.php
@@ -29,7 +29,7 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
*/
protected function getRuntimeLoaders()
{
- return array();
+ return [];
}
/**
@@ -37,7 +37,7 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
*/
protected function getExtensions()
{
- return array();
+ return [];
}
/**
@@ -45,7 +45,7 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
*/
protected function getTwigFilters()
{
- return array();
+ return [];
}
/**
@@ -53,7 +53,7 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
*/
protected function getTwigFunctions()
{
- return array();
+ return [];
}
/**
@@ -61,7 +61,7 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
*/
protected function getTwigTests()
{
- return array();
+ return [];
}
/**
@@ -84,7 +84,7 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
public function getTests($name, $legacyTests = false)
{
$fixturesDir = realpath($this->getFixturesDir());
- $tests = array();
+ $tests = [];
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($fixturesDir), RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
if (!preg_match('/\.test$/', $file)) {
@@ -103,7 +103,7 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
$deprecation = $match[3];
$templates = self::parseTemplates($match[4]);
$exception = $match[6];
- $outputs = array(array(null, $match[5], null, ''));
+ $outputs = [[null, $match[5], null, '']];
} elseif (preg_match('/--TEST--\s*(.*?)\s*(?:--CONDITION--\s*(.*))?\s*(?:--DEPRECATION--\s*(.*?))?\s*((?:--TEMPLATE(?:\(.*?\))?--(?:.*?))+)--DATA--.*?--EXPECT--.*/s', $test, $match)) {
$message = $match[1];
$condition = $match[2];
@@ -115,12 +115,12 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
throw new InvalidArgumentException(sprintf('Test "%s" is not valid.', str_replace($fixturesDir.'/', '', $file)));
}
- $tests[] = array(str_replace($fixturesDir.'/', '', $file), $message, $condition, $templates, $exception, $outputs, $deprecation);
+ $tests[] = [str_replace($fixturesDir.'/', '', $file), $message, $condition, $templates, $exception, $outputs, $deprecation];
}
if ($legacyTests && empty($tests)) {
// add a dummy test to avoid a PHPUnit message
- return array(array('not', '-', '', array(), '', array()));
+ return [['not', '-', '', [], '', []]];
}
return $tests;
@@ -147,10 +147,10 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
$loader = new Twig_Loader_Array($templates);
foreach ($outputs as $i => $match) {
- $config = array_merge(array(
+ $config = array_merge([
'cache' => false,
'strict_variables' => true,
- ), $match[2] ? eval($match[2].';') : array());
+ ], $match[2] ? eval($match[2].';') : []);
$twig = new Twig_Environment($loader, $config);
$twig->addGlobal('global', 'global');
foreach ($this->getRuntimeLoaders() as $runtimeLoader) {
@@ -178,13 +178,15 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
$p->setAccessible(true);
$p->setValue($twig, '__TwigTemplate_'.hash('sha256', uniqid(mt_rand(), true), false).'_');
- $deprecations = array();
+ $deprecations = [];
try {
- $prevHandler = set_error_handler(function ($type, $msg, $file, $line, $context = array()) use (&$deprecations, &$prevHandler) {
+ $prevHandler = set_error_handler(function ($type, $msg, $file, $line, $context = []) use (&$deprecations, &$prevHandler) {
if (E_USER_DEPRECATED === $type) {
$deprecations[] = $msg;
+
return true;
}
+
return $prevHandler ? $prevHandler($type, $msg, $file, $line, $context) : false;
});
@@ -242,7 +244,7 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
protected static function parseTemplates($test)
{
- $templates = array();
+ $templates = [];
preg_match_all('/--TEMPLATE(?:\((.*?)\))?--(.*?)(?=\-\-TEMPLATE|$)/s', $test, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
$templates[($match[1] ? $match[1] : 'index.twig')] = $match[2];
diff --git a/system/templateEngines/Twig/Twig2x/Test/NodeTestCase.php b/system/templateEngines/Twig/Twig2x/Test/NodeTestCase.php
index 158682c..f4ba058 100644
--- a/system/templateEngines/Twig/Twig2x/Test/NodeTestCase.php
+++ b/system/templateEngines/Twig/Twig2x/Test/NodeTestCase.php
@@ -42,7 +42,7 @@ abstract class Twig_Test_NodeTestCase extends TestCase
protected function getEnvironment()
{
- return new Twig_Environment(new Twig_Loader_Array(array()));
+ return new Twig_Environment(new Twig_Loader_Array([]));
}
protected function getVariableGetter($name, $line = false)
diff --git a/system/templateEngines/Twig/Twig2x/TokenParser/AutoEscape.php b/system/templateEngines/Twig/Twig2x/TokenParser/AutoEscape.php
index 73dd09a..789f9dc 100644
--- a/system/templateEngines/Twig/Twig2x/TokenParser/AutoEscape.php
+++ b/system/templateEngines/Twig/Twig2x/TokenParser/AutoEscape.php
@@ -30,7 +30,7 @@ final class Twig_TokenParser_AutoEscape extends Twig_TokenParser
}
$stream->expect(/* Twig_Token::BLOCK_END_TYPE */ 3);
- $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
+ $body = $this->parser->subparse([$this, 'decideBlockEnd'], true);
$stream->expect(/* Twig_Token::BLOCK_END_TYPE */ 3);
return new Twig_Node_AutoEscape($value, $body, $lineno, $this->getTag());
diff --git a/system/templateEngines/Twig/Twig2x/TokenParser/Block.php b/system/templateEngines/Twig/Twig2x/TokenParser/Block.php
index 7da0a43..1659361 100644
--- a/system/templateEngines/Twig/Twig2x/TokenParser/Block.php
+++ b/system/templateEngines/Twig/Twig2x/TokenParser/Block.php
@@ -30,12 +30,12 @@ final class Twig_TokenParser_Block extends Twig_TokenParser
if ($this->parser->hasBlock($name)) {
throw new Twig_Error_Syntax(sprintf("The block '%s' has already been defined line %d.", $name, $this->parser->getBlock($name)->getTemplateLine()), $stream->getCurrent()->getLine(), $stream->getSourceContext());
}
- $this->parser->setBlock($name, $block = new Twig_Node_Block($name, new Twig_Node(array()), $lineno));
+ $this->parser->setBlock($name, $block = new Twig_Node_Block($name, new Twig_Node([]), $lineno));
$this->parser->pushLocalScope();
$this->parser->pushBlockStack($name);
if ($stream->nextIf(/* Twig_Token::BLOCK_END_TYPE */ 3)) {
- $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
+ $body = $this->parser->subparse([$this, 'decideBlockEnd'], true);
if ($token = $stream->nextIf(/* Twig_Token::NAME_TYPE */ 5)) {
$value = $token->getValue();
@@ -44,9 +44,9 @@ final class Twig_TokenParser_Block extends Twig_TokenParser
}
}
} else {
- $body = new Twig_Node(array(
+ $body = new Twig_Node([
new Twig_Node_Print($this->parser->getExpressionParser()->parseExpression(), $lineno),
- ));
+ ]);
}
$stream->expect(/* Twig_Token::BLOCK_END_TYPE */ 3);
diff --git a/system/templateEngines/Twig/Twig2x/TokenParser/Deprecated.php b/system/templateEngines/Twig/Twig2x/TokenParser/Deprecated.php
new file mode 100644
index 0000000..be5d549
--- /dev/null
+++ b/system/templateEngines/Twig/Twig2x/TokenParser/Deprecated.php
@@ -0,0 +1,42 @@
+
+ * {% deprecated 'The "base.twig" template is deprecated, use "layout.twig" instead.' %}
+ *
+ * {% extends 'layout.html.twig' %}
+ *
+ *
+ * @author Yonel Ceruto
+ *
+ * @final
+ */
+class Twig_TokenParser_Deprecated extends Twig_TokenParser
+{
+ public function parse(Twig_Token $token)
+ {
+ $expr = $this->parser->getExpressionParser()->parseExpression();
+
+ $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
+
+ return new Twig_Node_Deprecated($expr, $token->getLine(), $this->getTag());
+ }
+
+ public function getTag()
+ {
+ return 'deprecated';
+ }
+}
+
+class_alias('Twig_TokenParser_Deprecated', 'Twig\TokenParser\DeprecatedTokenParser', false);
diff --git a/system/templateEngines/Twig/Twig2x/TokenParser/Embed.php b/system/templateEngines/Twig/Twig2x/TokenParser/Embed.php
index e0f10bb..273d823 100644
--- a/system/templateEngines/Twig/Twig2x/TokenParser/Embed.php
+++ b/system/templateEngines/Twig/Twig2x/TokenParser/Embed.php
@@ -30,14 +30,14 @@ final class Twig_TokenParser_Embed extends Twig_TokenParser_Include
}
// inject a fake parent to make the parent() function work
- $stream->injectTokens(array(
+ $stream->injectTokens([
new Twig_Token(/* Twig_Token::BLOCK_START_TYPE */ 1, '', $token->getLine()),
new Twig_Token(/* Twig_Token::NAME_TYPE */ 5, 'extends', $token->getLine()),
$parentToken,
new Twig_Token(/* Twig_Token::BLOCK_END_TYPE */ 3, '', $token->getLine()),
- ));
+ ]);
- $module = $this->parser->parse($stream, array($this, 'decideBlockEnd'), true);
+ $module = $this->parser->parse($stream, [$this, 'decideBlockEnd'], true);
// override the parent with the correct one
if ($fakeParentToken === $parentToken) {
diff --git a/system/templateEngines/Twig/Twig2x/TokenParser/Filter.php b/system/templateEngines/Twig/Twig2x/TokenParser/Filter.php
index acada49..2dc45e3 100644
--- a/system/templateEngines/Twig/Twig2x/TokenParser/Filter.php
+++ b/system/templateEngines/Twig/Twig2x/TokenParser/Filter.php
@@ -28,7 +28,7 @@ final class Twig_TokenParser_Filter extends Twig_TokenParser
$filter = $this->parser->getExpressionParser()->parseFilterExpressionRaw($ref, $this->getTag());
$this->parser->getStream()->expect(/* Twig_Token::BLOCK_END_TYPE */ 3);
- $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
+ $body = $this->parser->subparse([$this, 'decideBlockEnd'], true);
$this->parser->getStream()->expect(/* Twig_Token::BLOCK_END_TYPE */ 3);
$block = new Twig_Node_Block($name, $body, $token->getLine());
diff --git a/system/templateEngines/Twig/Twig2x/TokenParser/For.php b/system/templateEngines/Twig/Twig2x/TokenParser/For.php
index 68d03fd..fb86900 100644
--- a/system/templateEngines/Twig/Twig2x/TokenParser/For.php
+++ b/system/templateEngines/Twig/Twig2x/TokenParser/For.php
@@ -37,10 +37,10 @@ final class Twig_TokenParser_For extends Twig_TokenParser
}
$stream->expect(/* Twig_Token::BLOCK_END_TYPE */ 3);
- $body = $this->parser->subparse(array($this, 'decideForFork'));
+ $body = $this->parser->subparse([$this, 'decideForFork']);
if ('else' == $stream->next()->getValue()) {
$stream->expect(/* Twig_Token::BLOCK_END_TYPE */ 3);
- $else = $this->parser->subparse(array($this, 'decideForEnd'), true);
+ $else = $this->parser->subparse([$this, 'decideForEnd'], true);
} else {
$else = null;
}
@@ -67,7 +67,7 @@ final class Twig_TokenParser_For extends Twig_TokenParser
public function decideForFork(Twig_Token $token)
{
- return $token->test(array('else', 'endfor'));
+ return $token->test(['else', 'endfor']);
}
public function decideForEnd(Twig_Token $token)
@@ -97,7 +97,7 @@ final class Twig_TokenParser_For extends Twig_TokenParser
{
if ($node instanceof Twig_Node_Expression_GetAttr && $node->getNode('node') instanceof Twig_Node_Expression_Name && 'loop' == $node->getNode('node')->getAttribute('name')) {
$attribute = $node->getNode('attribute');
- if ($attribute instanceof Twig_Node_Expression_Constant && in_array($attribute->getAttribute('value'), array('length', 'revindex0', 'revindex', 'last'))) {
+ if ($attribute instanceof Twig_Node_Expression_Constant && in_array($attribute->getAttribute('value'), ['length', 'revindex0', 'revindex', 'last'])) {
throw new Twig_Error_Syntax(sprintf('The "loop.%s" variable is not defined when looping with a condition.', $attribute->getAttribute('value')), $node->getTemplateLine(), $stream->getSourceContext());
}
}
diff --git a/system/templateEngines/Twig/Twig2x/TokenParser/From.php b/system/templateEngines/Twig/Twig2x/TokenParser/From.php
index 4a2935e..b57b20a 100644
--- a/system/templateEngines/Twig/Twig2x/TokenParser/From.php
+++ b/system/templateEngines/Twig/Twig2x/TokenParser/From.php
@@ -24,7 +24,7 @@ final class Twig_TokenParser_From extends Twig_TokenParser
$stream = $this->parser->getStream();
$stream->expect('import');
- $targets = array();
+ $targets = [];
do {
$name = $stream->expect(/* Twig_Token::NAME_TYPE */ 5)->getValue();
diff --git a/system/templateEngines/Twig/Twig2x/TokenParser/If.php b/system/templateEngines/Twig/Twig2x/TokenParser/If.php
index 77f9499..8b20690 100644
--- a/system/templateEngines/Twig/Twig2x/TokenParser/If.php
+++ b/system/templateEngines/Twig/Twig2x/TokenParser/If.php
@@ -31,8 +31,8 @@ final class Twig_TokenParser_If extends Twig_TokenParser
$expr = $this->parser->getExpressionParser()->parseExpression();
$stream = $this->parser->getStream();
$stream->expect(/* Twig_Token::BLOCK_END_TYPE */ 3);
- $body = $this->parser->subparse(array($this, 'decideIfFork'));
- $tests = array($expr, $body);
+ $body = $this->parser->subparse([$this, 'decideIfFork']);
+ $tests = [$expr, $body];
$else = null;
$end = false;
@@ -40,13 +40,13 @@ final class Twig_TokenParser_If extends Twig_TokenParser
switch ($stream->next()->getValue()) {
case 'else':
$stream->expect(/* Twig_Token::BLOCK_END_TYPE */ 3);
- $else = $this->parser->subparse(array($this, 'decideIfEnd'));
+ $else = $this->parser->subparse([$this, 'decideIfEnd']);
break;
case 'elseif':
$expr = $this->parser->getExpressionParser()->parseExpression();
$stream->expect(/* Twig_Token::BLOCK_END_TYPE */ 3);
- $body = $this->parser->subparse(array($this, 'decideIfFork'));
+ $body = $this->parser->subparse([$this, 'decideIfFork']);
$tests[] = $expr;
$tests[] = $body;
break;
@@ -67,12 +67,12 @@ final class Twig_TokenParser_If extends Twig_TokenParser
public function decideIfFork(Twig_Token $token)
{
- return $token->test(array('elseif', 'else', 'endif'));
+ return $token->test(['elseif', 'else', 'endif']);
}
public function decideIfEnd(Twig_Token $token)
{
- return $token->test(array('endif'));
+ return $token->test(['endif']);
}
public function getTag()
diff --git a/system/templateEngines/Twig/Twig2x/TokenParser/Include.php b/system/templateEngines/Twig/Twig2x/TokenParser/Include.php
index a887bea..53d8c12 100644
--- a/system/templateEngines/Twig/Twig2x/TokenParser/Include.php
+++ b/system/templateEngines/Twig/Twig2x/TokenParser/Include.php
@@ -53,7 +53,7 @@ class Twig_TokenParser_Include extends Twig_TokenParser
$stream->expect(/* Twig_Token::BLOCK_END_TYPE */ 3);
- return array($variables, $only, $ignoreMissing);
+ return [$variables, $only, $ignoreMissing];
}
public function getTag()
diff --git a/system/templateEngines/Twig/Twig2x/TokenParser/Macro.php b/system/templateEngines/Twig/Twig2x/TokenParser/Macro.php
index 1182b68..315ed51 100644
--- a/system/templateEngines/Twig/Twig2x/TokenParser/Macro.php
+++ b/system/templateEngines/Twig/Twig2x/TokenParser/Macro.php
@@ -30,7 +30,7 @@ final class Twig_TokenParser_Macro extends Twig_TokenParser
$stream->expect(/* Twig_Token::BLOCK_END_TYPE */ 3);
$this->parser->pushLocalScope();
- $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
+ $body = $this->parser->subparse([$this, 'decideBlockEnd'], true);
if ($token = $stream->nextIf(/* Twig_Token::NAME_TYPE */ 5)) {
$value = $token->getValue();
@@ -41,7 +41,7 @@ final class Twig_TokenParser_Macro extends Twig_TokenParser
$this->parser->popLocalScope();
$stream->expect(/* Twig_Token::BLOCK_END_TYPE */ 3);
- $this->parser->setMacro($name, new Twig_Node_Macro($name, new Twig_Node_Body(array($body)), $arguments, $lineno, $this->getTag()));
+ $this->parser->setMacro($name, new Twig_Node_Macro($name, new Twig_Node_Body([$body]), $arguments, $lineno, $this->getTag()));
}
public function decideBlockEnd(Twig_Token $token)
diff --git a/system/templateEngines/Twig/Twig2x/TokenParser/Sandbox.php b/system/templateEngines/Twig/Twig2x/TokenParser/Sandbox.php
index f7d963e..495b72a 100644
--- a/system/templateEngines/Twig/Twig2x/TokenParser/Sandbox.php
+++ b/system/templateEngines/Twig/Twig2x/TokenParser/Sandbox.php
@@ -26,7 +26,7 @@ final class Twig_TokenParser_Sandbox extends Twig_TokenParser
{
$stream = $this->parser->getStream();
$stream->expect(/* Twig_Token::BLOCK_END_TYPE */ 3);
- $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
+ $body = $this->parser->subparse([$this, 'decideBlockEnd'], true);
$stream->expect(/* Twig_Token::BLOCK_END_TYPE */ 3);
// in a sandbox tag, only include tags are allowed
diff --git a/system/templateEngines/Twig/Twig2x/TokenParser/Set.php b/system/templateEngines/Twig/Twig2x/TokenParser/Set.php
index 0d3012c..cdc61d7 100644
--- a/system/templateEngines/Twig/Twig2x/TokenParser/Set.php
+++ b/system/templateEngines/Twig/Twig2x/TokenParser/Set.php
@@ -52,7 +52,7 @@ final class Twig_TokenParser_Set extends Twig_TokenParser
$stream->expect(/* Twig_Token::BLOCK_END_TYPE */ 3);
- $values = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
+ $values = $this->parser->subparse([$this, 'decideBlockEnd'], true);
$stream->expect(/* Twig_Token::BLOCK_END_TYPE */ 3);
}
diff --git a/system/templateEngines/Twig/Twig2x/TokenParser/Spaceless.php b/system/templateEngines/Twig/Twig2x/TokenParser/Spaceless.php
index 2c081bc..fda4c4f 100644
--- a/system/templateEngines/Twig/Twig2x/TokenParser/Spaceless.php
+++ b/system/templateEngines/Twig/Twig2x/TokenParser/Spaceless.php
@@ -29,7 +29,7 @@ final class Twig_TokenParser_Spaceless extends Twig_TokenParser
$lineno = $token->getLine();
$this->parser->getStream()->expect(/* Twig_Token::BLOCK_END_TYPE */ 3);
- $body = $this->parser->subparse(array($this, 'decideSpacelessEnd'), true);
+ $body = $this->parser->subparse([$this, 'decideSpacelessEnd'], true);
$this->parser->getStream()->expect(/* Twig_Token::BLOCK_END_TYPE */ 3);
return new Twig_Node_Spaceless($body, $lineno, $this->getTag());
diff --git a/system/templateEngines/Twig/Twig2x/TokenParser/Use.php b/system/templateEngines/Twig/Twig2x/TokenParser/Use.php
index efab152..9de07ba 100644
--- a/system/templateEngines/Twig/Twig2x/TokenParser/Use.php
+++ b/system/templateEngines/Twig/Twig2x/TokenParser/Use.php
@@ -34,7 +34,7 @@ final class Twig_TokenParser_Use extends Twig_TokenParser
throw new Twig_Error_Syntax('The template references in a "use" statement must be a string.', $stream->getCurrent()->getLine(), $stream->getSourceContext());
}
- $targets = array();
+ $targets = [];
if ($stream->nextIf('with')) {
do {
$name = $stream->expect(/* Twig_Token::NAME_TYPE */ 5)->getValue();
@@ -54,7 +54,7 @@ final class Twig_TokenParser_Use extends Twig_TokenParser
$stream->expect(/* Twig_Token::BLOCK_END_TYPE */ 3);
- $this->parser->addTrait(new Twig_Node(array('template' => $template, 'targets' => new Twig_Node($targets))));
+ $this->parser->addTrait(new Twig_Node(['template' => $template, 'targets' => new Twig_Node($targets)]));
return new Twig_Node();
}
diff --git a/system/templateEngines/Twig/Twig2x/TokenParser/With.php b/system/templateEngines/Twig/Twig2x/TokenParser/With.php
index 6f002cf..2b0f95f 100644
--- a/system/templateEngines/Twig/Twig2x/TokenParser/With.php
+++ b/system/templateEngines/Twig/Twig2x/TokenParser/With.php
@@ -29,7 +29,7 @@ final class Twig_TokenParser_With extends Twig_TokenParser
$stream->expect(/* Twig_Token::BLOCK_END_TYPE */ 3);
- $body = $this->parser->subparse(array($this, 'decideWithEnd'), true);
+ $body = $this->parser->subparse([$this, 'decideWithEnd'], true);
$stream->expect(/* Twig_Token::BLOCK_END_TYPE */ 3);
diff --git a/system/templateEngines/Twig/Twig2x/Util/DeprecationCollector.php b/system/templateEngines/Twig/Twig2x/Util/DeprecationCollector.php
index c3971ef..6959a41 100644
--- a/system/templateEngines/Twig/Twig2x/Util/DeprecationCollector.php
+++ b/system/templateEngines/Twig/Twig2x/Util/DeprecationCollector.php
@@ -49,7 +49,7 @@ final class Twig_Util_DeprecationCollector
*/
public function collect(Traversable $iterator)
{
- $deprecations = array();
+ $deprecations = [];
set_error_handler(function ($type, $msg) use (&$deprecations) {
if (E_USER_DEPRECATED === $type) {
$deprecations[] = $msg;
diff --git a/system/templateEngines/smarty/Autoloader.php b/system/templateEngines/smarty/Autoloader.php
index 3a0da8f..e4dc450 100644
--- a/system/templateEngines/smarty/Autoloader.php
+++ b/system/templateEngines/smarty/Autoloader.php
@@ -2,14 +2,14 @@
/**
* Smarty Autoloader
*
- * @package Smarty
+ * @package Smarty
*/
/**
* Smarty Autoloader
*
- * @package Smarty
- * @author Uwe Tews
+ * @package Smarty
+ * @author Uwe Tews
* Usage:
* require_once '...path/Autoloader.php';
* Smarty_Autoloader::register();
@@ -20,7 +20,7 @@
*/
class Smarty_Autoloader
{
- /**
+ /**
* Filepath to Smarty root
*
* @var string
@@ -54,8 +54,8 @@ class Smarty_Autoloader
if (!defined('SMARTY_SPL_AUTOLOAD')) {
define('SMARTY_SPL_AUTOLOAD', 0);
}
- if (SMARTY_SPL_AUTOLOAD &&
- set_include_path(get_include_path() . PATH_SEPARATOR . SMARTY_SYSPLUGINS_DIR) !== false
+ if (SMARTY_SPL_AUTOLOAD
+ && set_include_path(get_include_path() . PATH_SEPARATOR . SMARTY_SYSPLUGINS_DIR) !== false
) {
$registeredAutoLoadFunctions = spl_autoload_functions();
if (!isset($registeredAutoLoadFunctions[ 'spl_autoload' ])) {
diff --git a/system/templateEngines/smarty/Smarty.class.php b/system/templateEngines/smarty/Smarty.class.php
index 597fbbf..a896992 100644
--- a/system/templateEngines/smarty/Smarty.class.php
+++ b/system/templateEngines/smarty/Smarty.class.php
@@ -27,7 +27,7 @@
* @author Uwe Tews
* @author Rodney Rehm
* @package Smarty
- * @version 3.1.32
+ * @version 3.1.33
*/
/**
* set SMARTY_DIR to absolute path to Smarty library files.
@@ -112,7 +112,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* smarty version
*/
- const SMARTY_VERSION = '3.1.32';
+ const SMARTY_VERSION = '3.1.33';
/**
* define variable scopes
*/
@@ -166,133 +166,157 @@ class Smarty extends Smarty_Internal_TemplateBase
const PLUGIN_COMPILER = 'compiler';
const PLUGIN_MODIFIER = 'modifier';
const PLUGIN_MODIFIERCOMPILER = 'modifiercompiler';
+
/**
* assigned global tpl vars
*/
public static $global_tpl_vars = array();
+
/**
* Flag denoting if Multibyte String functions are available
*/
public static $_MBSTRING = SMARTY_MBSTRING;
+
/**
* The character set to adhere to (e.g. "UTF-8")
*/
public static $_CHARSET = SMARTY_RESOURCE_CHAR_SET;
+
/**
* The date format to be used internally
* (accepts date() and strftime())
*/
public static $_DATE_FORMAT = SMARTY_RESOURCE_DATE_FORMAT;
+
/**
* Flag denoting if PCRE should run in UTF-8 mode
*/
public static $_UTF8_MODIFIER = 'u';
+
/**
* Flag denoting if operating system is windows
*/
public static $_IS_WINDOWS = false;
+
/**
* auto literal on delimiters with whitespace
*
* @var boolean
*/
public $auto_literal = true;
+
/**
* display error on not assigned variables
*
* @var boolean
*/
public $error_unassigned = false;
+
/**
* look up relative file path in include_path
*
* @var boolean
*/
public $use_include_path = false;
+
/**
* flag if template_dir is normalized
*
* @var bool
*/
public $_templateDirNormalized = false;
+
/**
* joined template directory string used in cache keys
*
* @var string
*/
public $_joined_template_dir = null;
+
/**
* flag if config_dir is normalized
*
* @var bool
*/
public $_configDirNormalized = false;
+
/**
* joined config directory string used in cache keys
*
* @var string
*/
public $_joined_config_dir = null;
+
/**
* default template handler
*
* @var callable
*/
public $default_template_handler_func = null;
+
/**
* default config handler
*
* @var callable
*/
public $default_config_handler_func = null;
+
/**
* default plugin handler
*
* @var callable
*/
public $default_plugin_handler_func = null;
+
/**
* flag if template_dir is normalized
*
* @var bool
*/
public $_compileDirNormalized = false;
+
/**
* flag if plugins_dir is normalized
*
* @var bool
*/
public $_pluginsDirNormalized = false;
+
/**
* flag if template_dir is normalized
*
* @var bool
*/
public $_cacheDirNormalized = false;
+
/**
* force template compiling?
*
* @var boolean
*/
public $force_compile = false;
- /**
+
+ /**
* use sub dirs for compiled/cached files?
*
* @var boolean
*/
public $use_sub_dirs = false;
+
/**
* allow ambiguous resources (that are made unique by the resource handler)
*
* @var boolean
*/
public $allow_ambiguous_resources = false;
+
/**
* merge compiled includes
*
* @var boolean
*/
public $merge_compiled_includes = false;
+
/*
* flag for behaviour when extends: resource and {extends} tag are used simultaneous
* if false disable execution of {extends} in templates called by extends resource.
@@ -301,30 +325,35 @@ class Smarty extends Smarty_Internal_TemplateBase
* @var boolean
*/
public $extends_recursion = true;
+
/**
* force cache file creation
*
* @var boolean
*/
public $force_cache = false;
+
/**
* template left-delimiter
*
* @var string
*/
public $left_delimiter = "{";
+
/**
* template right-delimiter
*
* @var string
*/
public $right_delimiter = "}";
+
/**
* array of strings which shall be treated as literal by compiler
*
* @var array string
*/
public $literals = array();
+
/**
* class name
* This should be instance of Smarty_Security.
@@ -333,24 +362,28 @@ class Smarty extends Smarty_Internal_TemplateBase
* @see Smarty_Security
*/
public $security_class = 'Smarty_Security';
+
/**
* implementation of security class
*
* @var Smarty_Security
*/
public $security_policy = null;
+
/**
* controls handling of PHP-blocks
*
* @var integer
*/
public $php_handling = self::PHP_PASSTHRU;
+
/**
* controls if the php template file resource is allowed
*
* @var bool
*/
public $allow_php_templates = false;
+
/**
* debug mode
* Setting this to true enables the debug-console.
@@ -358,6 +391,7 @@ class Smarty extends Smarty_Internal_TemplateBase
* @var boolean
*/
public $debugging = false;
+
/**
* This determines if debugging is enable-able from the browser.
*
@@ -368,6 +402,7 @@ class Smarty extends Smarty_Internal_TemplateBase
* @var string
*/
public $debugging_ctrl = 'NONE';
+
/**
* Name of debugging URL-param.
* Only used when $debugging_ctrl is set to 'URL'.
@@ -376,54 +411,63 @@ class Smarty extends Smarty_Internal_TemplateBase
* @var string
*/
public $smarty_debug_id = 'SMARTY_DEBUG';
+
/**
* Path of debug template.
*
* @var string
*/
public $debug_tpl = null;
+
/**
* When set, smarty uses this value as error_reporting-level.
*
* @var int
*/
public $error_reporting = null;
+
/**
* Controls whether variables with the same name overwrite each other.
*
* @var boolean
*/
public $config_overwrite = true;
+
/**
* Controls whether config values of on/true/yes and off/false/no get converted to boolean.
*
* @var boolean
*/
public $config_booleanize = true;
+
/**
* Controls whether hidden config sections/vars are read from the file.
*
* @var boolean
*/
public $config_read_hidden = false;
+
/**
* locking concurrent compiles
*
* @var boolean
*/
public $compile_locking = true;
+
/**
* Controls whether cache resources should use locking mechanism
*
* @var boolean
*/
public $cache_locking = false;
+
/**
* seconds to wait for acquiring a lock before ignoring the write lock
*
* @var float
*/
public $locking_timeout = 10;
+
/**
* resource type used if none given
* Must be an valid key of $registered_resources.
@@ -431,6 +475,7 @@ class Smarty extends Smarty_Internal_TemplateBase
* @var string
*/
public $default_resource_type = 'file';
+
/**
* caching type
* Must be an element of $cache_resource_types.
@@ -438,160 +483,189 @@ class Smarty extends Smarty_Internal_TemplateBase
* @var string
*/
public $caching_type = 'file';
+
/**
* config type
*
* @var string
*/
public $default_config_type = 'file';
+
/**
* check If-Modified-Since headers
*
* @var boolean
*/
public $cache_modified_check = false;
+
/**
* registered plugins
*
* @var array
*/
public $registered_plugins = array();
+
/**
* registered objects
*
* @var array
*/
public $registered_objects = array();
+
/**
* registered classes
*
* @var array
*/
public $registered_classes = array();
+
/**
* registered filters
*
* @var array
*/
public $registered_filters = array();
+
/**
* registered resources
*
* @var array
*/
public $registered_resources = array();
+
/**
* registered cache resources
*
* @var array
*/
public $registered_cache_resources = array();
+
/**
* autoload filter
*
* @var array
*/
public $autoload_filters = array();
+
/**
* default modifier
*
* @var array
*/
public $default_modifiers = array();
+
/**
* autoescape variable output
*
* @var boolean
*/
public $escape_html = false;
+
/**
* start time for execution time calculation
*
* @var int
*/
public $start_time = 0;
+
/**
* required by the compiler for BC
*
* @var string
*/
public $_current_file = null;
+
/**
* internal flag to enable parser debugging
*
* @var bool
*/
public $_parserdebug = false;
+
/**
* This object type (Smarty = 1, template = 2, data = 4)
*
* @var int
*/
public $_objType = 1;
+
/**
* Debug object
*
* @var Smarty_Internal_Debug
*/
public $_debug = null;
+
/**
* template directory
*
* @var array
*/
protected $template_dir = array('./templates/');
+
/**
* flags for normalized template directory entries
*
* @var array
*/
protected $_processedTemplateDir = array();
+
/**
* config directory
*
* @var array
*/
protected $config_dir = array('./configs/');
+
/**
* flags for normalized template directory entries
*
* @var array
*/
protected $_processedConfigDir = array();
+
/**
* compile directory
*
* @var string
*/
protected $compile_dir = './templates_c/';
+
/**
* plugins directory
*
* @var array
*/
protected $plugins_dir = array();
+
/**
* cache directory
*
* @var string
*/
protected $cache_dir = './cache/';
+
/**
* removed properties
*
* @var string[]
*/
- protected $obsoleteProperties = array('resource_caching', 'template_resource_caching', 'direct_access_security',
- '_dir_perms', '_file_perms', 'plugin_search_order',
- 'inheritance_merge_compiled_includes', 'resource_cache_mode',);
+ protected $obsoleteProperties = array(
+ 'resource_caching', 'template_resource_caching', 'direct_access_security',
+ '_dir_perms', '_file_perms', 'plugin_search_order',
+ 'inheritance_merge_compiled_includes', 'resource_cache_mode',
+ );
+
/**
* List of private properties which will call getter/setter on a direct access
*
* @var string[]
*/
- protected $accessMap = array('template_dir' => 'TemplateDir', 'config_dir' => 'ConfigDir',
- 'plugins_dir' => 'PluginsDir', 'compile_dir' => 'CompileDir',
- 'cache_dir' => 'CacheDir',);
+ protected $accessMap = array(
+ 'template_dir' => 'TemplateDir', 'config_dir' => 'ConfigDir',
+ 'plugins_dir' => 'PluginsDir', 'compile_dir' => 'CompileDir',
+ 'cache_dir' => 'CacheDir',
+ );
/**
* Initialize new Smarty object
@@ -618,7 +692,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* Enable error handler to mute expected messages
*
- * @return boolean
+ * @return boolean
* @deprecated
*/
public static function muteExpectedErrors()
@@ -639,7 +713,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* Check if a template resource exists
*
- * @param string $resource_name template name
+ * @param string $resource_name template name
*
* @return bool status
* @throws \SmartyException
@@ -654,10 +728,10 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* Loads security class and enables security
*
- * @param string|Smarty_Security $security_class if a string is used, it must be class-name
+ * @param string|Smarty_Security $security_class if a string is used, it must be class-name
*
* @return Smarty current Smarty instance for chaining
- * @throws SmartyException when an invalid class name is provided
+ * @throws \SmartyException
*/
public function enableSecurity($security_class = null)
{
@@ -679,9 +753,9 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* Add template directory(s)
*
- * @param string|array $template_dir directory(s) of template sources
- * @param string $key of the array element to assign the template dir to
- * @param bool $isConfig true for config_dir
+ * @param string|array $template_dir directory(s) of template sources
+ * @param string $key of the array element to assign the template dir to
+ * @param bool $isConfig true for config_dir
*
* @return Smarty current Smarty instance for chaining
*/
@@ -747,8 +821,8 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* Set template directory
*
- * @param string|array $template_dir directory(s) of template sources
- * @param bool $isConfig true for config_dir
+ * @param string|array $template_dir directory(s) of template sources
+ * @param bool $isConfig true for config_dir
*
* @return \Smarty current Smarty instance for chaining
*/
@@ -835,7 +909,7 @@ class Smarty extends Smarty_Internal_TemplateBase
$this->plugins_dir = (array)$this->plugins_dir;
}
foreach ($this->plugins_dir as $k => $v) {
- $this->plugins_dir[ $k ] = $this->_realpath(rtrim($v, "/\\") . DIRECTORY_SEPARATOR, true);
+ $this->plugins_dir[ $k ] = $this->_realpath(rtrim($v, '/\\') . DIRECTORY_SEPARATOR, true);
}
$this->_cache[ 'plugin_files' ] = array();
$this->_pluginsDirNormalized = true;
@@ -846,7 +920,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* Set plugins directory
*
- * @param string|array $plugins_dir directory(s) of plugins
+ * @param string|array $plugins_dir directory(s) of plugins
*
* @return Smarty current Smarty instance for chaining
*/
@@ -901,7 +975,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* Set cache directory
*
- * @param string $cache_dir directory to store cached templates in
+ * @param string $cache_dir directory to store cached templates in
*
* @return Smarty current Smarty instance for chaining
*/
@@ -915,11 +989,11 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* creates a template object
*
- * @param string $template the resource handle of the template file
- * @param mixed $cache_id cache id to be used with this template
- * @param mixed $compile_id compile id to be used with this template
- * @param object $parent next higher level of Smarty variables
- * @param boolean $do_clone flag is Smarty object shall be cloned
+ * @param string $template the resource handle of the template file
+ * @param mixed $cache_id cache id to be used with this template
+ * @param mixed $compile_id compile id to be used with this template
+ * @param object $parent next higher level of Smarty variables
+ * @param boolean $do_clone flag is Smarty object shall be cloned
*
* @return \Smarty_Internal_Template template object
* @throws \SmartyException
@@ -946,7 +1020,7 @@ class Smarty extends Smarty_Internal_TemplateBase
Smarty_Internal_Template::$isCacheTplObj[ $_templateId ];
$tpl->inheritance = null;
$tpl->tpl_vars = $tpl->config_vars = array();
- } else if (!$do_clone && isset(Smarty_Internal_Template::$tplObjCache[ $_templateId ])) {
+ } elseif (!$do_clone && isset(Smarty_Internal_Template::$tplObjCache[ $_templateId ])) {
$tpl = clone Smarty_Internal_Template::$tplObjCache[ $_templateId ];
$tpl->inheritance = null;
$tpl->tpl_vars = $tpl->config_vars = array();
@@ -981,11 +1055,11 @@ class Smarty extends Smarty_Internal_TemplateBase
* class name format: Smarty_PluginType_PluginName
* plugin filename format: plugintype.pluginname.php
*
- * @param string $plugin_name class plugin name to load
- * @param bool $check check if already loaded
+ * @param string $plugin_name class plugin name to load
+ * @param bool $check check if already loaded
*
- * @throws SmartyException
* @return string |boolean filepath of loaded file or false
+ * @throws \SmartyException
*/
public function loadPlugin($plugin_name, $check = true)
{
@@ -1004,12 +1078,13 @@ class Smarty extends Smarty_Internal_TemplateBase
* @return string
* @throws \SmartyException
*/
- public function _getTemplateId($template_name,
- $cache_id = null,
- $compile_id = null,
- $caching = null,
- Smarty_Internal_Template $template = null)
- {
+ public function _getTemplateId(
+ $template_name,
+ $cache_id = null,
+ $compile_id = null,
+ $caching = null,
+ Smarty_Internal_Template $template = null
+ ) {
$template_name = (strpos($template_name, ':') === false) ? "{$this->default_resource_type}:{$template_name}" :
$template_name;
$cache_id = $cache_id === null ? $this->cache_id : $cache_id;
@@ -1033,33 +1108,22 @@ class Smarty extends Smarty_Internal_TemplateBase
* - remove /./ and /../
* - make it absolute if required
*
- * @param string $path file path
- * @param bool $realpath if true - convert to absolute
- * false - convert to relative
- * null - keep as it is but remove /./ /../
+ * @param string $path file path
+ * @param bool $realpath if true - convert to absolute
+ * false - convert to relative
+ * null - keep as it is but
+ * remove /./ /../
*
* @return string
*/
public function _realpath($path, $realpath = null)
{
- static $nds = null;
- static $sepDotsep = null;
- static $sepDot = null;
- static $sepSep =null;
- if (!isset($nds)) {
- $nds = array('/' => '\\', '\\' => '/');
- $sepDotsep = DIRECTORY_SEPARATOR . '.' . DIRECTORY_SEPARATOR;
- $sepDot = DIRECTORY_SEPARATOR . '.';
- $sepSep = DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR;
- }
- // normalize DIRECTORY_SEPARATOR
- $path = str_replace(array($nds[DIRECTORY_SEPARATOR], $sepDotsep), DIRECTORY_SEPARATOR, $path);
- if (strpos($path,$sepDot) === false && (($realpath === false && $path[0] === '.') || $realpath === null) && $path[0] !== '\\') {
- return $path;
- }
- preg_match('%^(?(?:[[:alpha:]]:[\\\\]|/|[\\\\]{2}[[:alpha:]]+|[[:print:]]{2,}:[/]{2}|[\\\\])?)(?(.*))$%u',
- $path,
- $parts);
+ $nds = array('/' => '\\', '\\' => '/');
+ preg_match(
+ '%^(?(?:[[:alpha:]]:[\\\\/]|/|[\\\\]{2}[[:alpha:]]+|[[:print:]]{2,}:[/]{2}|[\\\\])?)(?(.*))$%u',
+ $path,
+ $parts
+ );
$path = $parts[ 'path' ];
if ($parts[ 'root' ] === '\\') {
$parts[ 'root' ] = substr(getcwd(), 0, 2) . $parts[ 'root' ];
@@ -1068,24 +1132,18 @@ class Smarty extends Smarty_Internal_TemplateBase
$path = getcwd() . DIRECTORY_SEPARATOR . $path;
}
}
- // remove noop 'DIRECTORY_SEPARATOR DIRECTORY_SEPARATOR' and 'DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR' patterns
- $path = str_replace(array($sepDotsep,$sepSep), DIRECTORY_SEPARATOR, $path);
- // resolve '..DIRECTORY_SEPARATOR' pattern, smallest first
- if (strpos($path, '..' . DIRECTORY_SEPARATOR) !== false &&
- preg_match_all('#[\\\\/]([.][.][\\\\/])+#u', $path, $match)
- ) {
- $counts = array();
- foreach ($match[ 0 ] as $m) {
- $counts[] = (int)((strlen($m) - 1) / 3);
- }
- sort($counts);
- foreach ($counts as $count) {
- $path = preg_replace('#([\\\\/]+[^\\\\/]+){' . $count .
- '}[\\\\/]+([.][.][\\\\/]+){' . $count . '}#u',
- DIRECTORY_SEPARATOR,
- $path);
- }
- }
+ // normalize DIRECTORY_SEPARATOR
+ $path = str_replace($nds[ DIRECTORY_SEPARATOR ], DIRECTORY_SEPARATOR, $path);
+ $parts[ 'root' ] = str_replace($nds[ DIRECTORY_SEPARATOR ], DIRECTORY_SEPARATOR, $parts[ 'root' ]);
+ do {
+ $path = preg_replace(
+ array('#[\\\\/]{2}#', '#[\\\\/][.][\\\\/]#', '#[\\\\/]([^\\\\/.]+)[\\\\/][.][.][\\\\/]#'),
+ DIRECTORY_SEPARATOR,
+ $path,
+ -1,
+ $count
+ );
+ } while ($count > 0);
return $realpath !== false ? $parts[ 'root' ] . $path : str_ireplace(getcwd(), '.', $parts[ 'root' ] . $path);
}
@@ -1279,19 +1337,18 @@ class Smarty extends Smarty_Internal_TemplateBase
* Calls the appropriate getter function.
* Issues an E_USER_NOTICE if no valid getter is found.
*
- * @param string $name property name
+ * @param string $name property name
*
* @return mixed
- * @throws \SmartyException
*/
public function __get($name)
{
if (isset($this->accessMap[ $name ])) {
$method = 'get' . $this->accessMap[ $name ];
return $this->{$method}();
- } else if (isset($this->_cache[ $name ])) {
+ } elseif (isset($this->_cache[ $name ])) {
return $this->_cache[ $name ];
- } else if (in_array($name, $this->obsoleteProperties)) {
+ } elseif (in_array($name, $this->obsoleteProperties)) {
return null;
} else {
trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE);
@@ -1307,21 +1364,18 @@ class Smarty extends Smarty_Internal_TemplateBase
* @param string $name property name
* @param mixed $value parameter passed to setter
*
- * @throws \SmartyException
*/
public function __set($name, $value)
{
if (isset($this->accessMap[ $name ])) {
$method = 'set' . $this->accessMap[ $name ];
$this->{$method}($value);
- } else if (in_array($name, $this->obsoleteProperties)) {
+ } elseif (in_array($name, $this->obsoleteProperties)) {
return;
+ } elseif (is_object($value) && method_exists($value, $name)) {
+ $this->$name = $value;
} else {
- if (is_object($value) && method_exists($value, $name)) {
- $this->$name = $value;
- } else {
- trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE);
- }
+ trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE);
}
}
@@ -1345,7 +1399,6 @@ class Smarty extends Smarty_Internal_TemplateBase
* Normalize template_dir or config_dir
*
* @param bool $isConfig true for config_dir
- *
*/
private function _normalizeTemplateConfig($isConfig)
{
diff --git a/system/templateEngines/smarty/SmartyBC.class.php b/system/templateEngines/smarty/SmartyBC.class.php
index f2230fc..836f981 100644
--- a/system/templateEngines/smarty/SmartyBC.class.php
+++ b/system/templateEngines/smarty/SmartyBC.class.php
@@ -28,7 +28,7 @@
/**
* @ignore
*/
-require_once(dirname(__FILE__) . '/Smarty.class.php');
+require_once dirname(__FILE__) . '/Smarty.class.php';
/**
* Smarty Backward Compatibility Wrapper Class
@@ -53,7 +53,6 @@ class SmartyBC extends Smarty
/**
* Initialize new SmartyBC object
- *
*/
public function __construct()
{
@@ -127,12 +126,16 @@ class SmartyBC extends Smarty
* @param boolean $smarty_args smarty argument format, else traditional
* @param array $block_methods list of methods that are block format
*
- * @throws SmartyException
+ * @throws SmartyException
* @internal param array $block_functs list of methods that are block format
*/
- public function register_object($object, $object_impl, $allowed = array(), $smarty_args = true,
- $block_methods = array())
- {
+ public function register_object(
+ $object,
+ $object_impl,
+ $allowed = array(),
+ $smarty_args = true,
+ $block_methods = array()
+ ) {
settype($allowed, 'array');
settype($smarty_args, 'boolean');
$this->registerObject($object, $object_impl, $allowed, $smarty_args, $block_methods);
@@ -326,10 +329,10 @@ class SmartyBC extends Smarty
/**
* clear cached content for the given template and cache id
*
- * @param string $tpl_file name of template file
- * @param string $cache_id name of cache_id
- * @param string $compile_id name of compile_id
- * @param string $exp_time expiration time
+ * @param string $tpl_file name of template file
+ * @param string $cache_id name of cache_id
+ * @param string $compile_id name of compile_id
+ * @param string $exp_time expiration time
*
* @return boolean
*/
@@ -341,7 +344,7 @@ class SmartyBC extends Smarty
/**
* clear the entire contents of cache (all templates)
*
- * @param string $exp_time expire time
+ * @param string $exp_time expire time
*
* @return boolean
*/
@@ -353,9 +356,9 @@ class SmartyBC extends Smarty
/**
* test to see if valid cache exists for this template
*
- * @param string $tpl_file name of template file
- * @param string $cache_id
- * @param string $compile_id
+ * @param string $tpl_file name of template file
+ * @param string $cache_id
+ * @param string $compile_id
*
* @return bool
* @throws \Exception
@@ -379,9 +382,9 @@ class SmartyBC extends Smarty
* or all compiled template files if one is not specified.
* This function is for advanced use only, not normally needed.
*
- * @param string $tpl_file
- * @param string $compile_id
- * @param string $exp_time
+ * @param string $tpl_file
+ * @param string $compile_id
+ * @param string $exp_time
*
* @return boolean results of {@link smarty_core_rm_auto()}
*/
@@ -393,7 +396,7 @@ class SmartyBC extends Smarty
/**
* Checks whether requested template exists.
*
- * @param string $tpl_file
+ * @param string $tpl_file
*
* @return bool
* @throws \SmartyException
@@ -406,7 +409,7 @@ class SmartyBC extends Smarty
/**
* Returns an array containing template variables
*
- * @param string $name
+ * @param string $name
*
* @return array
*/
@@ -418,7 +421,7 @@ class SmartyBC extends Smarty
/**
* Returns an array containing config variables
*
- * @param string $name
+ * @param string $name
*
* @return array
*/
@@ -442,7 +445,7 @@ class SmartyBC extends Smarty
/**
* return a reference to a registered object
*
- * @param string $name
+ * @param string $name
*
* @return object
*/
diff --git a/system/templateEngines/smarty/bootstrap.php b/system/templateEngines/smarty/bootstrap.php
index dad72fc..2c83046 100644
--- a/system/templateEngines/smarty/bootstrap.php
+++ b/system/templateEngines/smarty/bootstrap.php
@@ -1,5 +1,5 @@
@@ -7,11 +7,10 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-
-/*
+/**
* Load and register Smarty Autoloader
*/
if (!class_exists('Smarty_Autoloader')) {
- require dirname(__FILE__) . '/Autoloader.php';
+ include dirname(__FILE__) . '/Autoloader.php';
}
Smarty_Autoloader::register(true);
diff --git a/system/templateEngines/smarty/debug.tpl b/system/templateEngines/smarty/debug.tpl
index 5526cbc..edc7bef 100644
--- a/system/templateEngines/smarty/debug.tpl
+++ b/system/templateEngines/smarty/debug.tpl
@@ -113,10 +113,10 @@
{foreach $template_data as $template}
{$template.name}
-
+
(compile {$template['compile_time']|string_format:"%.5f"}) (render {$template['render_time']|string_format:"%.5f"}) (cache {$template['cache_time']|string_format:"%.5f"})
-
+
{/foreach}
{/if}
@@ -127,7 +127,7 @@
{foreach $assigned_vars as $vars}
${$vars@key}
- {if isset($vars['nocache'])}Nocache{/if}
+ {if isset($vars['nocache'])}Nocache {/if}
{if isset($vars['scope'])}Origin: {$vars['scope']|debug_print_var nofilter}{/if}
|
Value{$vars['value']|debug_print_var:10:80 nofilter} |
diff --git a/system/templateEngines/smarty/plugins/block.textformat.php b/system/templateEngines/smarty/plugins/block.textformat.php
index 310a420..5e49463 100644
--- a/system/templateEngines/smarty/plugins/block.textformat.php
+++ b/system/templateEngines/smarty/plugins/block.textformat.php
@@ -20,7 +20,6 @@
* - indent_char - string (" ")
* - wrap_boundary - boolean (true)
*
- *
* @link http://www.smarty.net/manual/en/language.function.textformat.php {textformat}
* (Smarty online manual)
*
@@ -39,10 +38,15 @@ function smarty_block_textformat($params, $content, Smarty_Internal_Template $te
return;
}
if (Smarty::$_MBSTRING) {
- $template->_checkPlugins(array(array('function' => 'smarty_modifier_mb_wordwrap',
- 'file' => SMARTY_PLUGINS_DIR . 'modifier.mb_wordwrap.php')));
+ $template->_checkPlugins(
+ array(
+ array(
+ 'function' => 'smarty_modifier_mb_wordwrap',
+ 'file' => SMARTY_PLUGINS_DIR . 'modifier.mb_wordwrap.php'
+ )
+ )
+ );
}
-
$style = null;
$indent = 0;
$indent_first = 0;
@@ -51,47 +55,48 @@ function smarty_block_textformat($params, $content, Smarty_Internal_Template $te
$wrap_char = "\n";
$wrap_cut = false;
$assign = null;
-
foreach ($params as $_key => $_val) {
switch ($_key) {
case 'style':
case 'indent_char':
case 'wrap_char':
case 'assign':
- $$_key = (string) $_val;
+ $$_key = (string)$_val;
break;
-
case 'indent':
case 'indent_first':
case 'wrap':
- $$_key = (int) $_val;
+ $$_key = (int)$_val;
break;
-
case 'wrap_cut':
- $$_key = (bool) $_val;
+ $$_key = (bool)$_val;
break;
-
default:
trigger_error("textformat: unknown attribute '{$_key}'");
}
}
-
if ($style === 'email') {
$wrap = 72;
}
// split into paragraphs
$_paragraphs = preg_split('![\r\n]{2}!', $content);
-
foreach ($_paragraphs as &$_paragraph) {
if (!$_paragraph) {
continue;
}
// convert mult. spaces & special chars to single space
$_paragraph =
- preg_replace(array('!\s+!' . Smarty::$_UTF8_MODIFIER,
- '!(^\s+)|(\s+$)!' . Smarty::$_UTF8_MODIFIER),
- array(' ',
- ''), $_paragraph);
+ preg_replace(
+ array(
+ '!\s+!' . Smarty::$_UTF8_MODIFIER,
+ '!(^\s+)|(\s+$)!' . Smarty::$_UTF8_MODIFIER
+ ),
+ array(
+ ' ',
+ ''
+ ),
+ $_paragraph
+ );
// indent first line
if ($indent_first > 0) {
$_paragraph = str_repeat($indent_char, $indent_first) . $_paragraph;
@@ -108,7 +113,6 @@ function smarty_block_textformat($params, $content, Smarty_Internal_Template $te
}
}
$_output = implode($wrap_char . $wrap_char, $_paragraphs);
-
if ($assign) {
$template->assign($assign, $_output);
} else {
diff --git a/system/templateEngines/smarty/plugins/function.counter.php b/system/templateEngines/smarty/plugins/function.counter.php
index 9610362..a4129e7 100644
--- a/system/templateEngines/smarty/plugins/function.counter.php
+++ b/system/templateEngines/smarty/plugins/function.counter.php
@@ -5,7 +5,6 @@
* @package Smarty
* @subpackage PluginsFunction
*/
-
/**
* Smarty {counter} function plugin
* Type: function
@@ -24,50 +23,40 @@
function smarty_function_counter($params, $template)
{
static $counters = array();
-
$name = (isset($params[ 'name' ])) ? $params[ 'name' ] : 'default';
if (!isset($counters[ $name ])) {
$counters[ $name ] = array('start' => 1, 'skip' => 1, 'direction' => 'up', 'count' => 1);
}
$counter =& $counters[ $name ];
-
if (isset($params[ 'start' ])) {
- $counter[ 'start' ] = $counter[ 'count' ] = (int) $params[ 'start' ];
+ $counter[ 'start' ] = $counter[ 'count' ] = (int)$params[ 'start' ];
}
-
if (!empty($params[ 'assign' ])) {
$counter[ 'assign' ] = $params[ 'assign' ];
}
-
if (isset($counter[ 'assign' ])) {
$template->assign($counter[ 'assign' ], $counter[ 'count' ]);
}
-
if (isset($params[ 'print' ])) {
- $print = (bool) $params[ 'print' ];
+ $print = (bool)$params[ 'print' ];
} else {
$print = empty($counter[ 'assign' ]);
}
-
if ($print) {
$retval = $counter[ 'count' ];
} else {
$retval = null;
}
-
if (isset($params[ 'skip' ])) {
$counter[ 'skip' ] = $params[ 'skip' ];
}
-
if (isset($params[ 'direction' ])) {
$counter[ 'direction' ] = $params[ 'direction' ];
}
-
if ($counter[ 'direction' ] === 'down') {
$counter[ 'count' ] -= $counter[ 'skip' ];
} else {
$counter[ 'count' ] += $counter[ 'skip' ];
}
-
return $retval;
}
diff --git a/system/templateEngines/smarty/plugins/function.cycle.php b/system/templateEngines/smarty/plugins/function.cycle.php
index b871524..07ffcc5 100644
--- a/system/templateEngines/smarty/plugins/function.cycle.php
+++ b/system/templateEngines/smarty/plugins/function.cycle.php
@@ -5,7 +5,6 @@
* @package Smarty
* @subpackage PluginsFunction
*/
-
/**
* Smarty {cycle} function plugin
* Type: function
@@ -29,34 +28,29 @@
* {cycle name=row values="one,two,three" reset=true}
* {cycle name=row}
*
- *
- * @link http://www.smarty.net/manual/en/language.function.cycle.php {cycle}
+ * @link http://www.smarty.net/manual/en/language.function.cycle.php {cycle}
* (Smarty online manual)
- * @author Monte Ohrt
- * @author credit to Mark Priatel
- * @author credit to Gerard
- * @author credit to Jason Sweat
- * @version 1.3
+ * @author Monte Ohrt
+ * @author credit to Mark Priatel
+ * @author credit to Gerard
+ * @author credit to Jason Sweat
+ * @version 1.3
*
* @param array $params parameters
* @param Smarty_Internal_Template $template template object
*
* @return string|null
*/
-
function smarty_function_cycle($params, $template)
{
static $cycle_vars;
-
$name = (empty($params[ 'name' ])) ? 'default' : $params[ 'name' ];
- $print = (isset($params[ 'print' ])) ? (bool) $params[ 'print' ] : true;
- $advance = (isset($params[ 'advance' ])) ? (bool) $params[ 'advance' ] : true;
- $reset = (isset($params[ 'reset' ])) ? (bool) $params[ 'reset' ] : false;
-
+ $print = (isset($params[ 'print' ])) ? (bool)$params[ 'print' ] : true;
+ $advance = (isset($params[ 'advance' ])) ? (bool)$params[ 'advance' ] : true;
+ $reset = (isset($params[ 'reset' ])) ? (bool)$params[ 'reset' ] : false;
if (!isset($params[ 'values' ])) {
if (!isset($cycle_vars[ $name ][ 'values' ])) {
trigger_error('cycle: missing \'values\' parameter');
-
return;
}
} else {
@@ -65,41 +59,34 @@ function smarty_function_cycle($params, $template)
}
$cycle_vars[ $name ][ 'values' ] = $params[ 'values' ];
}
-
if (isset($params[ 'delimiter' ])) {
$cycle_vars[ $name ][ 'delimiter' ] = $params[ 'delimiter' ];
} elseif (!isset($cycle_vars[ $name ][ 'delimiter' ])) {
$cycle_vars[ $name ][ 'delimiter' ] = ',';
}
-
if (is_array($cycle_vars[ $name ][ 'values' ])) {
$cycle_array = $cycle_vars[ $name ][ 'values' ];
} else {
$cycle_array = explode($cycle_vars[ $name ][ 'delimiter' ], $cycle_vars[ $name ][ 'values' ]);
}
-
if (!isset($cycle_vars[ $name ][ 'index' ]) || $reset) {
$cycle_vars[ $name ][ 'index' ] = 0;
}
-
if (isset($params[ 'assign' ])) {
$print = false;
$template->assign($params[ 'assign' ], $cycle_array[ $cycle_vars[ $name ][ 'index' ] ]);
}
-
if ($print) {
$retval = $cycle_array[ $cycle_vars[ $name ][ 'index' ] ];
} else {
$retval = null;
}
-
if ($advance) {
if ($cycle_vars[ $name ][ 'index' ] >= count($cycle_array) - 1) {
$cycle_vars[ $name ][ 'index' ] = 0;
} else {
- $cycle_vars[ $name ][ 'index' ] ++;
+ $cycle_vars[ $name ][ 'index' ]++;
}
}
-
return $retval;
}
diff --git a/system/templateEngines/smarty/plugins/function.fetch.php b/system/templateEngines/smarty/plugins/function.fetch.php
index 9539e1f..768761b 100644
--- a/system/templateEngines/smarty/plugins/function.fetch.php
+++ b/system/templateEngines/smarty/plugins/function.fetch.php
@@ -5,7 +5,6 @@
* @package Smarty
* @subpackage PluginsFunction
*/
-
/**
* Smarty {fetch} plugin
* Type: function
@@ -26,20 +25,16 @@ function smarty_function_fetch($params, $template)
{
if (empty($params[ 'file' ])) {
trigger_error('[plugin] fetch parameter \'file\' cannot be empty', E_USER_NOTICE);
-
return;
}
-
// strip file protocol
if (stripos($params[ 'file' ], 'file://') === 0) {
$params[ 'file' ] = substr($params[ 'file' ], 7);
}
-
$protocol = strpos($params[ 'file' ], '://');
if ($protocol !== false) {
$protocol = strtolower(substr($params[ 'file' ], 0, $protocol));
}
-
if (isset($template->smarty->security_policy)) {
if ($protocol) {
// remote resource (or php stream, …)
@@ -53,7 +48,6 @@ function smarty_function_fetch($params, $template)
}
}
}
-
$content = '';
if ($protocol === 'http') {
// http fetch
@@ -104,7 +98,6 @@ function smarty_function_fetch($params, $template)
if (!empty($param_value)) {
if (!preg_match('![\w\d-]+: .+!', $param_value)) {
trigger_error("[plugin] invalid header format '{$param_value}'", E_USER_NOTICE);
-
return;
} else {
$extra_headers[] = $param_value;
@@ -118,10 +111,9 @@ function smarty_function_fetch($params, $template)
break;
case 'proxy_port':
if (!preg_match('!\D!', $param_value)) {
- $proxy_port = (int) $param_value;
+ $proxy_port = (int)$param_value;
} else {
trigger_error("[plugin] invalid value for attribute '{$param_key }'", E_USER_NOTICE);
-
return;
}
break;
@@ -137,16 +129,14 @@ function smarty_function_fetch($params, $template)
break;
case 'timeout':
if (!preg_match('!\D!', $param_value)) {
- $timeout = (int) $param_value;
+ $timeout = (int)$param_value;
} else {
trigger_error("[plugin] invalid value for attribute '{$param_key}'", E_USER_NOTICE);
-
return;
}
break;
default:
trigger_error("[plugin] unrecognized attribute '{$param_key}'", E_USER_NOTICE);
-
return;
}
}
@@ -156,10 +146,8 @@ function smarty_function_fetch($params, $template)
} else {
$fp = fsockopen($server_name, $port, $errno, $errstr, $timeout);
}
-
if (!$fp) {
trigger_error("[plugin] unable to fetch: $errstr ($errno)", E_USER_NOTICE);
-
return;
} else {
if ($_is_proxy) {
@@ -187,23 +175,19 @@ function smarty_function_fetch($params, $template)
if (!empty($user) && !empty($pass)) {
fputs($fp, 'Authorization: BASIC ' . base64_encode("$user:$pass") . "\r\n");
}
-
fputs($fp, "\r\n");
while (!feof($fp)) {
$content .= fgets($fp, 4096);
}
fclose($fp);
$csplit = preg_split("!\r\n\r\n!", $content, 2);
-
$content = $csplit[ 1 ];
-
if (!empty($params[ 'assign_headers' ])) {
$template->assign($params[ 'assign_headers' ], preg_split("!\r\n!", $csplit[ 0 ]));
}
}
} else {
trigger_error("[plugin fetch] unable to parse URL, check syntax", E_USER_NOTICE);
-
return;
}
} else {
@@ -212,7 +196,6 @@ function smarty_function_fetch($params, $template)
throw new SmartyException("{fetch} cannot read resource '" . $params[ 'file' ] . "'");
}
}
-
if (!empty($params[ 'assign' ])) {
$template->assign($params[ 'assign' ], $content);
} else {
diff --git a/system/templateEngines/smarty/plugins/function.html_checkboxes.php b/system/templateEngines/smarty/plugins/function.html_checkboxes.php
index d654cab..302358e 100644
--- a/system/templateEngines/smarty/plugins/function.html_checkboxes.php
+++ b/system/templateEngines/smarty/plugins/function.html_checkboxes.php
@@ -29,25 +29,29 @@
* - assign (optional) - assign the output as an array to this variable
* - escape (optional) - escape the content (not value), defaults to true
*
- *
- * @link http://www.smarty.net/manual/en/language.function.html.checkboxes.php {html_checkboxes}
+ * @link http://www.smarty.net/manual/en/language.function.html.checkboxes.php {html_checkboxes}
* (Smarty online manual)
- * @author Christopher Kvarme
- * @author credits to Monte Ohrt
- * @version 1.0
+ * @author Christopher Kvarme
+ * @author credits to Monte Ohrt
+ * @version 1.0
*
* @param array $params parameters
* @param Smarty_Internal_Template $template template object
*
* @return string
- * @uses smarty_function_escape_special_chars()
+ * @uses smarty_function_escape_special_chars()
* @throws \SmartyException
*/
function smarty_function_html_checkboxes($params, Smarty_Internal_Template $template)
{
- $template->_checkPlugins(array(array('function' => 'smarty_function_escape_special_chars',
- 'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php')));
-
+ $template->_checkPlugins(
+ array(
+ array(
+ 'function' => 'smarty_function_escape_special_chars',
+ 'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'
+ )
+ )
+ );
$name = 'checkbox';
$values = null;
$options = null;
@@ -57,31 +61,25 @@ function smarty_function_html_checkboxes($params, Smarty_Internal_Template $temp
$labels = true;
$label_ids = false;
$output = null;
-
$extra = '';
-
foreach ($params as $_key => $_val) {
switch ($_key) {
case 'name':
case 'separator':
- $$_key = (string) $_val;
+ $$_key = (string)$_val;
break;
-
case 'escape':
case 'labels':
case 'label_ids':
- $$_key = (bool) $_val;
+ $$_key = (bool)$_val;
break;
-
case 'options':
- $$_key = (array) $_val;
+ $$_key = (array)$_val;
break;
-
case 'values':
case 'output':
- $$_key = array_values((array) $_val);
+ $$_key = array_values((array)$_val);
break;
-
case 'checked':
case 'selected':
if (is_array($_val)) {
@@ -89,57 +87,61 @@ function smarty_function_html_checkboxes($params, Smarty_Internal_Template $temp
foreach ($_val as $_sel) {
if (is_object($_sel)) {
if (method_exists($_sel, '__toString')) {
- $_sel = smarty_function_escape_special_chars((string) $_sel->__toString());
+ $_sel = smarty_function_escape_special_chars((string)$_sel->__toString());
} else {
- trigger_error('html_checkboxes: selected attribute contains an object of class \'' .
- get_class($_sel) . '\' without __toString() method', E_USER_NOTICE);
+ trigger_error(
+ 'html_checkboxes: selected attribute contains an object of class \'' .
+ get_class($_sel) . '\' without __toString() method',
+ E_USER_NOTICE
+ );
continue;
}
} else {
- $_sel = smarty_function_escape_special_chars((string) $_sel);
+ $_sel = smarty_function_escape_special_chars((string)$_sel);
}
$selected[ $_sel ] = true;
}
} elseif (is_object($_val)) {
if (method_exists($_val, '__toString')) {
- $selected = smarty_function_escape_special_chars((string) $_val->__toString());
+ $selected = smarty_function_escape_special_chars((string)$_val->__toString());
} else {
- trigger_error('html_checkboxes: selected attribute is an object of class \'' . get_class($_val) .
- '\' without __toString() method', E_USER_NOTICE);
+ trigger_error(
+ 'html_checkboxes: selected attribute is an object of class \'' . get_class($_val) .
+ '\' without __toString() method',
+ E_USER_NOTICE
+ );
}
} else {
- $selected = smarty_function_escape_special_chars((string) $_val);
+ $selected = smarty_function_escape_special_chars((string)$_val);
}
break;
-
case 'checkboxes':
- trigger_error('html_checkboxes: the use of the "checkboxes" attribute is deprecated, use "options" instead',
- E_USER_WARNING);
- $options = (array) $_val;
+ trigger_error(
+ 'html_checkboxes: the use of the "checkboxes" attribute is deprecated, use "options" instead',
+ E_USER_WARNING
+ );
+ $options = (array)$_val;
break;
-
case 'assign':
break;
-
case 'strict':
break;
-
case 'disabled':
case 'readonly':
if (!empty($params[ 'strict' ])) {
if (!is_scalar($_val)) {
- trigger_error("html_options: {$_key} attribute must be a scalar, only boolean true or string '{$_key}' will actually add the attribute",
- E_USER_NOTICE);
+ trigger_error(
+ "html_options: {$_key} attribute must be a scalar, only boolean true or string '{$_key}' will actually add the attribute",
+ E_USER_NOTICE
+ );
}
-
if ($_val === true || $_val === $_key) {
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_key) . '"';
}
-
break;
}
// omit break; to fall through!
-
+ // no break
default:
if (!is_array($_val)) {
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
@@ -149,34 +151,49 @@ function smarty_function_html_checkboxes($params, Smarty_Internal_Template $temp
break;
}
}
-
if (!isset($options) && !isset($values)) {
return '';
} /* raise error here? */
-
$_html_result = array();
-
if (isset($options)) {
foreach ($options as $_key => $_val) {
$_html_result[] =
- smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels,
- $label_ids, $escape);
+ smarty_function_html_checkboxes_output(
+ $name,
+ $_key,
+ $_val,
+ $selected,
+ $extra,
+ $separator,
+ $labels,
+ $label_ids,
+ $escape
+ );
}
} else {
foreach ($values as $_i => $_key) {
$_val = isset($output[ $_i ]) ? $output[ $_i ] : '';
$_html_result[] =
- smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels,
- $label_ids, $escape);
+ smarty_function_html_checkboxes_output(
+ $name,
+ $_key,
+ $_val,
+ $selected,
+ $extra,
+ $separator,
+ $labels,
+ $label_ids,
+ $escape
+ );
}
}
-
if (!empty($params[ 'assign' ])) {
$template->assign($params[ 'assign' ], $_html_result);
} else {
return implode("\n", $_html_result);
}
}
+
/**
* @param $name
* @param $value
@@ -190,59 +207,69 @@ function smarty_function_html_checkboxes($params, Smarty_Internal_Template $temp
*
* @return string
*/
-function smarty_function_html_checkboxes_output($name, $value, $output, $selected, $extra, $separator, $labels,
- $label_ids, $escape = true)
-{
+function smarty_function_html_checkboxes_output(
+ $name,
+ $value,
+ $output,
+ $selected,
+ $extra,
+ $separator,
+ $labels,
+ $label_ids,
+ $escape = true
+) {
$_output = '';
-
if (is_object($value)) {
if (method_exists($value, '__toString')) {
- $value = (string) $value->__toString();
+ $value = (string)$value->__toString();
} else {
- trigger_error('html_options: value is an object of class \'' . get_class($value) .
- '\' without __toString() method', E_USER_NOTICE);
-
+ trigger_error(
+ 'html_options: value is an object of class \'' . get_class($value) .
+ '\' without __toString() method',
+ E_USER_NOTICE
+ );
return '';
}
} else {
- $value = (string) $value;
+ $value = (string)$value;
}
-
if (is_object($output)) {
if (method_exists($output, '__toString')) {
- $output = (string) $output->__toString();
+ $output = (string)$output->__toString();
} else {
- trigger_error('html_options: output is an object of class \'' . get_class($output) .
- '\' without __toString() method', E_USER_NOTICE);
-
+ trigger_error(
+ 'html_options: output is an object of class \'' . get_class($output) .
+ '\' without __toString() method',
+ E_USER_NOTICE
+ );
return '';
}
} else {
- $output = (string) $output;
+ $output = (string)$output;
}
-
if ($labels) {
if ($label_ids) {
- $_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!' . Smarty::$_UTF8_MODIFIER, '_',
- $name . '_' . $value));
+ $_id = smarty_function_escape_special_chars(
+ preg_replace(
+ '![^\w\-\.]!' . Smarty::$_UTF8_MODIFIER,
+ '_',
+ $name . '_' . $value
+ )
+ );
$_output .= '