diff --git a/src/Environment.php b/src/Environment.php index 003a44816..d26b368e0 100644 --- a/src/Environment.php +++ b/src/Environment.php @@ -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); } diff --git a/src/Extension/InitRuntimeInterface.php b/src/Extension/InitRuntimeInterface.php deleted file mode 100644 index 076bdbb98..000000000 --- a/src/Extension/InitRuntimeInterface.php +++ /dev/null @@ -1,34 +0,0 @@ - - * - * @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); -} diff --git a/src/ExtensionSet.php b/src/ExtensionSet.php index d09ed793c..6e32a0f76 100644 --- a/src/ExtensionSet.php +++ b/src/ExtensionSet.php @@ -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 diff --git a/test/Twig/Tests/EnvironmentTest.php b/test/Twig/Tests/EnvironmentTest.php index ad7ef591e..972757e7e 100644 --- a/test/Twig/Tests/EnvironmentTest.php +++ b/test/Twig/Tests/EnvironmentTest.php @@ -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()