addFunction(new TwigFunction('deprec', [$this, 'deprec'], ['deprecated' => '1.1', 'deprecating_package' => 'foo/bar'])); $collector = new DeprecationCollector($twig); $deprecations = $collector->collect(new Iterator()); $this->assertEquals(['Since foo/bar 1.1: Twig Function "deprec" is deprecated in deprec.twig at line 1.'], $deprecations); } public function deprec() { } } class Iterator implements \IteratorAggregate { public function getIterator(): \Traversable { return new \ArrayIterator([ 'ok.twig' => '{{ foo }}', 'deprec.twig' => '{{ deprec("foo") }}', ]); } }