code: private function addCallable($type='function', $name, $func)
      {
          if (!is_string($name) || !is_callable($func)) {
              return;
          }
          $twname = trim($name, '*');
          $params = [];
          if (strpos($name, '*') === 0) {
              $params['is_safe'] = ['html'];
          }
          if ($type === 'function') {
              $this->twig->addFunction(new Twig_SimpleFunction($twname, $func, $params));
          }
          if ($type === 'filter') {
              $this->twig->addFilter(new Twig_SimpleFilter($twname, $func, $params));
          }
      }
docs: Expose a function to the Twig environment as a function or filter
  @param string $type
  @param string $name
  @param string|Closure $func