Update Twig to v2.15.4

This commit is contained in:
slawkens
2023-02-02 10:37:45 +01:00
parent e552bcfe82
commit 130f7ba405
309 changed files with 3802 additions and 4005 deletions

View File

@@ -17,13 +17,10 @@ use Twig\Source;
/**
* @author Fabien Potencier <fabien@symfony.com>
*
* @final
*/
class DeprecationCollector
final class DeprecationCollector
{
private $twig;
private $deprecations;
public function __construct(Environment $twig)
{
@@ -58,9 +55,12 @@ class DeprecationCollector
*/
public function collect(\Traversable $iterator)
{
$this->deprecations = [];
set_error_handler([$this, 'errorHandler']);
$deprecations = [];
set_error_handler(function ($type, $msg) use (&$deprecations) {
if (\E_USER_DEPRECATED === $type) {
$deprecations[] = $msg;
}
});
foreach ($iterator as $name => $contents) {
try {
@@ -72,21 +72,8 @@ class DeprecationCollector
restore_error_handler();
$deprecations = $this->deprecations;
$this->deprecations = [];
return $deprecations;
}
/**
* @internal
*/
public function errorHandler($type, $msg)
{
if (E_USER_DEPRECATED === $type) {
$this->deprecations[] = $msg;
}
}
}
class_alias('Twig\Util\DeprecationCollector', 'Twig_Util_DeprecationCollector');

View File

@@ -16,11 +16,19 @@ namespace Twig\Util;
*/
class TemplateDirIterator extends \IteratorIterator
{
/**
* @return mixed
*/
#[\ReturnTypeWillChange]
public function current()
{
return file_get_contents(parent::current());
}
/**
* @return mixed
*/
#[\ReturnTypeWillChange]
public function key()
{
return (string) parent::key();