From c86bec7f08cb49bcaa041e6902794fb376ec6072 Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Wed, 27 Mar 2019 13:15:17 -0600 Subject: [PATCH] Replace deprecated Twig class references, refs: #4209. --- modules/cms/classes/CmsCompoundObject.php | 10 +++--- modules/cms/classes/CmsException.php | 4 +-- modules/cms/classes/CodeParser.php | 2 +- modules/cms/classes/Controller.php | 14 ++++---- modules/cms/twig/ComponentNode.php | 12 +++---- modules/cms/twig/ComponentTokenParser.php | 26 +++++++------- modules/cms/twig/ContentNode.php | 12 +++---- modules/cms/twig/ContentTokenParser.php | 26 +++++++------- modules/cms/twig/DebugExtension.php | 18 +++++----- modules/cms/twig/DefaultNode.php | 10 +++--- modules/cms/twig/DefaultTokenParser.php | 14 ++++---- modules/cms/twig/Extension.php | 22 ++++++------ modules/cms/twig/FlashNode.php | 12 +++---- modules/cms/twig/FlashTokenParser.php | 22 ++++++------ modules/cms/twig/FrameworkNode.php | 10 +++--- modules/cms/twig/FrameworkTokenParser.php | 16 ++++----- modules/cms/twig/Loader.php | 8 ++--- modules/cms/twig/PageNode.php | 10 +++--- modules/cms/twig/PageTokenParser.php | 14 ++++---- modules/cms/twig/PartialNode.php | 12 +++---- modules/cms/twig/PartialTokenParser.php | 26 +++++++------- modules/cms/twig/PlaceholderNode.php | 10 +++--- modules/cms/twig/PlaceholderTokenParser.php | 32 ++++++++--------- modules/cms/twig/PutNode.php | 12 +++---- modules/cms/twig/PutTokenParser.php | 22 ++++++------ modules/cms/twig/ScriptsNode.php | 10 +++--- modules/cms/twig/ScriptsTokenParser.php | 14 ++++---- modules/cms/twig/StylesNode.php | 10 +++--- modules/cms/twig/StylesTokenParser.php | 14 ++++---- modules/system/ServiceProvider.php | 5 ++- modules/system/classes/ErrorHandler.php | 2 +- modules/system/classes/MarkupManager.php | 12 +++---- modules/system/twig/Engine.php | 6 ++-- modules/system/twig/Extension.php | 11 +++--- modules/system/twig/Loader.php | 8 ++--- modules/system/twig/MailPartialNode.php | 12 +++---- .../system/twig/MailPartialTokenParser.php | 34 +++++++++---------- 37 files changed, 256 insertions(+), 258 deletions(-) diff --git a/modules/cms/classes/CmsCompoundObject.php b/modules/cms/classes/CmsCompoundObject.php index f5218c76e..6b5346198 100644 --- a/modules/cms/classes/CmsCompoundObject.php +++ b/modules/cms/classes/CmsCompoundObject.php @@ -9,8 +9,8 @@ use Cms\Twig\Extension as CmsTwigExtension; use Cms\Components\ViewBag; use System\Twig\Extension as SystemTwigExtension; use October\Rain\Halcyon\Processors\SectionParser; -use Twig_Source; -use Twig_Environment; +use Twig\Source as TwigSource; +use Twig\Environment as TwigEnvironment; use ApplicationException; /** @@ -405,16 +405,16 @@ class CmsCompoundObject extends CmsObject * @link http://twig.sensiolabs.org/doc/internals.html Twig internals * @param mixed $markup Specifies the markup content. * Use FALSE to load the content from the markup section. - * @return Twig_Node_Module A node tree + * @return Twig\Node\ModuleNode A node tree */ public function getTwigNodeTree($markup = false) { $loader = new TwigLoader(); - $twig = new Twig_Environment($loader, []); + $twig = new TwigEnvironment($loader, []); $twig->addExtension(new CmsTwigExtension()); $twig->addExtension(new SystemTwigExtension); - $stream = $twig->tokenize(new Twig_Source($markup === false ? $this->markup : $markup, 'getTwigNodeTree')); + $stream = $twig->tokenize(new TwigSource($markup === false ? $this->markup : $markup, 'getTwigNodeTree')); return $twig->parse($stream); } diff --git a/modules/cms/classes/CmsException.php b/modules/cms/classes/CmsException.php index 1b5a15998..602a9907e 100644 --- a/modules/cms/classes/CmsException.php +++ b/modules/cms/classes/CmsException.php @@ -1,7 +1,7 @@ twig = new Twig_Environment($this->loader, $options); + $this->twig = new TwigEnvironment($this->loader, $options); $this->twig->addExtension(new CmsTwigExtension($this)); $this->twig->addExtension(new SystemTwigExtension); @@ -1272,7 +1272,7 @@ class Controller /** * Returns the Twig environment. - * @return Twig_Environment + * @return TwigEnvironment */ public function getTwig() { diff --git a/modules/cms/twig/ComponentNode.php b/modules/cms/twig/ComponentNode.php index db3ae85da..c375d154a 100644 --- a/modules/cms/twig/ComponentNode.php +++ b/modules/cms/twig/ComponentNode.php @@ -1,7 +1,7 @@ $nodes], ['names' => $paramNames], $lineno, $tag); } @@ -19,9 +19,9 @@ class ComponentNode extends Twig_Node /** * Compiles the node to PHP. * - * @param Twig_Compiler $compiler A Twig_Compiler instance + * @param TwigCompiler $compiler A TwigCompiler instance */ - public function compile(Twig_Compiler $compiler) + public function compile(TwigCompiler $compiler) { $compiler->addDebugInfo($this); diff --git a/modules/cms/twig/ComponentTokenParser.php b/modules/cms/twig/ComponentTokenParser.php index 450f98860..568721f4a 100644 --- a/modules/cms/twig/ComponentTokenParser.php +++ b/modules/cms/twig/ComponentTokenParser.php @@ -1,9 +1,9 @@ getLine(); $stream = $this->parser->getStream(); @@ -35,18 +35,18 @@ class ComponentTokenParser extends Twig_TokenParser $current = $stream->next(); switch ($current->getType()) { - case Twig_Token::NAME_TYPE: + case TwigToken::NAME_TYPE: $paramNames[] = $current->getValue(); - $stream->expect(Twig_Token::OPERATOR_TYPE, '='); + $stream->expect(TwigToken::OPERATOR_TYPE, '='); $nodes[] = $this->parser->getExpressionParser()->parseExpression(); break; - case Twig_Token::BLOCK_END_TYPE: + case TwigToken::BLOCK_END_TYPE: $end = true; break; default: - throw new Twig_Error_Syntax( + throw new TwigErrorSyntax( sprintf('Invalid syntax in the component tag. Line %s', $lineno), $stream->getCurrent()->getLine(), $stream->getSourceContext() @@ -55,7 +55,7 @@ class ComponentTokenParser extends Twig_TokenParser } } - return new ComponentNode(new Twig_Node($nodes), $paramNames, $token->getLine(), $this->getTag()); + return new ComponentNode(new TwigNode($nodes), $paramNames, $token->getLine(), $this->getTag()); } /** diff --git a/modules/cms/twig/ContentNode.php b/modules/cms/twig/ContentNode.php index 280ea2ce2..02d8ab101 100644 --- a/modules/cms/twig/ContentNode.php +++ b/modules/cms/twig/ContentNode.php @@ -1,7 +1,7 @@ $nodes], ['names' => $paramNames], $lineno, $tag); } @@ -19,9 +19,9 @@ class ContentNode extends Twig_Node /** * Compiles the node to PHP. * - * @param Twig_Compiler $compiler A Twig_Compiler instance + * @param TwigCompiler $compiler A TwigCompiler instance */ - public function compile(Twig_Compiler $compiler) + public function compile(TwigCompiler $compiler) { $compiler->addDebugInfo($this); diff --git a/modules/cms/twig/ContentTokenParser.php b/modules/cms/twig/ContentTokenParser.php index 2ce3cad35..3bedc5796 100644 --- a/modules/cms/twig/ContentTokenParser.php +++ b/modules/cms/twig/ContentTokenParser.php @@ -1,9 +1,9 @@ getLine(); $stream = $this->parser->getStream(); @@ -39,18 +39,18 @@ class ContentTokenParser extends Twig_TokenParser $current = $stream->next(); switch ($current->getType()) { - case Twig_Token::NAME_TYPE: + case TwigToken::NAME_TYPE: $paramNames[] = $current->getValue(); - $stream->expect(Twig_Token::OPERATOR_TYPE, '='); + $stream->expect(TwigToken::OPERATOR_TYPE, '='); $nodes[] = $this->parser->getExpressionParser()->parseExpression(); break; - case Twig_Token::BLOCK_END_TYPE: + case TwigToken::BLOCK_END_TYPE: $end = true; break; default: - throw new Twig_Error_Syntax( + throw new TwigErrorSyntax( sprintf('Invalid syntax in the content tag. Line %s', $lineno), $stream->getCurrent()->getLine(), $stream->getSourceContext() @@ -59,7 +59,7 @@ class ContentTokenParser extends Twig_TokenParser } } - return new ContentNode(new Twig_Node($nodes), $paramNames, $token->getLine(), $this->getTag()); + return new ContentNode(new TwigNode($nodes), $paramNames, $token->getLine(), $this->getTag()); } /** diff --git a/modules/cms/twig/DebugExtension.php b/modules/cms/twig/DebugExtension.php index 5046b5728..ee151b13c 100644 --- a/modules/cms/twig/DebugExtension.php +++ b/modules/cms/twig/DebugExtension.php @@ -1,9 +1,9 @@ ['html'], 'needs_context' => true, 'needs_environment' => true @@ -79,11 +79,11 @@ class DebugExtension extends Twig_Extension /** * Processes the dump variables, if none is supplied, all the twig * template variables are used - * @param Twig_Environment $env + * @param TwigEnvironment $env * @param array $context * @return string */ - public function runDump(Twig_Environment $env, $context) + public function runDump(TwigEnvironment $env, $context) { if (!$env->isDebug()) { return; @@ -97,7 +97,7 @@ class DebugExtension extends Twig_Extension $this->variablePrefix = true; $vars = []; foreach ($context as $key => $value) { - if (!$value instanceof Twig_Template) { + if (!$value instanceof TwigTemplate) { $vars[$key] = $value; } } diff --git a/modules/cms/twig/DefaultNode.php b/modules/cms/twig/DefaultNode.php index 1578b5262..2cc4efbb7 100644 --- a/modules/cms/twig/DefaultNode.php +++ b/modules/cms/twig/DefaultNode.php @@ -1,7 +1,7 @@ addDebugInfo($this) diff --git a/modules/cms/twig/DefaultTokenParser.php b/modules/cms/twig/DefaultTokenParser.php index 8a1f8288e..e601c1b45 100644 --- a/modules/cms/twig/DefaultTokenParser.php +++ b/modules/cms/twig/DefaultTokenParser.php @@ -1,7 +1,7 @@ parser->getStream(); - $stream->expect(Twig_Token::BLOCK_END_TYPE); + $stream->expect(TwigToken::BLOCK_END_TYPE); return new DefaultNode($token->getLine(), $this->getTag()); } diff --git a/modules/cms/twig/Extension.php b/modules/cms/twig/Extension.php index 4b1987f0d..ed07dfb95 100644 --- a/modules/cms/twig/Extension.php +++ b/modules/cms/twig/Extension.php @@ -2,9 +2,9 @@ use Block; use Event; -use Twig_Extension; -use Twig_SimpleFilter; -use Twig_SimpleFunction; +use Twig\Extension\AbstractExtension as TwigExtension; +use Twig\TwigFilter as TwigSimpleFilter; +use Twig\TwigFunction as TwigSimpleFunction; use Cms\Classes\Controller; /** @@ -13,7 +13,7 @@ use Cms\Classes\Controller; * @package october\cms * @author Alexey Bobkov, Samuel Georges */ -class Extension extends Twig_Extension +class Extension extends TwigExtension { /** * @var \Cms\Classes\Controller A reference to the CMS controller. @@ -37,11 +37,11 @@ class Extension extends Twig_Extension public function getFunctions() { return [ - new Twig_SimpleFunction('page', [$this, 'pageFunction'], ['is_safe' => ['html']]), - new Twig_SimpleFunction('partial', [$this, 'partialFunction'], ['is_safe' => ['html']]), - new Twig_SimpleFunction('content', [$this, 'contentFunction'], ['is_safe' => ['html']]), - new Twig_SimpleFunction('component', [$this, 'componentFunction'], ['is_safe' => ['html']]), - new Twig_SimpleFunction('placeholder', [$this, 'placeholderFunction'], ['is_safe' => ['html']]), + new TwigSimpleFunction('page', [$this, 'pageFunction'], ['is_safe' => ['html']]), + new TwigSimpleFunction('partial', [$this, 'partialFunction'], ['is_safe' => ['html']]), + new TwigSimpleFunction('content', [$this, 'contentFunction'], ['is_safe' => ['html']]), + new TwigSimpleFunction('component', [$this, 'componentFunction'], ['is_safe' => ['html']]), + new TwigSimpleFunction('placeholder', [$this, 'placeholderFunction'], ['is_safe' => ['html']]), ]; } @@ -53,8 +53,8 @@ class Extension extends Twig_Extension public function getFilters() { return [ - new Twig_SimpleFilter('page', [$this, 'pageFilter'], ['is_safe' => ['html']]), - new Twig_SimpleFilter('theme', [$this, 'themeFilter'], ['is_safe' => ['html']]), + new TwigSimpleFilter('page', [$this, 'pageFilter'], ['is_safe' => ['html']]), + new TwigSimpleFilter('theme', [$this, 'themeFilter'], ['is_safe' => ['html']]), ]; } diff --git a/modules/cms/twig/FlashNode.php b/modules/cms/twig/FlashNode.php index 0e272e199..cf0f4ac7c 100644 --- a/modules/cms/twig/FlashNode.php +++ b/modules/cms/twig/FlashNode.php @@ -1,7 +1,7 @@ $body], ['name' => $name], $lineno, $tag); } @@ -19,9 +19,9 @@ class FlashNode extends Twig_Node /** * Compiles the node to PHP. * - * @param Twig_Compiler $compiler A Twig_Compiler instance + * @param TwigCompiler $compiler A TwigCompiler instance */ - public function compile(Twig_Compiler $compiler) + public function compile(TwigCompiler $compiler) { $attrib = $this->getAttribute('name'); diff --git a/modules/cms/twig/FlashTokenParser.php b/modules/cms/twig/FlashTokenParser.php index a7acb53cb..e6f707196 100644 --- a/modules/cms/twig/FlashTokenParser.php +++ b/modules/cms/twig/FlashTokenParser.php @@ -1,8 +1,8 @@ getLine(); $stream = $this->parser->getStream(); - if ($token = $stream->nextIf(Twig_Token::NAME_TYPE)) { + if ($token = $stream->nextIf(TwigToken::NAME_TYPE)) { $name = $token->getValue(); } else { $name = 'all'; } - $stream->expect(Twig_Token::BLOCK_END_TYPE); + $stream->expect(TwigToken::BLOCK_END_TYPE); $body = $this->parser->subparse([$this, 'decideIfEnd'], true); - $stream->expect(Twig_Token::BLOCK_END_TYPE); + $stream->expect(TwigToken::BLOCK_END_TYPE); return new FlashNode($name, $body, $lineno, $this->getTag()); } - public function decideIfEnd(Twig_Token $token) + public function decideIfEnd(TwigToken $token) { return $token->test(['endflash']); } diff --git a/modules/cms/twig/FrameworkNode.php b/modules/cms/twig/FrameworkNode.php index 4094f6127..e1af81a92 100644 --- a/modules/cms/twig/FrameworkNode.php +++ b/modules/cms/twig/FrameworkNode.php @@ -1,8 +1,8 @@ getAttribute('name'); $includeExtras = strtolower(trim($attrib)) == 'extras'; diff --git a/modules/cms/twig/FrameworkTokenParser.php b/modules/cms/twig/FrameworkTokenParser.php index 192b3c011..cea6aed82 100644 --- a/modules/cms/twig/FrameworkTokenParser.php +++ b/modules/cms/twig/FrameworkTokenParser.php @@ -1,7 +1,7 @@ getLine(); $stream = $this->parser->getStream(); $name = null; - if ($token = $stream->nextIf(Twig_Token::NAME_TYPE)) { + if ($token = $stream->nextIf(TwigToken::NAME_TYPE)) { $name = $token->getValue(); } - $stream->expect(Twig_Token::BLOCK_END_TYPE); + $stream->expect(TwigToken::BLOCK_END_TYPE); return new FrameworkNode($name, $lineno, $this->getTag()); } diff --git a/modules/cms/twig/Loader.php b/modules/cms/twig/Loader.php index 494f1bc25..59a85f70a 100644 --- a/modules/cms/twig/Loader.php +++ b/modules/cms/twig/Loader.php @@ -1,8 +1,8 @@ $content]; Event::fire('cms.template.processTwigContent', [$this->obj, $dataHolder]); - return new Twig_Source($dataHolder->content, $name); + return new TwigSource($dataHolder->content, $name); } /** diff --git a/modules/cms/twig/PageNode.php b/modules/cms/twig/PageNode.php index 39ef0a81b..32c92f7a6 100644 --- a/modules/cms/twig/PageNode.php +++ b/modules/cms/twig/PageNode.php @@ -1,7 +1,7 @@ addDebugInfo($this) diff --git a/modules/cms/twig/PageTokenParser.php b/modules/cms/twig/PageTokenParser.php index 056aac58d..1c6b48139 100644 --- a/modules/cms/twig/PageTokenParser.php +++ b/modules/cms/twig/PageTokenParser.php @@ -1,7 +1,7 @@ parser->getStream(); - $stream->expect(Twig_Token::BLOCK_END_TYPE); + $stream->expect(TwigToken::BLOCK_END_TYPE); return new PageNode($token->getLine(), $this->getTag()); } diff --git a/modules/cms/twig/PartialNode.php b/modules/cms/twig/PartialNode.php index 003bcf2fc..c6a484289 100644 --- a/modules/cms/twig/PartialNode.php +++ b/modules/cms/twig/PartialNode.php @@ -1,7 +1,7 @@ $nodes], ['names' => $paramNames], $lineno, $tag); } @@ -19,9 +19,9 @@ class PartialNode extends Twig_Node /** * Compiles the node to PHP. * - * @param Twig_Compiler $compiler A Twig_Compiler instance + * @param TwigCompiler $compiler A TwigCompiler instance */ - public function compile(Twig_Compiler $compiler) + public function compile(TwigCompiler $compiler) { $compiler->addDebugInfo($this); diff --git a/modules/cms/twig/PartialTokenParser.php b/modules/cms/twig/PartialTokenParser.php index 57e452ec6..b99625226 100644 --- a/modules/cms/twig/PartialTokenParser.php +++ b/modules/cms/twig/PartialTokenParser.php @@ -1,9 +1,9 @@ getLine(); $stream = $this->parser->getStream(); @@ -39,18 +39,18 @@ class PartialTokenParser extends Twig_TokenParser $current = $stream->next(); switch ($current->getType()) { - case Twig_Token::NAME_TYPE: + case TwigToken::NAME_TYPE: $paramNames[] = $current->getValue(); - $stream->expect(Twig_Token::OPERATOR_TYPE, '='); + $stream->expect(TwigToken::OPERATOR_TYPE, '='); $nodes[] = $this->parser->getExpressionParser()->parseExpression(); break; - case Twig_Token::BLOCK_END_TYPE: + case TwigToken::BLOCK_END_TYPE: $end = true; break; default: - throw new Twig_Error_Syntax( + throw new TwigErrorSyntax( sprintf('Invalid syntax in the partial tag. Line %s', $lineno), $stream->getCurrent()->getLine(), $stream->getSourceContext() @@ -59,7 +59,7 @@ class PartialTokenParser extends Twig_TokenParser } } - return new PartialNode(new Twig_Node($nodes), $paramNames, $token->getLine(), $this->getTag()); + return new PartialNode(new TwigNode($nodes), $paramNames, $token->getLine(), $this->getTag()); } /** diff --git a/modules/cms/twig/PlaceholderNode.php b/modules/cms/twig/PlaceholderNode.php index 62049d41d..4a40c757e 100644 --- a/modules/cms/twig/PlaceholderNode.php +++ b/modules/cms/twig/PlaceholderNode.php @@ -1,7 +1,7 @@ hasNode('default'); $varId = '__placeholder_'.$this->getAttribute('name').'_default_contents'; diff --git a/modules/cms/twig/PlaceholderTokenParser.php b/modules/cms/twig/PlaceholderTokenParser.php index 93e96c186..59d7c3d8b 100644 --- a/modules/cms/twig/PlaceholderTokenParser.php +++ b/modules/cms/twig/PlaceholderTokenParser.php @@ -1,9 +1,9 @@ parser->getStream(); - $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue(); + $name = $stream->expect(TwigToken::NAME_TYPE)->getValue(); $body = null; $params = []; - if ($stream->test(Twig_Token::NAME_TYPE, 'default')) { + if ($stream->test(TwigToken::NAME_TYPE, 'default')) { $stream->next(); $params = $this->loadParams($stream); $body = $this->parser->subparse([$this, 'decidePlaceholderEnd'], true); - $stream->expect(Twig_Token::BLOCK_END_TYPE); + $stream->expect(TwigToken::BLOCK_END_TYPE); } else { $params = $this->loadParams($stream); @@ -48,7 +48,7 @@ class PlaceholderTokenParser extends Twig_TokenParser return new PlaceholderNode($name, $params, $body, $token->getLine(), $this->getTag()); } - public function decidePlaceholderEnd(Twig_Token $token) + public function decidePlaceholderEnd(TwigToken $token) { return $token->test('endplaceholder'); } @@ -62,19 +62,19 @@ class PlaceholderTokenParser extends Twig_TokenParser $current = $stream->next(); switch ($current->getType()) { - case Twig_Token::NAME_TYPE: + case TwigToken::NAME_TYPE: $paramName = $current->getValue(); - $stream->expect(Twig_Token::OPERATOR_TYPE, '='); + $stream->expect(TwigToken::OPERATOR_TYPE, '='); $current = $stream->next(); $params[$paramName] = $current->getValue(); break; - case Twig_Token::BLOCK_END_TYPE: + case TwigToken::BLOCK_END_TYPE: $end = true; break; default: - throw new Twig_Error_Syntax( + throw new TwigErrorSyntax( sprintf('Invalid syntax in the placeholder tag. Line %s', $stream->getCurrent()->getLine()), $stream->getCurrent()->getLine(), $stream->getSourceContext() diff --git a/modules/cms/twig/PutNode.php b/modules/cms/twig/PutNode.php index c98e38731..82ff67c9b 100644 --- a/modules/cms/twig/PutNode.php +++ b/modules/cms/twig/PutNode.php @@ -1,7 +1,7 @@ $body], ['name' => $name, 'endType' => $endType], $lineno, $tag); } @@ -19,9 +19,9 @@ class PutNode extends Twig_Node /** * Compiles the node to PHP. * - * @param Twig_Compiler $compiler A Twig_Compiler instance + * @param TwigCompiler $compiler A TwigCompiler instance */ - public function compile(Twig_Compiler $compiler) + public function compile(TwigCompiler $compiler) { $compiler ->addDebugInfo($this) diff --git a/modules/cms/twig/PutTokenParser.php b/modules/cms/twig/PutTokenParser.php index f13248522..ec5572bf2 100644 --- a/modules/cms/twig/PutTokenParser.php +++ b/modules/cms/twig/PutTokenParser.php @@ -1,7 +1,7 @@ getLine(); $stream = $this->parser->getStream(); - $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue(); - $stream->expect(Twig_Token::BLOCK_END_TYPE); + $name = $stream->expect(TwigToken::NAME_TYPE)->getValue(); + $stream->expect(TwigToken::BLOCK_END_TYPE); $body = $this->parser->subparse([$this, 'decidePutEnd'], true); $endType = null; - if ($token = $stream->nextIf(Twig_Token::NAME_TYPE)) { + if ($token = $stream->nextIf(TwigToken::NAME_TYPE)) { $endType = $token->getValue(); } - $stream->expect(Twig_Token::BLOCK_END_TYPE); + $stream->expect(TwigToken::BLOCK_END_TYPE); return new PutNode($body, $name, $endType, $lineno, $this->getTag()); } - public function decidePutEnd(Twig_Token $token) + public function decidePutEnd(TwigToken $token) { return $token->test('endput'); } diff --git a/modules/cms/twig/ScriptsNode.php b/modules/cms/twig/ScriptsNode.php index 72324b6fb..96c71b642 100644 --- a/modules/cms/twig/ScriptsNode.php +++ b/modules/cms/twig/ScriptsNode.php @@ -1,7 +1,7 @@ addDebugInfo($this) diff --git a/modules/cms/twig/ScriptsTokenParser.php b/modules/cms/twig/ScriptsTokenParser.php index ac3ab21fb..8965aee85 100644 --- a/modules/cms/twig/ScriptsTokenParser.php +++ b/modules/cms/twig/ScriptsTokenParser.php @@ -1,7 +1,7 @@ parser->getStream(); - $stream->expect(Twig_Token::BLOCK_END_TYPE); + $stream->expect(TwigToken::BLOCK_END_TYPE); return new ScriptsNode($token->getLine(), $this->getTag()); } diff --git a/modules/cms/twig/StylesNode.php b/modules/cms/twig/StylesNode.php index 5905d001d..e3ad91a5e 100644 --- a/modules/cms/twig/StylesNode.php +++ b/modules/cms/twig/StylesNode.php @@ -1,7 +1,7 @@ addDebugInfo($this) diff --git a/modules/cms/twig/StylesTokenParser.php b/modules/cms/twig/StylesTokenParser.php index 05621d0b9..eaa934626 100644 --- a/modules/cms/twig/StylesTokenParser.php +++ b/modules/cms/twig/StylesTokenParser.php @@ -1,7 +1,7 @@ parser->getStream(); - $stream->expect(Twig_Token::BLOCK_END_TYPE); + $stream->expect(TwigToken::BLOCK_END_TYPE); return new StylesNode($token->getLine(), $this->getTag()); } diff --git a/modules/system/ServiceProvider.php b/modules/system/ServiceProvider.php index 4711de05d..d10e42c8e 100644 --- a/modules/system/ServiceProvider.php +++ b/modules/system/ServiceProvider.php @@ -8,8 +8,7 @@ use Backend; use Request; use BackendMenu; use BackendAuth; -use Twig_Environment; -use Twig_Loader_String; +use Twig\Environment as TwigEnvironment; use System\Classes\MailManager; use System\Classes\ErrorHandler; use System\Classes\MarkupManager; @@ -281,7 +280,7 @@ class ServiceProvider extends ModuleServiceProvider * Register system Twig environment */ App::singleton('twig.environment', function ($app) { - $twig = new Twig_Environment(new TwigLoader, ['auto_reload' => true]); + $twig = new TwigEnvironment(new TwigLoader, ['auto_reload' => true]); $twig->addExtension(new TwigExtension); return $twig; }); diff --git a/modules/system/classes/ErrorHandler.php b/modules/system/classes/ErrorHandler.php index e0e02b7f7..910f044e8 100644 --- a/modules/system/classes/ErrorHandler.php +++ b/modules/system/classes/ErrorHandler.php @@ -24,7 +24,7 @@ class ErrorHandler extends ErrorHandlerBase // { // // The Twig runtime error is not very useful // if ( - // $proposedException instanceof Twig_Error_Runtime && + // $proposedException instanceof \Twig\Error\RuntimeError && // ($previousException = $proposedException->getPrevious()) && // (!$previousException instanceof CmsException) // ) { diff --git a/modules/system/classes/MarkupManager.php b/modules/system/classes/MarkupManager.php index 7708021a2..64a3e0526 100644 --- a/modules/system/classes/MarkupManager.php +++ b/modules/system/classes/MarkupManager.php @@ -1,9 +1,9 @@ ['html']]); + $functions[] = new TwigSimpleFunction($name, $callable, ['is_safe' => ['html']]); } return $functions; @@ -277,7 +277,7 @@ class MarkupManager throw new ApplicationException(sprintf('The markup filter for %s is not callable.', $name)); } - $filters[] = new Twig_SimpleFilter($name, $callable, ['is_safe' => ['html']]); + $filters[] = new TwigSimpleFilter($name, $callable, ['is_safe' => ['html']]); } return $filters; @@ -296,7 +296,7 @@ class MarkupManager $extraParsers = $this->listTokenParsers(); foreach ($extraParsers as $obj) { - if (!$obj instanceof Twig_TokenParser) { + if (!$obj instanceof TwigTokenParser) { continue; } diff --git a/modules/system/twig/Engine.php b/modules/system/twig/Engine.php index 995edb263..affcab34e 100644 --- a/modules/system/twig/Engine.php +++ b/modules/system/twig/Engine.php @@ -1,6 +1,6 @@ environment = $environment; } diff --git a/modules/system/twig/Extension.php b/modules/system/twig/Extension.php index 36b7b8ae3..71e1e6fed 100644 --- a/modules/system/twig/Extension.php +++ b/modules/system/twig/Extension.php @@ -1,8 +1,8 @@ ['html']]), - new Twig_SimpleFilter('media', [$this, 'mediaFilter'], ['is_safe' => ['html']]), + new TwigSimpleFilter('app', [$this, 'appFilter'], ['is_safe' => ['html']]), + new TwigSimpleFilter('media', [$this, 'mediaFilter'], ['is_safe' => ['html']]), ]; /* diff --git a/modules/system/twig/Loader.php b/modules/system/twig/Loader.php index a581df9b9..6be498588 100644 --- a/modules/system/twig/Loader.php +++ b/modules/system/twig/Loader.php @@ -2,8 +2,8 @@ use App; use File; -use Twig_Source; -use Twig_LoaderInterface; +use Twig\Source as TwigSource;; +use Twig\Loader\LoaderInterface as TwigLoaderInterface; use Exception; /** @@ -12,7 +12,7 @@ use Exception; * @package october\system * @author Alexey Bobkov, Samuel Georges */ -class Loader implements Twig_LoaderInterface +class Loader implements TwigLoaderInterface { /** * @var string Expected file extension @@ -52,7 +52,7 @@ class Loader implements Twig_LoaderInterface public function getSourceContext($name) { - return new Twig_Source(File::get($this->findTemplate($name)), $name); + return new TwigSource(File::get($this->findTemplate($name)), $name); } public function getCacheKey($name) diff --git a/modules/system/twig/MailPartialNode.php b/modules/system/twig/MailPartialNode.php index 9b54c536a..ebf38b43e 100644 --- a/modules/system/twig/MailPartialNode.php +++ b/modules/system/twig/MailPartialNode.php @@ -1,7 +1,7 @@ $nodes]; @@ -25,9 +25,9 @@ class MailPartialNode extends Twig_Node /** * Compiles the node to PHP. * - * @param Twig_Compiler $compiler A Twig_Compiler instance + * @param TwigCompiler $compiler A TwigCompiler instance */ - public function compile(Twig_Compiler $compiler) + public function compile(TwigCompiler $compiler) { $compiler->addDebugInfo($this); diff --git a/modules/system/twig/MailPartialTokenParser.php b/modules/system/twig/MailPartialTokenParser.php index d0f273ccf..f69097762 100644 --- a/modules/system/twig/MailPartialTokenParser.php +++ b/modules/system/twig/MailPartialTokenParser.php @@ -1,9 +1,9 @@ getLine(); $stream = $this->parser->getStream(); @@ -41,26 +41,26 @@ class MailPartialTokenParser extends Twig_TokenParser $current = $stream->next(); if ( - $current->test(Twig_Token::NAME_TYPE, 'body') && - !$stream->test(Twig_Token::OPERATOR_TYPE, '=') + $current->test(TwigToken::NAME_TYPE, 'body') && + !$stream->test(TwigToken::OPERATOR_TYPE, '=') ) { $hasBody = true; $current = $stream->next(); } switch ($current->getType()) { - case Twig_Token::NAME_TYPE: + case TwigToken::NAME_TYPE: $paramNames[] = $current->getValue(); - $stream->expect(Twig_Token::OPERATOR_TYPE, '='); + $stream->expect(TwigToken::OPERATOR_TYPE, '='); $nodes[] = $this->parser->getExpressionParser()->parseExpression(); break; - case Twig_Token::BLOCK_END_TYPE: + case TwigToken::BLOCK_END_TYPE: $end = true; break; default: - throw new Twig_Error_Syntax( + throw new TwigErrorSyntax( sprintf('Invalid syntax in the partial tag. Line %s', $lineno), $stream->getCurrent()->getLine(), $stream->getSourceContext() @@ -71,13 +71,13 @@ class MailPartialTokenParser extends Twig_TokenParser if ($hasBody) { $body = $this->parser->subparse([$this, 'decidePartialEnd'], true); - $stream->expect(Twig_Token::BLOCK_END_TYPE); + $stream->expect(TwigToken::BLOCK_END_TYPE); } - return new MailPartialNode(new Twig_Node($nodes), $paramNames, $body, $token->getLine(), $this->getTag()); + return new MailPartialNode(new TwigNode($nodes), $paramNames, $body, $token->getLine(), $this->getTag()); } - public function decidePartialEnd(Twig_Token $token) + public function decidePartialEnd(TwigToken $token) { return $token->test('endpartial'); }