minor #33649 Allow Twig 3 (nicolas-grekas)

This PR was merged into the 4.4 branch.

Discussion
----------

Allow Twig 3

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Needs https://github.com/twigphp/Twig/pull/3156
And https://github.com/twigphp/Twig/pull/3158

Commits
-------

09f4eb5cd8 Allow Twig 3
This commit is contained in:
Fabien Potencier 2019-09-23 16:39:44 +02:00
commit 8eaa5a86f4
21 changed files with 52 additions and 9 deletions

View File

@ -20,7 +20,7 @@
"ext-xml": "*",
"doctrine/event-manager": "~1.0",
"doctrine/persistence": "~1.0",
"twig/twig": "^1.41|^2.10",
"twig/twig": "^1.41|^2.10|^3.0",
"psr/cache": "~1.0",
"psr/container": "^1.0",
"psr/link": "^1.0",

View File

@ -33,6 +33,9 @@ class ProfilerExtension extends BaseProfilerExtension
$this->events = new \SplObjectStorage();
}
/**
* @return void
*/
public function enter(Profile $profile)
{
if ($this->stopwatch && $profile->isTemplate()) {
@ -42,6 +45,9 @@ class ProfilerExtension extends BaseProfilerExtension
parent::enter($profile);
}
/**
* @return void
*/
public function leave(Profile $profile)
{
parent::leave($profile);

View File

@ -35,7 +35,7 @@ class DumpNode extends Node
}
/**
* {@inheritdoc}
* @return void
*/
public function compile(Compiler $compiler)
{

View File

@ -27,6 +27,9 @@ class FormThemeNode extends Node
parent::__construct(['form' => $form, 'resources' => $resources], ['only' => $only], $lineno, $tag);
}
/**
* @return void
*/
public function compile(Compiler $compiler)
{
$compiler

View File

@ -26,6 +26,9 @@ use Twig\Node\Expression\FunctionExpression;
*/
class RenderBlockNode extends FunctionExpression
{
/**
* @return void
*/
public function compile(Compiler $compiler)
{
$compiler->addDebugInfo($this);

View File

@ -23,6 +23,9 @@ use Twig\Node\Expression\FunctionExpression;
*/
class SearchAndRenderBlockNode extends FunctionExpression
{
/**
* @return void
*/
public function compile(Compiler $compiler)
{
$compiler->addDebugInfo($this);

View File

@ -29,6 +29,9 @@ class StopwatchNode extends Node
parent::__construct(['body' => $body, 'name' => $name, 'var' => $var], [], $lineno, $tag);
}
/**
* @return void
*/
public function compile(Compiler $compiler)
{
$compiler

View File

@ -27,6 +27,9 @@ class TransDefaultDomainNode extends Node
parent::__construct(['expr' => $expr], [], $lineno, $tag);
}
/**
* @return void
*/
public function compile(Compiler $compiler)
{
// noop as this node is just a marker for TranslationDefaultDomainNodeVisitor

View File

@ -48,6 +48,9 @@ class TransNode extends Node
parent::__construct($nodes, [], $lineno, $tag);
}
/**
* @return void
*/
public function compile(Compiler $compiler)
{
$compiler->addDebugInfo($this);

View File

@ -32,12 +32,18 @@ class TranslationNodeVisitor extends AbstractNodeVisitor
private $enabled = false;
private $messages = [];
/**
* @return void
*/
public function enable()
{
$this->enabled = true;
$this->messages = [];
}
/**
* @return void
*/
public function disable()
{
$this->enabled = false;

View File

@ -15,6 +15,9 @@ use Twig\Loader\FilesystemLoader;
class StubFilesystemLoader extends FilesystemLoader
{
/**
* @return string|null
*/
protected function findTemplate($name, $throw = true)
{
// strip away bundle name

View File

@ -18,7 +18,7 @@
"require": {
"php": "^7.1.3",
"symfony/translation-contracts": "^1.1|^2",
"twig/twig": "^1.41|^2.10"
"twig/twig": "^1.41|^2.10|^3.0"
},
"require-dev": {
"egulias/email-validator": "^2.1.10",

View File

@ -60,7 +60,7 @@
"symfony/property-info": "^3.4|^4.0|^5.0",
"symfony/web-link": "^4.4|^5.0",
"phpdocumentor/reflection-docblock": "^3.0|^4.0",
"twig/twig": "~1.41|~2.10"
"twig/twig": "^1.41|^2.10|^3.0"
},
"conflict": {
"phpdocumentor/reflection-docblock": "<3.0",

View File

@ -44,7 +44,7 @@
"symfony/yaml": "^3.4|^4.0|^5.0",
"symfony/expression-language": "^3.4|^4.0|^5.0",
"doctrine/doctrine-bundle": "~1.5",
"twig/twig": "~1.41|~2.10"
"twig/twig": "^1.41|^2.10|^3.0"
},
"conflict": {
"symfony/browser-kit": "<4.2",

View File

@ -23,6 +23,8 @@ class NativeFilesystemLoader extends FilesystemLoader
{
/**
* {@inheritdoc}
*
* @return string|null
*/
protected function findTemplate($template, $throw = true)
{

View File

@ -22,7 +22,7 @@
"symfony/http-foundation": "^4.3|^5.0",
"symfony/http-kernel": "^4.4",
"symfony/polyfill-ctype": "~1.8",
"twig/twig": "~1.41|~2.10"
"twig/twig": "^1.41|^2.10|^3.0"
},
"require-dev": {
"symfony/asset": "^3.4|^4.0|^5.0",

View File

@ -15,6 +15,7 @@ use Symfony\Bundle\WebProfilerBundle\Profiler\TemplateManager;
use Symfony\Bundle\WebProfilerBundle\Tests\TestCase;
use Symfony\Component\HttpKernel\Profiler\Profile;
use Twig\Environment;
use Twig\Source;
/**
* Test for TemplateManager class.
@ -107,6 +108,7 @@ class TemplateManagerTest extends TestCase
$loader = $this->getMockBuilder('Twig\Loader\SourceContextLoaderInterface')->getMock();
} else {
$loader = $this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock();
$loader->method('getSourceContext')->willReturn(new Source('source-code', 'source-name'));
}
$this->twigEnvironment->expects($this->any())->method('getLoader')->willReturn($loader);

View File

@ -48,11 +48,17 @@ class WebProfilerExtension extends ProfilerExtension
$this->dumper->setOutput($this->output = fopen('php://memory', 'r+b'));
}
/**
* @return void
*/
public function enter(Profile $profile)
{
++$this->stackLevel;
}
/**
* @return void
*/
public function leave(Profile $profile)
{
if (0 === --$this->stackLevel) {

View File

@ -23,7 +23,7 @@
"symfony/routing": "^3.4|^4.0|^5.0",
"symfony/twig-bundle": "^4.2|^5.0",
"symfony/var-dumper": "^3.4|^4.0|^5.0",
"twig/twig": "^1.41|^2.10"
"twig/twig": "^1.41|^2.10|^3.0"
},
"require-dev": {
"symfony/console": "^3.4|^4.0|^5.0",

View File

@ -42,7 +42,7 @@
"symfony/translation-contracts": "^1.1|^2",
"symfony/var-dumper": "^4.1.1|^5.0",
"psr/cache": "~1.0",
"twig/twig": "^1.34|^2.4"
"twig/twig": "^1.34|^2.4|^3.0"
},
"provide": {
"psr/log-implementation": "1.0"

View File

@ -24,7 +24,7 @@
"ext-iconv": "*",
"symfony/console": "^3.4|^4.0|^5.0",
"symfony/process": "^4.4|^5.0",
"twig/twig": "~1.34|~2.4"
"twig/twig": "^1.34|^2.4|^3.0"
},
"conflict": {
"phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0",