From dfe0dc2b581ebe80f5a366af2463c9c9fdbff744 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 5 Jun 2017 20:12:18 +0200 Subject: [PATCH] Use class_exists instead of require to play nice with inlining --- lib/Twig/BaseNodeVisitor.php | 4 ++-- lib/Twig/Compiler.php | 2 +- lib/Twig/Error.php | 2 +- lib/Twig/Extension.php | 2 +- lib/Twig/Extension/Profiler.php | 2 +- lib/Twig/ExtensionInterface.php | 2 +- lib/Twig/Node.php | 2 +- lib/Twig/NodeVisitorInterface.php | 4 ++-- lib/Twig/Parser.php | 4 ++-- lib/Twig/Test/NodeTestCase.php | 4 ++-- lib/Twig/TokenParserInterface.php | 4 ++-- 11 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/Twig/BaseNodeVisitor.php b/lib/Twig/BaseNodeVisitor.php index fac1ec819..6314dacb2 100644 --- a/lib/Twig/BaseNodeVisitor.php +++ b/lib/Twig/BaseNodeVisitor.php @@ -9,8 +9,8 @@ * file that was distributed with this source code. */ -require_once __DIR__.'/Environment.php'; -require_once __DIR__.'/Node.php'; +class_exists('Twig_Environment'); +class_exists('Twig_Node'); /** * Twig_BaseNodeVisitor can be used to make node visitors compatible with Twig 1.x and 2.x. diff --git a/lib/Twig/Compiler.php b/lib/Twig/Compiler.php index 37584f2b0..6c07737c1 100644 --- a/lib/Twig/Compiler.php +++ b/lib/Twig/Compiler.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -require_once __DIR__.'/Node.php'; +class_exists('Twig_Node'); /** * Compiles a node to PHP code. diff --git a/lib/Twig/Error.php b/lib/Twig/Error.php index 763a47474..697f5d343 100644 --- a/lib/Twig/Error.php +++ b/lib/Twig/Error.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -require_once __DIR__.'/Source.php'; +class_exists('Twig_Source'); /** * Twig base exception. diff --git a/lib/Twig/Extension.php b/lib/Twig/Extension.php index 20a794508..12b08b7a8 100644 --- a/lib/Twig/Extension.php +++ b/lib/Twig/Extension.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -require_once __DIR__.'/Environment.php'; +class_exists('Twig_Environment'); abstract class Twig_Extension implements Twig_ExtensionInterface { diff --git a/lib/Twig/Extension/Profiler.php b/lib/Twig/Extension/Profiler.php index 14aaf4eee..20b3063fe 100644 --- a/lib/Twig/Extension/Profiler.php +++ b/lib/Twig/Extension/Profiler.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -require_once __DIR__.'/../Profiler/Profile.php'; +class_exists('Twig_Profiler_Profile'); class Twig_Extension_Profiler extends Twig_Extension { diff --git a/lib/Twig/ExtensionInterface.php b/lib/Twig/ExtensionInterface.php index c029a13d2..b74154e86 100644 --- a/lib/Twig/ExtensionInterface.php +++ b/lib/Twig/ExtensionInterface.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -require_once __DIR__.'/Environment.php'; +class_exists('Twig_Environment'); /** * Interface implemented by extension classes. diff --git a/lib/Twig/Node.php b/lib/Twig/Node.php index 9251b0839..06b9397bd 100644 --- a/lib/Twig/Node.php +++ b/lib/Twig/Node.php @@ -10,7 +10,7 @@ * file that was distributed with this source code. */ -require_once __DIR__.'/Compiler.php'; +class_exists('Twig_Compiler'); /** * Represents a node in the AST. diff --git a/lib/Twig/NodeVisitorInterface.php b/lib/Twig/NodeVisitorInterface.php index 9879b5e5a..4589f0f5a 100644 --- a/lib/Twig/NodeVisitorInterface.php +++ b/lib/Twig/NodeVisitorInterface.php @@ -9,8 +9,8 @@ * file that was distributed with this source code. */ -require_once __DIR__.'/Environment.php'; -require_once __DIR__.'/Node.php'; +class_exists('Twig_Environment'); +class_exists('Twig_Node'); /** * Twig_NodeVisitorInterface is the interface the all node visitor classes must implement. diff --git a/lib/Twig/Parser.php b/lib/Twig/Parser.php index d8bb4d2f0..9afce806b 100644 --- a/lib/Twig/Parser.php +++ b/lib/Twig/Parser.php @@ -10,8 +10,8 @@ * file that was distributed with this source code. */ -require_once __DIR__.'/Node.php'; -require_once __DIR__.'/TokenStream.php'; +class_exists('Twig_Node'); +class_exists('Twig_TokenStream'); /** * Default parser implementation. diff --git a/lib/Twig/Test/NodeTestCase.php b/lib/Twig/Test/NodeTestCase.php index 35d0686bd..9002c7505 100644 --- a/lib/Twig/Test/NodeTestCase.php +++ b/lib/Twig/Test/NodeTestCase.php @@ -9,8 +9,8 @@ * file that was distributed with this source code. */ -require_once __DIR__.'/../Environment.php'; -require_once __DIR__.'/../Node.php'; +class_exists('Twig_Environment'); +class_exists('Twig_Node'); use PHPUnit\Framework\TestCase; diff --git a/lib/Twig/TokenParserInterface.php b/lib/Twig/TokenParserInterface.php index cd559f987..658227edb 100644 --- a/lib/Twig/TokenParserInterface.php +++ b/lib/Twig/TokenParserInterface.php @@ -9,8 +9,8 @@ * file that was distributed with this source code. */ -require_once __DIR__.'/Parser.php'; -require_once __DIR__.'/Token.php'; +class_exists('Twig_Parser'); +class_exists('Twig_Token'); /** * Interface implemented by token parsers.