mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-12 02:16:41 +00:00
fixed class usage
This commit is contained in:
@@ -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
@@ -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 {
|
||||
|
||||
@@ -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
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user