protected function getFormatter(XType $type)
    {
        $name = $type->getName();

        if (isset($this->formatterCache[$name])) {
            return $this->formatterCache[$name];
        }

        $class = get_class($type);

        if (isset($this->formatterCache[$class])) {
            return $this->formatterCache[$class];
        }

        if (isset($this->_extensions[$name])) {
            $this->formatterCache[$name] = $this->_extensions[$name];
            return $this->formatterCache[$name];
        }

        if ($extension = $this->nearestForClass($class)) {
            $this->formatterCache[$name] = $extension;
            $this->formatterCache[$class] = $extension;
            return $this->formatterCache[$name];
        }

        return $this->ownExtension;
    }