mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 20:08:53 +00:00
Merge pull request #6091 from rxu/ticket/16654
[ticket/16654] Upgrade Twig to version 3
This commit is contained in:
commit
1306e63fd7
14 changed files with 83 additions and 79 deletions
|
@ -43,53 +43,57 @@
|
|||
<dt><label for="{{ storage.get_name }}">{{ lang('STORAGE_SELECT') }}{{ lang('COLON') }}</label><br /><span>{{ lang('STORAGE_SELECT_DESC') }}</span></dt>
|
||||
<dd>
|
||||
<select id="{{ storage.get_name }}" name="{{ storage.get_name }}[provider]" data-togglable-settings="true">
|
||||
{% for provider in PROVIDERS if provider.is_available %}
|
||||
<option value="{{ get_class(provider) }}"{{ attribute(config, 'storage\\' ~ storage.get_name ~ '\\provider') == get_class(provider) ? ' selected' : '' }} data-toggle-setting="#{{ storage.get_name }}_{{ provider.get_name }}_settings">
|
||||
{{ lang('STORAGE_ADAPTER_' ~ provider.get_name | upper ~ '_NAME') }}
|
||||
</option>
|
||||
{% for provider in PROVIDERS %}
|
||||
{% if provider.is_available %}
|
||||
<option value="{{ get_class(provider) }}"{{ attribute(config, 'storage\\' ~ storage.get_name ~ '\\provider') == get_class(provider) ? ' selected' : '' }} data-toggle-setting="#{{ storage.get_name }}_{{ provider.get_name }}_settings">
|
||||
{{ lang('STORAGE_ADAPTER_' ~ provider.get_name | upper ~ '_NAME') }}
|
||||
</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
</dd>
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
||||
{% for provider in PROVIDERS if provider.is_available %}
|
||||
<fieldset id="{{ storage.get_name }}_{{ provider.get_name }}_settings">
|
||||
<legend>{{ lang('STORAGE_' ~ storage.get_name | upper ~ '_TITLE') }} - {{ lang('STORAGE_ADAPTER_' ~ provider.get_name | upper ~ '_NAME') }}</legend>
|
||||
{% for name, options in provider.get_options %}
|
||||
{% set title = 'STORAGE_ADAPTER_' ~ provider.get_name | upper ~ '_OPTION_' ~ name | upper %}
|
||||
{% set description = 'STORAGE_ADAPTER_' ~ provider.get_name | upper ~ '_OPTION_' ~ name | upper ~ '_EXPLAIN' %}
|
||||
{% set input_id = storage.get_name ~ '_' ~ provider.get_name ~ '_' ~ name %}
|
||||
{% set input_type = options['type'] %}
|
||||
{% set input_name = storage.get_name ~ '[' ~ name ~ ']' %}
|
||||
{% set input_value = attribute(config, 'storage\\' ~ storage.get_name ~ '\\config\\' ~ name) %}
|
||||
<dl>
|
||||
<dt>
|
||||
<label for="{{ input_id }}}">{{ lang(title) }}{{ lang('COLON') }}</label>
|
||||
{% if lang_defined(description) %}
|
||||
<br /><span>{{ lang(description) }}</span>
|
||||
{% endif %}
|
||||
</dt>
|
||||
<dd>
|
||||
{% if input_type in ['text', 'password', 'email'] %}
|
||||
<input id="{{ input_id }}" type="{{ input_type }}" name="{{ input_name }}" value="{{ input_value }}" maxlength="{{ options['maxlength'] ?: 255 }}" />
|
||||
{% elseif input_type == 'textarea' %}
|
||||
<textarea id="{{ input_id }}" name="{{ input_name }}">{{ input_value }}</textarea>
|
||||
{% elseif input_type == 'radio' %}
|
||||
{% for option_name, option_value in options['options'] %}
|
||||
<input type="radio" name="{{ input_name }}" value="{{ option_value }}" class="radio"{% if loop.first %} id="{{ input_id }}"{% endif %}{{ (option_value == input_value) ? ' checked="checked"' }}> {{ lang(option_name) }}
|
||||
{% endfor %}
|
||||
{% elseif input_type == 'select' %}
|
||||
<select name="{{ input_name }}" id="{{ input_id }}">
|
||||
{% for provider in PROVIDERS %}
|
||||
{% if provider.is_available %}
|
||||
<fieldset id="{{ storage.get_name }}_{{ provider.get_name }}_settings">
|
||||
<legend>{{ lang('STORAGE_' ~ storage.get_name | upper ~ '_TITLE') }} - {{ lang('STORAGE_ADAPTER_' ~ provider.get_name | upper ~ '_NAME') }}</legend>
|
||||
{% for name, options in provider.get_options %}
|
||||
{% set title = 'STORAGE_ADAPTER_' ~ provider.get_name | upper ~ '_OPTION_' ~ name | upper %}
|
||||
{% set description = 'STORAGE_ADAPTER_' ~ provider.get_name | upper ~ '_OPTION_' ~ name | upper ~ '_EXPLAIN' %}
|
||||
{% set input_id = storage.get_name ~ '_' ~ provider.get_name ~ '_' ~ name %}
|
||||
{% set input_type = options['type'] %}
|
||||
{% set input_name = storage.get_name ~ '[' ~ name ~ ']' %}
|
||||
{% set input_value = attribute(config, 'storage\\' ~ storage.get_name ~ '\\config\\' ~ name) %}
|
||||
<dl>
|
||||
<dt>
|
||||
<label for="{{ input_id }}}">{{ lang(title) }}{{ lang('COLON') }}</label>
|
||||
{% if lang_defined(description) %}
|
||||
<br /><span>{{ lang(description) }}</span>
|
||||
{% endif %}
|
||||
</dt>
|
||||
<dd>
|
||||
{% if input_type in ['text', 'password', 'email'] %}
|
||||
<input id="{{ input_id }}" type="{{ input_type }}" name="{{ input_name }}" value="{{ input_value }}" maxlength="{{ options['maxlength'] ?: 255 }}" />
|
||||
{% elseif input_type == 'textarea' %}
|
||||
<textarea id="{{ input_id }}" name="{{ input_name }}">{{ input_value }}</textarea>
|
||||
{% elseif input_type == 'radio' %}
|
||||
{% for option_name, option_value in options['options'] %}
|
||||
<option value="{{ option_value }}"{{ (option_value == input_value) ? ' selected' }}>{{ lang(option_name) }}</option>
|
||||
<input type="radio" name="{{ input_name }}" value="{{ option_value }}" class="radio"{% if loop.first %} id="{{ input_id }}"{% endif %}{{ (option_value == input_value) ? ' checked="checked"' }}> {{ lang(option_name) }}
|
||||
{% endfor %}
|
||||
</select>
|
||||
{% endif %}
|
||||
</dd>
|
||||
</dl>
|
||||
{% endfor %}
|
||||
</fieldset>
|
||||
{% elseif input_type == 'select' %}
|
||||
<select name="{{ input_name }}" id="{{ input_id }}">
|
||||
{% for option_name, option_value in options['options'] %}
|
||||
<option value="{{ option_value }}"{{ (option_value == input_value) ? ' selected' }}>{{ lang(option_name) }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
{% endif %}
|
||||
</dd>
|
||||
</dl>
|
||||
{% endfor %}
|
||||
</fieldset>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
"symfony/routing": "~5.2",
|
||||
"symfony/twig-bridge": "~5.2",
|
||||
"symfony/yaml": "~5.2",
|
||||
"twig/twig": "^1.0 || ^2.0"
|
||||
"twig/twig": "^3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"fabpot/goutte": "~3.2",
|
||||
|
|
35
phpBB/composer.lock
generated
35
phpBB/composer.lock
generated
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "f33ff5b8d67189b9b8c2bf749f8fd4e0",
|
||||
"content-hash": "8b28fd874f1be23586736a9c2155f5c4",
|
||||
"packages": [
|
||||
{
|
||||
"name": "bantu/ini-get-wrapper",
|
||||
|
@ -1553,24 +1553,26 @@
|
|||
},
|
||||
{
|
||||
"name": "laminas/laminas-zendframework-bridge",
|
||||
"version": "1.1.1",
|
||||
"version": "1.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/laminas/laminas-zendframework-bridge.git",
|
||||
"reference": "6ede70583e101030bcace4dcddd648f760ddf642"
|
||||
"reference": "6cccbddfcfc742eb02158d6137ca5687d92cee32"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/laminas/laminas-zendframework-bridge/zipball/6ede70583e101030bcace4dcddd648f760ddf642",
|
||||
"reference": "6ede70583e101030bcace4dcddd648f760ddf642",
|
||||
"url": "https://api.github.com/repos/laminas/laminas-zendframework-bridge/zipball/6cccbddfcfc742eb02158d6137ca5687d92cee32",
|
||||
"reference": "6cccbddfcfc742eb02158d6137ca5687d92cee32",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^5.6 || ^7.0 || ^8.0"
|
||||
"php": "^7.3 || ^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^5.7 || ^6.5 || ^7.5 || ^8.1 || ^9.3",
|
||||
"squizlabs/php_codesniffer": "^3.5"
|
||||
"psalm/plugin-phpunit": "^0.15.1",
|
||||
"squizlabs/php_codesniffer": "^3.5",
|
||||
"vimeo/psalm": "^4.6"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
|
@ -1609,7 +1611,7 @@
|
|||
"type": "community_bridge"
|
||||
}
|
||||
],
|
||||
"time": "2020-09-14T14:23:00+00:00"
|
||||
"time": "2021-02-25T21:54:58+00:00"
|
||||
},
|
||||
{
|
||||
"name": "lusitanian/oauth",
|
||||
|
@ -4883,16 +4885,16 @@
|
|||
},
|
||||
{
|
||||
"name": "twig/twig",
|
||||
"version": "v2.14.3",
|
||||
"version": "v3.3.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/twigphp/Twig.git",
|
||||
"reference": "8bc568d460d88b25c00c046256ec14a787ea60d9"
|
||||
"reference": "1f3b7e2c06cc05d42936a8ad508ff1db7975cdc5"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/twigphp/Twig/zipball/8bc568d460d88b25c00c046256ec14a787ea60d9",
|
||||
"reference": "8bc568d460d88b25c00c046256ec14a787ea60d9",
|
||||
"url": "https://api.github.com/repos/twigphp/Twig/zipball/1f3b7e2c06cc05d42936a8ad508ff1db7975cdc5",
|
||||
"reference": "1f3b7e2c06cc05d42936a8ad508ff1db7975cdc5",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -4907,13 +4909,10 @@
|
|||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.14-dev"
|
||||
"dev-master": "3.3-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Twig_": "lib/"
|
||||
},
|
||||
"psr-4": {
|
||||
"Twig\\": "src/"
|
||||
}
|
||||
|
@ -4946,7 +4945,7 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/twigphp/Twig/issues",
|
||||
"source": "https://github.com/twigphp/Twig/tree/v2.14.3"
|
||||
"source": "https://github.com/twigphp/Twig/tree/v3.3.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
@ -4958,7 +4957,7 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2021-01-05T15:34:33+00:00"
|
||||
"time": "2021-02-08T09:54:36+00:00"
|
||||
}
|
||||
],
|
||||
"packages-dev": [
|
||||
|
|
|
@ -181,7 +181,7 @@ class environment extends \Twig\Environment
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function render($name, array $context = [])
|
||||
public function render($name, array $context = []) : string
|
||||
{
|
||||
return $this->display_with_assets($name, $context);
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ class environment extends \Twig\Environment
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function display($name, array $context = [])
|
||||
public function display($name, array $context = []) : void
|
||||
{
|
||||
echo $this->display_with_assets($name, $context);
|
||||
}
|
||||
|
@ -259,12 +259,13 @@ class environment extends \Twig\Environment
|
|||
/**
|
||||
* Loads a template by name.
|
||||
*
|
||||
* @param string $cls The template class associated with the given template name
|
||||
* @param string $name The template name
|
||||
* @param integer $index The index if it is an embedded template
|
||||
* @return \Twig\Template A template instance representing the given template name
|
||||
* @throws \Twig\Error\LoaderError
|
||||
*/
|
||||
public function loadTemplate($name, $index = null)
|
||||
public function loadTemplate(string $cls, string $name, int $index = null) : \Twig\Template
|
||||
{
|
||||
if (strpos($name, '@') === false)
|
||||
{
|
||||
|
@ -274,10 +275,10 @@ class environment extends \Twig\Environment
|
|||
{
|
||||
if ($namespace === '__main__')
|
||||
{
|
||||
return parent::loadTemplate($name, $index);
|
||||
return parent::loadTemplate($cls, $name, $index);
|
||||
}
|
||||
|
||||
return parent::loadTemplate('@' . $namespace . '/' . $name, $index);
|
||||
return parent::loadTemplate($this->getTemplateClass('@' . $namespace . '/' . $name), '@' . $namespace . '/' . $name, $index);
|
||||
}
|
||||
catch (\Twig\Error\LoaderError $e)
|
||||
{
|
||||
|
@ -289,7 +290,7 @@ class environment extends \Twig\Environment
|
|||
}
|
||||
else
|
||||
{
|
||||
return parent::loadTemplate($name, $index);
|
||||
return parent::loadTemplate($cls, $name, $index);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace phpbb\template\twig;
|
|||
|
||||
class lexer extends \Twig\Lexer
|
||||
{
|
||||
public function tokenize(\Twig\Source $source)
|
||||
public function tokenize(\Twig\Source $source) : \Twig\TokenStream
|
||||
{
|
||||
$code = $source->getCode();
|
||||
$filename = $source->getName();
|
||||
|
|
|
@ -99,9 +99,9 @@ class loader extends \Twig\Loader\FilesystemLoader
|
|||
*
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function addPath($path, $namespace = self::MAIN_NAMESPACE)
|
||||
public function addPath($path, $namespace = self::MAIN_NAMESPACE) : void
|
||||
{
|
||||
return parent::addPath(filesystem_helper::realpath($path), $namespace);
|
||||
parent::addPath(filesystem_helper::realpath($path), $namespace);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -65,7 +65,7 @@ class event extends \Twig\Node\Node
|
|||
|
||||
// We set the namespace lookup order to be this extension first, then the main path
|
||||
->write("\$this->env->setNamespaceLookUpOrder(array('{$ext_namespace}', '__main__'));\n")
|
||||
->write("\$this->env->loadTemplate('@{$ext_namespace}/{$location}.html')->display(\$context);\n")
|
||||
->write("\$this->env->loadTemplate(\$this->env->getTemplateClass('@{$ext_namespace}/{$location}.html'), '@{$ext_namespace}/{$location}.html')->display(\$context);\n")
|
||||
->write("\$this->env->setNamespaceLookUpOrder(\$previous_look_up_order);\n")
|
||||
;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace phpbb\template\twig\node\expression\binary;
|
|||
|
||||
class equalequal extends \Twig\Node\Expression\Binary\AbstractBinary
|
||||
{
|
||||
public function operator(\Twig\Compiler $compiler)
|
||||
public function operator(\Twig\Compiler $compiler) : \Twig\Compiler
|
||||
{
|
||||
return $compiler->raw('===');
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace phpbb\template\twig\node\expression\binary;
|
|||
|
||||
class notequalequal extends \Twig\Node\Expression\Binary\AbstractBinary
|
||||
{
|
||||
public function operator(\Twig\Compiler $compiler)
|
||||
public function operator(\Twig\Compiler $compiler) : \Twig\Compiler
|
||||
{
|
||||
return $compiler->raw('!==');
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ class includenode extends \Twig\Node\IncludeNode
|
|||
*
|
||||
* @param \Twig\Compiler A Twig\Compiler instance
|
||||
*/
|
||||
public function compile(\Twig\Compiler $compiler)
|
||||
public function compile(\Twig\Compiler $compiler) : void
|
||||
{
|
||||
$compiler->addDebugInfo($this);
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ class defineparser extends \Twig\TokenParser\AbstractTokenParser
|
|||
{
|
||||
// This would happen if someone improperly formed their DEFINE syntax
|
||||
// e.g. <!-- DEFINE $VAR = foo -->
|
||||
throw new \Twig\Error\SyntaxError('Invalid DEFINE', $token->getLine(), $this->parser->getStream()->getSourceContext()->getPath());
|
||||
throw new \Twig\Error\SyntaxError('Invalid DEFINE', $token->getLine(), $this->parser->getStream()->getSourceContext());
|
||||
}
|
||||
|
||||
$stream->expect(\Twig\Token::BLOCK_END_TYPE);
|
||||
|
|
|
@ -23,7 +23,7 @@ class includeparser extends \Twig\TokenParser\IncludeTokenParser
|
|||
*
|
||||
* @return \Twig\Node\Node A Twig\Node instance
|
||||
*/
|
||||
public function parse(\Twig\Token $token)
|
||||
public function parse(\Twig\Token $token) : \Twig\Node\Node
|
||||
{
|
||||
$expr = $this->parser->getExpressionParser()->parseExpression();
|
||||
|
||||
|
@ -37,7 +37,7 @@ class includeparser extends \Twig\TokenParser\IncludeTokenParser
|
|||
*
|
||||
* @return string The tag name
|
||||
*/
|
||||
public function getTag()
|
||||
public function getTag() : string
|
||||
{
|
||||
return 'INCLUDE';
|
||||
}
|
||||
|
|
|
@ -32,12 +32,12 @@
|
|||
<!-- IF AUTHOR_AVATAR --><a href="{U_MESSAGE_AUTHOR}" class="avatar">{AUTHOR_AVATAR}</a><!-- ENDIF -->
|
||||
<!-- EVENT ucp_pm_viewmessage_avatar_after -->
|
||||
</div>
|
||||
{% spaceless %}
|
||||
{% apply spaceless %}
|
||||
{% EVENT ucp_pm_viewmessage_author_full_before %}
|
||||
{MESSAGE_AUTHOR_FULL}
|
||||
{% EVENT ucp_pm_viewmessage_author_full_after %}
|
||||
<!-- IF S_ONLINE --> {{ Icon('iconify', 'fa:circle', lang('ONLINE'), true, 'c-online-icon') }}<!-- ENDIF -->
|
||||
{% endspaceless %}
|
||||
{% endapply %}
|
||||
</dt>
|
||||
|
||||
<!-- EVENT ucp_pm_viewmessage_rank_before -->
|
||||
|
|
|
@ -522,7 +522,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
|
|||
$this->template->set_filenames(array('test' => $filename));
|
||||
$this->assertFileNotExists($this->template_path . '/' . $filename, 'Testing missing file, file cannot exist');
|
||||
|
||||
$this->expectException('Twig_Error_Loader');
|
||||
$this->expectException(\Twig\Error\LoaderError::class);
|
||||
|
||||
$this->display('test');
|
||||
}
|
||||
|
@ -530,7 +530,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
|
|||
|
||||
public function test_invalid_handle()
|
||||
{
|
||||
$this->expectException('Twig_Error_Loader');
|
||||
$this->expectException(\Twig\Error\LoaderError::class);
|
||||
|
||||
$this->display('test');
|
||||
}
|
||||
|
@ -1076,7 +1076,7 @@ EOT
|
|||
|
||||
public function test_define_error()
|
||||
{
|
||||
$this->expectException('Twig_Error_Syntax');
|
||||
$this->expectException(\Twig\Error\SyntaxError::class);
|
||||
$this->run_template('define_error.html', array(), array(), array(), '');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue