From 65c0559125c5d11b96162bbb54182c7e85578bdd Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Tue, 12 Mar 2019 15:24:00 +0100 Subject: [PATCH] force loading class aliases used in typehints --- src/Extension/ExtensionInterface.php | 3 +++ src/Node/Node.php | 3 +++ src/NodeVisitor/NodeVisitorInterface.php | 3 +++ src/TokenParser/TokenParserInterface.php | 4 ++++ src/TwigFilter.php | 3 +++ src/TwigFunction.php | 3 +++ 6 files changed, 19 insertions(+) diff --git a/src/Extension/ExtensionInterface.php b/src/Extension/ExtensionInterface.php index 8aa9ec413..3342a166d 100644 --- a/src/Extension/ExtensionInterface.php +++ b/src/Extension/ExtensionInterface.php @@ -18,6 +18,9 @@ use Twig\TwigFilter; use Twig\TwigFunction; use Twig\TwigTest; +// Ensure that the aliased name is loaded to keep BC for classes implementing the typehint with the old aliased name. +class_exists('Twig\Environment'); + /** * Interface implemented by extension classes. * diff --git a/src/Node/Node.php b/src/Node/Node.php index 948d9c10a..2b6ddede7 100644 --- a/src/Node/Node.php +++ b/src/Node/Node.php @@ -14,6 +14,9 @@ namespace Twig\Node; use Twig\Compiler; +// Ensure that the aliased name is loaded to keep BC for classes implementing the typehint with the old aliased name. +class_exists('Twig\Compiler'); + /** * Represents a node in the AST. * diff --git a/src/NodeVisitor/NodeVisitorInterface.php b/src/NodeVisitor/NodeVisitorInterface.php index 1a5cc2d78..9d354262d 100644 --- a/src/NodeVisitor/NodeVisitorInterface.php +++ b/src/NodeVisitor/NodeVisitorInterface.php @@ -13,6 +13,9 @@ namespace Twig\NodeVisitor; use Twig\Environment; +// Ensure that the aliased name is loaded to keep BC for classes implementing the typehint with the old aliased name. +class_exists('Twig\Environment'); + /** * Interface for node visitor classes. * diff --git a/src/TokenParser/TokenParserInterface.php b/src/TokenParser/TokenParserInterface.php index 8e10b9892..d49072a73 100644 --- a/src/TokenParser/TokenParserInterface.php +++ b/src/TokenParser/TokenParserInterface.php @@ -15,6 +15,10 @@ use Twig\Error\SyntaxError; use Twig\Parser; use Twig\Token; +// Ensure that the aliased name is loaded to keep BC for classes implementing the typehint with the old aliased name. +class_exists('Twig\Token'); +class_exists('Twig\Parser'); + /** * Interface implemented by token parsers. * diff --git a/src/TwigFilter.php b/src/TwigFilter.php index f07f066be..65a231d6a 100644 --- a/src/TwigFilter.php +++ b/src/TwigFilter.php @@ -13,6 +13,9 @@ namespace Twig; use Twig\Node\Node; +// Ensure that the aliased name is loaded to keep BC for classes implementing the typehint with the old aliased name. +class_exists('Twig\Node\Node'); + /** * Represents a template filter. * diff --git a/src/TwigFunction.php b/src/TwigFunction.php index af2107ff1..a23e13912 100644 --- a/src/TwigFunction.php +++ b/src/TwigFunction.php @@ -13,6 +13,9 @@ namespace Twig; use Twig\Node\Node; +// Ensure that the aliased name is loaded to keep BC for classes implementing the typehint with the old aliased name. +class_exists('Twig\Node\Node'); + /** * Represents a template function. *