Merge branch '1.7' into feature/clockwork-twig

This commit is contained in:
Andy Miller
2019-06-02 14:23:40 -06:00
21 changed files with 255 additions and 213 deletions

View File

@@ -4,7 +4,8 @@
1. [](#new)
* Added support for [clokcwork](https://underground.works/clockwork) developer tools
* Added support for [Tideways XHProf](https://github.com/tideways/php-xhprof-extension) PHP Extension for profiling method calls
* Added support for Twig 2.10
* Updated Symfony Components to 4.3
* Added support for Twig 2.11 (compatible with Twig 1.40+)
# v1.6.10
## mm/dd/2019

145
composer.lock generated
View File

@@ -1838,25 +1838,27 @@
},
{
"name": "symfony/console",
"version": "v4.2.9",
"version": "v4.3.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "7a293c9a4587a92e6a0e81edb0bea54071b1b99d"
"reference": "707b619d2c3bedf0224d56f95f77dabc60102305"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/7a293c9a4587a92e6a0e81edb0bea54071b1b99d",
"reference": "7a293c9a4587a92e6a0e81edb0bea54071b1b99d",
"url": "https://api.github.com/repos/symfony/console/zipball/707b619d2c3bedf0224d56f95f77dabc60102305",
"reference": "707b619d2c3bedf0224d56f95f77dabc60102305",
"shasum": ""
},
"require": {
"php": "^7.1.3",
"symfony/contracts": "^1.0",
"symfony/polyfill-mbstring": "~1.0"
"symfony/polyfill-mbstring": "~1.0",
"symfony/polyfill-php73": "^1.8",
"symfony/service-contracts": "^1.1"
},
"conflict": {
"symfony/dependency-injection": "<3.4",
"symfony/event-dispatcher": "<4.3",
"symfony/process": "<3.3"
},
"provide": {
@@ -1866,9 +1868,10 @@
"psr/log": "~1.0",
"symfony/config": "~3.4|~4.0",
"symfony/dependency-injection": "~3.4|~4.0",
"symfony/event-dispatcher": "~3.4|~4.0",
"symfony/event-dispatcher": "^4.3",
"symfony/lock": "~3.4|~4.0",
"symfony/process": "~3.4|~4.0"
"symfony/process": "~3.4|~4.0",
"symfony/var-dumper": "^4.3"
},
"suggest": {
"psr/log": "For using the console logger",
@@ -1879,7 +1882,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.2-dev"
"dev-master": "4.3-dev"
}
},
"autoload": {
@@ -1906,7 +1909,7 @@
],
"description": "Symfony Console Component",
"homepage": "https://symfony.com",
"time": "2019-05-09T09:19:46+00:00"
"time": "2019-05-27T08:16:38+00:00"
},
{
"name": "symfony/contracts",
@@ -1989,30 +1992,36 @@
},
{
"name": "symfony/event-dispatcher",
"version": "v4.2.9",
"version": "v4.3.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher.git",
"reference": "fbce53cd74ac509cbe74b6f227622650ab759b02"
"reference": "c71314cd3b9420b732e1526f33a24eff5430b5b3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/fbce53cd74ac509cbe74b6f227622650ab759b02",
"reference": "fbce53cd74ac509cbe74b6f227622650ab759b02",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/c71314cd3b9420b732e1526f33a24eff5430b5b3",
"reference": "c71314cd3b9420b732e1526f33a24eff5430b5b3",
"shasum": ""
},
"require": {
"php": "^7.1.3",
"symfony/contracts": "^1.0"
"symfony/event-dispatcher-contracts": "^1.1"
},
"conflict": {
"symfony/dependency-injection": "<3.4"
},
"provide": {
"psr/event-dispatcher-implementation": "1.0",
"symfony/event-dispatcher-implementation": "1.1"
},
"require-dev": {
"psr/log": "~1.0",
"symfony/config": "~3.4|~4.0",
"symfony/dependency-injection": "~3.4|~4.0",
"symfony/expression-language": "~3.4|~4.0",
"symfony/http-foundation": "^3.4|^4.0",
"symfony/service-contracts": "^1.1",
"symfony/stopwatch": "~3.4|~4.0"
},
"suggest": {
@@ -2022,7 +2031,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.2-dev"
"dev-master": "4.3-dev"
}
},
"autoload": {
@@ -2049,7 +2058,7 @@
],
"description": "Symfony EventDispatcher Component",
"homepage": "https://symfony.com",
"time": "2019-04-06T13:51:08+00:00"
"time": "2019-05-28T07:50:59+00:00"
},
{
"name": "symfony/polyfill-ctype",
@@ -2342,16 +2351,16 @@
},
{
"name": "symfony/process",
"version": "v4.2.9",
"version": "v4.3.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/process.git",
"reference": "57f11a07b34f009ef64a3f95ad218f895ad95374"
"reference": "a5e3dd4e93a364668034a3cb6efa963d0b33ab45"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/process/zipball/57f11a07b34f009ef64a3f95ad218f895ad95374",
"reference": "57f11a07b34f009ef64a3f95ad218f895ad95374",
"url": "https://api.github.com/repos/symfony/process/zipball/a5e3dd4e93a364668034a3cb6efa963d0b33ab45",
"reference": "a5e3dd4e93a364668034a3cb6efa963d0b33ab45",
"shasum": ""
},
"require": {
@@ -2360,7 +2369,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.2-dev"
"dev-master": "4.3-dev"
}
},
"autoload": {
@@ -2387,20 +2396,20 @@
],
"description": "Symfony Process Component",
"homepage": "https://symfony.com",
"time": "2019-05-26T20:47:34+00:00"
"time": "2019-05-26T20:47:49+00:00"
},
{
"name": "symfony/var-dumper",
"version": "v4.2.9",
"version": "v4.3.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/var-dumper.git",
"reference": "3c4084cb1537c0e2ad41aad622bbf55a44a5c9ce"
"reference": "2fd2ecf7913fb96f0c2e941ca15bb702184c6574"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/3c4084cb1537c0e2ad41aad622bbf55a44a5c9ce",
"reference": "3c4084cb1537c0e2ad41aad622bbf55a44a5c9ce",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/2fd2ecf7913fb96f0c2e941ca15bb702184c6574",
"reference": "2fd2ecf7913fb96f0c2e941ca15bb702184c6574",
"shasum": ""
},
"require": {
@@ -2429,7 +2438,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.2-dev"
"dev-master": "4.3-dev"
}
},
"autoload": {
@@ -2463,20 +2472,20 @@
"debug",
"dump"
],
"time": "2019-05-01T12:55:36+00:00"
"time": "2019-05-01T12:55:49+00:00"
},
{
"name": "symfony/yaml",
"version": "v4.2.9",
"version": "v4.3.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
"reference": "6712daf03ee25b53abb14e7e8e0ede1a770efdb1"
"reference": "c60ecf5ba842324433b46f58dc7afc4487dbab99"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/6712daf03ee25b53abb14e7e8e0ede1a770efdb1",
"reference": "6712daf03ee25b53abb14e7e8e0ede1a770efdb1",
"url": "https://api.github.com/repos/symfony/yaml/zipball/c60ecf5ba842324433b46f58dc7afc4487dbab99",
"reference": "c60ecf5ba842324433b46f58dc7afc4487dbab99",
"shasum": ""
},
"require": {
@@ -2495,7 +2504,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.2-dev"
"dev-master": "4.3-dev"
}
},
"autoload": {
@@ -2522,20 +2531,20 @@
],
"description": "Symfony Yaml Component",
"homepage": "https://symfony.com",
"time": "2019-03-30T15:58:42+00:00"
"time": "2019-04-06T14:04:46+00:00"
},
{
"name": "twig/twig",
"version": "v2.10.0",
"version": "v2.11.0",
"source": {
"type": "git",
"url": "https://github.com/twigphp/Twig.git",
"reference": "5240e21982885b76629552d83b4ebb6d41ccde6b"
"reference": "c344879ae57dc1487b1df3e3d8325936125ba2cc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/5240e21982885b76629552d83b4ebb6d41ccde6b",
"reference": "5240e21982885b76629552d83b4ebb6d41ccde6b",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/c344879ae57dc1487b1df3e3d8325936125ba2cc",
"reference": "c344879ae57dc1487b1df3e3d8325936125ba2cc",
"shasum": ""
},
"require": {
@@ -2551,7 +2560,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.10-dev"
"dev-master": "2.11-dev"
}
},
"autoload": {
@@ -2589,7 +2598,7 @@
"keywords": [
"templating"
],
"time": "2019-05-14T12:03:52+00:00"
"time": "2019-05-31T06:21:42+00:00"
},
{
"name": "willdurand/negotiation",
@@ -5311,16 +5320,16 @@
},
{
"name": "symfony/browser-kit",
"version": "v4.2.9",
"version": "v4.3.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/browser-kit.git",
"reference": "c09c18cca96d7067152f78956faf55346c338283"
"reference": "3fa7d8cbd2e5006038a09b8ef93f3859a89b627e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/browser-kit/zipball/c09c18cca96d7067152f78956faf55346c338283",
"reference": "c09c18cca96d7067152f78956faf55346c338283",
"url": "https://api.github.com/repos/symfony/browser-kit/zipball/3fa7d8cbd2e5006038a09b8ef93f3859a89b627e",
"reference": "3fa7d8cbd2e5006038a09b8ef93f3859a89b627e",
"shasum": ""
},
"require": {
@@ -5329,6 +5338,8 @@
},
"require-dev": {
"symfony/css-selector": "~3.4|~4.0",
"symfony/http-client": "^4.3",
"symfony/mime": "^4.3",
"symfony/process": "~3.4|~4.0"
},
"suggest": {
@@ -5337,7 +5348,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.2-dev"
"dev-master": "4.3-dev"
}
},
"autoload": {
@@ -5364,20 +5375,20 @@
],
"description": "Symfony BrowserKit Component",
"homepage": "https://symfony.com",
"time": "2019-04-07T09:56:43+00:00"
"time": "2019-04-15T20:15:25+00:00"
},
{
"name": "symfony/css-selector",
"version": "v4.2.9",
"version": "v4.3.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/css-selector.git",
"reference": "48eddf66950fa57996e1be4a55916d65c10c604a"
"reference": "105c98bb0c5d8635bea056135304bd8edcc42b4d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/css-selector/zipball/48eddf66950fa57996e1be4a55916d65c10c604a",
"reference": "48eddf66950fa57996e1be4a55916d65c10c604a",
"url": "https://api.github.com/repos/symfony/css-selector/zipball/105c98bb0c5d8635bea056135304bd8edcc42b4d",
"reference": "105c98bb0c5d8635bea056135304bd8edcc42b4d",
"shasum": ""
},
"require": {
@@ -5386,7 +5397,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.2-dev"
"dev-master": "4.3-dev"
}
},
"autoload": {
@@ -5417,20 +5428,20 @@
],
"description": "Symfony CssSelector Component",
"homepage": "https://symfony.com",
"time": "2019-01-16T20:31:39+00:00"
"time": "2019-01-16T21:53:39+00:00"
},
{
"name": "symfony/dom-crawler",
"version": "v4.2.9",
"version": "v4.3.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/dom-crawler.git",
"reference": "53c97769814c80a84a8403efcf3ae7ae966d53bb"
"reference": "28edb1d371640654fbfb9df53d70fa03fdf69fb6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/dom-crawler/zipball/53c97769814c80a84a8403efcf3ae7ae966d53bb",
"reference": "53c97769814c80a84a8403efcf3ae7ae966d53bb",
"url": "https://api.github.com/repos/symfony/dom-crawler/zipball/28edb1d371640654fbfb9df53d70fa03fdf69fb6",
"reference": "28edb1d371640654fbfb9df53d70fa03fdf69fb6",
"shasum": ""
},
"require": {
@@ -5438,7 +5449,11 @@
"symfony/polyfill-ctype": "~1.8",
"symfony/polyfill-mbstring": "~1.0"
},
"conflict": {
"masterminds/html5": "<2.6"
},
"require-dev": {
"masterminds/html5": "^2.6",
"symfony/css-selector": "~3.4|~4.0"
},
"suggest": {
@@ -5447,7 +5462,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.2-dev"
"dev-master": "4.3-dev"
}
},
"autoload": {
@@ -5474,20 +5489,20 @@
],
"description": "Symfony DomCrawler Component",
"homepage": "https://symfony.com",
"time": "2019-02-23T15:17:42+00:00"
"time": "2019-04-26T05:53:56+00:00"
},
{
"name": "symfony/finder",
"version": "v4.2.9",
"version": "v4.3.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
"reference": "e0ff582c4b038567a7c6630f136488b1d793e6a9"
"reference": "b3d4f4c0e4eadfdd8b296af9ca637cfbf51d8176"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/e0ff582c4b038567a7c6630f136488b1d793e6a9",
"reference": "e0ff582c4b038567a7c6630f136488b1d793e6a9",
"url": "https://api.github.com/repos/symfony/finder/zipball/b3d4f4c0e4eadfdd8b296af9ca637cfbf51d8176",
"reference": "b3d4f4c0e4eadfdd8b296af9ca637cfbf51d8176",
"shasum": ""
},
"require": {
@@ -5496,7 +5511,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.2-dev"
"dev-master": "4.3-dev"
}
},
"autoload": {
@@ -5523,7 +5538,7 @@
],
"description": "Symfony Finder Component",
"homepage": "https://symfony.com",
"time": "2019-05-26T20:47:34+00:00"
"time": "2019-05-26T20:47:49+00:00"
},
{
"name": "theseer/tokenizer",

View File

@@ -28,7 +28,7 @@ class TwigNodeMarkdown extends Node implements NodeOutputInterface
/**
* Compiles the node to PHP.
*
* @param Compiler $compiler A Twig_Compiler instance
* @param Compiler $compiler A Twig Compiler instance
*/
public function compile(Compiler $compiler)
{

View File

@@ -41,7 +41,7 @@ class TwigNodeRender extends Node implements NodeCaptureInterface
/**
* Compiles the node to PHP.
*
* @param Compiler $compiler A Twig_Compiler instance
* @param Compiler $compiler A Twig Compiler instance
* @throws \LogicException
*/
public function compile(Compiler $compiler)

View File

@@ -46,7 +46,7 @@ class TwigNodeScript extends Node implements NodeCaptureInterface
/**
* Compiles the node to PHP.
*
* @param Compiler $compiler A Twig_Compiler instance
* @param Compiler $compiler A Twig Compiler instance
* @throws \LogicException
*/
public function compile(Compiler $compiler)

View File

@@ -46,7 +46,7 @@ class TwigNodeStyle extends Node implements NodeCaptureInterface
/**
* Compiles the node to PHP.
*
* @param Compiler $compiler A Twig_Compiler instance
* @param Compiler $compiler A Twig Compiler instance
* @throws \LogicException
*/
public function compile(Compiler $compiler)

View File

@@ -39,7 +39,7 @@ class TwigNodeSwitch extends Node
/**
* Compiles the node to PHP.
*
* @param Compiler $compiler A Twig_Compiler instance
* @param Compiler $compiler A Twig Compiler instance
*/
public function compile(Compiler $compiler)
{

View File

@@ -34,7 +34,7 @@ class TwigNodeThrow extends Node
/**
* Compiles the node to PHP.
*
* @param Compiler $compiler A Twig_Compiler instance
* @param Compiler $compiler A Twig Compiler instance
* @throws \LogicException
*/
public function compile(Compiler $compiler)

View File

@@ -37,7 +37,7 @@ class TwigNodeTryCatch extends Node
/**
* Compiles the node to PHP.
*
* @param Compiler $compiler A Twig_Compiler instance
* @param Compiler $compiler A Twig Compiler instance
* @throws \LogicException
*/
public function compile(Compiler $compiler)

View File

@@ -24,9 +24,9 @@ class TwigTokenParserRender extends AbstractTokenParser
/**
* Parses a token and returns a node.
*
* @param Token $token A Twig_Token instance
* @param Token $token A Twig Token instance
*
* @return Node A Twig_Node instance
* @return Node A Twig Node instance
*/
public function parse(Token $token)
{

View File

@@ -29,9 +29,9 @@ class TwigTokenParserScript extends AbstractTokenParser
/**
* Parses a token and returns a node.
*
* @param Token $token A Twig_Token instance
* @param Token $token A Twig Token instance
*
* @return Node A Twig_Node instance
* @return Node A Twig Node instance
*/
public function parse(Token $token)
{

View File

@@ -28,9 +28,9 @@ class TwigTokenParserStyle extends AbstractTokenParser
/**
* Parses a token and returns a node.
*
* @param Token $token A Twig_Token instance
* @param Token $token A Twig Token instance
*
* @return Node A Twig_Node instance
* @return Node A Twig Node instance
*/
public function parse(Token $token)
{

View File

@@ -26,9 +26,9 @@ class TwigTokenParserThrow extends AbstractTokenParser
/**
* Parses a token and returns a node.
*
* @param Token $token A Twig_Token instance
* @param Token $token A Twig Token instance
*
* @return Node A Twig_Node instance
* @return Node A Twig Node instance
*/
public function parse(Token $token)
{

View File

@@ -30,9 +30,9 @@ class TwigTokenParserTryCatch extends AbstractTokenParser
/**
* Parses a token and returns a node.
*
* @param Token $token A Twig_Token instance
* @param Token $token A Twig Token instance
*
* @return Node A Twig_Node instance
* @return Node A Twig Node instance
*/
public function parse(Token $token)
{

View File

@@ -18,11 +18,21 @@ use Grav\Common\Page\Pages;
use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
use RocketTheme\Toolbox\Event\Event;
use Phive\Twig\Extensions\Deferred\DeferredExtension;
use Twig\Cache\FilesystemCache;
use Twig\Environment;
use Twig\Error\LoaderError;
use Twig\Extension\CoreExtension;
use Twig\Extension\DebugExtension;
use Twig\Loader\ArrayLoader;
use Twig\Loader\ChainLoader;
use Twig\Loader\FilesystemLoader;
use Twig\TwigFilter;
use Twig\TwigFunction;
class Twig
{
/**
* @var \Twig_Environment
* @var Environment
*/
public $twig;
@@ -47,12 +57,12 @@ class Twig
protected $grav;
/**
* @var \Twig_Loader_Filesystem
* @var FilesystemLoader
*/
protected $loader;
/**
* @var \Twig_Loader_Array
* @var ArrayLoader
*/
protected $loaderArray;
@@ -104,7 +114,7 @@ class Twig
$core_templates = array_merge($locator->findResources('system://templates'), $locator->findResources('system://templates/testing'));
$this->twig_paths = array_merge($this->twig_paths, $core_templates);
$this->loader = new \Twig_Loader_Filesystem($this->twig_paths);
$this->loader = new FilesystemLoader($this->twig_paths);
// Register all other prefixes as namespaces in twig
foreach ($locator->getPaths('theme') as $prefix => $_) {
@@ -130,13 +140,13 @@ class Twig
$this->grav->fireEvent('onTwigLoader');
$this->loaderArray = new \Twig_Loader_Array([]);
$loader_chain = new \Twig_Loader_Chain([$this->loaderArray, $this->loader]);
$this->loaderArray = new ArrayLoader([]);
$loader_chain = new ChainLoader([$this->loaderArray, $this->loader]);
$params = $config->get('system.twig');
if (!empty($params['cache'])) {
$cachePath = $locator->findResource('cache://twig', true, true);
$params['cache'] = new \Twig_Cache_Filesystem($cachePath, \Twig_Cache_Filesystem::FORCE_BYTECODE_INVALIDATION);
$params['cache'] = new FilesystemCache($cachePath, FilesystemCache::FORCE_BYTECODE_INVALIDATION);
}
if (!$config->get('system.strict_mode.twig_compat', true)) {
@@ -155,10 +165,10 @@ class Twig
if ($config->get('system.twig.undefined_functions')) {
$this->twig->registerUndefinedFunctionCallback(function ($name) {
if (function_exists($name)) {
return new \Twig_SimpleFunction($name, $name);
return new TwigFunction($name, $name);
}
return new \Twig_SimpleFunction($name, function () {
return new TwigFunction($name, function () {
});
});
}
@@ -166,10 +176,10 @@ class Twig
if ($config->get('system.twig.undefined_filters')) {
$this->twig->registerUndefinedFilterCallback(function ($name) {
if (function_exists($name)) {
return new \Twig_SimpleFilter($name, $name);
return new TwigFilter($name, $name);
}
return new \Twig_SimpleFilter($name, function () {
return new TwigFilter($name, function () {
});
});
}
@@ -178,13 +188,13 @@ class Twig
// set default date format if set in config
if ($config->get('system.pages.dateformat.long')) {
/** @var \Twig_Extension_Core $extension */
$extension = $this->twig->getExtension('Twig_Extension_Core');
/** @var CoreExtension $extension */
$extension = $this->twig->getExtension(CoreExtension::class);
$extension->setDateFormat($config->get('system.pages.dateformat.long'));
}
// enable the debug extension if required
if ($config->get('system.twig.debug')) {
$this->twig->addExtension(new \Twig_Extension_Debug());
$this->twig->addExtension(new DebugExtension());
}
$this->twig->addExtension(new TwigExtension());
$this->twig->addExtension(new DeferredExtension());
@@ -225,7 +235,7 @@ class Twig
}
/**
* @return \Twig_Environment
* @return Environment
*/
public function twig()
{
@@ -233,7 +243,7 @@ class Twig
}
/**
* @return \Twig_Loader_Filesystem
* @return FilesystemLoader
*/
public function loader()
{
@@ -266,7 +276,6 @@ class Twig
* @param string $content Optional content override
*
* @return string The rendered output
* @throws \Twig_Error_Loader
*/
public function processPage(PageInterface $item, $content = null)
{
@@ -300,7 +309,7 @@ class Twig
$output = $local_twig->render($name, $twig_vars);
}
} catch (\Twig_Error_Loader $e) {
} catch (LoaderError $e) {
throw new \RuntimeException($e->getRawMessage(), 404, $e);
}
@@ -324,7 +333,7 @@ class Twig
try {
$output = $this->twig->render($template, $vars);
} catch (\Twig_Error_Loader $e) {
} catch (LoaderError $e) {
throw new \RuntimeException($e->getRawMessage(), 404, $e);
}
@@ -353,7 +362,7 @@ class Twig
try {
$output = $this->twig->render($name, $vars);
} catch (\Twig_Error_Loader $e) {
} catch (LoaderError $e) {
throw new \RuntimeException($e->getRawMessage(), 404, $e);
}
@@ -398,14 +407,14 @@ class Twig
try {
$output = $this->twig->render($template, $vars + $twig_vars);
} catch (\Twig_Error_Loader $e) {
} catch (LoaderError $e) {
$error_msg = $e->getMessage();
// Try html version of this template if initial template was NOT html
if ($ext !== '.html' . TWIG_EXT) {
try {
$page->templateFormat('html');
$output = $this->twig->render($page->template() . '.html' . TWIG_EXT, $vars + $twig_vars);
} catch (\Twig_Error_Loader $e) {
} catch (LoaderError $e) {
throw new \RuntimeException($error_msg, 400, $e);
}
} else {
@@ -417,9 +426,10 @@ class Twig
}
/**
* Wraps the Twig_Loader_Filesystem addPath method (should be used only in `onTwigLoader()` event
* Wraps the FilesystemLoader addPath method (should be used only in `onTwigLoader()` event
* @param string $template_path
* @param string $namespace
* @throws LoaderError
*/
public function addPath($template_path, $namespace = '__main__')
{
@@ -427,9 +437,10 @@ class Twig
}
/**
* Wraps the Twig_Loader_Filesystem prependPath method (should be used only in `onTwigLoader()` event
* Wraps the FilesystemLoader prependPath method (should be used only in `onTwigLoader()` event
* @param string $template_path
* @param string $namespace
* @throws LoaderError
*/
public function prependPath($template_path, $namespace = '__main__')
{

View File

@@ -9,7 +9,9 @@
namespace Grav\Common\Twig;
class TwigEnvironment extends \Twig_Environment
use Twig\Environment;
class TwigEnvironment extends Environment
{
use WriteCacheFileTrait;
}

View File

@@ -30,8 +30,14 @@ use Grav\Common\Utils;
use Grav\Common\Yaml;
use Grav\Common\Helpers\Base32;
use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
use Twig\Environment;
use Twig\Extension\AbstractExtension;
use Twig\Extension\GlobalsInterface;
use Twig\Loader\FilesystemLoader;
use Twig\TwigFilter;
use Twig\TwigFunction;
class TwigExtension extends \Twig_Extension implements \Twig_Extension_GlobalsInterface
class TwigExtension extends AbstractExtension implements GlobalsInterface
{
/** @var Grav */
protected $grav;
@@ -72,60 +78,60 @@ class TwigExtension extends \Twig_Extension implements \Twig_Extension_GlobalsIn
public function getFilters()
{
return [
new \Twig_SimpleFilter('*ize', [$this, 'inflectorFilter']),
new \Twig_SimpleFilter('absolute_url', [$this, 'absoluteUrlFilter']),
new \Twig_SimpleFilter('contains', [$this, 'containsFilter']),
new \Twig_SimpleFilter('chunk_split', [$this, 'chunkSplitFilter']),
new \Twig_SimpleFilter('nicenumber', [$this, 'niceNumberFunc']),
new \Twig_SimpleFilter('nicefilesize', [$this, 'niceFilesizeFunc']),
new \Twig_SimpleFilter('nicetime', [$this, 'nicetimeFunc']),
new \Twig_SimpleFilter('defined', [$this, 'definedDefaultFilter']),
new \Twig_SimpleFilter('ends_with', [$this, 'endsWithFilter']),
new \Twig_SimpleFilter('fieldName', [$this, 'fieldNameFilter']),
new \Twig_SimpleFilter('ksort', [$this, 'ksortFilter']),
new \Twig_SimpleFilter('ltrim', [$this, 'ltrimFilter']),
new \Twig_SimpleFilter('markdown', [$this, 'markdownFunction'], ['is_safe' => ['html']]),
new \Twig_SimpleFilter('md5', [$this, 'md5Filter']),
new \Twig_SimpleFilter('base32_encode', [$this, 'base32EncodeFilter']),
new \Twig_SimpleFilter('base32_decode', [$this, 'base32DecodeFilter']),
new \Twig_SimpleFilter('base64_encode', [$this, 'base64EncodeFilter']),
new \Twig_SimpleFilter('base64_decode', [$this, 'base64DecodeFilter']),
new \Twig_SimpleFilter('randomize', [$this, 'randomizeFilter']),
new \Twig_SimpleFilter('modulus', [$this, 'modulusFilter']),
new \Twig_SimpleFilter('rtrim', [$this, 'rtrimFilter']),
new \Twig_SimpleFilter('pad', [$this, 'padFilter']),
new \Twig_SimpleFilter('regex_replace', [$this, 'regexReplace']),
new \Twig_SimpleFilter('safe_email', [$this, 'safeEmailFilter']),
new \Twig_SimpleFilter('safe_truncate', ['\Grav\Common\Utils', 'safeTruncate']),
new \Twig_SimpleFilter('safe_truncate_html', ['\Grav\Common\Utils', 'safeTruncateHTML']),
new \Twig_SimpleFilter('sort_by_key', [$this, 'sortByKeyFilter']),
new \Twig_SimpleFilter('starts_with', [$this, 'startsWithFilter']),
new \Twig_SimpleFilter('truncate', ['\Grav\Common\Utils', 'truncate']),
new \Twig_SimpleFilter('truncate_html', ['\Grav\Common\Utils', 'truncateHTML']),
new \Twig_SimpleFilter('json_decode', [$this, 'jsonDecodeFilter']),
new \Twig_SimpleFilter('array_unique', 'array_unique'),
new \Twig_SimpleFilter('basename', 'basename'),
new \Twig_SimpleFilter('dirname', 'dirname'),
new \Twig_SimpleFilter('print_r', 'print_r'),
new \Twig_SimpleFilter('yaml_encode', [$this, 'yamlEncodeFilter']),
new \Twig_SimpleFilter('yaml_decode', [$this, 'yamlDecodeFilter']),
new \Twig_SimpleFilter('nicecron', [$this, 'niceCronFilter']),
new TwigFilter('*ize', [$this, 'inflectorFilter']),
new TwigFilter('absolute_url', [$this, 'absoluteUrlFilter']),
new TwigFilter('contains', [$this, 'containsFilter']),
new TwigFilter('chunk_split', [$this, 'chunkSplitFilter']),
new TwigFilter('nicenumber', [$this, 'niceNumberFunc']),
new TwigFilter('nicefilesize', [$this, 'niceFilesizeFunc']),
new TwigFilter('nicetime', [$this, 'nicetimeFunc']),
new TwigFilter('defined', [$this, 'definedDefaultFilter']),
new TwigFilter('ends_with', [$this, 'endsWithFilter']),
new TwigFilter('fieldName', [$this, 'fieldNameFilter']),
new TwigFilter('ksort', [$this, 'ksortFilter']),
new TwigFilter('ltrim', [$this, 'ltrimFilter']),
new TwigFilter('markdown', [$this, 'markdownFunction'], ['is_safe' => ['html']]),
new TwigFilter('md5', [$this, 'md5Filter']),
new TwigFilter('base32_encode', [$this, 'base32EncodeFilter']),
new TwigFilter('base32_decode', [$this, 'base32DecodeFilter']),
new TwigFilter('base64_encode', [$this, 'base64EncodeFilter']),
new TwigFilter('base64_decode', [$this, 'base64DecodeFilter']),
new TwigFilter('randomize', [$this, 'randomizeFilter']),
new TwigFilter('modulus', [$this, 'modulusFilter']),
new TwigFilter('rtrim', [$this, 'rtrimFilter']),
new TwigFilter('pad', [$this, 'padFilter']),
new TwigFilter('regex_replace', [$this, 'regexReplace']),
new TwigFilter('safe_email', [$this, 'safeEmailFilter']),
new TwigFilter('safe_truncate', ['\Grav\Common\Utils', 'safeTruncate']),
new TwigFilter('safe_truncate_html', ['\Grav\Common\Utils', 'safeTruncateHTML']),
new TwigFilter('sort_by_key', [$this, 'sortByKeyFilter']),
new TwigFilter('starts_with', [$this, 'startsWithFilter']),
new TwigFilter('truncate', ['\Grav\Common\Utils', 'truncate']),
new TwigFilter('truncate_html', ['\Grav\Common\Utils', 'truncateHTML']),
new TwigFilter('json_decode', [$this, 'jsonDecodeFilter']),
new TwigFilter('array_unique', 'array_unique'),
new TwigFilter('basename', 'basename'),
new TwigFilter('dirname', 'dirname'),
new TwigFilter('print_r', 'print_r'),
new TwigFilter('yaml_encode', [$this, 'yamlEncodeFilter']),
new TwigFilter('yaml_decode', [$this, 'yamlDecodeFilter']),
new TwigFilter('nicecron', [$this, 'niceCronFilter']),
// Translations
new \Twig_SimpleFilter('t', [$this, 'translate'], ['needs_environment' => true]),
new \Twig_SimpleFilter('tl', [$this, 'translateLanguage']),
new \Twig_SimpleFilter('ta', [$this, 'translateArray']),
new TwigFilter('t', [$this, 'translate'], ['needs_environment' => true]),
new TwigFilter('tl', [$this, 'translateLanguage']),
new TwigFilter('ta', [$this, 'translateArray']),
// Casting values
new \Twig_SimpleFilter('string', [$this, 'stringFilter']),
new \Twig_SimpleFilter('int', [$this, 'intFilter'], ['is_safe' => ['all']]),
new \Twig_SimpleFilter('bool', [$this, 'boolFilter']),
new \Twig_SimpleFilter('float', [$this, 'floatFilter'], ['is_safe' => ['all']]),
new \Twig_SimpleFilter('array', [$this, 'arrayFilter']),
new TwigFilter('string', [$this, 'stringFilter']),
new TwigFilter('int', [$this, 'intFilter'], ['is_safe' => ['all']]),
new TwigFilter('bool', [$this, 'boolFilter']),
new TwigFilter('float', [$this, 'floatFilter'], ['is_safe' => ['all']]),
new TwigFilter('array', [$this, 'arrayFilter']),
// Object Types
new \Twig_SimpleFilter('get_type', [$this, 'getTypeFunc']),
new \Twig_SimpleFilter('of_type', [$this, 'ofTypeFunc'])
new TwigFilter('get_type', [$this, 'getTypeFunc']),
new TwigFilter('of_type', [$this, 'ofTypeFunc'])
];
}
@@ -137,54 +143,54 @@ class TwigExtension extends \Twig_Extension implements \Twig_Extension_GlobalsIn
public function getFunctions()
{
return [
new \Twig_SimpleFunction('array', [$this, 'arrayFilter']),
new \Twig_SimpleFunction('array_key_value', [$this, 'arrayKeyValueFunc']),
new \Twig_SimpleFunction('array_key_exists', 'array_key_exists'),
new \Twig_SimpleFunction('array_unique', 'array_unique'),
new \Twig_SimpleFunction('array_intersect', [$this, 'arrayIntersectFunc']),
new \Twig_SimpleFunction('authorize', [$this, 'authorize']),
new \Twig_SimpleFunction('debug', [$this, 'dump'], ['needs_context' => true, 'needs_environment' => true]),
new \Twig_SimpleFunction('dump', [$this, 'dump'], ['needs_context' => true, 'needs_environment' => true]),
new \Twig_SimpleFunction('vardump', [$this, 'vardumpFunc']),
new \Twig_SimpleFunction('print_r', 'print_r'),
new \Twig_SimpleFunction('http_response_code', 'http_response_code'),
new \Twig_SimpleFunction('evaluate', [$this, 'evaluateStringFunc'], ['needs_context' => true]),
new \Twig_SimpleFunction('evaluate_twig', [$this, 'evaluateTwigFunc'], ['needs_context' => true]),
new \Twig_SimpleFunction('gist', [$this, 'gistFunc']),
new \Twig_SimpleFunction('nonce_field', [$this, 'nonceFieldFunc']),
new \Twig_SimpleFunction('pathinfo', 'pathinfo'),
new \Twig_SimpleFunction('random_string', [$this, 'randomStringFunc']),
new \Twig_SimpleFunction('repeat', [$this, 'repeatFunc']),
new \Twig_SimpleFunction('regex_replace', [$this, 'regexReplace']),
new \Twig_SimpleFunction('regex_filter', [$this, 'regexFilter']),
new \Twig_SimpleFunction('string', [$this, 'stringFunc']),
new \Twig_SimpleFunction('url', [$this, 'urlFunc']),
new \Twig_SimpleFunction('json_decode', [$this, 'jsonDecodeFilter']),
new \Twig_SimpleFunction('get_cookie', [$this, 'getCookie']),
new \Twig_SimpleFunction('redirect_me', [$this, 'redirectFunc']),
new \Twig_SimpleFunction('range', [$this, 'rangeFunc']),
new \Twig_SimpleFunction('isajaxrequest', [$this, 'isAjaxFunc']),
new \Twig_SimpleFunction('exif', [$this, 'exifFunc']),
new \Twig_SimpleFunction('media_directory', [$this, 'mediaDirFunc']),
new \Twig_SimpleFunction('body_class', [$this, 'bodyClassFunc']),
new \Twig_SimpleFunction('theme_var', [$this, 'themeVarFunc']),
new \Twig_SimpleFunction('header_var', [$this, 'pageHeaderVarFunc']),
new \Twig_SimpleFunction('read_file', [$this, 'readFileFunc']),
new \Twig_SimpleFunction('nicenumber', [$this, 'niceNumberFunc']),
new \Twig_SimpleFunction('nicefilesize', [$this, 'niceFilesizeFunc']),
new \Twig_SimpleFunction('nicetime', [$this, 'nicetimeFunc']),
new \Twig_SimpleFunction('cron', [$this, 'cronFunc']),
new \Twig_SimpleFunction('xss', [$this, 'xssFunc']),
new TwigFunction('array', [$this, 'arrayFilter']),
new TwigFunction('array_key_value', [$this, 'arrayKeyValueFunc']),
new TwigFunction('array_key_exists', 'array_key_exists'),
new TwigFunction('array_unique', 'array_unique'),
new TwigFunction('array_intersect', [$this, 'arrayIntersectFunc']),
new TwigFunction('authorize', [$this, 'authorize']),
new TwigFunction('debug', [$this, 'dump'], ['needs_context' => true, 'needs_environment' => true]),
new TwigFunction('dump', [$this, 'dump'], ['needs_context' => true, 'needs_environment' => true]),
new TwigFunction('vardump', [$this, 'vardumpFunc']),
new TwigFunction('print_r', 'print_r'),
new TwigFunction('http_response_code', 'http_response_code'),
new TwigFunction('evaluate', [$this, 'evaluateStringFunc'], ['needs_context' => true]),
new TwigFunction('evaluate_twig', [$this, 'evaluateTwigFunc'], ['needs_context' => true]),
new TwigFunction('gist', [$this, 'gistFunc']),
new TwigFunction('nonce_field', [$this, 'nonceFieldFunc']),
new TwigFunction('pathinfo', 'pathinfo'),
new TwigFunction('random_string', [$this, 'randomStringFunc']),
new TwigFunction('repeat', [$this, 'repeatFunc']),
new TwigFunction('regex_replace', [$this, 'regexReplace']),
new TwigFunction('regex_filter', [$this, 'regexFilter']),
new TwigFunction('string', [$this, 'stringFunc']),
new TwigFunction('url', [$this, 'urlFunc']),
new TwigFunction('json_decode', [$this, 'jsonDecodeFilter']),
new TwigFunction('get_cookie', [$this, 'getCookie']),
new TwigFunction('redirect_me', [$this, 'redirectFunc']),
new TwigFunction('range', [$this, 'rangeFunc']),
new TwigFunction('isajaxrequest', [$this, 'isAjaxFunc']),
new TwigFunction('exif', [$this, 'exifFunc']),
new TwigFunction('media_directory', [$this, 'mediaDirFunc']),
new TwigFunction('body_class', [$this, 'bodyClassFunc']),
new TwigFunction('theme_var', [$this, 'themeVarFunc']),
new TwigFunction('header_var', [$this, 'pageHeaderVarFunc']),
new TwigFunction('read_file', [$this, 'readFileFunc']),
new TwigFunction('nicenumber', [$this, 'niceNumberFunc']),
new TwigFunction('nicefilesize', [$this, 'niceFilesizeFunc']),
new TwigFunction('nicetime', [$this, 'nicetimeFunc']),
new TwigFunction('cron', [$this, 'cronFunc']),
new TwigFunction('xss', [$this, 'xssFunc']),
// Translations
new \Twig_SimpleFunction('t', [$this, 'translate'], ['needs_environment' => true]),
new \Twig_SimpleFunction('tl', [$this, 'translateLanguage']),
new \Twig_SimpleFunction('ta', [$this, 'translateArray']),
new TwigFunction('t', [$this, 'translate'], ['needs_environment' => true]),
new TwigFunction('tl', [$this, 'translateLanguage']),
new TwigFunction('ta', [$this, 'translateArray']),
// Object Types
new \Twig_SimpleFunction('get_type', [$this, 'getTypeFunc']),
new \Twig_SimpleFunction('of_type', [$this, 'ofTypeFunc'])
new TwigFunction('get_type', [$this, 'getTypeFunc']),
new TwigFunction('of_type', [$this, 'ofTypeFunc'])
];
}
@@ -651,7 +657,7 @@ class TwigExtension extends \Twig_Extension implements \Twig_Extension_GlobalsIn
*/
public function definedDefaultFilter($value, $default = null)
{
return null !== $value ? $value : $default;
return $value ?? $default;
}
/**
@@ -733,9 +739,10 @@ class TwigExtension extends \Twig_Extension implements \Twig_Extension_GlobalsIn
}
/**
* @param Environment $twig
* @return string
*/
public function translate(\Twig_Environment $twig)
public function translate(Environment $twig)
{
// shift off the environment
$args = func_get_args();
@@ -828,8 +835,8 @@ class TwigExtension extends \Twig_Extension implements \Twig_Extension_GlobalsIn
*/
public function evaluateTwigFunc($context, $twig ) {
$loader = new \Twig_Loader_Filesystem('.');
$env = new \Twig_Environment($loader);
$loader = new FilesystemLoader('.');
$env = new Environment($loader);
$template = $env->createTemplate($twig);
@@ -850,13 +857,13 @@ class TwigExtension extends \Twig_Extension implements \Twig_Extension_GlobalsIn
/**
* Based on Twig_Extension_Debug / twig_var_dump
* Based on Twig\Extension\Debug / twig_var_dump
* (c) 2011 Fabien Potencier
*
* @param \Twig_Environment $env
* @param Environment $env
* @param string $context
*/
public function dump(\Twig_Environment $env, $context)
public function dump(Environment $env, $context)
{
if (!$env->isDebug() || !$this->debugger) {
return;

View File

@@ -333,9 +333,9 @@ class FlexForm implements FlexFormInterface
/**
* Filter validated data.
*
* @param \ArrayAccess $data
* @param \ArrayAccess|Data $data
*/
protected function filterData(\ArrayAccess $data): void
protected function filterData($data): void
{
if ($data instanceof Data) {
$data->filter(true, true);

View File

@@ -9,7 +9,6 @@ namespace Grav\Framework\Flex\Traits;
* @license MIT License; see LICENSE file for details.
*/
use Grav\Common\Cache;
use Grav\Common\Config\Config;
use Grav\Common\Filesystem\Folder;
use Grav\Common\Grav;
@@ -19,6 +18,7 @@ use Grav\Common\Page\Medium\AbstractMedia;
use Grav\Common\Page\Medium\Medium;
use Grav\Common\Page\Medium\MediumFactory;
use Grav\Common\Utils;
use Grav\Framework\Cache\CacheInterface;
use Grav\Framework\Flex\FlexDirectory;
use Grav\Framework\Form\FormFlashFile;
use Psr\Http\Message\UploadedFileInterface;
@@ -313,7 +313,7 @@ trait FlexMediaTrait
}
/**
* @return Cache
* @return CacheInterface
*/
protected function getMediaCache()
{

View File

@@ -45,7 +45,7 @@ trait FormTrait
private $uniqueid;
/** @var bool */
private $submitted;
/** @var \ArrayAccess|Data|object|null */
/** @var \ArrayAccess|Data|null */
private $data;
/** @var array|UploadedFileInterface[] */
private $files;
@@ -501,7 +501,7 @@ trait FormTrait
*
* @param \ArrayAccess|Data $data
*/
protected function filterData(\ArrayAccess $data): void
protected function filterData($data): void
{
if ($data instanceof Data) {
$data->filter();

View File

@@ -35,12 +35,18 @@ parameters:
-
message: '#Call to deprecated method writeCacheFile\(\) of class Twig\\Environment#'
path: 'system/src/Grav/Common/Twig/WriteCacheFileTrait.php'
-
message: '#Call to an undefined static method Twig\\Environment::writeCacheFile#'
path: 'system/src/Grav/Common/Twig/WriteCacheFileTrait.php'
# Needed: full coverage (probably with admin plugin...) then redesign constructor
-
message: '#Grav\\Common\\GPM\\Remote\\GravCore::__construct\(\) does not call parent constructor from Grav\\Common\\GPM\\Remote\\AbstractPackageCollection#'
path: 'system/src/Grav/Common/GPM/Remote/GravCore.php'
# XHprof
- '#tideways_xhprof_enable#'
# PSR-16 Exception interfaces do not extend \Throwable
- '#PHPDoc tag \@throws with type Psr\\SimpleCache\\(CacheException|InvalidArgumentException) is not subtype of Throwable#'
- '#expects Exception, Psr\\SimpleCache\\InvalidArgumentException&Throwable given#'