src/Leevel/Http/Bag.php
public function filter(string $key, $defaults = null, $filter = null, array $options = [])
    {
        $key = $this->normalize($key);

        $filter = $this->parseFilter($filter);

        list($key, $filter) = $this->parseKeyFilter($key, $filter);

        $part = '';

        if (false !== strpos($key, '\\')) {
            list($key, $part) = explode('\\', $key);
        }

        $result = array_key_exists($key, $this->elements) ? $this->elements[$key] : $defaults;

        if ($part) {
            $result = $this->getPartData($part, $result, $defaults);
        }

        if ($filter) {
            $result = $this->filterValue($result, $defaults, $filter, $options);
        }

        return $result;
    }
public function filter(string $key, $defaults = null, $filter = null, array $options = [])
    {
        $key = $this->normalize($key);

        $filter = $this->parseFilter($filter);

        list($key, $filter) = $this->parseKeyFilter($key, $filter);

        $part = '';

        if (false !== strpos($key, '\\')) {
            list($key, $part) = explode('\\', $key);
        }

        $result = array_key_exists($key, $this->elements) ? $this->elements[$key] : $defaults;

        if ($part) {
            $result = $this->getPartData($part, $result, $defaults);
        }

        if ($filter) {
            $result = $this->filterValue($result, $defaults, $filter, $options);
        }

        return $result;
    }
获取过滤变量.

@param string           $key
@param mixed            $defaults
@param array|int|string $filter
@param array            $options

@return mixed