removed InitRuntimeInterface and RuntimeExtensionInterface

This commit is contained in:
Fabien Potencier
2019-03-06 10:22:32 +01:00
parent f84c21fae5
commit 829cb71788
4 changed files with 2 additions and 84 deletions
+1 -2
View File
@@ -374,8 +374,7 @@ class Environment
}
}
// to be removed in 3.0
$this->extensionSet->initRuntime($this);
$this->extensionSet->initRuntime();
return $this->loadedTemplates[$cls] = new $cls($this);
}
-34
View File
@@ -1,34 +0,0 @@
<?php
/*
* This file is part of Twig.
*
* (c) Fabien Potencier
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Twig\Extension;
use Twig\Environment;
/**
* Enables usage of the deprecated Twig\Extension\AbstractExtension::initRuntime() method.
*
* Explicitly implement this interface if you really need to implement the
* deprecated initRuntime() method in your extensions.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @deprecated since Twig 2.7, to be removed in 3.0
*/
interface InitRuntimeInterface
{
/**
* Initializes the runtime environment.
*
* This is where you can load some file that contains filter functions for instance.
*/
public function initRuntime(Environment $environment);
}
+1 -17
View File
@@ -14,7 +14,6 @@ namespace Twig;
use Twig\Error\RuntimeError;
use Twig\Extension\ExtensionInterface;
use Twig\Extension\GlobalsInterface;
use Twig\Extension\InitRuntimeInterface;
use Twig\Extension\StagingExtension;
use Twig\NodeVisitor\NodeVisitorInterface;
use Twig\TokenParser\TokenParserInterface;
@@ -47,24 +46,9 @@ final class ExtensionSet
$this->staging = new StagingExtension();
}
/**
* Initializes the runtime environment.
*
* @deprecated since Twig 2.7
*/
public function initRuntime(Environment $env)
public function initRuntime()
{
if ($this->runtimeInitialized) {
return;
}
$this->runtimeInitialized = true;
foreach ($this->extensions as $extension) {
if ($extension instanceof InitRuntimeInterface) {
$extension->initRuntime($env);
}
}
}
public function hasExtension(string $class): bool
-31
View File
@@ -15,7 +15,6 @@ use Twig\Environment;
use Twig\Extension\AbstractExtension;
use Twig\Extension\ExtensionInterface;
use Twig\Extension\GlobalsInterface;
use Twig\Extension\InitRuntimeInterface;
use Twig\Loader\ArrayLoader;
use Twig\Loader\LoaderInterface;
use Twig\Node\Node;
@@ -305,22 +304,6 @@ class Twig_Tests_EnvironmentTest extends \PHPUnit\Framework\TestCase
$this->assertTrue($twig->isTemplateFresh('page', time()));
}
/**
* @group legacy
*/
public function testInitRuntimeWithAnExtensionUsingInitRuntimeNoDeprecation()
{
$loader = $this->getMockBuilder(LoaderInterface::class)->getMock();
$twig = new Environment($loader);
$loader->expects($this->once())->method('getSourceContext')->will($this->returnValue(new Source('', '')));
$twig->addExtension(new Twig_Tests_EnvironmentTest_ExtensionWithoutDeprecationInitRuntime());
$twig->load('');
// add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above
// can be executed without throwing any deprecations
$this->addToAssertionCount(1);
}
/**
* @expectedException \LogicException
* @expectedExceptionMessage Unable to register extension "Twig_Tests_EnvironmentTest_Extension" as it is already registered.
@@ -479,20 +462,6 @@ class Twig_Tests_EnvironmentTest_NodeVisitor implements NodeVisitorInterface
}
}
class Twig_Tests_EnvironmentTest_ExtensionWithDeprecationInitRuntime extends AbstractExtension
{
public function initRuntime(Environment $env)
{
}
}
class Twig_Tests_EnvironmentTest_ExtensionWithoutDeprecationInitRuntime extends AbstractExtension implements InitRuntimeInterface
{
public function initRuntime(Environment $env)
{
}
}
class Twig_Tests_EnvironmentTest_ExtensionWithoutRuntime extends AbstractExtension
{
public function getFunctions()