fixed class usage

This commit is contained in:
Fabien Potencier
2019-03-05 07:00:11 +01:00
parent eb8532a895
commit 7e3c90dbbb
4 changed files with 8 additions and 7 deletions
+3 -3
View File
@@ -116,7 +116,7 @@ class Twig_Environment
$options = array_merge([
'debug' => false,
'charset' => 'UTF-8',
'base_template_class' => '\\'.Twig\Template::class,
'base_template_class' => Template::class,
'strict_variables' => false,
'autoescape' => 'html',
'cache' => false,
@@ -126,8 +126,8 @@ class Twig_Environment
$this->debug = (bool) $options['debug'];
$this->setCharset($options['charset']);
$this->baseTemplateClass = $options['base_template_class'];
if ('\Twig\Template' !== $options['base_template_class']) {
$this->baseTemplateClass = '\\'.ltrim($options['base_template_class'], '\\');
if ('\Twig\Template' !== $this->baseTemplateClass && '\Twig_Template' !== $this->baseTemplateClass) {
@trigger_error('The "base_template_class" option on '.__CLASS__.' is deprecated since Twig 2.7.0.', E_USER_DEPRECATED);
}
$this->autoReload = null === $options['auto_reload'] ? $this->debug : (bool) $options['auto_reload'];
+1 -1
View File
@@ -65,7 +65,7 @@ class Twig_Error extends \Exception
if (null === $source) {
$name = null;
} elseif (!$source instanceof Source) {
} elseif (!$source instanceof Source && !$source instanceof \Twig_Source) {
@trigger_error(sprintf('Passing a string as a source to %s is deprecated since Twig 2.6.1; pass a Twig\Source instance instead.', __CLASS__), E_USER_DEPRECATED);
$name = $source;
} else {
+2 -1
View File
@@ -10,6 +10,7 @@
*/
use Twig\Extension\AbstractExtension;
use Twig\FileExtensionEscapingStrategy;
use Twig\NodeVisitor\EscaperNodeVisitor;
use Twig\TokenParser\AutoEscapeTokenParser;
use Twig\TwigFilter;
@@ -56,7 +57,7 @@ final class Twig_Extension_Escaper extends AbstractExtension
public function setDefaultStrategy($defaultStrategy)
{
if ('name' === $defaultStrategy) {
$defaultStrategy = ['Twig_FileExtensionEscapingStrategy', 'guess'];
$defaultStrategy = [FileExtensionEscapingStrategy::class, 'guess'];
}
$this->defaultStrategy = $defaultStrategy;
+2 -2
View File
@@ -372,7 +372,7 @@ class Twig_Parser
// "block" tags that are not captured (see above) are only used for defining
// the content of the block. In such a case, nesting it does not work as
// expected as the definition is not part of the default template code flow.
if ($nested && $node instanceof BlockReferenceNode) {
if ($nested && ($node instanceof BlockReferenceNode || $node instanceof \Twig_Node_BlockReference)) {
//throw new SyntaxError('A block definition cannot be nested under non-capturing nodes.', $node->getTemplateLine(), $this->stream->getSourceContext());
@trigger_error(sprintf('Nesting a block definition under a non-capturing node in "%s" at line %d is deprecated since Twig 2.5.0 and will become a syntax error in 3.0.', $this->stream->getSourceContext()->getName(), $node->getTemplateLine()), E_USER_DEPRECATED);
@@ -386,7 +386,7 @@ class Twig_Parser
// here, $nested means "being at the root level of a child template"
// we need to discard the wrapping "Twig_Node" for the "body" node
$nested = $nested || 'Twig_Node' !== \get_class($node);
$nested = $nested || ('Twig_Node' !== \get_class($node) && Node::class !== \get_class($node));
foreach ($node as $k => $n) {
if (null !== $n && null === $this->filterBodyNodes($n, $nested)) {
$node->removeNode($k);