mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-10 09:26:29 +00:00
prepared use statements
This commit is contained in:
@@ -100,7 +100,7 @@ class Twig_Environment
|
||||
if (null !== $loader) {
|
||||
$this->setLoader($loader);
|
||||
} else {
|
||||
@trigger_error('Not passing a Twig_LoaderInterface as the first constructor argument of Twig_Environment is deprecated since version 1.21.', E_USER_DEPRECATED);
|
||||
@trigger_error('Not passing a "Twig\Lodaer\LoaderInterface" as the first constructor argument of "Twig\Environment" is deprecated since version 1.21.', E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
$options = array_merge([
|
||||
@@ -130,14 +130,14 @@ class Twig_Environment
|
||||
if (\is_string($this->originalCache)) {
|
||||
$r = new \ReflectionMethod($this, 'writeCacheFile');
|
||||
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
|
||||
@trigger_error('The \Twig\Environment::writeCacheFile method is deprecated since version 1.22 and will be removed in Twig 2.0.', E_USER_DEPRECATED);
|
||||
@trigger_error('The Twig\Environment::writeCacheFile method is deprecated since version 1.22 and will be removed in Twig 2.0.', E_USER_DEPRECATED);
|
||||
|
||||
$this->bcWriteCacheFile = true;
|
||||
}
|
||||
|
||||
$r = new \ReflectionMethod($this, 'getCacheFilename');
|
||||
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
|
||||
@trigger_error('The \Twig\Environment::getCacheFilename method is deprecated since version 1.22 and will be removed in Twig 2.0.', E_USER_DEPRECATED);
|
||||
@trigger_error('The Twig\Environment::getCacheFilename method is deprecated since version 1.22 and will be removed in Twig 2.0.', E_USER_DEPRECATED);
|
||||
|
||||
$this->bcGetCacheFilename = true;
|
||||
}
|
||||
@@ -663,7 +663,7 @@ class Twig_Environment
|
||||
public function tokenize($source, $name = null)
|
||||
{
|
||||
if (!$source instanceof \Twig\Source) {
|
||||
@trigger_error(sprintf('Passing a string as the $source argument of %s() is deprecated since version 1.27. Pass a Twig_Source instance instead.', __METHOD__), E_USER_DEPRECATED);
|
||||
@trigger_error(sprintf('Passing a string as the $source argument of %s() is deprecated since version 1.27. Pass a Twig\Source instance instead.', __METHOD__), E_USER_DEPRECATED);
|
||||
$source = new \Twig\Source($source, $name);
|
||||
}
|
||||
|
||||
@@ -763,7 +763,7 @@ class Twig_Environment
|
||||
public function compileSource($source, $name = null)
|
||||
{
|
||||
if (!$source instanceof \Twig\Source) {
|
||||
@trigger_error(sprintf('Passing a string as the $source argument of %s() is deprecated since version 1.27. Pass a Twig_Source instance instead.', __METHOD__), E_USER_DEPRECATED);
|
||||
@trigger_error(sprintf('Passing a string as the $source argument of %s() is deprecated since version 1.27. Pass a Twig\Source instance instead.', __METHOD__), E_USER_DEPRECATED);
|
||||
$source = new \Twig\Source($source, $name);
|
||||
}
|
||||
|
||||
@@ -834,7 +834,7 @@ class Twig_Environment
|
||||
$m = new \ReflectionMethod($extension, 'initRuntime');
|
||||
|
||||
if ('Twig_Extension' !== $m->getDeclaringClass()->getName()) {
|
||||
@trigger_error(sprintf('Defining the initRuntime() method in the "%s" extension is deprecated since version 1.23. Use the `needs_environment` option to get the Twig_Environment instance in filters, functions, or tests; or explicitly implement Twig_Extension_InitRuntimeInterface if needed (not recommended).', $name), E_USER_DEPRECATED);
|
||||
@trigger_error(sprintf('Defining the initRuntime() method in the "%s" extension is deprecated since version 1.23. Use the `needs_environment` option to get the Twig_Environment instance in filters, functions, or tests; or explicitly implement Twig\Extension\InitRuntimeInterface if needed (not recommended).', $name), E_USER_DEPRECATED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1472,7 +1472,7 @@ class Twig_Environment
|
||||
$m = new \ReflectionMethod($extension, 'getGlobals');
|
||||
|
||||
if ('Twig_Extension' !== $m->getDeclaringClass()->getName()) {
|
||||
@trigger_error(sprintf('Defining the getGlobals() method in the "%s" extension without explicitly implementing Twig_Extension_GlobalsInterface is deprecated since version 1.23.', $name), E_USER_DEPRECATED);
|
||||
@trigger_error(sprintf('Defining the getGlobals() method in the "%s" extension without explicitly implementing Twig\Extension\GlobalsInterface is deprecated since version 1.23.', $name), E_USER_DEPRECATED);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
* if a template cannot be loaded, there is nothing to guess.
|
||||
* However, when a template is loaded from another one, then, we need
|
||||
* to find the current context and this is automatically done by
|
||||
* \Twig\Template::displayWithErrorHandling().
|
||||
* Twig\Template::displayWithErrorHandling().
|
||||
*
|
||||
* This strategy makes \Twig\Environment::resolveTemplate() much faster.
|
||||
* This strategy makes Twig\Environment::resolveTemplate() much faster.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Enables usage of the deprecated \Twig\Extension\AbstractExtension::getGlobals() method.
|
||||
* Enables usage of the deprecated Twig\Extension\AbstractExtension::getGlobals() method.
|
||||
*
|
||||
* Explicitly implement this interface if you really need to implement the
|
||||
* deprecated getGlobals() method in your extensions.
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Enables usage of the deprecated \Twig\Extension\AbstractExtension::initRuntime() method.
|
||||
* Enables usage of the deprecated Twig\Extension\AbstractExtension::initRuntime() method.
|
||||
*
|
||||
* Explicitly implement this interface if you really need to implement the
|
||||
* deprecated initRuntime() method in your extensions.
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
@trigger_error('The Twig_Loader_String class is deprecated since version 1.18.1 and will be removed in 2.0. Use Twig_Loader_Array instead or \Twig\Environment::createTemplate().', E_USER_DEPRECATED);
|
||||
@trigger_error('The Twig_Loader_String class is deprecated since version 1.18.1 and will be removed in 2.0. Use "Twig\Loader\ArrayLoader" instead or "Twig\Environment::createTemplate()".', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* Loads a template from a string.
|
||||
|
||||
@@ -154,10 +154,26 @@ class Twig_Node_Module extends \Twig\Node\Node
|
||||
{
|
||||
$compiler
|
||||
->write("\n\n")
|
||||
;
|
||||
if (!$this->getAttribute('index')) {
|
||||
$compiler
|
||||
->write("use Twig\Environment;\n")
|
||||
->write("use Twig\Error\LoaderError;\n")
|
||||
->write("use Twig\Error\RuntimeError;\n")
|
||||
->write("use Twig\Markup;\n")
|
||||
->write("use Twig\Sandbox\SecurityError;\n")
|
||||
->write("use Twig\Sandbox\SecurityNotAllowedTagError;\n")
|
||||
->write("use Twig\Sandbox\SecurityNotAllowedFilterError;\n")
|
||||
->write("use Twig\Sandbox\SecurityNotAllowedFunctionError;\n")
|
||||
->write("use Twig\Source;\n")
|
||||
->write("use Twig\Template;\n\n")
|
||||
;
|
||||
}
|
||||
$compiler
|
||||
// if the template name contains */, add a blank to avoid a PHP parse error
|
||||
->write('/* '.str_replace('*/', '* /', $this->source->getName())." */\n")
|
||||
->write('class '.$compiler->getEnvironment()->getTemplateClass($this->source->getName(), $this->getAttribute('index')))
|
||||
->raw(sprintf(" extends %s\n", $compiler->getEnvironment()->getBaseTemplateClass()))
|
||||
->raw(sprintf(" extends %s\n", $compiler->getEnvironment()->getBaseTemplateClass()))
|
||||
->write("{\n")
|
||||
->indent()
|
||||
;
|
||||
|
||||
@@ -23,7 +23,7 @@ class Twig_Node_Set extends \Twig\Node\Node implements \Twig\Node\NodeCaptureInt
|
||||
/*
|
||||
* Optimizes the node when capture is used for a large block of text.
|
||||
*
|
||||
* {% set foo %}foo{% endset %} is compiled to $context['foo'] = new \Twig\Markup("foo");
|
||||
* {% set foo %}foo{% endset %} is compiled to $context['foo'] = new Twig\Markup("foo");
|
||||
*/
|
||||
if ($this->getAttribute('capture')) {
|
||||
$this->setAttribute('safe', true);
|
||||
|
||||
@@ -21,7 +21,7 @@ final class Twig_TemplateWrapper
|
||||
|
||||
/**
|
||||
* This method is for internal use only and should never be called
|
||||
* directly (use \Twig\Environment::load() instead).
|
||||
* directly (use Twig\Environment::load() instead).
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
|
||||
+1
-1
@@ -159,7 +159,7 @@ class Twig_Token
|
||||
throw new \LogicException(sprintf('Token of type "%s" does not exist.', $type));
|
||||
}
|
||||
|
||||
return $short ? $name : '\Twig\Token::'.$name;
|
||||
return $short ? $name : 'Twig\Token::'.$name;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,7 +31,7 @@ interface Twig_TokenParserBrokerInterface
|
||||
public function getTokenParser($tag);
|
||||
|
||||
/**
|
||||
* Calls \Twig\TokenParser\TokenParserInterface::setParser on all parsers the implementation knows of.
|
||||
* Calls Twig\TokenParser\TokenParserInterface::setParser on all parsers the implementation knows of.
|
||||
*/
|
||||
public function setParser(Twig_ParserInterface $parser);
|
||||
|
||||
|
||||
@@ -381,7 +381,9 @@ class Twig_Tests_EnvironmentTest extends \PHPUnit\Framework\TestCase
|
||||
// should be replaced by the following in 2.0 (this current code is just to avoid a dep notice)
|
||||
// $extension = $this->getMockBuilder('\Twig\Extension\AbstractExtension')->getMock();
|
||||
$extension = eval(<<<EOF
|
||||
class Twig_Tests_EnvironmentTest_ExtensionInEval extends \Twig\Extension\AbstractExtension
|
||||
use Twig\Extension\AbstractExtension;
|
||||
|
||||
class Twig_Tests_EnvironmentTest_ExtensionInEval extends AbstractExtension
|
||||
{
|
||||
}
|
||||
EOF
|
||||
|
||||
@@ -45,8 +45,19 @@ class Twig_Tests_Node_ModuleTest extends \Twig\Test\NodeTestCase
|
||||
$tests[] = [$node, <<<EOF
|
||||
<?php
|
||||
|
||||
use Twig\Environment;
|
||||
use Twig\Error\LoaderError;
|
||||
use Twig\Error\RuntimeError;
|
||||
use Twig\Markup;
|
||||
use Twig\Sandbox\SecurityError;
|
||||
use Twig\Sandbox\SecurityNotAllowedTagError;
|
||||
use Twig\Sandbox\SecurityNotAllowedFilterError;
|
||||
use Twig\Sandbox\SecurityNotAllowedFunctionError;
|
||||
use Twig\Source;
|
||||
use Twig\Template;
|
||||
|
||||
/* foo.twig */
|
||||
class __TwigTemplate_%x extends \Twig\Template
|
||||
class __TwigTemplate_%x extends \Twig\Template
|
||||
{
|
||||
public function __construct(\Twig\Environment \$env)
|
||||
{
|
||||
@@ -71,7 +82,7 @@ class __TwigTemplate_%x extends \Twig\Template
|
||||
|
||||
public function getDebugInfo()
|
||||
{
|
||||
return array ( 19 => 1,);
|
||||
return array ( 30 => 1,);
|
||||
}
|
||||
|
||||
/** @deprecated since 1.27 (to be removed in 2.0). Use getSourceContext() instead */
|
||||
@@ -99,8 +110,19 @@ EOF
|
||||
$tests[] = [$node, <<<EOF
|
||||
<?php
|
||||
|
||||
use Twig\Environment;
|
||||
use Twig\Error\LoaderError;
|
||||
use Twig\Error\RuntimeError;
|
||||
use Twig\Markup;
|
||||
use Twig\Sandbox\SecurityError;
|
||||
use Twig\Sandbox\SecurityNotAllowedTagError;
|
||||
use Twig\Sandbox\SecurityNotAllowedFilterError;
|
||||
use Twig\Sandbox\SecurityNotAllowedFunctionError;
|
||||
use Twig\Source;
|
||||
use Twig\Template;
|
||||
|
||||
/* foo.twig */
|
||||
class __TwigTemplate_%x extends \Twig\Template
|
||||
class __TwigTemplate_%x extends \Twig\Template
|
||||
{
|
||||
public function __construct(\Twig\Environment \$env)
|
||||
{
|
||||
@@ -137,7 +159,7 @@ class __TwigTemplate_%x extends \Twig\Template
|
||||
|
||||
public function getDebugInfo()
|
||||
{
|
||||
return array ( 26 => 1, 24 => 2, 11 => 1,);
|
||||
return array ( 37 => 1, 35 => 2, 22 => 1,);
|
||||
}
|
||||
|
||||
/** @deprecated since 1.27 (to be removed in 2.0). Use getSourceContext() instead */
|
||||
@@ -170,8 +192,19 @@ EOF
|
||||
$tests[] = [$node, <<<EOF
|
||||
<?php
|
||||
|
||||
use Twig\Environment;
|
||||
use Twig\Error\LoaderError;
|
||||
use Twig\Error\RuntimeError;
|
||||
use Twig\Markup;
|
||||
use Twig\Sandbox\SecurityError;
|
||||
use Twig\Sandbox\SecurityNotAllowedTagError;
|
||||
use Twig\Sandbox\SecurityNotAllowedFilterError;
|
||||
use Twig\Sandbox\SecurityNotAllowedFunctionError;
|
||||
use Twig\Source;
|
||||
use Twig\Template;
|
||||
|
||||
/* foo.twig */
|
||||
class __TwigTemplate_%x extends \Twig\Template
|
||||
class __TwigTemplate_%x extends \Twig\Template
|
||||
{
|
||||
protected function doGetParent(array \$context)
|
||||
{
|
||||
@@ -199,7 +232,7 @@ class __TwigTemplate_%x extends \Twig\Template
|
||||
|
||||
public function getDebugInfo()
|
||||
{
|
||||
return array ( 17 => 2, 15 => 4, 9 => 2,);
|
||||
return array ( 28 => 2, 26 => 4, 20 => 2,);
|
||||
}
|
||||
|
||||
/** @deprecated since 1.27 (to be removed in 2.0). Use getSourceContext() instead */
|
||||
|
||||
Reference in New Issue
Block a user