Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. DeprecationCollector.php

function DeprecationCollector::collect

Returns deprecations for passed templates.

Parameters

\Traversable $iterator An iterator of templates (where keys are template names and values the contents of the template):

Return value

array An array of deprecations

1 call to DeprecationCollector::collect()
DeprecationCollector::collectDir in vendor/twig/twig/src/Util/DeprecationCollector.php
Returns deprecations for templates contained in a directory.

File

vendor/twig/twig/src/Util/DeprecationCollector.php, line 54

Class

DeprecationCollector
@author Fabien Potencier <fabien@symfony.com>

Namespace

Twig\Util

Code

public function collect(\Traversable $iterator) : array {
    $deprecations = [];
    set_error_handler(function ($type, $msg) use (&$deprecations) {
        if (\E_USER_DEPRECATED === $type) {
            $deprecations[] = $msg;
        }
        return false;
    });
    foreach ($iterator as $name => $contents) {
        try {
            $this->twig
                ->parse($this->twig
                ->tokenize(new Source($contents, $name)));
        } catch (SyntaxError $e) {
            // ignore templates containing syntax errors
        }
    }
    restore_error_handler();
    return $deprecations;
}
RSS feed
Powered by Drupal