Latte\Runtime\FilterExecutor::__get PHP Method

__get() public method

Returns filter for classic calling.
public __get ( $name ) : callable
return callable
    public function __get($name)
    {
        $lname = strtolower($name);
        if (isset($this->{$lname})) {
            // case mismatch
            return $this->{$lname};
        } elseif (isset($this->_static[$lname])) {
            list($callback, $aware) = $this->prepareFilter($lname);
            if ($aware) {
                // FilterInfo aware filter
                return $this->{$lname} = function ($arg) use($callback) {
                    $args = func_get_args();
                    array_unshift($args, $info = new FilterInfo());
                    if ($arg instanceof IHtmlString) {
                        $args[1] = $arg->__toString();
                        $info->contentType = Engine::CONTENT_HTML;
                    }
                    $res = call_user_func_array($callback, $args);
                    return $info->contentType === Engine::CONTENT_HTML ? new Html($res) : $res;
                };
            } else {
                // classic filter
                return $this->{$lname} = $callback;
            }
        }
        return $this->{$lname} = function ($arg) use($lname, $name) {
            // dynamic filter
            $args = func_get_args();
            array_unshift($args, $lname);
            foreach ($this->_dynamic as $filter) {
                $res = call_user_func_array(Helpers::checkCallback($filter), $args);
                if ($res !== NULL) {
                    return $res;
                } elseif (isset($this->_static[$lname])) {
                    // dynamic converted to classic
                    $this->{$name} = Helpers::checkCallback($this->_static[$lname][0]);
                    return call_user_func_array($this->{$name}, func_get_args());
                }
            }
            $hint = ($t = Helpers::getSuggestion(array_keys($this->_static), $name)) ? ", did you mean '{$t}'?" : '.';
            throw new \LogicException("Filter '{$name}' is not defined{$hint}");
        };
    }