mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-12 10:26:32 +00:00
Fix incompatibility with old PHP versions
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# 3.9.0 (2024-XX-XX)
|
||||
|
||||
* Deprecate AbstractNodeVisitor
|
||||
* Deprecate passing Template to Environment::resolveTemplate() and Template::loadTemplate()
|
||||
* Deprecate passing Template to Environment::resolveTemplate(), Environment::load(), and Template::loadTemplate()
|
||||
* Add a new "yield" mode for output generation;
|
||||
Node implementations that use "echo" or "print" should use "yield" instead;
|
||||
all Node implementations should be flagged with `#[YieldReady]` once they've been made ready for "yield";
|
||||
|
||||
@@ -23,3 +23,11 @@ Node Visitors
|
||||
|
||||
* The ``Twig\NodeVisitor\AbstractNodeVisitor`` class is deprecated, implement the
|
||||
``Twig\NodeVisitor\NodeVisitorInterface`` interface instead.
|
||||
|
||||
Templates
|
||||
---------
|
||||
|
||||
* Passing ``Twig\\Template`` instances to Twig public API is deprecated (like
|
||||
in ``Environment::resolveTemplate()``, ``Environment::load()``, and
|
||||
``Template::loadTemplate()``); pass instances of ``Twig\\TemplateWrapper``
|
||||
instead.
|
||||
|
||||
+6
-1
@@ -327,6 +327,11 @@ class Environment
|
||||
if ($name instanceof TemplateWrapper) {
|
||||
return $name;
|
||||
}
|
||||
if ($name instanceof Template) {
|
||||
trigger_deprecation('twig/twig', '3.9', 'Passing a "%s" instance to "%s" is deprecated.', self::class, __METHOD__);
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
return new TemplateWrapper($this, $this->loadTemplate($this->getTemplateClass($name), $name));
|
||||
}
|
||||
@@ -448,7 +453,7 @@ class Environment
|
||||
* @throws LoaderError When none of the templates can be found
|
||||
* @throws SyntaxError When an error occurred during compilation
|
||||
*/
|
||||
public function resolveTemplate(string|TemplateWrapper|Template|array $names): TemplateWrapper
|
||||
public function resolveTemplate($names): TemplateWrapper
|
||||
{
|
||||
if (!\is_array($names)) {
|
||||
return $this->load($names);
|
||||
|
||||
+1
-1
@@ -253,7 +253,7 @@ abstract class Template
|
||||
*
|
||||
* @return self|TemplateWrapper
|
||||
*/
|
||||
protected function loadTemplate(string|TemplateWrapper|self|array $template, $templateName = null, $line = null, $index = null)
|
||||
protected function loadTemplate($template, $templateName = null, $line = null, $index = null)
|
||||
{
|
||||
try {
|
||||
if (\is_array($template)) {
|
||||
|
||||
Reference in New Issue
Block a user